summaryrefslogtreecommitdiff
path: root/daemon/gdm-wayland-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-wayland-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-wayland-session.c')
-rw-r--r--daemon/gdm-wayland-session.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/daemon/gdm-wayland-session.c b/daemon/gdm-wayland-session.c
index efdb34e8..af796089 100644
--- a/daemon/gdm-wayland-session.c
+++ b/daemon/gdm-wayland-session.c
@@ -280,6 +280,11 @@ spawn_session (State *state,
gboolean is_running = FALSE;
int ret;
char **argv = NULL;
+ static const char *session_variables[] = { "DISPLAY",
+ "XAUTHORITY",
+ "WAYLAND_DISPLAY",
+ "WAYLAND_SOCKET",
+ NULL };
g_debug ("Running wayland session");
@@ -313,18 +318,20 @@ 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]);
+ }
+ }
}
if (state->bus_address != NULL) {
g_subprocess_launcher_setenv (launcher, "DBUS_SESSION_BUS_ADDRESS", state->bus_address, TRUE);
}
- /* Don't allow session specific environment variables from earlier sessions to leak through */
- g_subprocess_launcher_unsetenv (launcher, "DISPLAY");
- g_subprocess_launcher_unsetenv (launcher, "XAUTHORITY");
- g_subprocess_launcher_unsetenv (launcher, "WAYLAND_DISPLAY");
- g_subprocess_launcher_unsetenv (launcher, "WAYLAND_SOCKET");
-
subprocess = g_subprocess_launcher_spawnv (launcher,
(const char * const *) argv,
&error);