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.
This commit is contained in:
Hiltjo Posthuma 2014-07-09 14:08:09 +00:00 committed by sin
parent 10c8b71fd2
commit 528f10be6c
1 changed files with 5 additions and 5 deletions

View File

@ -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;