From 2d2a21a90ad1b53594b1b90b97486189ec54afce Mon Sep 17 00:00:00 2001 From: Markus Teich Date: Wed, 23 Nov 2016 00:29:18 +0100 Subject: [PATCH 01/10] rm trailing whitespace in README --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index a81290d..dcacd01 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ slock - simple screen locker ============================ -simple screen locker utility for X. +simple screen locker utility for X. Requirements From 35633d45672d14bd798c478c45d1a17064701aa9 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Sat, 25 Mar 2017 21:16:01 +0100 Subject: [PATCH 02/10] Properly clear the last entered character When enter is pressed, passwd[len] will be set to '\0'. Pressing backspace is supposed to remove the last entered character. But currently, the clearing has an off-by-one, as in setting passwd[len] to '\0' just like enter would do. You can also verify it by imagining len=1 and that it's impossible to clear passwd[0] by pressing backspace with the current code. Signed-off-by: Tobias Stoeckmann --- slock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slock.c b/slock.c index d55eb3d..5ae738c 100644 --- a/slock.c +++ b/slock.c @@ -177,7 +177,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, break; case XK_BackSpace: if (len) - passwd[len--] = '\0'; + passwd[--len] = '\0'; break; default: if (num && !iscntrl((int)buf[0]) && From 265704d73647e0d4823126bbb7ddde1d415a618d Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Tue, 4 Oct 2022 19:44:47 +0200 Subject: [PATCH 03/10] Makefile: explicit_bzero.c was copied twice (GNU make gives a warning) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f4ffbb7..b20fd4e 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ dist: clean @echo creating dist tarball @mkdir -p slock-${VERSION} @cp -R LICENSE Makefile README slock.1 config.mk \ - ${SRC} explicit_bzero.c config.def.h arg.h util.h slock-${VERSION} + ${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} From 4f045545a25cc02c64bfc08d27ed2ccecb962292 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Tue, 4 Oct 2022 19:45:14 +0200 Subject: [PATCH 04/10] bump version to 1.5 --- config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.mk b/config.mk index 74429ae..1e1ca45 100644 --- a/config.mk +++ b/config.mk @@ -1,5 +1,5 @@ # slock version -VERSION = 1.4 +VERSION = 1.5 # Customize below to fit your system From aecfb3f6803bc2e7a5478aeb4f3390cbaaa563c7 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Fri, 6 Oct 2023 11:39:31 +0200 Subject: [PATCH 05/10] update LICENSE --- LICENSE | 1 + 1 file changed, 1 insertion(+) 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 © 2006-2014 Anselm R Garbe © 2014-2016 Laslo Hunhold +© 2016-2023 Hiltjo Posthuma Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), From 5678764412873baa62e1536f0622d6a7cec62181 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Fri, 6 Oct 2023 11:39:40 +0200 Subject: [PATCH 06/10] Makefile: be verbose and remove options Some things to improve at some point: * Respect system/packaging CFLAGS/LDFLAGS (don't hardcode -Os -Wall -pedantic, -s, etc). --- Makefile | 55 ++++++++++++++++++++----------------------------------- 1 file changed, 20 insertions(+), 35 deletions(-) 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" ${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" ${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 From 2fec14c567411b939e717c380d8b4460d462b146 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Fri, 6 Oct 2023 11:41:19 +0200 Subject: [PATCH 07/10] config.mk: no need to set CC --- config.mk | 3 --- 1 file changed, 3 deletions(-) diff --git a/config.mk b/config.mk index 1e1ca45..514c236 100644 --- a/config.mk +++ b/config.mk @@ -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 From ca6f30f621c1195b577ace7a14b9037fab0dab91 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Fri, 6 Oct 2023 11:48:40 +0200 Subject: [PATCH 08/10] slock.1: improve man page * Fix all lint warnings. * Remove "Op Ar arg..." in the description. It looks ugly. * No need to set -offset left for .Bd literal. --- slock.1 | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/slock.1 b/slock.1 index 82cdcd6..bea2b13 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,33 @@ .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 .Bl -tag -width Ds .It Fl v Print version information to stdout and exit. .El +.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. From e8bca65d629a4faa89439c9f0e599efb5a259573 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Fri, 6 Oct 2023 11:50:11 +0200 Subject: [PATCH 09/10] write version to stdout like the man page says --- slock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slock.c b/slock.c index 5ae738c..b2f14e3 100644 --- a/slock.c +++ b/slock.c @@ -317,7 +317,7 @@ main(int argc, char **argv) { ARGBEGIN { case 'v': - fprintf(stderr, "slock-"VERSION"\n"); + puts("slock-"VERSION); return 0; default: usage(); From a34d8fb4327bbb1afd92e7527c53fcaad547a495 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Fri, 6 Oct 2023 11:57:31 +0200 Subject: [PATCH 10/10] slock.1: use standard wording for options Remove the OPTIONS section and add an EXIT STATUS section. --- slock.1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/slock.1 b/slock.1 index bea2b13..40c15e1 100644 --- a/slock.1 +++ b/slock.1 @@ -14,11 +14,14 @@ 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