[wiki] [sites] [slock][patch][user] Introduce patch 'user' for slock || Phillip Tischler
commit b295d6f6e5085ddea5ee46cadd71f6eb3b462c62
Author: Phillip Tischler <ptgit_AT_protonmail.com>
Date: Sat Mar 18 23:26:00 2023 +0100
[slock][patch][user] Introduce patch 'user' for slock
Always use the current users ($USER) password instead of
relying on a configured user and group name.
diff --git a/tools.suckless.org/slock/patches/user/index.md b/tools.suckless.org/slock/patches/user/index.md
new file mode 100644
index 00000000..c95bd076
--- /dev/null
+++ b/tools.suckless.org/slock/patches/user/index.md
_AT_@ -0,0 +1,15 @@
+User
+============
+
+Description
+-----------
+This patch uses the $USER environment variable to determine which user and group
+to use for the password instead of having to rely on fixed configuration values.
+
+Download
+--------
+* [slock-user-1.5.diff](slock-user-1.5.diff)
+
+Authors
+-------
+* Phillip Tischler <ptgit_AT_protonmail.com>
diff --git a/tools.suckless.org/slock/patches/user/slock-user-1.5.diff b/tools.suckless.org/slock/patches/user/slock-user-1.5.diff
new file mode 100644
index 00000000..ee057473
--- /dev/null
+++ b/tools.suckless.org/slock/patches/user/slock-user-1.5.diff
_AT_@ -0,0 +1,47 @@
+From 7f1f66dfb1feb2b6df87565f1b895dd7a12d7ceb Mon Sep 17 00:00:00 2001
+From: Phillip Tischler <ptgit_AT_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
+_AT_@ -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
+_AT_@ -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
", user,
++ if (!(pwd = getpwnam(getenv("USER"))))
++ die("slock: getpwnam %s: %s
", getenv("USER"),
+ errno ? strerror(errno) : "user entry not found");
+ duid = pwd->pw_uid;
+ errno = 0;
+- if (!(grp = getgrnam(group)))
+- die("slock: getgrnam %s: %s
", group,
++ if (!(grp = getgrnam(getenv("USER"))))
++ die("slock: getgrnam %s: %s
", getenv("USER"),
+ errno ? strerror(errno) : "group entry not found");
+ dgid = grp->gr_gid;
+
+--
+2.30.2
+
Received on Sat Mar 18 2023 - 23:27:11 CET
This archive was generated by hypermail 2.3.0
: Sat Mar 18 2023 - 23:36:52 CET