singleuser program

Christopher Lott cml at cis.ohio-state.edu
Sat Dec 31 05:42:12 AEST 1988


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 at 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 <pwd.h>
#include <stdio.h>
#include <signal.h>
#include <sys/reboot.h>

#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----------



More information about the Comp.sys.sun mailing list