summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsin <sin@2f30.org>2014-07-09 14:40:49 +0100
committersin <sin@2f30.org>2014-07-09 14:41:32 +0100
commit8745098fa440ef3bf1d8e173dcd91514b34600c6 (patch)
tree42fe8184d9851a8361172a83e57579e8102e8eae
parent9db14b10dd09336c6a8fe283f99108c9acc4667a (diff)
Only check errno if getpwuid() fails
Checking errno otherwise is unspecified.
-rw-r--r--slock.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/slock.c b/slock.c
index aedee2e..399386b 100644
--- a/slock.c
+++ b/slock.c
@@ -67,10 +67,12 @@ getpw(void) { /* only run as root */
errno = 0;
pw = getpwuid(getuid());
- if (errno)
- die("slock: getpwuid: %s\n", strerror(errno));
- else if (!pw)
- die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n");
+ if (!pw) {
+ if (errno)
+ die("slock: getpwuid: %s\n", strerror(errno));
+ else
+ die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n");
+ }
endpwent();
rval = pw->pw_passwd;