pinosaur
/
slock.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ba3acfc
)
Set errno to 0 before getpwuid() and check it afterwards
author
sin
<sin@2f30.org>
Thu, 14 Nov 2013 11:24:08 +0000
(11:24 +0000)
committer
sin
<sin@2f30.org>
Wed, 29 Jan 2014 14:19:35 +0000
(14:19 +0000)
slock.c
patch
|
blob
|
history
diff --git
a/slock.c
b/slock.c
index
467937c
..
506231e
100644
(file)
--- a/
slock.c
+++ b/
slock.c
@@
-65,8
+65,11
@@
getpw(void) { /* only run as root */
const char *rval;
struct passwd *pw;
+ errno = 0;
pw = getpwuid(getuid());
- if(!pw)
+ 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");
endpwent();
rval = pw->pw_passwd;