summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <halfline@gmail.com>2021-02-24 20:13:14 +0000
committerRay Strode <halfline@gmail.com>2021-02-24 20:13:14 +0000
commit349e6af855a1c1dbee9af3e5881e00b66482d155 (patch)
tree3fff8aa6aa5a41ec14df817bfd49561f0b15a88f
parent8dc721eb73c0cfcde1a1e4ce8b8f28623c9e2051 (diff)
parentccecd9c975d04da80db4cd547b67a1a94fa83292 (diff)
downloadgdm-349e6af855a1c1dbee9af3e5881e00b66482d155.tar.gz
Merge branch 'fix/systemd-user-path' into 'master'
gdm-{wayland,x}-session: import PATH from systemd Closes #385 See merge request GNOME/gdm!92
-rw-r--r--daemon/gdm-wayland-session.c22
-rw-r--r--daemon/gdm-x-session.c22
2 files changed, 42 insertions, 2 deletions
diff --git a/daemon/gdm-wayland-session.c b/daemon/gdm-wayland-session.c
index 35679b19..d0404d2c 100644
--- a/daemon/gdm-wayland-session.c
+++ b/daemon/gdm-wayland-session.c
@@ -289,6 +289,17 @@ spawn_session (State *state,
"WAYLAND_SOCKET",
"GNOME_SHELL_SESSION_MODE",
NULL };
+ /* The environment variables listed below are those we have set (or
+ * received from our own execution environment) only as a fallback to
+ * make things work, as opposed to a information directly pertaining to
+ * the session about to be started. Variables listed here will not
+ * overwrite the existing environment (possibly) imported from the
+ * systemd --user instance.
+ * As an example: We need a PATH for some of the launched subprocesses
+ * to work, but if the user (or the distributor) has customized the PATH
+ * via one of systemds user-environment-generators, that version should
+ * be preferred. */
+ static const char *fallback_variables[] = { "PATH", NULL };
g_debug ("Running wayland session");
@@ -320,7 +331,16 @@ spawn_session (State *state,
continue;
}
- g_subprocess_launcher_setenv (launcher, environment_entry[0], environment_entry[1], FALSE);
+ /* Merge the environment block imported from systemd --user with the
+ * environment we have set for ourselves (and thus pass on to the
+ * launcher process). Variables we have set have precedence, as to not
+ * import stale data from prior user sessions, with the exception of
+ * those listed in fallback_variables. See the comment there for more
+ * explanations. */
+ g_subprocess_launcher_setenv (launcher,
+ environment_entry[0],
+ environment_entry[1],
+ g_strv_contains (fallback_variables, environment_entry[0]));
}
/* Don't allow session specific environment variables from earlier sessions to
diff --git a/daemon/gdm-x-session.c b/daemon/gdm-x-session.c
index b1548361..5962da57 100644
--- a/daemon/gdm-x-session.c
+++ b/daemon/gdm-x-session.c
@@ -615,6 +615,17 @@ spawn_session (State *state,
"WAYLAND_SOCKET",
"GNOME_SHELL_SESSION_MODE",
NULL };
+ /* The environment variables listed below are those we have set (or
+ * received from our own execution environment) only as a fallback to
+ * make things work, as opposed to a information directly pertaining to
+ * the session about to be started. Variables listed here will not
+ * overwrite the existing environment (possibly) imported from the
+ * systemd --user instance.
+ * As an example: We need a PATH for some of the launched subprocesses
+ * to work, but if the user (or the distributor) has customized the PATH
+ * via one of systemds user-environment-generators, that version should
+ * be preferred. */
+ static const char *fallback_variables[] = { "PATH", NULL };
g_debug ("Running X session");
@@ -636,7 +647,16 @@ spawn_session (State *state,
continue;
}
- g_subprocess_launcher_setenv (launcher, environment_entry[0], environment_entry[1], FALSE);
+ /* Merge the environment block imported from systemd --user with the
+ * environment we have set for ourselves (and thus pass on to the
+ * launcher process). Variables we have set have precedence, as to not
+ * import stale data from prior user sessions, with the exception of
+ * those listed in fallback_variables. See the comment there for more
+ * explanations. */
+ g_subprocess_launcher_setenv (launcher,
+ environment_entry[0],
+ environment_entry[1],
+ g_strv_contains (fallback_variables, environment_entry[0]));
}
/* Don't allow session specific environment variables from earlier sessions to