ubase

suckless linux base utils
git clone git://git.2f30.org/ubase.git
Log | Files | Refs | README | LICENSE

commit 1b6fab85d627114f1a8f7674e47b867e2d00d8a9
parent 834279b4a9d52fa12c379b85812e781c01531e13
Author: sin <sin@2f30.org>
Date:   Mon Jun  9 12:46:40 +0100

Fix passwd semantics

Diffstat:
passwd.c | 31++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/passwd.c b/passwd.c @@ -45,25 +45,26 @@ main(int argc, char *argv[]) else if (!pw) eprintf("who are you?\n"); - uid = getuid(); - if (uid == 0) - goto newpass; - - switch (pw->pw_passwd[0]) { - case '!': - case '*': - eprintf("denied\n"); - } + if (pw->pw_passwd[0] == 'x' && pw->pw_passwd[1] == '\0') + eprintf("no shadow support\n"); - if (pw->pw_passwd[0] == '\0') { - /* Default to SHA-512 for empty passwords */ - pw->pw_passwd = "$6$"; + uid = getuid(); + if (uid == 0) { + if (pw->pw_passwd[0] == '!' || + pw->pw_passwd[0] == '*' || + pw->pw_passwd[0] == '\0') + pw->pw_passwd = "$6$"; goto newpass; + } else { + if (pw->pw_passwd[0] == '!' || + pw->pw_passwd[0] == '*') + eprintf("denied\n"); + if (pw->pw_passwd[0] == '\0') { + pw->pw_passwd = "$6$"; + goto newpass; + } } - if (pw->pw_passwd[0] == 'x' && pw->pw_passwd[1] == '\0') - eprintf("no shadow support\n"); - /* Flush pending input */ ioctl(STDIN_FILENO, TCFLSH, (void *)0);