--- passwd.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/passwd.c b/passwd.c index 3ea3dd1..5cf88a7 100644 --- a/passwd.c +++ b/passwd.c _AT_@ -141,9 +141,12 @@ main(int argc, char *argv[]) struct passwd *pw; struct spwd *spw = NULL; FILE *fp = NULL; - int r = -1, status = 1; + int r = -1, status = 1, dflg = 0; ARGBEGIN { + case 'd': + dflg = 1; + break; default: usage(); } ARGEND; _AT_@ -207,10 +210,13 @@ main(int argc, char *argv[]) eprintf("incorrect password\n"); newpass: - inpass = getpass("Enter new password: "); + if (dflg) + inpass = ""; + else + inpass = getpass("Enter new password: "); if (!inpass) eprintf("getpass:"); - if (inpass[0] == '\0') + if (inpass[0] == '\0' && !dflg) eprintf("no password supplied\n"); p = crypt(inpass, salt); if (!p) _AT_@ -222,10 +228,11 @@ newpass: /* Flush pending input */ ioctl(0, TCFLSH, (void *)0); - inpass = getpass("Retype new password: "); + if (!dflg) + inpass = getpass("Retype new password: "); if (!inpass) eprintf("getpass:"); - if (inpass[0] == '\0') + if (inpass[0] == '\0' && !dflg) eprintf("no password supplied\n"); p = crypt(inpass, salt); if (!p) -- 2.10.2Received on Tue Mar 14 2017 - 22:44:06 CET
This archive was generated by hypermail 2.3.0 : Tue Mar 14 2017 - 22:48:17 CET