2 Commits
Author SHA1 Message Date
Hiltjo Posthuma 65cb721c9e 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>
2026-09-05 12:57:54 +02:00
Hiltjo Posthuma 890eaf6343 bump LICENSE year
... and sort by maintainer
2026-09-05 12:53:39 +02:00
5 changed files with 8 additions and 96 deletions

No files matched your search

+1 -1
View File
@@ -1,10 +1,10 @@
MIT/X Consortium License MIT/X Consortium License
© 2016-2026 Hiltjo Posthuma <hiltjo@codemadness.org>
© 2015-2016 Markus Teich <markus.teich@stusta.mhn.de> © 2015-2016 Markus Teich <markus.teich@stusta.mhn.de>
© 2014 Dimitris Papastamos <sin@2f30.org> © 2014 Dimitris Papastamos <sin@2f30.org>
© 2006-2014 Anselm R Garbe <anselm@garbe.us> © 2006-2014 Anselm R Garbe <anselm@garbe.us>
© 2014-2016 Laslo Hunhold <dev@frign.de> © 2014-2016 Laslo Hunhold <dev@frign.de>
© 2016-2023 Hiltjo Posthuma <hiltjo@codemadness.org>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
+2 -2
View File
@@ -11,7 +11,7 @@ all: slock
.c.o: .c.o:
${CC} -c ${CFLAGS} $< ${CC} -c ${CFLAGS} $<
${OBJ}: config.h config.mk arg.h util.h ${OBJ}: config.h config.mk util.h
config.h: config.h:
cp config.def.h $@ cp config.def.h $@
@@ -25,7 +25,7 @@ clean:
dist: clean dist: clean
mkdir -p slock-${VERSION} mkdir -p slock-${VERSION}
cp -R LICENSE Makefile README slock.1 config.mk \ cp -R LICENSE Makefile README slock.1 config.mk \
${SRC} config.def.h arg.h util.h slock-${VERSION} ${SRC} config.def.h util.h slock-${VERSION}
tar -cf slock-${VERSION}.tar slock-${VERSION} tar -cf slock-${VERSION}.tar slock-${VERSION}
gzip slock-${VERSION}.tar gzip slock-${VERSION}.tar
rm -rf slock-${VERSION} rm -rf slock-${VERSION}
-65
View File
@@ -1,65 +0,0 @@
/*
* Copy me if you can.
* by 20h
*/
#ifndef ARG_H__
#define ARG_H__
extern char *argv0;
/* use main(int argc, char *argv[]) */
#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
argv[0] && argv[0][0] == '-'\
&& argv[0][1];\
argc--, argv++) {\
char argc_;\
char **argv_;\
int brk_;\
if (argv[0][1] == '-' && argv[0][2] == '\0') {\
argv++;\
argc--;\
break;\
}\
for (brk_ = 0, argv[0]++, argv_ = argv;\
argv[0][0] && !brk_;\
argv[0]++) {\
if (argv_ != argv)\
break;\
argc_ = argv[0][0];\
switch (argc_)
/* Handles obsolete -NUM syntax */
#define ARGNUM case '0':\
case '1':\
case '2':\
case '3':\
case '4':\
case '5':\
case '6':\
case '7':\
case '8':\
case '9'
#define ARGEND }\
}
#define ARGC() argc_
#define ARGNUMF() (brk_ = 1, estrtonum(argv[0], 0, INT_MAX))
#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\
((x), abort(), (char *)0) :\
(brk_ = 1, (argv[0][1] != '\0')?\
(&argv[0][1]) :\
(argc--, argv++, argv[0])))
#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\
(char *)0 :\
(brk_ = 1, (argv[0][1] != '\0')?\
(&argv[0][1]) :\
(argc--, argv++, argv[0])))
#define LNGARG() &argv[0][0]
#endif
+1 -10
View File
@@ -1,4 +1,4 @@
.Dd October 6, 2023 .Dd September 5, 2026
.Dt SLOCK 1 .Dt SLOCK 1
.Os .Os
.Sh NAME .Sh NAME
@@ -7,14 +7,9 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl v .Op Fl v
.Op Ar cmd Op Ar arg ...
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
is a simple X screen locker. is a simple X screen locker.
If provided,
.Ar cmd
is executed after the screen has been locked.
.Pp
The options are as follows: The options are as follows:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Fl v .It Fl v
@@ -22,10 +17,6 @@ Print version information to stdout and exit.
.El .El
.Sh EXIT STATUS .Sh EXIT STATUS
.Ex -std .Ex -std
.Sh EXAMPLES
$
.Nm
/usr/sbin/s2ram
.Sh SECURITY CONSIDERATIONS .Sh SECURITY CONSIDERATIONS
To make sure a locked screen can not be bypassed by switching VTs To make sure a locked screen can not be bypassed by switching VTs
or killing the X server with Ctrl+Alt+Backspace, it is recommended or killing the X server with Ctrl+Alt+Backspace, it is recommended
+4 -18
View File
@@ -13,14 +13,12 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <spawn.h>
#include <sys/types.h> #include <sys/types.h>
#include <X11/extensions/Xrandr.h> #include <X11/extensions/Xrandr.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include "arg.h"
#include "util.h" #include "util.h"
char *argv0; char *argv0;
@@ -304,7 +302,7 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
static void static void
usage(void) usage(void)
{ {
die("usage: slock [-v] [cmd [arg ...]]\n"); die("usage: slock [-v]\n");
} }
int int
@@ -319,13 +317,12 @@ main(int argc, char **argv) {
Display *dpy; Display *dpy;
int s, nlocks, nscreens; int s, nlocks, nscreens;
ARGBEGIN { if (argc > 1 && !strcmp(argv[1], "-v")) {
case 'v':
puts("slock-"VERSION); puts("slock-"VERSION);
return 0; return 0;
default: } else if (argc > 1) {
usage(); usage();
} ARGEND }
/* validate drop-user and -group */ /* validate drop-user and -group */
errno = 0; errno = 0;
@@ -378,17 +375,6 @@ main(int argc, char **argv) {
if (nlocks != nscreens) if (nlocks != nscreens)
return 1; 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 */ /* everything is now blank. Wait for the correct password */
readpw(dpy, &rr, locks, nscreens, hash); readpw(dpy, &rr, locks, nscreens, hash);