diff options
Diffstat (limited to 'slock.c')
-rw-r--r-- | slock.c | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -301,7 +301,7 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen) static void usage(void) { - die("usage: slock [-f [-p]] [-v] [cmd [arg ...]]\n"); + die("usage: slock [-k] [-f [-p]] [-v] [cmd [arg ...]]\n"); } int @@ -315,13 +315,17 @@ main(int argc, char **argv) { const char *hash; Display *dpy; int s, nlocks, nscreens; - int opt_fork, opt_pid; + int opt_killable, opt_fork, opt_pid; pid_t pid; + opt_killable = 0; opt_fork = 0; opt_pid = 0; ARGBEGIN { + case 'k': + opt_killable = 1; + break; case 'f': opt_fork = 1; break; @@ -365,10 +369,17 @@ main(int argc, char **argv) { /* drop privileges */ if (setgroups(0, NULL) < 0) die("slock: setgroups: %s\n", strerror(errno)); - if (setgid(dgid) < 0) - die("slock: setgid: %s\n", strerror(errno)); - if (setuid(duid) < 0) - die("slock: setuid: %s\n", strerror(errno)); + if (opt_killable) { + if (setregid(-1, dgid) < 0) + die("slock: setregid: %s\n", strerror(errno)); + if (setreuid(-1, duid) < 0) + die("slock: setreuid: %s\n", strerror(errno)); + } else { + if (setgid(dgid) < 0) + die("slock: setgid: %s\n", strerror(errno)); + if (setuid(duid) < 0) + die("slock: setuid: %s\n", strerror(errno)); + } /* check for Xrandr support */ rr.active = XRRQueryExtension(dpy, &rr.evbase, &rr.errbase); |