[ale] Limiting "shutdown"

Mike Kachline kachline at medept17.coon.gatech.edu
Wed Aug 11 00:14:28 EDT 1999


On Tue, 10 Aug 1999, Denny Chambers wrote:

> Is there a way to limit the "shutdown" command to only be use at the
> console?
<snip>
	Denny,

	Though I'm sure there's a better way, you could try hiding
/sbin/shutdown, then executing the following. Of course, perhaps there's a
way to incorporate this script into your rc.0 scripts s.t. when init level
0 is started, it'll just kick itself back into init level 5.

	Also, though I've not tried this method, according to my man page
for shutdown, you could create /etc/shutdown.allow; though I think one
could still shutdown via X if they open up a "console" window (as opposed
to an xterm).

---- shutdown(8) ----
       in /etc/inittab. This means that everyone who has physical
       access to the console keyboard can shut the  system  down.
       To  prevent  this,  shutdown can check to see if an autho-
       rized user is logged in on one of the virtual consoles. If
       shutdown  is  called from init(8), it checks to see if the
       file /etc/shutdown.allow is present.  It then compares the
---- snip ----



						My $0.02,
							- Mike


----- snip here -----
#!/bin/bash

IN_WINDOWS="`xwininfo -root 2> /dev/null`"

if test -z "$IN_WINDOWS" ; then
	#We couldn't find a root window. Must be in a console.
        /sbin/shutdown -h now
else
	#We found a root window. We're probably in X right now.
	/bin/echo "Sorry. You may only shutdown from a console."
fi

---- snip here ----

====================================================================
Michael Kachline CS, Georgia Institute of Technlology
kachline at brightstar.gt.ed.net
http://brightstar.gt.ed.net/kachline
====================================================================






More information about the Ale mailing list