version 1.6, 1996/09/06 01:57:15 |
version 1.7, 1996/10/16 00:09:20 |
|
|
#include <termios.h> |
#include <termios.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
|
#ifdef SKEY |
|
#include <skey.h> |
|
#endif |
|
|
#define TIMEOUT 15 |
#define TIMEOUT 15 |
|
|
void quit(), bye(), hi(); |
void quit(), bye(), hi(); |
|
|
int argc; |
int argc; |
char **argv; |
char **argv; |
{ |
{ |
extern char *optarg; |
|
struct passwd *pw; |
struct passwd *pw; |
struct timeval timval; |
struct timeval timval; |
struct itimerval ntimer, otimer; |
struct itimerval ntimer, otimer; |
|
|
int ch, sectimeout, usemine; |
int ch, sectimeout, usemine; |
char *ap, *mypw, *ttynam, *tzn; |
char *ap, *mypw, *ttynam, *tzn; |
char hostname[MAXHOSTNAMELEN], s[BUFSIZ], s1[BUFSIZ]; |
char hostname[MAXHOSTNAMELEN], s[BUFSIZ], s1[BUFSIZ]; |
char *crypt(); |
|
|
|
sectimeout = TIMEOUT; |
sectimeout = TIMEOUT; |
mypw = NULL; |
mypw = NULL; |
|
|
} |
} |
timeout.tv_sec = sectimeout * 60; |
timeout.tv_sec = sectimeout * 60; |
|
|
setuid(getuid()); /* discard privs */ |
seteuid(getuid()); /* discard what privs we can */ |
|
|
if (tcgetattr(0, &tty) < 0) /* get information for header */ |
if (tcgetattr(0, &tty) < 0) /* get information for header */ |
exit(1); |
exit(1); |
|
|
(void)fgets(s1, sizeof(s1), stdin); |
(void)fgets(s1, sizeof(s1), stdin); |
(void)putchar('\n'); |
(void)putchar('\n'); |
if (strcmp(s1, s)) { |
if (strcmp(s1, s)) { |
(void)printf("\alock: passwords didn't match.\n"); |
(void)puts("\alock: passwords didn't match."); |
(void)tcsetattr(0, TCSADRAIN, &tty); |
(void)tcsetattr(0, TCSADRAIN, &tty); |
exit(1); |
exit(1); |
} |
} |
|
|
s[strlen(s) - 1] = '\0'; |
s[strlen(s) - 1] = '\0'; |
#ifdef SKEY |
#ifdef SKEY |
if (strcasecmp(s, "s/key") == 0) { |
if (strcasecmp(s, "s/key") == 0) { |
if (skey_auth(pw->pw_name)) |
/* S/Key lookup needs to be done as root */ |
|
seteuid(0); |
|
ch = skey_auth(pw->pw_name); |
|
seteuid(getuid()); |
|
if (ch) |
break; |
break; |
} |
} |
#endif |
#endif |
|
|
skey_auth(user) |
skey_auth(user) |
char *user; |
char *user; |
{ |
{ |
char s[128], *ask, *skey_keyinfo __P((char *name)); |
char s[256], *ask; |
int ret = 0; |
int ret = 0; |
|
|
if (!skey_haskey(user) && (ask = skey_keyinfo(user))) { |
if (!skey_haskey(user) && (ask = skey_keyinfo(user))) { |
printf("\n[%s]\nResponse: ", ask); |
printf("\n%s\nResponse: ", ask); |
if (!fgets(s, sizeof(s), stdin) || *s == '\n') |
if (!fgets(s, sizeof(s), stdin) || *s == '\n') |
clearerr(stdin); |
clearerr(stdin); |
else { |
else { |