version 1.9, 1997/07/27 21:29:59 |
version 1.10, 1997/07/27 21:47:07 |
|
|
|
|
#define TIMEOUT 15 |
#define TIMEOUT 15 |
|
|
int skey_auth __P((char *)); |
void bye __P((int)); |
void quit __P((int)); |
void hi __P((int)); |
void bye __P((int)); |
void quit __P((int)); |
void hi __P((int)); |
int skey_auth __P((char *)); |
|
|
struct timeval timeout; |
struct timeval timeout; |
struct timeval zerotime; |
struct timeval zerotime; |
|
|
break; |
break; |
case '?': |
case '?': |
default: |
default: |
fprintf(stderr, "usage: lock [-n] [-p] [-t timeout]\n"); |
(void)fprintf(stderr, |
|
"usage: lock [-n] [-p] [-t timeout]\n"); |
exit(1); |
exit(1); |
} |
} |
timeout.tv_sec = sectimeout * 60; |
timeout.tv_sec = sectimeout * 60; |
|
|
|
|
if (!mypw) { |
if (!mypw) { |
/* get key and check again */ |
/* get key and check again */ |
printf("Key: "); |
(void)fputs("Key: ", stdout); |
if (!fgets(s, sizeof(s), stdin) || *s == '\n') |
if (!fgets(s, sizeof(s), stdin) || *s == '\n') |
quit(0); |
quit(0); |
printf("\nAgain: "); |
(void)fputs("\nAgain: ", stdout); |
/* |
/* |
* Don't need EOF test here, if we get EOF, then s1 != s |
* Don't need EOF test here, if we get EOF, then s1 != s |
* and the right things will happen. |
* and the right things will happen. |
|
|
|
|
/* header info */ |
/* header info */ |
if (no_timeout) { |
if (no_timeout) { |
printf("lock: %s on %s. no timeout\ntime now is %.20s%s%s", |
(void)printf("lock: %s on %s. no timeout\ntime now is %.20s%s%s", |
ttynam, hostname, ap, tzn, ap + 19); |
ttynam, hostname, ap, tzn, ap + 19); |
} else { |
} else { |
printf("lock: %s on %s. timeout in %d minutes\ntime now is %.20s%s%s", |
(void)printf("lock: %s on %s. timeout in %d minutes\ntime now is %.20s%s%s", |
ttynam, hostname, sectimeout, ap, tzn, ap + 19); |
ttynam, hostname, sectimeout, ap, tzn, ap + 19); |
} |
} |
|
|
for (;;) { |
for (;;) { |
printf("Key: "); |
(void)fputs("Key: ", stdout); |
if (!fgets(s, sizeof(s), stdin)) { |
if (!fgets(s, sizeof(s), stdin)) { |
clearerr(stdin); |
clearerr(stdin); |
hi(0); |
hi(0); |
|
|
} |
} |
else if (!strcmp(s, s1)) |
else if (!strcmp(s, s1)) |
break; |
break; |
printf("\a\n"); |
(void)puts("\a"); |
if (tcsetattr(0, TCSADRAIN, &ntty) < 0) |
if (tcsetattr(0, TCSADRAIN, &ntty) < 0) |
exit(1); |
exit(1); |
} |
} |
|
|
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); |
(void)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 { |
s[strlen(s) - 1] = '\0'; |
rip(s); |
if (skey_passcheck(user, s) != -1) |
if (skey_passcheck(user, s) != -1) |
ret = 1; |
ret = 1; |
} |
} |
} else |
} else |
printf("Sorry, you have no s/key.\n"); |
(void)printf("Sorry, you have no s/key.\n"); |
return ret; |
return(ret); |
} |
} |
#endif |
#endif |
|
|
|
|
if (no_timeout) { |
if (no_timeout) { |
putchar('\n'); |
putchar('\n'); |
} else { |
} else { |
printf("timeout in %ld:%ld minutes\n", |
(void)printf("timeout in %ld:%ld minutes\n", |
(nexttime - timval.tv_sec) / 60, |
(nexttime - timval.tv_sec) / 60, |
(nexttime - timval.tv_sec) % 60); |
(nexttime - timval.tv_sec) % 60); |
} |
} |
|
|
{ |
{ |
if (!no_timeout) { |
if (!no_timeout) { |
(void)tcsetattr(0, TCSADRAIN, &tty); |
(void)tcsetattr(0, TCSADRAIN, &tty); |
printf("lock: timeout\n"); |
(void)puts("lock: timeout"); |
exit(1); |
exit(1); |
} |
} |
} |
} |