#if HAVE_SHADOW_H
if (hash[0] == 'x' && hash[1] == '\0') {
struct spwd *sp;
- if (!(sp = getspnam(getenv("USER"))))
+ if (!(sp = getspnam(pw->pw_name)))
die("slock: getspnam: cannot retrieve shadow entry (make sure to suid or sgid slock)\n");
hash = sp->sp_pwdp;
}
#else
if (hash[0] == '*' && hash[1] == '\0') {
#ifdef __OpenBSD__
- if (!(pw = getpwnam_shadow(getenv("USER"))))
+ if (!(pw = getpwuid_shadow(getuid())))
die("slock: getpwnam_shadow: cannot retrieve shadow entry (make sure to suid or sgid slock)\n");
hash = pw->pw_passwd;
#else
running = 1;
failure = 0;
- /* As "slock" stands for "Simple X display locker", the DPMS settings
- * had been removed and you can set it with "xset" or some other
- * utility. This way the user can easily set a customized DPMS
- * timeout. */
while (running && !XNextEvent(dpy, &ev)) {
if (ev.type == KeyPress) {
explicit_bzero(&buf, sizeof(buf));
#endif
hash = gethash();
- if (strlen(hash) < 2)
- die("slock: failed to get user password hash.\n");
+ errno = 0;
+ if (!crypt("", hash))
+ die("slock: crypt: %s\n", strerror(errno));
if (!(dpy = XOpenDisplay(NULL)))
die("slock: cannot open display\n");