Article View: pe.cust.sources
Article #14Simple program to allow users to shut the system down
From: Earl Wallace
Date: Wed, 05 Jun 1985 22:30
Date: Wed, 05 Jun 1985 22:30
49 lines
2048 bytes
2048 bytes
Here is a very simple interface to the /etc/shutdown script that allows
users, with access to the system console, to shut the system down for
whatever reason (backups, maint. , etc.). Its not great but it does work.
The security is ok but hasn't been tested for every little hole. Have fun!
-earlw
----------------------------- CUT HERE -----------------------------
/*
* special shutdown program for the rest of us - earlw
* The executable file should be owned by 'root' with group 'sys' and
* mode 6111
*/
main()
{
register char *tty, *user;
extern char *getlogin(), *ttyname(), *getcwd();
/* check user */
if (strcmp((user=getlogin()), "root") &&
strcmp(user, "you") &&
strcmp(user, "me") &&
strcmp(user, "thedog") &&
strcmp(user, "thecat") ) {
printf("Sorry %s, ", user);
printf("You must be an authorized user to run the ");
printf("shutdown program\n");
exit(2);
}
if (strncmp(getcwd((char *)0, 64), "/", 64)) {
printf("You must be in / to run the shutdown program!\n");
exit(3);
}
if (!(tty=ttyname(0))) {
printf("Don't run the shutdown program in the background!\n");
exit(4);
}
if (strcmp(tty, "/dev/console")) {
printf("You must be at the system console to run the ");
printf("shutdown program\n");
exit(1);
}
setgid(0);
setuid(0);
printf("calling shutdown now...\n");
execlp("/etc/shutdown", "SHUTDOWN", "120", 0);
printf("shutdown failed!\n");
exit(0);
}
Technical Details
Message-ID:
<2743@pesnta.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!lsuc!per!pesnta!earlwShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2(pesnta/xelos-%I%) 9/18/84; site pesnta.UUCP Path: arc1-ca.pugleaf.net!utzoo!lsuc!per!pesnta!earlw From: earlw@pesnta.UUCP (Earl Wallace ) Newsgroups: pe.cust.sources Subject: Simple program to allow users to shut the system down Message-ID: <2743@pesnta.UUCP> Date: Wed, 5-Jun-85 18:30:52 EDT Article-I.D.: pesnta.2743 Posted: Wed Jun 5 18:30:52 1985 Date-Received: Thu, 6-Jun-85 12:56:22 EDT Distribution: pe.cust Organization: Perkin-Elmer DSG/CSD, Santa Clara, Ca. Lines: 49