From: Mike Gilbert Date: Tue, 26 Apr 2022 17:58:12 +0000 (-0400) Subject: lib: allow safe_getenv to work for non-root users X-Git-Tag: v2.39-rc1~685^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=16a2e0603f15c4a8f4517264930c7bdea5885bae;p=thirdparty%2Futil-linux.git lib: allow safe_getenv to work for non-root users This allows users to override settings like BLKID_FILE, as is done in the e2fsprogs test suite. Bug: https://bugs.gentoo.org/839825 Fixes: 035507c84b53bceb143d0923e65916cbf90979c7 Signed-off-by: Mike Gilbert --- diff --git a/lib/env.c b/lib/env.c index a3dd335bfe..37125f4d5a 100644 --- a/lib/env.c +++ b/lib/env.c @@ -161,9 +161,7 @@ void sanitize_env(void) char *safe_getenv(const char *arg) { - uid_t ruid = getuid(); - - if (ruid != 0 || (ruid != geteuid()) || (getgid() != getegid())) + if ((getuid() != geteuid()) || (getgid() != getegid())) return NULL; #ifdef HAVE_PRCTL if (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) == 0)