From 528f10be6c3f38fdb99193e8fff1e810c5ccb1c5 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Wed, 9 Jul 2014 14:08:09 +0000 Subject: [PATCH] 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//shadow doesn't exist. --- util/passwd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/util/passwd.c b/util/passwd.c index 2d91763..d805955 100644 --- 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;