X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=slock.c;h=399386bd31fc3f16bb39bc59e556e72d72c9ee28;hb=8745098fa440ef3bf1d8e173dcd91514b34600c6;hp=506231e16ee779633e5cc4d0e838372f26d42175;hpb=6a5512835485ac501d983161ca15b311a95c5649;p=slock.git diff --git a/slock.c b/slock.c index 506231e..399386b 100644 --- a/slock.c +++ b/slock.c @@ -67,15 +67,17 @@ 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"); + 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"); + } endpwent(); 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) @@ -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; }