halt not by root
Wim Rijnsburger
wim at dx7.UUCP
Fri Sep 30 22:29:10 AEST 1988
In article <1128 at usfvax2.EDU> ssi at usfvax2.EDU (Ssi) writes:
>I run a Sun file server with clients. My question is
>how can I give halt(8) permission to users other than
>root. We shut the system down at night and root is
>at home.
>
> Greg Ripp Voice Ph = (813)628-6100
We had the same problem and I've made a command for that.
It is called "safehalt" and the manual page says:
Safehalt first checks for other users and remotely mounted
filesystems. The system is only halted, if there are no
other users and there are no remote hosts, with mounted
filesystems from this host.
This command is provided to enable unexperienced users to
stop the system, without affecting other users or other
hosts. If an useraccount is created with root userid and
this command as login process, then it is not necessary to
give root passwords to unexperienced users, but they still
can stop the system to put the power down. In /etc/passwd
this line can be added:
halt::0:1:System Shutdown::/usr/local/bin/safehalt
Here it is, the command, the manual page and the makefile to install
the whole thing.
-- cut here ------- cut here ------- cut here ------- cut here --
: To unbundle, sh this file
echo Makefile
cat >Makefile <<'@@@ Fin de Makefile'
install:
cp safehalt /usr/local/bin
cp safehalt.l /usr/man/manl
@@@ Fin de Makefile
echo safehalt
cat >safehalt <<'@@@ Fin de safehalt'
#!/bin/csh
#
# This command checks for other users and remotely mounted filesystems
# The system is only halted if there are no other users and there
# are no remote hosts, with mounted filesystems from this host
#
# (c) 1988 Wim Rijnsburger (mcvax!ecn!wim)
# Netherlands Energy Research Foundation ECN
# P.O.box 1
# 1755 ZG Petten
# Holland
#
set u= (`users`)
set m= (`/usr/etc/showmount -a`)
if ($#u > 1) echo "Cannot shutdown... users: $u."
if ($#m > 0) echo "Cannot shutdown... mounted: $m."
if (($#u == 1) && ($#m == 0)) then
/etc/umount -a
/etc/shutdown -h now
endif
@@@ Fin de safehalt
echo safehalt.l
cat >safehalt.l <<'@@@ Fin de safehalt.l'
.TH SAFEHALT 8 "5 July 1988" "ECN, Petten (Holland)"
.SH NAME
safehalt\- halt the processor safely
.SH SYNOPSIS
.B safehalt
.SH DESCRIPTION
.LP
\fISafehalt\fP first checks for other users and remotely mounted
filesystems. The system is only halted, if there are no other users
and there are no remote hosts, with mounted filesystems from this
host.
.LP
This command is provided to enable unexperienced users to stop the
system, without affecting other users or other hosts. If an useraccount
is created with root userid and this command as login process, then it
is not necessary to give root passwords to unexperienced users, but
they still can stop the system to put the power down. In /etc/passwd
this line can be added:
.IP
halt::0:1:System Shutdown::/usr/local/bin/safehalt
.SH "SEE ALSO"
halt(8), showmount(8), users(1).
.SH "FILES"
/usr/local/bin/safehalt
.SH DIAGNOSTICS
The status messages given should be self explanatory.
.SH AUTHOR
Wim Rijnsburger, ECN, PO box 1, 1755 ZG Petten (NH), Holland.
.br
e-mail: mcvax!ecn!wim
.SH BUGS
Please contact me about bugs and wishes.
.SH NOTES
The development of \fBsafehalt\fP is part of a research project of the
\fINetherlands Energy Research Foundation (ECN), Petten (NH),
Holland\fP.
@@@ Fin de safehalt.l
exit 0
More information about the Comp.unix.questions
mailing list