]> git.armaanb.net Git - slock.git/commitdiff
Add /etc/passwd support
authorFRIGN <dev@frign.de>
Tue, 3 Jun 2014 17:19:10 +0000 (19:19 +0200)
committersin <sin@2f30.org>
Mon, 9 Jun 2014 18:14:31 +0000 (19:14 +0100)
Fix slock to work with /etc/passwd without /etc/shadow.
while we're at it, remove an occurence of trailing whitespace.

slock.c

diff --git a/slock.c b/slock.c
index 506231e16ee779633e5cc4d0e838372f26d42175..aedee2e8eceac44bc60304424bbcece4b32f6269 100644 (file)
--- a/slock.c
+++ b/slock.c
@@ -75,7 +75,7 @@ getpw(void) { /* only run as root */
        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 +147,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;
                                }