salimma / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone
771b4bc
From 822625de3d5dc7675e37af1c383ff1d42d943c86 Mon Sep 17 00:00:00 2001
771b4bc
From: Lennart Poettering <lennart@poettering.net>
771b4bc
Date: Wed, 11 Apr 2012 13:19:26 +0200
771b4bc
Subject: [PATCH] main: unset some bash specific environment variables that
771b4bc
 might get leaked to us
771b4bc
771b4bc
https://bugzilla.redhat.com/show_bug.cgi?id=811537
771b4bc
(cherry picked from commit 9543ad166338a7bef8718070f11465df4b9badd7)
771b4bc
---
771b4bc
 src/main.c |    6 ++++++
771b4bc
 1 file changed, 6 insertions(+)
771b4bc
771b4bc
diff --git a/src/main.c b/src/main.c
771b4bc
index a0bcbdf..6656cb4 100644
771b4bc
--- a/src/main.c
771b4bc
+++ b/src/main.c
771b4bc
@@ -1343,6 +1343,12 @@ int main(int argc, char *argv[]) {
771b4bc
                 unsetenv("HOME");
771b4bc
                 unsetenv("TERM");
771b4bc
 
771b4bc
+                /* When we are invoked by a shell, these might be set,
771b4bc
+                 * but make little sense to pass on */
771b4bc
+                unsetenv("PWD");
771b4bc
+                unsetenv("SHLVL");
771b4bc
+                unsetenv("_");
771b4bc
+
771b4bc
                 /* All other variables are left as is, so that clients
771b4bc
                  * can still read them via /proc/1/environ */
771b4bc
         }