summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-01-12 20:10:40 +0800
committerLennart Poettering <lennart@poettering.net>2014-01-12 20:10:40 +0800
commitf069efb4710332139ac508180cb8246b02428c17 (patch)
tree94fe26fe374e5f79519453e786ebfdac367a2821 /src
parent09ecd746c9d6581664873674c2188f8c93ed7780 (diff)
core: don't allow setting NOTIFY_SOCKET and similar env vars we need ourselves via SetEnvironment bus calls
We just quietly eat them up, so that simple environment importing still works without error.
Diffstat (limited to 'src')
-rw-r--r--src/core/manager.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/core/manager.c b/src/core/manager.c
index 91c3d59d2b..95fc7e64ac 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -332,6 +332,23 @@ static int manager_setup_signals(Manager *m) {
return 0;
}
+static void manager_clean_environment(Manager *m) {
+ assert(m);
+
+ /* Let's remove some environment variables that we
+ * need ourselves to communicate with our clients */
+ strv_env_unset_many(
+ m->environment,
+ "NOTIFY_SOCKET",
+ "MAINPID",
+ "MANAGERPID",
+ "LISTEN_PID",
+ "LISTEN_FDS",
+ "WATCHDOG_PID",
+ "WATCHDOG_USEC",
+ NULL);
+}
+
static int manager_default_environment(Manager *m) {
assert(m);
@@ -352,24 +369,12 @@ static int manager_default_environment(Manager *m) {
/* The user manager passes its own environment
* along to its children. */
m->environment = strv_copy(environ);
-
- /* Let's remove some environment variables that we
- * need ourselves to communicate with our clients */
- strv_env_unset_many(
- m->environment,
- "NOTIFY_SOCKET",
- "MAINPID",
- "MANAGERPID",
- "LISTEN_PID",
- "LISTEN_FDS",
- "WATCHDOG_PID",
- "WATCHDOG_USEC",
- NULL);
}
if (!m->environment)
return -ENOMEM;
+ manager_clean_environment(m);
strv_sort(m->environment);
return 0;
@@ -2689,7 +2694,10 @@ int manager_environment_add(Manager *m, char **minus, char **plus) {
if (b != l)
strv_free(b);
- m->environment = strv_sort(l);
+ m->environment = l;
+ manager_clean_environment(m);
+ strv_sort(m->environment);
+
return 0;
}