diff options
| author | sin <sin@2f30.org> | 2014-07-09 14:40:49 +0100 |
|---|---|---|
| committer | sin <sin@2f30.org> | 2014-07-09 14:41:32 +0100 |
| commit | 8745098fa440ef3bf1d8e173dcd91514b34600c6 (patch) | |
| tree | 42fe8184d9851a8361172a83e57579e8102e8eae | |
| parent | 9db14b10dd09336c6a8fe283f99108c9acc4667a (diff) | |
Only check errno if getpwuid() fails
Checking errno otherwise is unspecified.
| -rw-r--r-- | slock.c | 10 |
1 files changed, 6 insertions, 4 deletions
| @@ -67,10 +67,12 @@ getpw(void) { /* only run as root */ | |||
| 67 | 67 | ||
| 68 | errno = 0; | 68 | errno = 0; |
| 69 | pw = getpwuid(getuid()); | 69 | pw = getpwuid(getuid()); |
| 70 | if (errno) | 70 | if (!pw) { |
| 71 | die("slock: getpwuid: %s\n", strerror(errno)); | 71 | if (errno) |
| 72 | else if (!pw) | 72 | die("slock: getpwuid: %s\n", strerror(errno)); |
| 73 | die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n"); | 73 | else |
| 74 | die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n"); | ||
| 75 | } | ||
| 74 | endpwent(); | 76 | endpwent(); |
| 75 | rval = pw->pw_passwd; | 77 | rval = pw->pw_passwd; |
| 76 | 78 | ||
