Re-add ascii2addr() and addr2ascii() prototypes.
[dragonfly.git] / lib / libskey / skey_getpass.c
blobe788a8a8e95c6c25014264af6dc081a1e7839e3a
1 /* $DragonFly: src/lib/libskey/skey_getpass.c,v 1.2 2008/09/30 16:57:05 swildner Exp $ */
3 #include <unistd.h>
4 #include <stdio.h>
5 #include <skey.h>
7 /* skey_getpass - read regular or s/key password */
9 char *
10 skey_getpass(const char *prompt, struct passwd *pwd, int pwok)
12 static char buf[128];
13 struct skey skey;
14 char *pass;
15 int sflag;
17 /* Attempt an s/key challenge. */
18 sflag = (pwd == NULL || skeyinfo(&skey, pwd->pw_name, buf));
19 if (!sflag) {
20 printf("%s\n", buf);
21 if (!pwok)
22 printf("(s/key required)\n");
25 pass = getpass(prompt);
27 /* Give S/Key users a chance to do it with echo on. */
28 if (!sflag && !feof(stdin) && *pass == '\0') {
29 fputs(" (turning echo on)\n", stdout);
30 fputs(prompt, stdout);
31 fflush(stdout);
32 fgets(buf, sizeof(buf), stdin);
33 rip(buf);
34 return (buf);
35 } else
36 return (pass);