]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib: allow safe_getenv to work for non-root users
authorMike Gilbert <floppym@gentoo.org>
Tue, 26 Apr 2022 17:58:12 +0000 (13:58 -0400)
committerMike Gilbert <floppym@gentoo.org>
Tue, 26 Apr 2022 18:04:24 +0000 (14:04 -0400)
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 <floppym@gentoo.org>
lib/env.c

index a3dd335bfe4e836aad121b864f169cdd2b2edd34..37125f4d5a0e62e78de839bb6d273a8e10b31e29 100644 (file)
--- 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)