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:
parent
10c8b71fd2
commit
528f10be6c
@ -38,11 +38,11 @@ pw_check(struct passwd *pw, const char *pass)
|
|||||||
if (pw->pw_passwd[0] == 'x' && pw->pw_passwd[1] == '\0') {
|
if (pw->pw_passwd[0] == 'x' && pw->pw_passwd[1] == '\0') {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
spw = getspnam(pw->pw_name);
|
spw = getspnam(pw->pw_name);
|
||||||
if (errno) {
|
if (!spw) {
|
||||||
weprintf("getspnam: %s:", pw->pw_name);
|
if (errno)
|
||||||
return -1;
|
weprintf("getspnam: %s:", pw->pw_name);
|
||||||
} else if (!spw) {
|
else
|
||||||
weprintf("who are you?\n");
|
weprintf("who are you?\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p = spw->sp_pwdp;
|
p = spw->sp_pwdp;
|
||||||
|
Loading…
Reference in New Issue
Block a user