]> git.armaanb.net Git - slock.git/blobdiff - slock.c
applied sin's patch and prepared new release
[slock.git] / slock.c
diff --git a/slock.c b/slock.c
index 506231e16ee779633e5cc4d0e838372f26d42175..5051f04eb8a70a2fc7756fd29d6950850fb4236d 100644 (file)
--- a/slock.c
+++ b/slock.c
@@ -23,6 +23,8 @@
 #include <bsd_auth.h>
 #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;
                                }