1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-21 11:13:30 +00:00
freebsd/lib/libskey/skey_getpass.c

42 lines
859 B
C
Raw Normal View History

1994-10-19 00:14:32 +00:00
#include <unistd.h>
#include <stdio.h>
#include <skey.h>
/* skey_getpass - read regular or s/key password */
char *skey_getpass(prompt, pwd, pwok)
char *prompt;
struct passwd *pwd;
int pwok;
{
static char buf[128];
struct skey skey;
char *pass = "";
char *username = pwd ? pwd->pw_name : ":";
1994-10-19 00:14:32 +00:00
int sflag;
/* Attempt an s/key challenge. */
1995-06-11 19:33:05 +00:00
sflag = skeyinfo(&skey, username, buf);
1994-10-19 00:14:32 +00:00
if (!sflag)
printf("%s\n", buf);
if (!pwok) {
1994-10-19 00:14:32 +00:00
printf("(s/key required)\n");
if (sflag)
return (pass);
}
1994-10-19 00:14:32 +00: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 00:14:32 +00:00
}