sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit b295d6f6e5085ddea5ee46cadd71f6eb3b462c62
parent 7cd867d4e6a30efcb6ec80be64000f4d78d469f3
Author: Phillip Tischler <ptgit@protonmail.com>
Date:   Sat, 18 Mar 2023 23:26:00 +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.

Diffstat:
Atools.suckless.org/slock/patches/user/index.md | 15+++++++++++++++
Atools.suckless.org/slock/patches/user/slock-user-1.5.diff | 47+++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/tools.suckless.org/slock/patches/user/index.md b/tools.suckless.org/slock/patches/user/index.md @@ -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@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 @@ -0,0 +1,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 +