ubase

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

commit 528f10be6c3f38fdb99193e8fff1e810c5ccb1c5
parent 10c8b71fd235be78cd483864e32d51aa4c225dae
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Wed,  9 Jul 2014 14:08:09 +0000

util/passwd.c: check errno only if spw is NULL

this is more reliable. there is a difference between glibc and musl
errno if /etc/tcb/<name>/shadow doesn't exist.

Diffstat:
util/passwd.c | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/util/passwd.c b/util/passwd.c @@ -38,11 +38,11 @@ pw_check(struct passwd *pw, const char *pass) if (pw->pw_passwd[0] == 'x' && pw->pw_passwd[1] == '\0') { errno = 0; spw = getspnam(pw->pw_name); - if (errno) { - weprintf("getspnam: %s:", pw->pw_name); - return -1; - } else if (!spw) { - weprintf("who are you?\n"); + if (!spw) { + if (errno) + weprintf("getspnam: %s:", pw->pw_name); + else + weprintf("who are you?\n"); return -1; } p = spw->sp_pwdp;