Make setthetime() static per the prototype.
[dragonfly.git] / lib / libskey / skey_getpass.c
1 #include <unistd.h>
2 #include <stdio.h>
3 #include <skey.h>
4
5 /* skey_getpass - read regular or s/key password */
6
7 char *skey_getpass(prompt, pwd, pwok)
8 const char *prompt;
9 struct passwd *pwd;
10 int     pwok;
11 {
12     static char buf[128];
13     struct skey skey;
14     char   *pass;
15     int     sflag;
16
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");
23     }
24
25     pass = getpass(prompt);
26
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);
37 }