slock-user-1.5.diff - sites - public wiki contents of suckless.org | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
slock-user-1.5.diff (1425B) | |
--- | |
1 From 7f1f66dfb1feb2b6df87565f1b895dd7a12d7ceb Mon Sep 17 00:00:00 2001 | |
2 From: Phillip Tischler <[email protected]> | |
3 Date: Sat, 18 Mar 2023 22:59:55 +0100 | |
4 Subject: [PATCH] Always use the current users password ($USER) | |
5 | |
6 --- | |
7 config.def.h | 4 ---- | |
8 slock.c | 8 ++++---- | |
9 2 files changed, 4 insertions(+), 8 deletions(-) | |
10 | |
11 diff --git a/config.def.h b/config.def.h | |
12 index 9855e21..3229e62 100644 | |
13 --- a/config.def.h | |
14 +++ b/config.def.h | |
15 @@ -1,7 +1,3 @@ | |
16 -/* user and group to drop privileges to */ | |
17 -static const char *user = "nobody"; | |
18 -static const char *group = "nogroup"; | |
19 - | |
20 static const char *colorname[NUMCOLS] = { | |
21 [INIT] = "black", /* after initialization */ | |
22 [INPUT] = "#005577", /* during input */ | |
23 diff --git a/slock.c b/slock.c | |
24 index 5ae738c..7444eac 100644 | |
25 --- a/slock.c | |
26 +++ b/slock.c | |
27 @@ -325,13 +325,13 @@ main(int argc, char **argv) { | |
28 | |
29 /* validate drop-user and -group */ | |
30 errno = 0; | |
31 - if (!(pwd = getpwnam(user))) | |
32 - die("slock: getpwnam %s: %s\n", user, | |
33 + if (!(pwd = getpwnam(getenv("USER")))) | |
34 + die("slock: getpwnam %s: %s\n", getenv("USER"), | |
35 errno ? strerror(errno) : "user entry not found"); | |
36 duid = pwd->pw_uid; | |
37 errno = 0; | |
38 - if (!(grp = getgrnam(group))) | |
39 - die("slock: getgrnam %s: %s\n", group, | |
40 + if (!(grp = getgrnam(getenv("USER")))) | |
41 + die("slock: getgrnam %s: %s\n", getenv("USER"), | |
42 errno ? strerror(errno) : "group entry not found"); | |
43 dgid = grp->gr_gid; | |
44 | |
45 -- | |
46 2.30.2 | |
47 |