diff options
-rw-r--r-- | slock.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -123,7 +123,7 @@ readpw(Display *dpy) | |||
123 | readpw(Display *dpy, const char *pws) | 123 | readpw(Display *dpy, const char *pws) |
124 | #endif | 124 | #endif |
125 | { | 125 | { |
126 | char buf[32], passwd[256]; | 126 | char buf[32], passwd[256], *encrypted; |
127 | int num, screen; | 127 | int num, screen; |
128 | unsigned int len, color; | 128 | unsigned int len, color; |
129 | KeySym ksym; | 129 | KeySym ksym; |
@@ -159,7 +159,11 @@ readpw(Display *dpy, const char *pws) | |||
159 | #ifdef HAVE_BSD_AUTH | 159 | #ifdef HAVE_BSD_AUTH |
160 | running = !auth_userokay(getlogin(), NULL, "auth-slock", passwd); | 160 | running = !auth_userokay(getlogin(), NULL, "auth-slock", passwd); |
161 | #else | 161 | #else |
162 | running = !!strcmp(crypt(passwd, pws), pws); | 162 | errno = 0; |
163 | if (!(encrypted = crypt(passwd, pws))) | ||
164 | fprintf(stderr, "slock: crypt: %s\n", strerror(errno)); | ||
165 | else | ||
166 | running = !!strcmp(encrypted, pws); | ||
163 | #endif | 167 | #endif |
164 | if (running) { | 168 | if (running) { |
165 | XBell(dpy, 100); | 169 | XBell(dpy, 100); |
@@ -312,6 +316,8 @@ main(int argc, char **argv) { | |||
312 | 316 | ||
313 | #ifndef HAVE_BSD_AUTH | 317 | #ifndef HAVE_BSD_AUTH |
314 | pws = getpw(); | 318 | pws = getpw(); |
319 | if (strlen(pws) < 2) | ||
320 | die("slock: failed to get user password hash.\n"); | ||
315 | #endif | 321 | #endif |
316 | 322 | ||
317 | if (!(dpy = XOpenDisplay(NULL))) | 323 | if (!(dpy = XOpenDisplay(NULL))) |