1994-10-19 01:14:32 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <skey.h>
|
|
|
|
|
|
|
|
/* skey_getpass - read regular or s/key password */
|
|
|
|
|
1997-03-08 06:22:51 +00:00
|
|
|
char *skey_getpass(prompt, pwd, pwok)
|
|
|
|
const char *prompt;
|
1994-10-19 01:14:32 +01:00
|
|
|
struct passwd *pwd;
|
|
|
|
int pwok;
|
|
|
|
{
|
|
|
|
static char buf[128];
|
|
|
|
struct skey skey;
|
1996-10-18 17:52:33 +01:00
|
|
|
char *pass;
|
1994-10-19 01:14:32 +01:00
|
|
|
int sflag;
|
|
|
|
|
|
|
|
/* Attempt an s/key challenge. */
|
1996-10-18 17:52:33 +01:00
|
|
|
sflag = (pwd == NULL || skeyinfo(&skey, pwd->pw_name, buf));
|
|
|
|
if (!sflag) {
|
1994-10-19 01:14:32 +01:00
|
|
|
printf("%s\n", buf);
|
1996-10-18 17:52:33 +01:00
|
|
|
if (!pwok)
|
|
|
|
printf("(s/key required)\n");
|
1996-10-17 14:43:58 +01:00
|
|
|
}
|
1994-10-19 01:14:32 +01:00
|
|
|
|
|
|
|
pass = getpass(prompt);
|
|
|
|
|
|
|
|
/* Give S/Key users a chance to do it with echo on. */
|
|
|
|
if (!sflag && !feof(stdin) && *pass == '\0') {
|
|
|
|
fputs(" (turning echo on)\n", stdout);
|
|
|
|
fputs(prompt, stdout);
|
|
|
|
fflush(stdout);
|
|
|
|
fgets(buf, sizeof(buf), stdin);
|
|
|
|
rip(buf);
|
|
|
|
return (buf);
|
1994-10-27 18:15:42 +00:00
|
|
|
} else
|
|
|
|
return (pass);
|
1994-10-19 01:14:32 +01:00
|
|
|
}
|