1: /* su -- become super-user */
   2: 
   3: char    password[100];
   4: char    pwbuf[100];
   5: int ttybuf[3];
   6: main()
   7: {
   8:     register char *p, *q;
   9:     extern fin;
  10: 
  11:     if(getpw(0, pwbuf))
  12:         goto badpw;
  13:     (&fin)[1] = 0;
  14:     p = pwbuf;
  15:     while(*p != ':')
  16:         if(*p++ == '\0')
  17:             goto badpw;
  18:     if(*++p == ':')
  19:         goto ok;
  20:     gtty(0, ttybuf);
  21:     ttybuf[2] =& ~010;
  22:     stty(0, ttybuf);
  23:     printf("password: ");
  24:     q = password;
  25:     while((*q = getchar()) != '\n')
  26:         if(*q++ == '\0')
  27:             return;
  28:     *q = '\0';
  29:     ttybuf[2] =| 010;
  30:     stty(0, ttybuf);
  31:     printf("\n");
  32:     q = crypt(password);
  33:     while(*q++ == *p++);
  34:     if(*--q == '\0' && *--p == ':')
  35:         goto ok;
  36:     goto error;
  37: 
  38: badpw:
  39:     printf("bad password file\n");
  40: ok:
  41:     setuid(0);
  42:     execl("/bin/sh", "-", 0);
  43:     printf("cannot execute shell\n");
  44: error:
  45:     printf("sorry\n");
  46: }

Defined functions

main defined in line 6; never used

Defined variables

password defined in line 3; used 2 times
pwbuf defined in line 4; used 2 times
ttybuf defined in line 5; used 5 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 687
Valid CSS Valid XHTML 1.0 Strict