mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-11 17:04:19 +01:00
new file does skey_getpass() support
This commit is contained in:
parent
cdb29d3268
commit
6d7d1e5932
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=3709
40
lib/libskey/skey_getpass.c
Normal file
40
lib/libskey/skey_getpass.c
Normal file
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user