summaryrefslogtreecommitdiff
path: root/daemon/gdm-x-session.c
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2017-08-07 14:26:08 +0800
committerRay Strode <rstrode@redhat.com>2017-09-08 15:27:19 -0400
commitcc7c9dc0d4a7512b641b2b3ffe2a9b651880bdbf (patch)
tree1471f0fb8b474770c3f2efbbe66a2e8859a54c84 /daemon/gdm-x-session.c
parent95b46d9d91a35ec740ce64fb11491f9eeaa02a03 (diff)
downloadgdm-cc7c9dc0d4a7512b641b2b3ffe2a9b651880bdbf.tar.gz
gdm-{wayland,x}-session: only omit unset session variables from environment
The display server launcher wrapper scripts try to unset any stale environment variables imported from systemd. There is a possibility, some of these stale variables, however, could be "refreshed" by gdm in the current session. If that's the case, we shouldn't clear them. This reworks the unset calls into a loop, and guards each unset call with a check to make sure it's not in the current environment. https://bugzilla.gnome.org/show_bug.cgi?id=785918
Diffstat (limited to 'daemon/gdm-x-session.c')
-rw-r--r--daemon/gdm-x-session.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/daemon/gdm-x-session.c b/daemon/gdm-x-session.c
index b919e6e9..b5c0d20c 100644
--- a/daemon/gdm-x-session.c
+++ b/daemon/gdm-x-session.c
@@ -605,14 +605,16 @@ spawn_session (State *state,
GError *error = NULL;
gboolean is_running = FALSE;
const char *vt;
+ static const char *session_variables[] = { "DISPLAY",
+ "XAUTHORITY",
+ "WAYLAND_DISPLAY",
+ "WAYLAND_SOCKET",
+ NULL };
g_debug ("Running X session");
launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
- g_subprocess_launcher_setenv (launcher, "DISPLAY", state->display_name, TRUE);
- g_subprocess_launcher_setenv (launcher, "XAUTHORITY", state->auth_file, TRUE);
-
if (state->environment != NULL) {
size_t i;
@@ -631,8 +633,19 @@ spawn_session (State *state,
g_subprocess_launcher_setenv (launcher, environment_entry[0], environment_entry[1], FALSE);
}
+
+ /* Don't allow session specific environment variables from earlier sessions to
+ * leak through */
+ for (i = 0; session_variables[i] != NULL; i++) {
+ if (g_getenv (session_variables[i]) == NULL) {
+ g_subprocess_launcher_unsetenv (launcher, session_variables[i]);
+ }
+ }
}
+ g_subprocess_launcher_setenv (launcher, "DISPLAY", state->display_name, TRUE);
+ g_subprocess_launcher_setenv (launcher, "XAUTHORITY", state->auth_file, TRUE);
+
if (state->bus_address != NULL) {
g_subprocess_launcher_setenv (launcher, "DBUS_SESSION_BUS_ADDRESS", state->bus_address, TRUE);
}