Blob Blame History Raw
From 85951a0384cb7f37d99669575fad4aea155f25a8 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Wed, 5 May 2021 10:50:56 -0400
Subject: [PATCH 1/5] Revert "gdm-{wayland,x}-session: don't overwrite user env
 with fallback vars"

This reverts commit ccecd9c975d04da80db4cd547b67a1a94fa83292.
---
 daemon/gdm-wayland-session.c | 22 +---------------------
 daemon/gdm-x-session.c       | 22 +---------------------
 2 files changed, 2 insertions(+), 42 deletions(-)

diff --git a/daemon/gdm-wayland-session.c b/daemon/gdm-wayland-session.c
index d0404d2c1..35679b194 100644
--- a/daemon/gdm-wayland-session.c
+++ b/daemon/gdm-wayland-session.c
@@ -262,112 +262,92 @@ on_session_finished (GSubprocess  *subprocess,
 
                 state->session_exit_status = exit_status;
         } else {
                 int signal_number;
 
                 signal_number = g_subprocess_get_term_sig (subprocess);
                 g_debug ("session was killed with status %d", signal_number);
         }
 
         g_clear_object (&state->session_subprocess);
 out:
         g_main_loop_quit (state->main_loop);
 }
 
 static gboolean
 spawn_session (State        *state,
                GCancellable *cancellable)
 {
         GSubprocessLauncher *launcher = NULL;
         GSubprocess         *subprocess = NULL;
         GError              *error = NULL;
         gboolean             is_running = FALSE;
         int                  ret;
         char               **argv = NULL;
         static const char  *session_variables[] = { "DISPLAY",
                                                     "XAUTHORITY",
                                                     "WAYLAND_DISPLAY",
                                                     "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");
 
         ret = g_shell_parse_argv (state->session_command,
                                   NULL,
                                   &argv,
                                   &error);
 
         if (!ret) {
                 g_debug ("could not parse session arguments: %s", error->message);
                 goto out;
         }
 
         launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
 
         if (state->environment != NULL) {
                 size_t i;
 
                 for (i = 0; state->environment[i] != NULL; i++) {
                         g_auto(GStrv) environment_entry = NULL;
 
                         if (state->environment[i][0] == '\0') {
                                 continue;
                         }
 
                         environment_entry = g_strsplit (state->environment[i], "=", 2);
 
                         if (environment_entry[0] == NULL || environment_entry[1] == NULL) {
                                 continue;
                         }
 
-                        /* 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]));
+                        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);
         }
 
         subprocess = g_subprocess_launcher_spawnv (launcher,
                                                    (const char * const *) argv,
                                                    &error);
         g_strfreev (argv);
 
         if (subprocess == NULL) {
                 g_debug ("could not start session: %s", error->message);
                 goto out;
         }
 
         state->session_subprocess = g_object_ref (subprocess);
 
         g_subprocess_wait_async (state->session_subprocess,
                                  cancellable,
                                  (GAsyncReadyCallback)
diff --git a/daemon/gdm-x-session.c b/daemon/gdm-x-session.c
index 5962da572..b15483614 100644
--- a/daemon/gdm-x-session.c
+++ b/daemon/gdm-x-session.c
@@ -588,102 +588,82 @@ on_session_finished (GSubprocess  *subprocess,
 
                 state->session_exit_status = exit_status;
         } else {
                 int signal_number;
 
                 signal_number = g_subprocess_get_term_sig (subprocess);
                 g_debug ("session was killed with status %d", signal_number);
         }
 
         g_clear_object (&state->session_subprocess);
 out:
         g_main_loop_quit (state->main_loop);
 }
 
 static gboolean
 spawn_session (State        *state,
                gboolean      run_script,
                GCancellable *cancellable)
 {
         GSubprocessLauncher *launcher = NULL;
         GSubprocess         *subprocess = NULL;
         GError              *error = NULL;
         gboolean             is_running = FALSE;
         const char          *vt;
         static const char   *session_variables[] = { "DISPLAY",
                                                      "XAUTHORITY",
                                                      "WAYLAND_DISPLAY",
                                                      "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");
 
         launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
 
         if (state->environment != NULL) {
                 size_t i;
 
                 for (i = 0; state->environment[i] != NULL; i++) {
                         g_auto(GStrv) environment_entry = NULL;
 
                         if (state->environment[i][0] == '\0') {
                                 continue;
                         }
 
                         environment_entry = g_strsplit (state->environment[i], "=", 2);
 
                         if (environment_entry[0] == NULL || environment_entry[1] == NULL) {
                                 continue;
                         }
 
-                        /* 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]));
+                        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);
         }
 
         vt = g_getenv ("XDG_VTNR");
 
         if (vt != NULL) {
                 g_subprocess_launcher_setenv (launcher, "WINDOWPATH", vt, TRUE);
         }
 
         if (run_script) {
                 subprocess = g_subprocess_launcher_spawn (launcher,
                                                           &error,
                                                           GDMCONFDIR "/Xsession",
                                                           state->session_command,
                                                           NULL);
-- 
2.30.1