=================================================================== RCS file: /src/master/skey/man/key.1,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 key.1 --- 1.1.1.1 1995/05/22 14:01:38 +++ key.1 1995/05/22 14:23:07 @@ -8,7 +8,7 @@ .SH NAME key \- Stand\-alone program for computing responses to S/Key challenges. .SH SYNOPSIS -.B key [\-n ] [\-p ] +.B key [\-e] [\-n ] [\-p ] .SH DESCRIPTION .I key Takes the optional count of the number of one time access @@ -31,6 +31,9 @@ > .LP .SH OPTIONS +.LP +.B \-e +Don't disable echo during secret password entry. .LP .B \-n the number of one time access passwords to print. =================================================================== RCS file: /src/master/skey/man/keyinit.1,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 keyinit.1 --- 1.1.1.1 1995/05/22 14:01:38 +++ keyinit.1 1995/05/22 14:23:09 @@ -8,26 +8,30 @@ .SH NAME keyinit \- Change password or add user to S/Key authentication system. .SH SYNOPSIS -.B keyinit [\-s] [] +.B keyinit [\-r] [\-u] [\-n] [\-s] [\-f] [] .SH DESCRIPTION .I keyinit will initialize the system information to allow one to use S/Key to login. .sp 1 .SH OPTIONS -.B \-s -Set secure mode where the user is expected to have used a secure -machine to generate the first one time password. Without the \-s the +.B \-r +Set remote mode where the user is expected to have used a secure +machine to generate the first one time password. Without the \-r the system will assume you are direct connected over secure communications and prompt you for your secret password. -The \-s option also allows one to set the seed and count for complete -control of the parameters. You can use keyinit -s in compination with -the -.I key -command to set the seed and count if you do not like the defaults. -To do this run keyinit in one window and put in your count and seed -then run key in another window to generate the correct 6 english words -for that count and seed. You can then -"cut" and "paste" them or copy them into the keyinit window. +.sp +.B \-u +Set the internal s/key name that skey uses to authenticate you with. +.sp +.B \-n +Allows entry of the number of key generations you can use. +.sp +.B \-s +Sets -run flags for backwards compatability. +.sp +.B \-f +Force key generation even if the user specified (on the command line) does not exist. +It also ONLY works if the user does not exist. .sp .LP .B =================================================================== RCS file: /src/master/skey/src/Makefile,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 Makefile --- 1.1.1.1 1995/05/22 14:01:30 +++ Makefile 1995/05/22 14:23:34 @@ -8,7 +8,8 @@ MANDIR = /usr/local/man/man8 DESTDIR = /usr/local/bin -CFLAGS = -g -DUSE_ECHO +CC = gcc +CFLAGS = -g -O -DUSE_ECHO LIB = libskey.a LIBOBJS = skeylogin.o skeysubr.o md4.o put.o @@ -45,11 +46,14 @@ make all SYS=$@ RANLIB="echo" CFLAGS="$(CFLAGS) -DSYSV -DSOLARIS \ -DSIGVOID" -sunos4: - make all SYS=$@ RANLIB="/bin/ranlib" CFLAGS="$(CFLAGS) -DSUN" +bsd sunos4: + make all SYS=$@ RANLIB="ranlib" CFLAGS="$(CFLAGS) -DSUN" ultrix: make all SYS=$@ RANLIB="/usr/bin/ranlib" CFLAGS="$(CFLAGS) -DULTRIX" + +irix: + make all SYS=$@ RANLIB="echo" CFLAGS="$(CFLAGS) -DSYSV" sysv: make all SYS=$@ RANLIB="echo" CFLAGS="$(CFLAGS) -DSYSV" =================================================================== RCS file: /src/master/skey/src/md4.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 md4.c --- 1.1.1.1 1995/05/22 14:01:30 +++ md4.c 1995/05/22 14:23:36 @@ -38,7 +38,7 @@ #define FALSE 0 #if (defined(__MSDOS__) || defined(MPU8086) || defined(MPU8080) \ - || defined(vax) || defined (MIPSEL)) + || defined(vax) || defined (MIPSEL) || defined (i386)) #define LOWBYTEFIRST TRUE /* Low order bytes are first in memory */ #else /* Almost all other machines are big-endian */ #define LOWBYTEFIRST FALSE =================================================================== RCS file: /src/master/skey/src/put.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 put.c --- 1.1.1.1 1995/05/22 14:01:30 +++ put.c 1995/05/22 14:23:38 @@ -15,13 +15,13 @@ #include #include "skey.h" -static unsigned long extract __ARGS ((char *s, int start, int length)); -static void standard __ARGS ((char *word)); -static void insert __ARGS ((char *s, int x, int start, int length)); -static int wsrch __ARGS ((char *w, int low, int high)); +static unsigned long skey_extract __ARGS ((char *s, int start, int length)); +static void skey_standard __ARGS ((char *word)); +static void skey_insert __ARGS ((char *s, int x, int start, int length)); +static int skey_wsrch __ARGS ((char *w, int low, int high)); /* Dictionary for integer-word translations */ -char Wp[2048][4] = { +char skey_Wp[2048][4] = { "A", "ABE", "ACE", @@ -2076,7 +2076,7 @@ * Returns a pointer to a static buffer */ char * - btoe (engout, c) +skey_btoe (engout, c) char *c, *engout; { char cp[9]; /* add in room for the parity 2 bits */ @@ -2086,21 +2086,21 @@ memcpy (cp, c, 8); /* compute parity */ for (p = 0, i = 0; i < 64; i += 2) - p += extract (cp, i, 2); + p += skey_extract (cp, i, 2); cp[8] = (char) p << 6; - strncat (engout, &Wp[extract (cp, 0, 11)][0], 4); + strncat (engout, &skey_Wp[skey_extract (cp, 0, 11)][0], 4); strcat (engout, " "); - strncat (engout, &Wp[extract (cp, 11, 11)][0], 4); + strncat (engout, &skey_Wp[skey_extract (cp, 11, 11)][0], 4); strcat (engout, " "); - strncat (engout, &Wp[extract (cp, 22, 11)][0], 4); + strncat (engout, &skey_Wp[skey_extract (cp, 22, 11)][0], 4); strcat (engout, " "); - strncat (engout, &Wp[extract (cp, 33, 11)][0], 4); + strncat (engout, &skey_Wp[skey_extract (cp, 33, 11)][0], 4); strcat (engout, " "); - strncat (engout, &Wp[extract (cp, 44, 11)][0], 4); + strncat (engout, &skey_Wp[skey_extract (cp, 44, 11)][0], 4); strcat (engout, " "); - strncat (engout, &Wp[extract (cp, 55, 11)][0], 4); + strncat (engout, &skey_Wp[skey_extract (cp, 55, 11)][0], 4); #ifdef notdef printf ("engout is %s\n\r", engout); @@ -2115,7 +2115,7 @@ * -2 words OK but parity is wrong */ int - etob (out, e) +skey_etob (out, e) char *out; char *e; { @@ -2148,19 +2148,19 @@ low = 571; high = 2047; } - standard (word); + skey_standard (word); - if ((v = wsrch (word, low, high)) < 0) + if ((v = skey_wsrch (word, low, high)) < 0) return 0; - insert (b, v, p, 11); + skey_insert (b, v, p, 11); } /* now check the parity of what we got */ for (p = 0, i = 0; i < 64; i += 2) - p += extract (b, i, 2); + p += skey_extract (b, i, 2); - if ((p & 3) != extract (b, 64, 2)) + if ((p & 3) != skey_extract (b, 64, 2)) return -2; memcpy (out, b, 8); @@ -2170,7 +2170,7 @@ /* Display 8 bytes as a series of 16-bit hex digits */ char * - put8 (out, s) +skey_put8 (out, s) char *out; char *s; { @@ -2186,7 +2186,7 @@ * Provided as a possible alternative to btoe() */ char * - btoc (cp) +skey_btoc (cp) char *cp; { int i; @@ -2196,7 +2196,7 @@ for (i = 0; i <= 10; i++) { /* last one is only 4 bits not 6 */ - out[i] = '!' + extract (cp, 6 * i, i >= 10 ? 4 : 6); + out[i] = '!' + skey_extract (cp, 6 * i, i >= 10 ? 4 : 6); } out[i] = '\0'; return (out); @@ -2208,7 +2208,7 @@ /* Dictionary binary search */ static int - wsrch (w, low, high) +skey_wsrch (w, low, high) char *w; int low, high; { @@ -2217,12 +2217,12 @@ for (;;) { i = (low + high) / 2; - if ((j = strncmp (w, Wp[i], 4)) == 0) + if ((j = strncmp (w, skey_Wp[i], 4)) == 0) return i; /* Found it */ if (high == low + 1) { /* Avoid effects of integer truncation in /2 */ - if (strncmp (w, Wp[high], 4) == 0) + if (strncmp (w, skey_Wp[high], 4) == 0) return high; else return -1; @@ -2236,7 +2236,7 @@ } } static void - insert (s, x, start, length) +skey_insert (s, x, start, length) char *s; int x; int start, length; @@ -2275,7 +2275,7 @@ } static void - standard (word) +skey_standard (word) register char *word; { while (*word) @@ -2296,7 +2296,7 @@ /* Extract 'length' bits from the char array 's' starting with bit 'start' */ static unsigned long - extract (s, start, length) + skey_extract (s, start, length) char *s; int start, length; { =================================================================== RCS file: /src/master/skey/src/skey.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 skey.c --- 1.1.1.1 1995/05/22 14:01:31 +++ skey.c 1995/05/22 14:23:39 @@ -35,7 +35,7 @@ #include "md4.h" #include "skey.h" -char *readpass (); +char *skey_readpass (); void usage (); int getopt (); extern int optind; @@ -47,13 +47,17 @@ { int n, cnt, i, pass = 0; char passwd[256], key[8], buf[33], *seed, *slash; + int noecho = 1; cnt = 1; - while ((i = getopt (argc, argv, "n:p:")) != EOF) + while ((i = getopt (argc, argv, "en:p:")) != EOF) { switch (i) { + case 'e': + noecho = 0; + break; case 'n': cnt = atoi (optarg); break; @@ -106,14 +110,24 @@ /* Get user's secret password */ if (!pass) { + printf ("Reminder - Do not use this program while logged in via telnet or rlogin.\n"); printf ("Enter secret password: "); - readpass (passwd, sizeof (passwd)); + if (noecho) + { + skey_set_term (); + skey_echo_off (); + } + + skey_readpass (passwd, sizeof (passwd)); + + if (noecho) + skey_unset_term (); } - rip (passwd); + skey_rip (passwd); /* Crunch seed and password into starting key */ - if (keycrunch (key, seed, passwd) != 0) + if (skey_keycrunch (key, seed, passwd) != 0) { fprintf (stderr, "%s: key crunch failed\n", argv[0]); exit (1); @@ -121,8 +135,8 @@ if (cnt == 1) { while (n-- != 0) - f (key); - printf ("%s\n", btoe (buf, key)); + skey_f (key); + printf ("%s\n", skey_btoe (buf, key)); #ifdef HEXIN printf ("%s\n", put8 (buf, key)); #endif @@ -130,15 +144,15 @@ else { for (i = 0; i <= n - cnt; i++) - f (key); + skey_f (key); for (; i <= n; i++) { #ifdef HEXIN - printf ("%d: %-29s %s\n", i, btoe (buf, key), put8 (buf, key)); + printf ("%d: %-29s %s\n", i, skey_btoe (buf, key), put8 (buf, key)); #else - printf ("%d: %-29s\n", i, btoe (buf, key)); + printf ("%d: %-29s\n", i, skey_btoe (buf, key)); #endif - f (key); + skey_f (key); } } exit (0); @@ -148,5 +162,5 @@ usage (s) char *s; { - printf ("Usage: %s [-n count] [-p password ] [/] \n", s); + printf ("Usage: %s [-e] [-n count] [-p password ] [/] \n", s); } =================================================================== RCS file: /src/master/skey/src/skey.h,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 skey.h --- 1.1.1.1 1995/05/22 14:01:31 +++ skey.h 1995/05/22 14:23:40 @@ -50,12 +50,14 @@ int cnt; }; -void f __ARGS ((char *x)); -int keycrunch __ARGS ((char *result, char *seed, char *passwd)); -char *btoe __ARGS ((char *engout, char *c)); -char *put8 __ARGS ((char *out, char *s)); -int etob __ARGS ((char *out, char *e)); -void rip __ARGS ((char *buf)); +void skey_f __ARGS ((char *x)); +int skey_keycrunch __ARGS ((char *result, char *seed, char *passwd)); +char *skey_btoe __ARGS ((char *engout, char *c)); +char *skey_put8 __ARGS ((char *out, char *s)); +int skey_etob __ARGS ((char *out, char *e)); +void skey_rip __ARGS ((char *buf)); int skeychallenge __ARGS ((struct skey * mp, char *name, char *ss)); int skeylookup __ARGS ((struct skey * mp, char *name)); int skeyverify __ARGS ((struct skey * mp, char *response)); + +extern char *skey_keyfile; =================================================================== RCS file: /src/master/skey/src/skeyinit.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 skeyinit.c --- 1.1.1.1 1995/05/22 14:01:31 +++ skeyinit.c 1995/05/22 14:23:42 @@ -12,7 +12,8 @@ #include #include #include -#incoude +#include +#include #include #ifdef __svr4__ @@ -27,18 +28,28 @@ extern int optind; extern char *optarg; -char *readpass (), *malloc (), *getpass (), *crypt (); +char *skey_readpass (), *malloc (), *getpass (), *crypt (); int skeylookup __ARGS ((struct skey * mp, char *name)); #define NAMELEN 2 +int enternumber=0; +int entersecret=1; +int enteruname=0; +int overridelocal=0; + +char *Usage = "%s [-run] [-f skeyfile] []\n-r Enter result of key instead of secret key\n-u Enter the S/Key userid\n-n Enter the total number of allowed logins for this userid (1-999)\n-f Use the supplied skey file instead of /etc/skeykeys (disables suid)\n\n"; + main (argc, argv) int argc; char *argv[]; { - int rval, n, nn, i, defaultsetup, l; + int c, iserror = 0; + extern char *optarg; + extern int optind; + int rval, n, nn, i, l; time_t now; char seed[18], tmp[80], key[8], defaultseed[17], passwd[256], passwd2[256], tbuf[27], buf[60], lastc, me[80], user [8], *salt, *p, *pw; @@ -46,6 +57,33 @@ struct passwd *pp; struct tm *tm; + while ((c = getopt(argc, argv, "runf:")) != -1) + switch (c) + { + case 'r': + entersecret = 0; + break; + case 'u': + enteruname = 1; + break; + case 'n': + enternumber=1; + break; + case 'f': + overridelocal = 1; + skey_keyfile = optarg; + setgid(getgid()); /* Give up privs */ + setuid(getuid()); /* Give up privs */ + break; + case '?': + iserror++; + } + + if (iserror || ((argc-optind) > 1) || (overridelocal && (argc-optind) != 1)) + { + fprintf(stderr,Usage,argv[0]); + exit(1); + } time (&now); tm = localtime (&now); @@ -56,210 +94,205 @@ strcpy (&defaultseed[NAMELEN], tbuf); - pp = getpwuid (getuid ()); - strcpy (me, pp->pw_name); + if (argc-optind == 1) + { + pp = getpwnam (argv[optind]); + strcpy (me,argv[optind]); + } + else + { + pp = getpwuid (getuid ()); + if (pp) + strcpy (me, pp->pw_name); + } - if ((pp = getpwnam (me)) == NULL) { - fprintf(stderr, "Who are you?\n"); - exit(1); - } - - defaultsetup = 1; - - if (argc > 1) - { - if (strcmp ("-s", argv[1]) == 0) - defaultsetup = 0; - else - pp = getpwnam (argv[1]); - - if (argc > 2) - pp = getpwnam (argv[2]); - - } - - if (pp == NULL) - { - printf ("User unknown\n"); - exit (1); - } - if (strcmp (pp->pw_name, me) != 0) - { - if (getuid () != 0) + if (!overridelocal && pp == NULL) { - /* Only root can change other's passwds */ - printf ("Permission denied.\n"); + fprintf (stderr,"User %s unknown\n",me); exit (1); } - } - salt = pp->pw_passwd; + if (!overridelocal && strcmp (pp->pw_name, me) != 0) + if (getuid () != 0) + { + /* Only root can change other's passwds */ + fprintf (stderr,"Permission denied.\n"); + exit (1); + } + setpriority (PRIO_PROCESS, 0, -4); - if (getuid () != 0) { - setpriority (PRIO_PROCESS, 0, -4); + if (!overridelocal && getuid () != 0) + { + setpriority (PRIO_PROCESS, 0, -4); + + pw = getpass ("Unix Password:"); - pw = getpass ("Password:"); - p = crypt (pw, salt); + salt = pp->pw_passwd; + p = crypt (pw, salt); - setpriority(PRIO_PROCESS, 0, 0); + setpriority(PRIO_PROCESS, 0, 0); - if (pp && strcmp(p, pp->pw_passwd)) { - printf ("Password incorrect.\n"); - exit (-1); - } - } + if (pp && strcmp(p, pp->pw_passwd)) + { + fprintf (stderr,"Password incorrect.\n"); + exit (-1); + } + } - rval = skeylookup (&skey, pp->pw_name); + rval = skeylookup (&skey, me); switch (rval) - { - case -1: - perror ("Error opening database: "); - exit (1); - case 0: - printf ("[Updating %s]\n", pp->pw_name); - printf ("Old key: %s\n", skey.seed); - - /* lets be nice if they have a skey.seed that ends in 0-8 just add one */ - l = strlen (skey.seed); - if (l > 0) { - lastc = skey.seed[l - 1]; - if (isdigit (lastc) && lastc != '9') - { - strcpy (defaultseed, skey.seed); - defaultseed[l - 1] = lastc + 1; - } - if (isdigit (lastc) && lastc == '9' && l < 16) - { - strcpy (defaultseed, skey.seed); - defaultseed[l - 1] = '0'; - defaultseed[l] = '0'; - defaultseed[l + 1] = '\0'; - } + case -1: + perror ("Error opening database: "); + exit (1); + case 0: + printf ("[Updating %s]\n", me); + printf ("Old key: %s\n", skey.seed); + + /* lets be nice if they have a skey.seed that ends in 0-8 just add one */ + l = strlen (skey.seed); + if (l > 0) + { + lastc = skey.seed[l - 1]; + if (isdigit (lastc) && lastc != '9') + { + strcpy (defaultseed, skey.seed); + defaultseed[l - 1] = lastc + 1; + } + if (isdigit (lastc) && lastc == '9' && l < 16) + { + strcpy (defaultseed, skey.seed); + defaultseed[l - 1] = '0'; + defaultseed[l] = '0'; + defaultseed[l + 1] = '\0'; + } + } + break; + case 1: + printf ("[Adding %s]\n", me); + break; } - break; - case 1: - printf ("[Adding %s]\n", pp->pw_name); - break; - } n = 99; - if (!defaultsetup) - { - printf ("You need the 6 english words generated from the \"key\" command.\n"); + if (enternumber) for (i = 0 ;; i++) + { + if (i >= 2) + exit (1); + printf ("Enter sequence count from 1 to 10000: "); + fgets (tmp, sizeof (tmp), stdin); + n = atoi (tmp); + if (n > 0 && n < 10000) + break; /* Valid range */ + fprintf (stderr,"\n Error: Count must be > 0 and < 10000\n"); + } + + if (enteruname) { - if (i >= 2) - exit (1); - printf ("Enter sequence count from 1 to 10000: "); - fgets (tmp, sizeof (tmp), stdin); - n = atoi (tmp); - if (n > 0 && n < 10000) - break; /* Valid range */ - printf ("\n Error: Count must be > 0 and < 10000\n"); - } - } - - if (!defaultsetup) - { - printf ("Enter new key [default %s]: ", defaultseed); - fflush (stdout); - fgets (seed, sizeof (seed), stdin); - rip (seed); - if (strlen (seed) > 16) - { - printf ("Notice: Seed truncated to 16 characters.\n"); - seed[16] = '\0'; + printf ("Enter new key [default %s]: ", defaultseed); + fflush (stdout); + fgets (seed, sizeof (seed), stdin); + skey_rip (seed); + if (strlen (seed) > 16) + { + printf ("Notice: Seed truncated to 16 characters.\n"); + seed[16] = '\0'; + } + + if (seed[0] == '\0') + strcpy (seed, defaultseed); + else + strcpy (defaultseed, seed); } - if (seed[0] == '\0') - strcpy (seed, defaultseed); - - for (i = 0 ;; i++) + if (!entersecret) { - if (i >= 2) - exit (1); - - printf ("s/key %d %s\ns/key access password: ", n, seed); - fgets (tmp, sizeof (tmp), stdin); - rip (tmp); - backspace (tmp); - - if (tmp[0] == '?') - { - printf ("Enter 6 English words from secure S/Key calculation.\n"); - continue; - } - - if (tmp[0] == '\0') - { - exit (1); - } - if (etob (key, tmp) == 1 || atob8 (key, tmp) == 0) - break; /* Valid format */ - printf ("Invalid format - try again with 6 English words.\n"); + printf ("You need the 6 english words generated from the \"key\" command.\n"); + for (i = 0 ;; i++) + { + if (i >= 2) + exit (1); + + printf ("s/key %d %s\ns/key access password: ", n, seed); + fgets (tmp, sizeof (tmp), stdin); + skey_rip (tmp); + skey_backspace (tmp); + + if (tmp[0] == '?') + { + printf ("Enter 6 English words from secure S/Key calculation.\n"); + continue; + } + + if (tmp[0] == '\0') + { + exit (1); + } + if (skey_etob (key, tmp) == 1 || skey_atob8 (key, tmp) == 0) + break; /* Valid format */ + fprintf (stderr,"Invalid format - try again with 6 English words from secure S/Key calculation.\n"); + } } - } else - { - /* Get user's secret password */ - for (i = 0 ;; i++) { + /* Get user's secret password */ + for (i = 0 ;; i++) + { - if (i >= 2) - exit (1); + if (i >= 2) + exit (1); - printf ("Enter secret password: "); - readpass (passwd, sizeof (passwd)); + printf ("Enter secret password: "); + skey_readpass (passwd, sizeof (passwd)); - if (passwd[0] == '\0') - exit (1); + if (passwd[0] == '\0') + exit (1); - printf ("Again secret password: "); - readpass (passwd2, sizeof (passwd)); + printf ("Again secret password: "); + skey_readpass (passwd2, sizeof (passwd)); - if (passwd2[0] == '\0') - exit (1); + if (passwd2[0] == '\0') + exit (1); - if (strlen (passwd) < 4 && strlen (passwd2) < 4) - { - fprintf (stderr, "Error: Your password must be longer.\n\r"); - exit (1); - } + if (strlen (passwd) < 4 && strlen (passwd2) < 4) + { + fprintf (stderr, "Error: Your password must be longer.\n\r"); + exit (1); + } - if (strcmp (passwd, passwd2) == 0) - break; + if (strcmp (passwd, passwd2) == 0) + break; - printf ("Error: Passwords dont match.\n"); - } - strcpy (seed, defaultseed); + printf ("Error: Passwords dont match.\n"); + } + strcpy (seed, defaultseed); - /* Crunch seed and password into starting key */ - if (keycrunch (key, seed, passwd) != 0) - { - fprintf (stderr, "%s: key crunch failed.\n", argv[0]); - exit (2); + /* Crunch seed and password into starting key */ + if (skey_keycrunch (key, seed, passwd) != 0) + { + fprintf (stderr, "%s: key crunch failed.\n", argv[0]); + exit (2); + } + nn = n; + while (nn-- != 0) + skey_f (key); } - nn = n; - while (nn-- != 0) - f (key); - } time (&now); tm = localtime (&now); strftime (tbuf, sizeof (tbuf), " %b %d,%Y %T", tm); skey.val = malloc (16 + 1); - btoa8 (skey.val, key); + skey_btoa8 (skey.val, key); - fprintf (skey.keyfile, "%s %04d %-16s %s %-21s\n", pp->pw_name, n, + fprintf (skey.keyfile, "%s %04d %-16s %s %-21s\n", me, n, seed, skey.val, tbuf); fclose (skey.keyfile); - printf ("\nID %s s/key is %d %s\n", pp->pw_name, n, seed); - printf ("Next login password: %s\n", btoe (buf, key)); + printf ("\nID %s s/key is %d %s\n", me, n, seed); + printf ("Next login password: %s\n", skey_btoe (buf, key)); #ifdef HEXIN printf ("%s\n", put8 (buf, key)); #endif =================================================================== RCS file: /src/master/skey/src/skeylogin.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 skeylogin.c --- 1.1.1.1 1995/05/22 14:01:31 +++ skeylogin.c 1995/05/22 14:23:43 @@ -15,7 +15,9 @@ #endif #include #include +#ifndef __sgi__ #include +#endif #include @@ -28,8 +30,9 @@ #include "skey.h" #define KEYFILE "/etc/skeykeys" +char *skey_keyfile = KEYFILE; -char *skipspace(); +char *skey_skipspace(); int skeylookup __ARGS((struct skey *mp,char *name)); @@ -48,7 +51,7 @@ { int rval; - sevenbit(name); + skey_sevenbit(name); rval = skeylookup(mp,name); strcpy(prompt,"s/key 55 latour1\n"); switch(rval){ @@ -110,11 +113,11 @@ struct stat statbuf; /* See if the KEYFILE exists, and create it if not */ - if(stat(KEYFILE,&statbuf) == -1 && errno == ENOENT){ - mp->keyfile = fopen(KEYFILE,"w+"); + if(stat(skey_keyfile,&statbuf) == -1 && errno == ENOENT){ + mp->keyfile = fopen(skey_keyfile,"w+"); } else { /* Otherwise open normally for update */ - mp->keyfile = fopen(KEYFILE,"r+"); + mp->keyfile = fopen(skey_keyfile,"r+"); } if(mp->keyfile == NULL) return -1; @@ -129,7 +132,7 @@ if(fgets(mp->buf,sizeof(mp->buf),mp->keyfile) != mp->buf){ break; } - rip(mp->buf); + skey_rip(mp->buf); if(mp->buf[0] == '#') continue; /* Comment */ if((mp->logname = strtok(mp->buf," \t")) == NULL) @@ -188,10 +191,10 @@ fclose(mp->keyfile); return -1; } - rip (response); + skey_rip (response); /* Convert response to binary */ - if(etob(key, response) != 1 && atob8(key, response) != 0){ + if(skey_etob(key, response) != 1 && skey_atob8(key, response) != 0){ /* Neither english words or ascii hex */ fclose(mp->keyfile); return -1; @@ -201,7 +204,7 @@ memcpy(fkey,key,sizeof(key)); fflush (stdout); - f(fkey); + skey_f(fkey); /* in order to make the window of update as short as possible we must do the comparison here and if OK write it back other wise the same password can be used twice to get in @@ -218,13 +221,13 @@ fclose(mp->keyfile); return -1; } - rip(mp->buf); + skey_rip(mp->buf); mp->logname = strtok(mp->buf," \t"); cp = strtok(NULL," \t") ; mp->seed = strtok(NULL," \t"); mp->val = strtok(NULL," \t"); /* And convert file value to hex for comparison */ - atob8(filekey,mp->val); + skey_atob8(filekey,mp->val); /* Do actual comparison */ fflush (stdout); @@ -240,7 +243,7 @@ * that we must write exactly the same number of bytes as in * the original record (note fixed width field for N) */ - btoa8(mp->val,key); + skey_btoa8(mp->val,key); mp->n--; fseek(mp->keyfile,mp->recstart,0); fprintf(mp->keyfile,"%s %04d %-16s %s %-21s\n",mp->logname,mp->n,mp->seed, @@ -256,7 +259,7 @@ /* Convert 8-byte hex-ascii string to binary array * Returns 0 on success, -1 on error */ -atob8(out,in) +skey_atob8(out,in) register char *out,*in; { register int i; @@ -266,15 +269,15 @@ return -1; for(i=0;i<8;i++){ - if((in = skipspace(in)) == NULL) + if((in = skey_skipspace(in)) == NULL) return -1; - if((val = htoi(*in++)) == -1) + if((val = skey_htoi(*in++)) == -1) return -1; *out = val << 4; - if((in = skipspace(in)) == NULL) + if((in = skey_skipspace(in)) == NULL) return -1; - if((val = htoi(*in++)) == -1) + if((val = skey_htoi(*in++)) == -1) return -1; *out++ |= val; } @@ -282,7 +285,7 @@ } char * -skipspace(cp) +skey_skipspace(cp) register char *cp; { while(*cp == ' ' || *cp == '\t') @@ -296,7 +299,7 @@ /* Convert 8-byte binary array to hex-ascii string */ int -btoa8(out,in) +skey_btoa8(out,in) register char *out,*in; { register int i; @@ -314,7 +317,7 @@ /* Convert hex digit to binary integer */ int -htoi(c) +skey_htoi(c) register char c; { if('0' <= c && c <= '9') @@ -353,7 +356,7 @@ char *username; { int i; - char str [50]; + static char str [50]; struct skey skey; @@ -419,8 +422,8 @@ fflush (stdout); printf ("Response: "); - readpass (pbuf, sizeof (pbuf)); - rip (pbuf); + skey_readpass (pbuf, sizeof (pbuf)); + skey_rip (pbuf); /* Is it a valid response? */ if (i == 0 && skeyverify (&skey, pbuf) == 0) =================================================================== RCS file: /src/master/skey/src/skeysubr.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 skeysubr.c --- 1.1.1.1 1995/05/22 14:01:31 +++ skeysubr.c 1995/05/22 14:23:45 @@ -47,12 +47,12 @@ #endif #ifdef SYSV - struct termio newtty; - struct termio oldtty; + struct termio skey_newtty; + struct termio skey_oldtty; #else - struct sgttyb newtty; - struct sgttyb oldtty; - struct tchars chars; + struct sgttyb skey_newtty; + struct sgttyb skey_oldtty; + struct tchars skey_chars; #endif #ifdef SIGVOID @@ -61,13 +61,18 @@ #define SIGTYPE void #endif -SIGTYPE trapped(); +SIGTYPE skey_trapped(); #include "md4.h" #include "skey.h" +#ifdef __bsdi__ +#undef LITTLE_ENDIAN +#undef BIG_ENDIAN +#endif /*BSDI*/ + #if (defined(__MSDOS__) || defined(MPU8086) || defined(MPU8080) \ - || defined(vax) || defined (MIPSEL)) + || defined(vax) || defined (MIPSEL) || defined(i386)) #define LITTLE_ENDIAN #endif @@ -76,7 +81,7 @@ * collapse to 64 bits. This is defined as the user's starting key. */ int -keycrunch(result,seed,passwd) +skey_keycrunch(result,seed,passwd) char *result; /* 8-byte result */ char *seed; /* Seed, any length */ char *passwd; /* Password, any length */ @@ -96,7 +101,7 @@ strcat(buf,passwd); /* Crunch the key through MD4 */ - sevenbit(buf); + skey_sevenbit(buf); MDbegin(&md); MDupdate(&md,(unsigned char *)buf,8*buflen); @@ -129,7 +134,7 @@ } /* The one-way function f(). Takes 8 bytes and returns 8 bytes in place */ -void f (x) +void skey_f (x) char *x; { MDstruct md; @@ -173,7 +178,7 @@ } /* Strip trailing cr/lf from a line of text */ -void rip (buf) +void skey_rip (buf) char *buf; { char *cp; @@ -186,7 +191,7 @@ } #ifdef __MSDOS__ -char *readpass(buf,n) +char *skey_readpass(buf,n) char *buf; int n; { @@ -203,81 +208,81 @@ } #else -char *readpass (buf,n) +char *skey_readpass (buf,n) char *buf; int n; { #ifndef USE_ECHO - set_term (); - echo_off (); + skey_set_term (); + skey_echo_off (); #endif fgets (buf, n, stdin); - rip (buf); + skey_rip (buf); printf ("\n\n"); - sevenbit (buf); + skey_sevenbit (buf); #ifndef USE_ECHO - unset_term (); + skey_unset_term (); #endif return buf; } -set_term () +skey_set_term () { - gtty (fileno(stdin), &newtty); - gtty (fileno(stdin), &oldtty); + gtty (fileno(stdin), &skey_newtty); + gtty (fileno(stdin), &skey_oldtty); - signal (SIGINT, trapped); + signal (SIGINT, skey_trapped); } -echo_off () +skey_echo_off () { #ifdef SYSV - newtty.c_lflag &= ~(ICANON | ECHO | ECHONL); + skey_newtty.c_lflag &= ~(ICANON | ECHO | ECHONL); #else - newtty.sg_flags |= CBREAK; - newtty.sg_flags &= ~ECHO; + skey_newtty.sg_flags |= CBREAK; + skey_newtty.sg_flags &= ~ECHO; #endif #ifdef SYSV - newtty.c_cc[VMIN] = 1; - newtty.c_cc[VTIME] = 0; - newtty.c_cc[VINTR] = 3; + skey_newtty.c_cc[VMIN] = 1; + skey_newtty.c_cc[VTIME] = 0; + skey_newtty.c_cc[VINTR] = 3; #else - ioctl(fileno(stdin), TIOCGETC, &chars); - chars.t_intrc = 3; - ioctl(fileno(stdin), TIOCSETC, &chars); + ioctl(fileno(stdin), TIOCGETC, &skey_chars); + skey_chars.t_intrc = 3; + ioctl(fileno(stdin), TIOCSETC, &skey_chars); #endif - stty (fileno (stdin), &newtty); + stty (fileno (stdin), &skey_newtty); } -unset_term () +skey_unset_term () { - stty (fileno (stdin), &oldtty); + stty (fileno (stdin), &skey_oldtty); #ifndef SYSV - ioctl(fileno(stdin), TIOCSETC, &chars); + ioctl(fileno(stdin), TIOCSETC, &skey_chars); #endif } -void trapped() +void skey_trapped() { - signal (SIGINT, trapped); + signal (SIGINT, skey_trapped); printf ("^C\n"); - unset_term (); + skey_unset_term (); exit (-1); } #endif /* removebackspaced over charaters from the string */ -backspace(buf) +skey_backspace(buf) char *buf; { char bs = 0x8; @@ -309,7 +314,7 @@ * Make sure line is all seven bits. */ -sevenbit (s) +skey_sevenbit (s) char *s; { while (*s) {