diff options
author | Ray Strode <rstrode@redhat.com> | 2017-08-07 14:26:08 +0800 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2017-09-08 15:27:19 -0400 |
commit | cc7c9dc0d4a7512b641b2b3ffe2a9b651880bdbf (patch) | |
tree | 1471f0fb8b474770c3f2efbbe66a2e8859a54c84 /daemon | |
parent | 95b46d9d91a35ec740ce64fb11491f9eeaa02a03 (diff) | |
download | gdm-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')
-rw-r--r-- | daemon/gdm-wayland-session.c | 19 | ||||
-rw-r--r-- | daemon/gdm-x-session.c | 19 |
2 files changed, 29 insertions, 9 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); 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); } |