remove support for running post lock command
This command was used for example to suspend-to-ram (man page example). On Linux running this command inherits OOM killer immunity. This could be abused by an other local user on the same machine (abusing resources). To keep the use-case for suspend-to-ram an user could write a wrapper script for it, outside the scope of slock. Simplify argument handling, because the post-lock command parameter is removed. Reported by: Acts1631 <acts1631kjv@proton.me>
This commit is contained in:
1 parent
890eaf6343
commit
65cb721c9e
4 files changed
+7
-95
No files matched your search
@@ -13,14 +13,12 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <spawn.h>
|
||||
#include <sys/types.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include "arg.h"
|
||||
#include "util.h"
|
||||
|
||||
char *argv0;
|
||||
@@ -304,7 +302,7 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
die("usage: slock [-v] [cmd [arg ...]]\n");
|
||||
die("usage: slock [-v]\n");
|
||||
}
|
||||
|
||||
int
|
||||
@@ -319,13 +317,12 @@ main(int argc, char **argv) {
|
||||
Display *dpy;
|
||||
int s, nlocks, nscreens;
|
||||
|
||||
ARGBEGIN {
|
||||
case 'v':
|
||||
if (argc > 1 && !strcmp(argv[1], "-v")) {
|
||||
puts("slock-"VERSION);
|
||||
return 0;
|
||||
default:
|
||||
} else if (argc > 1) {
|
||||
usage();
|
||||
} ARGEND
|
||||
}
|
||||
|
||||
/* validate drop-user and -group */
|
||||
errno = 0;
|
||||
@@ -378,17 +375,6 @@ main(int argc, char **argv) {
|
||||
if (nlocks != nscreens)
|
||||
return 1;
|
||||
|
||||
/* run post-lock command */
|
||||
if (argc > 0) {
|
||||
pid_t pid;
|
||||
extern char **environ;
|
||||
int err = posix_spawnp(&pid, argv[0], NULL, NULL, argv, environ);
|
||||
if (err) {
|
||||
die("slock: failed to execute post-lock command: %s: %s\n",
|
||||
argv[0], strerror(err));
|
||||
}
|
||||
}
|
||||
|
||||
/* everything is now blank. Wait for the correct password */
|
||||
readpw(dpy, &rr, locks, nscreens, hash);
|
||||
|
||||
|
||||
Reference in new issue
Block a user