From 7d6e5770c7a42379fb8e938455a18b68a65d84b3 Mon Sep 17 00:00:00 2001 From: pst Date: Wed, 19 Oct 1994 00:14:32 +0000 Subject: new file does skey_getpass() support --- lib/libskey/skey_getpass.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 lib/libskey/skey_getpass.c (limited to 'lib/libskey') diff --git a/lib/libskey/skey_getpass.c b/lib/libskey/skey_getpass.c new file mode 100644 index 0000000..1608355 --- /dev/null +++ b/lib/libskey/skey_getpass.c @@ -0,0 +1,40 @@ +#include +#include +#include + +/* 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 : "nope"; + int sflag; + + /* Attempt an s/key challenge. */ + sflag = skeychallenge(&skey, username, 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); + } + + putchar('\n'); + return (pass); +} -- cgit v1.1