summaryrefslogtreecommitdiff
path: root/slock/patches/slock-user-1.5.diff
blob: ee057473f5939a7d2cd5e144b93c45dcba4afc83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From 7f1f66dfb1feb2b6df87565f1b895dd7a12d7ceb Mon Sep 17 00:00:00 2001
From: Phillip Tischler <ptgit@protonmail.com>
Date: Sat, 18 Mar 2023 22:59:55 +0100
Subject: [PATCH] Always use the current users password ($USER)

---
 config.def.h | 4 ----
 slock.c      | 8 ++++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/config.def.h b/config.def.h
index 9855e21..3229e62 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,7 +1,3 @@
-/* user and group to drop privileges to */
-static const char *user  = "nobody";
-static const char *group = "nogroup";
-
 static const char *colorname[NUMCOLS] = {
 	[INIT] =   "black",     /* after initialization */
 	[INPUT] =  "#005577",   /* during input */
diff --git a/slock.c b/slock.c
index 5ae738c..7444eac 100644
--- a/slock.c
+++ b/slock.c
@@ -325,13 +325,13 @@ main(int argc, char **argv) {
 
 	/* validate drop-user and -group */
 	errno = 0;
-	if (!(pwd = getpwnam(user)))
-		die("slock: getpwnam %s: %s\n", user,
+	if (!(pwd = getpwnam(getenv("USER"))))
+		die("slock: getpwnam %s: %s\n", getenv("USER"),
 		    errno ? strerror(errno) : "user entry not found");
 	duid = pwd->pw_uid;
 	errno = 0;
-	if (!(grp = getgrnam(group)))
-		die("slock: getgrnam %s: %s\n", group,
+	if (!(grp = getgrnam(getenv("USER"))))
+		die("slock: getgrnam %s: %s\n", getenv("USER"),
 		    errno ? strerror(errno) : "group entry not found");
 	dgid = grp->gr_gid;
 
-- 
2.30.2