🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pe.cust.sources
1 messages
1 total messages Started by Earl Wallace Wed, 05 Jun 1985 22:30
Simple program to allow users to shut the system down
#14
Author: Earl Wallace
Date: Wed, 05 Jun 1985 22:30
49 lines
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);
}
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads