~kris/suckless

slock

35fd53f6f2f5c911532572e889333c4b43927afa — bakkeby 5 years ago 7dc4501
Adding secret password patch
4 files changed, 37 insertions(+), 1 deletions(-)

M README.md
M config.def.h
M patches.def.h
M slock.c
M README.md => README.md +4 -1
@@ 26,7 26,7 @@ slock tool, how to install it and how it works.

### Changelog:

2021-09-09 - Added the failure-command patch
2021-09-09 - Added the failure-command and secret-password patches

2021-06-08 - Added the color message patch



@@ 88,6 88,9 @@ slock tool, how to install it and how it works.
      - this can be useful if you forgot to disable xautolock during an activity that requires no
        input (e.g. reading text, watching video, etc.)

   - [secret-password](https://tools.suckless.org/slock/patches/secret-password/)
      - allows for commands to be executed when the user enters special passwords

   - [terminalkeys](https://tools.suckless.org/slock/patches/terminalkeys/)
      - adds key commands that are commonly used in terminal applications (in particular the login
        prompt)

M config.def.h => config.def.h +7 -0
@@ 65,6 65,13 @@ static const int failcount = 0;
static const char *failcommand = "shutdown";
#endif // FAILURE_COMMAND_PATCH

#if SECRET_PASSWORD_PATCH
static const secretpass scom[] = {
	/* Password             command */
	{ "shutdown",           "doas poweroff"},
};
#endif // SECRET_PASSWORD_PATCH

#if BLUR_PIXELATED_SCREEN_PATCH
/* Enable blur */
#define BLUR

M patches.def.h => patches.def.h +5 -0
@@ 102,6 102,11 @@
 */
#define QUICKCANCEL_PATCH 0

/* This patch allows for commands to be executed when the user enters special passwords.
 * https://tools.suckless.org/slock/patches/secret-password/
 */
#define SECRET_PASSWORD_PATCH 0

/* Adds key commands that are commonly used in terminal applications (in particular the
 * login prompt) to slock.
 * https://tools.suckless.org/slock/patches/terminalkeys/

M slock.c => slock.c +21 -0
@@ 1,5 1,6 @@
/* See LICENSE file for license details. */
#define _XOPEN_SOURCE 500
#define LENGTH(X) (sizeof X / sizeof X[0])
#if HAVE_SHADOW_H
#include <shadow.h>
#endif


@@ 77,6 78,14 @@ struct lock {
	unsigned long colors[NUMCOLS];
};

#if SECRET_PASSWORD_PATCH
typedef struct secretpass secretpass;
struct secretpass {
	char *pass;
	char *command;
};
#endif // SECRET_PASSWORD_PATCH

struct xrandr {
	int active;
	int evbase;


@@ 245,6 254,18 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
			case XK_Return:
				passwd[len] = '\0';
				errno = 0;

				#if SECRET_PASSWORD_PATCH
				for (int i = 0; i < LENGTH(scom); i++) {
					if (strcmp(scom[i].pass, passwd) == 0) {
						system(scom[i].command);
						#if FAILURE_COMMAND_PATCH
						failtrack = -1;
						#endif // FAILURE_COMMAND_PATCH
					}
				}
				#endif // SECRET_PASSWORD_PATCH

				#if PAMAUTH_PATCH
				retval = pam_start(pam_service, hash, &pamc, &pamh);
				color = PAM;