mirror of git://git.suckless.org/ubase
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') {
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue