Only check errno if getpwuid() fails
Checking errno otherwise is unspecified.
This commit is contained in:
parent
9db14b10dd
commit
8745098fa4
1 changed files with 6 additions and 4 deletions
4
slock.c
4
slock.c
|
@ -67,10 +67,12 @@ getpw(void) { /* only run as root */
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
pw = getpwuid(getuid());
|
pw = getpwuid(getuid());
|
||||||
|
if (!pw) {
|
||||||
if (errno)
|
if (errno)
|
||||||
die("slock: getpwuid: %s\n", strerror(errno));
|
die("slock: getpwuid: %s\n", strerror(errno));
|
||||||
else if (!pw)
|
else
|
||||||
die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n");
|
die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n");
|
||||||
|
}
|
||||||
endpwent();
|
endpwent();
|
||||||
rval = pw->pw_passwd;
|
rval = pw->pw_passwd;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue