slock-secret-password-2022-10-01-35633d4.diff - sites - public wiki contents of… | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
slock-secret-password-2022-10-01-35633d4.diff (1129B) | |
--- | |
1 diff --git a/config.def.h b/config.def.h | |
2 index 9855e21..a2020bb 100644 | |
3 --- a/config.def.h | |
4 +++ b/config.def.h | |
5 @@ -10,3 +10,13 @@ static const char *colorname[NUMCOLS] = { | |
6 | |
7 /* treat a cleared input like a wrong password (color) */ | |
8 static const int failonclear = 1; | |
9 + | |
10 +/* length of entires in scom */ | |
11 +#define ENTRYLEN 1 | |
12 + | |
13 +static const secretpass scom[ENTRYLEN] = { | |
14 +/* Password command */ | |
15 + { "shutdown", "doas poweroff" }, | |
16 +}; | |
17 diff --git a/slock.c b/slock.c | |
18 index 5ae738c..b92ae4e 100644 | |
19 --- a/slock.c | |
20 +++ b/slock.c | |
21 @@ -44,6 +44,11 @@ struct xrandr { | |
22 int errbase; | |
23 }; | |
24 | |
25 +typedef struct secretpass { | |
26 + char pass[256]; | |
27 + char command[256]; | |
28 +} secretpass; | |
29 + | |
30 #include "config.h" | |
31 | |
32 static void | |
33 @@ -160,6 +165,13 @@ readpw(Display *dpy, struct xrandr *rr, struct lock… | |
34 case XK_Return: | |
35 passwd[len] = '\0'; | |
36 errno = 0; | |
37 + | |
38 + for (int i = 0; i < ENTRYLEN; i++){ | |
39 + if (strcmp(scom[i].pass, passwd… | |
40 + system(scom[i].command); | |
41 + } | |
42 + } | |
43 + | |
44 if (!(inputhash = crypt(passwd, hash))) | |
45 fprintf(stderr, "slock: crypt: … | |
46 else |