aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsin <sin@2f30.org>2013-11-14 11:24:08 +0000
committersin <sin@2f30.org>2014-01-29 14:19:35 +0000
commit6a5512835485ac501d983161ca15b311a95c5649 (patch)
treec78b7e26ba7979b47e4793a453e1d0ab367f34a6
parentba3acfc0dcf1d0603bd9d6bdee1e319339b1a509 (diff)
downloadslock-6a5512835485ac501d983161ca15b311a95c5649.tar.gz
slock-6a5512835485ac501d983161ca15b311a95c5649.tar.xz
Set errno to 0 before getpwuid() and check it afterwards
-rw-r--r--slock.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/slock.c b/slock.c
index 467937c..506231e 100644
--- 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;