X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=slock.c;h=face75e7e3e09ba96453e7fea5b6a9aef9c21c22;hb=66e31556db4921b5f24ced47dae5e1c7ea3bd150;hp=506231e16ee779633e5cc4d0e838372f26d42175;hpb=6a5512835485ac501d983161ca15b311a95c5649;p=slock.git diff --git a/slock.c b/slock.c index 506231e..face75e 100644 --- a/slock.c +++ b/slock.c @@ -23,6 +23,8 @@ #include #endif +#include "config.h" + typedef struct { int screen; Window root, win; @@ -67,20 +69,20 @@ 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"); - endpwent(); + 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"); + } rval = pw->pw_passwd; #if HAVE_SHADOW_H - if (strlen(rval) >= 1) { /* kludge, assumes pw placeholder entry has len >= 1 */ + if (rval[0] == 'x' && rval[1] == '\0') { struct spwd *sp; sp = getspnam(getenv("USER")); if(!sp) die("slock: cannot retrieve shadow entry (make sure to suid or sgid slock)\n"); - endspent(); rval = sp->sp_pwdp; } #endif @@ -147,7 +149,7 @@ readpw(Display *dpy, const char *pws) --len; break; default: - if(num && !iscntrl((int) buf[0]) && (len + num < sizeof passwd)) { + if(num && !iscntrl((int) buf[0]) && (len + num < sizeof passwd)) { memcpy(passwd + len, buf, num); len += num; } @@ -259,7 +261,7 @@ main(int argc, char **argv) { int screen; if((argc == 2) && !strcmp("-v", argv[1])) - die("slock-%s, © 2006-2012 Anselm R Garbe\n", VERSION); + die("slock-%s, © 2006-2014 slock engineers\n", VERSION); else if(argc != 1) usage();