mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-20 11:11:24 +00:00
1a277b7ae9
Cannidate for: 2.2 (please!)
38 lines
796 B
C
38 lines
796 B
C
#include <unistd.h>
|
|
#include <stdio.h>
|
|
#include <skey.h>
|
|
|
|
/* skey_getpass - read regular or s/key password */
|
|
|
|
char *skey_getpass(prompt, pwd, pwok)
|
|
const char *prompt;
|
|
struct passwd *pwd;
|
|
int pwok;
|
|
{
|
|
static char buf[128];
|
|
struct skey skey;
|
|
char *pass;
|
|
int sflag;
|
|
|
|
/* Attempt an s/key challenge. */
|
|
sflag = (pwd == NULL || skeyinfo(&skey, pwd->pw_name, buf));
|
|
if (!sflag) {
|
|
printf("%s\n", buf);
|
|
if (!pwok)
|
|
printf("(s/key required)\n");
|
|
}
|
|
|
|
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);
|
|
} else
|
|
return (pass);
|
|
}
|