summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE1
-rw-r--r--Makefile55
-rw-r--r--config.def.h6
-rw-r--r--config.mk5
-rw-r--r--slock.126
-rw-r--r--slock.c18
6 files changed, 49 insertions, 62 deletions
diff --git a/LICENSE b/LICENSE
index 2e4419b..cb52dba 100644
--- a/LICENSE
+++ b/LICENSE
@@ -4,6 +4,7 @@ MIT/X Consortium License
© 2014 Dimitris Papastamos <sin@2f30.org>
© 2006-2014 Anselm R Garbe <anselm@garbe.us>
© 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
copy of this software and associated documentation files (the "Software"),
diff --git a/Makefile b/Makefile
index b20fd4e..6d74b21 100644
--- a/Makefile
+++ b/Makefile
@@ -6,56 +6,41 @@ include config.mk
SRC = slock.c ${COMPATSRC}
OBJ = ${SRC:.c=.o}
-all: options slock
-
-options:
- @echo slock build options:
- @echo "CFLAGS = ${CFLAGS}"
- @echo "LDFLAGS = ${LDFLAGS}"
- @echo "CC = ${CC}"
+all: slock
.c.o:
- @echo CC $<
- @${CC} -c ${CFLAGS} $<
+ ${CC} -c ${CFLAGS} $<
${OBJ}: config.h config.mk arg.h util.h
config.h:
- @echo creating $@ from config.def.h
- @cp config.def.h $@
+ cp config.def.h $@
slock: ${OBJ}
- @echo CC -o $@
- @${CC} -o $@ ${OBJ} ${LDFLAGS}
+ ${CC} -o $@ ${OBJ} ${LDFLAGS}
clean:
- @echo cleaning
- @rm -f slock ${OBJ} slock-${VERSION}.tar.gz
+ rm -f slock ${OBJ} slock-${VERSION}.tar.gz
dist: clean
- @echo creating dist tarball
- @mkdir -p slock-${VERSION}
- @cp -R LICENSE Makefile README slock.1 config.mk \
+ mkdir -p slock-${VERSION}
+ cp -R LICENSE Makefile README slock.1 config.mk \
${SRC} config.def.h arg.h util.h slock-${VERSION}
- @tar -cf slock-${VERSION}.tar slock-${VERSION}
- @gzip slock-${VERSION}.tar
- @rm -rf slock-${VERSION}
+ tar -cf slock-${VERSION}.tar slock-${VERSION}
+ gzip slock-${VERSION}.tar
+ rm -rf slock-${VERSION}
install: all
- @echo installing executable file to ${DESTDIR}${PREFIX}/bin
- @mkdir -p ${DESTDIR}${PREFIX}/bin
- @cp -f slock ${DESTDIR}${PREFIX}/bin
- @chmod 755 ${DESTDIR}${PREFIX}/bin/slock
- @chmod u+s ${DESTDIR}${PREFIX}/bin/slock
- @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
- @mkdir -p ${DESTDIR}${MANPREFIX}/man1
- @sed "s/VERSION/${VERSION}/g" <slock.1 >${DESTDIR}${MANPREFIX}/man1/slock.1
- @chmod 644 ${DESTDIR}${MANPREFIX}/man1/slock.1
+ mkdir -p ${DESTDIR}${PREFIX}/bin
+ cp -f slock ${DESTDIR}${PREFIX}/bin
+ chmod 755 ${DESTDIR}${PREFIX}/bin/slock
+ chmod u+s ${DESTDIR}${PREFIX}/bin/slock
+ mkdir -p ${DESTDIR}${MANPREFIX}/man1
+ sed "s/VERSION/${VERSION}/g" <slock.1 >${DESTDIR}${MANPREFIX}/man1/slock.1
+ chmod 644 ${DESTDIR}${MANPREFIX}/man1/slock.1
uninstall:
- @echo removing executable file from ${DESTDIR}${PREFIX}/bin
- @rm -f ${DESTDIR}${PREFIX}/bin/slock
- @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
- @rm -f ${DESTDIR}${MANPREFIX}/man1/slock.1
+ rm -f ${DESTDIR}${PREFIX}/bin/slock
+ rm -f ${DESTDIR}${MANPREFIX}/man1/slock.1
-.PHONY: all options clean dist install uninstall
+.PHONY: all clean dist install uninstall
diff --git a/config.def.h b/config.def.h
index 9855e21..9d910ea 100644
--- a/config.def.h
+++ b/config.def.h
@@ -3,9 +3,9 @@ static const char *user = "nobody";
static const char *group = "nogroup";
static const char *colorname[NUMCOLS] = {
- [INIT] = "black", /* after initialization */
- [INPUT] = "#005577", /* during input */
- [FAILED] = "#CC3333", /* wrong password */
+ [INIT] = "black", /* after initialization */
+ [INPUT] = "black", /* during input */
+ [FAILED] = "black", /* wrong password */
};
/* treat a cleared input like a wrong password (color) */
diff --git a/config.mk b/config.mk
index 1e1ca45..dcd27d0 100644
--- a/config.mk
+++ b/config.mk
@@ -1,5 +1,5 @@
# slock version
-VERSION = 1.5
+VERSION = 1.6
# Customize below to fit your system
@@ -27,6 +27,3 @@ COMPATSRC = explicit_bzero.c
#CPPFLAGS = -DVERSION=\"${VERSION}\" -D_BSD_SOURCE -D_NETBSD_SOURCE
# On OpenBSD set COMPATSRC to empty
#COMPATSRC =
-
-# compiler and linker
-CC = cc
diff --git a/slock.1 b/slock.1
index 82cdcd6..40c15e1 100644
--- a/slock.1
+++ b/slock.1
@@ -1,5 +1,6 @@
-.Dd 2016-08-23
+.Dd October 6, 2023
.Dt SLOCK 1
+.Os
.Sh NAME
.Nm slock
.Nd simple X screen locker
@@ -9,31 +10,36 @@
.Op Ar cmd Op Ar arg ...
.Sh DESCRIPTION
.Nm
-is a simple X screen locker. If provided,
-.Ar cmd Op Ar arg ...
+is a simple X screen locker.
+If provided,
+.Ar cmd
is executed after the screen has been locked.
-.Sh OPTIONS
+.Pp
+The options are as follows:
.Bl -tag -width Ds
.It Fl v
Print version information to stdout and exit.
.El
+.Sh EXIT STATUS
+.Ex -std
+.Sh EXAMPLES
+$
+.Nm
+/usr/sbin/s2ram
.Sh SECURITY CONSIDERATIONS
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
to disable both in
.Xr xorg.conf 5
for maximum security:
-.Bd -literal -offset left
+.Bd -literal
Section "ServerFlags"
Option "DontVTSwitch" "True"
Option "DontZap" "True"
EndSection
.Ed
-.Sh EXAMPLES
-$
-.Nm
-/usr/sbin/s2ram
.Sh CUSTOMIZATION
.Nm
can be customized by creating a custom config.h from config.def.h and
-(re)compiling the source code. This keeps it fast, secure and simple.
+(re)compiling the source code.
+This keeps it fast, secure and simple.
diff --git a/slock.c b/slock.c
index 5ae738c..b5a9b04 100644
--- a/slock.c
+++ b/slock.c
@@ -13,6 +13,7 @@
#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>
@@ -317,7 +318,7 @@ main(int argc, char **argv) {
ARGBEGIN {
case 'v':
- fprintf(stderr, "slock-"VERSION"\n");
+ puts("slock-"VERSION);
return 0;
default:
usage();
@@ -376,15 +377,12 @@ main(int argc, char **argv) {
/* run post-lock command */
if (argc > 0) {
- switch (fork()) {
- case -1:
- die("slock: fork failed: %s\n", strerror(errno));
- case 0:
- if (close(ConnectionNumber(dpy)) < 0)
- die("slock: close: %s\n", strerror(errno));
- execvp(argv[0], argv);
- fprintf(stderr, "slock: execvp %s: %s\n", argv[0], strerror(errno));
- _exit(1);
+ 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));
}
}