Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef HAVE_BSD_AUTH
- static const char *
- get_password() { /* only run as root */
- const char *rval;
- struct passwd *pw;
- if(geteuid() != 0)
- die("slock: cannot retrieve password entry (make sure to suid slock)\n");
- pw = getpwuid(getuid());
- endpwent();
- rval = pw->pw_passwd;
- #if HAVE_SHADOW_H
- {
- struct spwd *sp;
- sp = getspnam(getenv("USER"));
- endspent();
- rval = sp->sp_pwdp;
- }
- #endif
- /* drop privileges */
- if(setgid(pw->pw_gid) < 0 || setuid(pw->pw_uid) < 0)
- die("slock: cannot drop privileges\n");
- return rval;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement