Path: utzoo!utgpu!watmath!clyde!att!ucbvax!husc6!rice!sun-spots-request From: cml@cis.ohio-state.edu (Christopher Lott) Newsgroups: comp.sys.sun Subject: singleuser program Message-ID: <8812201742.AA00923@brachiosaur.cis.ohio-state.edu> Date: 30 Dec 88 19:42:12 GMT Sender: usenet@rice.edu Organization: Sun-Spots Lines: 53 Approved: Sun-Spots@rice.edu Original-Date: Tue, 20 Dec 88 12:42:58 EST X-Sun-Spots-Digest: Volume 7, Issue 82, message 8 of 18 Hi, Here is a quick program, in fact the one referenced by Karl Kleinpaste, used at OSU to prevent anyone from booting a sun singleuser. It halts the sun if the passwd is given incorrectly, and never times out. ---------snip, snip---------- /* singleuser.c * Christopher Lott 870924 * cml@cis.ohio-state.edu * written for use in root's .profile * requests the root passwd from the console; halts unix if it fails * This program placed in the public domain by the author */ #include #include #include #include #define ROOT_UID 0 main () { char *userword, *rootword, *result, salt[3]; struct passwd *pwentry; char *crypt(), *getpass(); signal(SIGINT, SIG_IGN); signal(SIGHUP, SIG_IGN); signal(SIGQUIT, SIG_IGN); signal(SIGTSTP, SIG_IGN); pwentry = getpwuid(ROOT_UID); /* get passwd file entry */ rootword = pwentry->pw_passwd; salt[0] = rootword[0]; /* grab the salt */ salt[1] = rootword[1]; salt[2] = NULL; userword = getpass ("Password:"); /* get one from console */ result = crypt(userword, salt); if ( !(strcmp (result, rootword)) ) { printf ("hi, root person.\n"); exit (0); } else { printf ("Sorry - halting Unix.\n"); sync(); reboot (RB_HALT); } } ---------snip, snip----------