From 545573af708f195e1f59e56c1b81a41f5e2824c6 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 21 Sep 2023 12:45:49 -0400 Subject: [PATCH] apply user patch --- 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 87b7679..bfb54c5 100644 --- a/config.def.h +++ b/config.def.h @@ -4,10 +4,6 @@ static const int failonclear = 1; /* Time in seconds before the monitor shuts down */ static const int monitortime = 5; -/* User and group to drop privileges to */ -static const char *user = "nobody"; -static const char *group = "nogroup"; - static const char *colorname[NUMCOLS] = { [BACKGROUND] = "white", [INIT] = "2d2d2d", /* after initialization */ diff --git a/slock.c b/slock.c index a302723..5674d07 100644 --- a/slock.c +++ b/slock.c @@ -471,13 +471,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;