aboutsummaryrefslogtreecommitdiffstats
path: root/lib/env.c
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2025-05-20 19:49:13 +0200
committerKarel Zak <kzak@redhat.com>2025-05-20 19:49:13 +0200
commitf8d41ab00438a85cc955b9b2004f3034b8fa6029 (patch)
tree93091899dfeda5c3bce6884f0b81d0357ed88c73 /lib/env.c
parent2461c23de03c450a6d399ad1870caf56460f77b8 (diff)
parentb36add06585acf77e1a50fc0d2c901a0129582a4 (diff)
downloadutil-linux-f8d41ab00438a85cc955b9b2004f3034b8fa6029.tar.gz
Merge branch 'at_secure' of https://github.com/MaxKellermann/util-linux into PR/AT_SECURE
* 'at_secure' of https://github.com/MaxKellermann/util-linux: lib/env, ...: use getauxval(AT_SECURE) for SUID check
Diffstat (limited to 'lib/env.c')
-rw-r--r--lib/env.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/env.c b/lib/env.c
index 0874fe482b..3fc4f2e21e 100644
--- a/lib/env.c
+++ b/lib/env.c
@@ -16,6 +16,7 @@
#include <sys/syscall.h>
#endif
#include <unistd.h>
+#include <sys/auxv.h> // for getauxval()
#include <sys/types.h>
#include "env.h"
@@ -260,7 +261,7 @@ void sanitize_env(void)
char *safe_getenv(const char *arg)
{
- if ((getuid() != geteuid()) || (getgid() != getegid()))
+ if (getauxval(AT_SECURE))
return NULL;
#ifdef HAVE_PRCTL
if (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) == 0)