diff options
author | Paul Traina <pst@FreeBSD.org> | 1994-10-19 00:14:32 +0000 |
---|---|---|
committer | Paul Traina <pst@FreeBSD.org> | 1994-10-19 00:14:32 +0000 |
commit | 6d7d1e5932bd000cb1f40a30d117d32ca23acd9a (patch) | |
tree | 1ae0404a30c16c2168f89f9f9791df58e3d3357a /lib/libskey | |
parent | cdb29d3268214f3e3e9cbdd5baeb4c3b88b4d0d4 (diff) | |
download | src-6d7d1e5932bd000cb1f40a30d117d32ca23acd9a.tar.gz src-6d7d1e5932bd000cb1f40a30d117d32ca23acd9a.zip |
new file does skey_getpass() support
Notes
Notes:
svn path=/head/; revision=3709
Diffstat (limited to 'lib/libskey')
-rw-r--r-- | lib/libskey/skey_getpass.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/libskey/skey_getpass.c b/lib/libskey/skey_getpass.c new file mode 100644 index 000000000000..1608355f9eff --- /dev/null +++ b/lib/libskey/skey_getpass.c @@ -0,0 +1,40 @@ +#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 : "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); +} |