aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slock.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/slock.c b/slock.c
index 2dce109..d150009 100644
--- a/slock.c
+++ b/slock.c
@@ -50,9 +50,9 @@ getpw(void) { /* only run as root */
50 const char *rval; 50 const char *rval;
51 struct passwd *pw; 51 struct passwd *pw;
52 52
53 if(geteuid() != 0)
54 die("cannot retrieve password entry (make sure to suid slock)");
55 pw = getpwuid(getuid()); 53 pw = getpwuid(getuid());
54 if(!pw)
55 die("cannot retrieve password entry (make sure to suid or sgid slock)");
56 endpwent(); 56 endpwent();
57 rval = pw->pw_passwd; 57 rval = pw->pw_passwd;
58 58
@@ -60,6 +60,8 @@ getpw(void) { /* only run as root */
60 { 60 {
61 struct spwd *sp; 61 struct spwd *sp;
62 sp = getspnam(getenv("USER")); 62 sp = getspnam(getenv("USER"));
63 if(!sp)
64 die("slock: cannot retrieve shadow entry (make sure to suid or sgid slock)\n");
63 endspent(); 65 endspent();
64 rval = sp->sp_pwdp; 66 rval = sp->sp_pwdp;
65 } 67 }