Blame SOURCES/0001-Revert-gdm-wayland-x-session-don-t-overwrite-user-en.patch

9cc5e2
From 85951a0384cb7f37d99669575fad4aea155f25a8 Mon Sep 17 00:00:00 2001
9cc5e2
From: Ray Strode <rstrode@redhat.com>
9cc5e2
Date: Wed, 5 May 2021 10:50:56 -0400
9cc5e2
Subject: [PATCH 1/5] Revert "gdm-{wayland,x}-session: don't overwrite user env
9cc5e2
 with fallback vars"
9cc5e2
9cc5e2
This reverts commit ccecd9c975d04da80db4cd547b67a1a94fa83292.
9cc5e2
---
9cc5e2
 daemon/gdm-wayland-session.c | 22 +---------------------
9cc5e2
 daemon/gdm-x-session.c       | 22 +---------------------
9cc5e2
 2 files changed, 2 insertions(+), 42 deletions(-)
9cc5e2
9cc5e2
diff --git a/daemon/gdm-wayland-session.c b/daemon/gdm-wayland-session.c
9cc5e2
index d0404d2c1..35679b194 100644
9cc5e2
--- a/daemon/gdm-wayland-session.c
9cc5e2
+++ b/daemon/gdm-wayland-session.c
9cc5e2
@@ -262,112 +262,92 @@ on_session_finished (GSubprocess  *subprocess,
9cc5e2
 
9cc5e2
                 state->session_exit_status = exit_status;
9cc5e2
         } else {
9cc5e2
                 int signal_number;
9cc5e2
 
9cc5e2
                 signal_number = g_subprocess_get_term_sig (subprocess);
9cc5e2
                 g_debug ("session was killed with status %d", signal_number);
9cc5e2
         }
9cc5e2
 
9cc5e2
         g_clear_object (&state->session_subprocess);
9cc5e2
 out:
9cc5e2
         g_main_loop_quit (state->main_loop);
9cc5e2
 }
9cc5e2
 
9cc5e2
 static gboolean
9cc5e2
 spawn_session (State        *state,
9cc5e2
                GCancellable *cancellable)
9cc5e2
 {
9cc5e2
         GSubprocessLauncher *launcher = NULL;
9cc5e2
         GSubprocess         *subprocess = NULL;
9cc5e2
         GError              *error = NULL;
9cc5e2
         gboolean             is_running = FALSE;
9cc5e2
         int                  ret;
9cc5e2
         char               **argv = NULL;
9cc5e2
         static const char  *session_variables[] = { "DISPLAY",
9cc5e2
                                                     "XAUTHORITY",
9cc5e2
                                                     "WAYLAND_DISPLAY",
9cc5e2
                                                     "WAYLAND_SOCKET",
9cc5e2
                                                     "GNOME_SHELL_SESSION_MODE",
9cc5e2
                                                     NULL };
9cc5e2
-        /* The environment variables listed below are those we have set (or
9cc5e2
-         * received from our own execution environment) only as a fallback to
9cc5e2
-         * make things work, as opposed to a information directly pertaining to
9cc5e2
-         * the session about to be started. Variables listed here will not
9cc5e2
-         * overwrite the existing environment (possibly) imported from the
9cc5e2
-         * systemd --user instance.
9cc5e2
-         * As an example: We need a PATH for some of the launched subprocesses
9cc5e2
-         * to work, but if the user (or the distributor) has customized the PATH
9cc5e2
-         * via one of systemds user-environment-generators, that version should
9cc5e2
-         * be preferred. */
9cc5e2
-        static const char  *fallback_variables[] = { "PATH", NULL };
9cc5e2
 
9cc5e2
         g_debug ("Running wayland session");
9cc5e2
 
9cc5e2
         ret = g_shell_parse_argv (state->session_command,
9cc5e2
                                   NULL,
9cc5e2
                                   &argv,
9cc5e2
                                   &error);
9cc5e2
 
9cc5e2
         if (!ret) {
9cc5e2
                 g_debug ("could not parse session arguments: %s", error->message);
9cc5e2
                 goto out;
9cc5e2
         }
9cc5e2
 
9cc5e2
         launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
9cc5e2
 
9cc5e2
         if (state->environment != NULL) {
9cc5e2
                 size_t i;
9cc5e2
 
9cc5e2
                 for (i = 0; state->environment[i] != NULL; i++) {
9cc5e2
                         g_auto(GStrv) environment_entry = NULL;
9cc5e2
 
9cc5e2
                         if (state->environment[i][0] == '\0') {
9cc5e2
                                 continue;
9cc5e2
                         }
9cc5e2
 
9cc5e2
                         environment_entry = g_strsplit (state->environment[i], "=", 2);
9cc5e2
 
9cc5e2
                         if (environment_entry[0] == NULL || environment_entry[1] == NULL) {
9cc5e2
                                 continue;
9cc5e2
                         }
9cc5e2
 
9cc5e2
-                        /* Merge the environment block imported from systemd --user with the
9cc5e2
-                         * environment we have set for ourselves (and thus pass on to the
9cc5e2
-                         * launcher process). Variables we have set have precedence, as to not
9cc5e2
-                         * import stale data from prior user sessions, with the exception of
9cc5e2
-                         * those listed in fallback_variables. See the comment there for more
9cc5e2
-                         * explanations. */
9cc5e2
-                        g_subprocess_launcher_setenv (launcher,
9cc5e2
-                                                      environment_entry[0],
9cc5e2
-                                                      environment_entry[1],
9cc5e2
-                                                      g_strv_contains (fallback_variables, environment_entry[0]));
9cc5e2
+                        g_subprocess_launcher_setenv (launcher, environment_entry[0], environment_entry[1], FALSE);
9cc5e2
                 }
9cc5e2
 
9cc5e2
                 /* Don't allow session specific environment variables from earlier sessions to
9cc5e2
                  * leak through */
9cc5e2
                 for (i = 0; session_variables[i] != NULL; i++) {
9cc5e2
                         if (g_getenv (session_variables[i]) == NULL) {
9cc5e2
                                 g_subprocess_launcher_unsetenv (launcher, session_variables[i]);
9cc5e2
                         }
9cc5e2
                 }
9cc5e2
         }
9cc5e2
 
9cc5e2
         if (state->bus_address != NULL) {
9cc5e2
                 g_subprocess_launcher_setenv (launcher, "DBUS_SESSION_BUS_ADDRESS", state->bus_address, TRUE);
9cc5e2
         }
9cc5e2
 
9cc5e2
         subprocess = g_subprocess_launcher_spawnv (launcher,
9cc5e2
                                                    (const char * const *) argv,
9cc5e2
                                                    &error);
9cc5e2
         g_strfreev (argv);
9cc5e2
 
9cc5e2
         if (subprocess == NULL) {
9cc5e2
                 g_debug ("could not start session: %s", error->message);
9cc5e2
                 goto out;
9cc5e2
         }
9cc5e2
 
9cc5e2
         state->session_subprocess = g_object_ref (subprocess);
9cc5e2
 
9cc5e2
         g_subprocess_wait_async (state->session_subprocess,
9cc5e2
                                  cancellable,
9cc5e2
                                  (GAsyncReadyCallback)
9cc5e2
diff --git a/daemon/gdm-x-session.c b/daemon/gdm-x-session.c
9cc5e2
index 5962da572..b15483614 100644
9cc5e2
--- a/daemon/gdm-x-session.c
9cc5e2
+++ b/daemon/gdm-x-session.c
9cc5e2
@@ -588,102 +588,82 @@ on_session_finished (GSubprocess  *subprocess,
9cc5e2
 
9cc5e2
                 state->session_exit_status = exit_status;
9cc5e2
         } else {
9cc5e2
                 int signal_number;
9cc5e2
 
9cc5e2
                 signal_number = g_subprocess_get_term_sig (subprocess);
9cc5e2
                 g_debug ("session was killed with status %d", signal_number);
9cc5e2
         }
9cc5e2
 
9cc5e2
         g_clear_object (&state->session_subprocess);
9cc5e2
 out:
9cc5e2
         g_main_loop_quit (state->main_loop);
9cc5e2
 }
9cc5e2
 
9cc5e2
 static gboolean
9cc5e2
 spawn_session (State        *state,
9cc5e2
                gboolean      run_script,
9cc5e2
                GCancellable *cancellable)
9cc5e2
 {
9cc5e2
         GSubprocessLauncher *launcher = NULL;
9cc5e2
         GSubprocess         *subprocess = NULL;
9cc5e2
         GError              *error = NULL;
9cc5e2
         gboolean             is_running = FALSE;
9cc5e2
         const char          *vt;
9cc5e2
         static const char   *session_variables[] = { "DISPLAY",
9cc5e2
                                                      "XAUTHORITY",
9cc5e2
                                                      "WAYLAND_DISPLAY",
9cc5e2
                                                      "WAYLAND_SOCKET",
9cc5e2
                                                      "GNOME_SHELL_SESSION_MODE",
9cc5e2
                                                      NULL };
9cc5e2
-        /* The environment variables listed below are those we have set (or
9cc5e2
-         * received from our own execution environment) only as a fallback to
9cc5e2
-         * make things work, as opposed to a information directly pertaining to
9cc5e2
-         * the session about to be started. Variables listed here will not
9cc5e2
-         * overwrite the existing environment (possibly) imported from the
9cc5e2
-         * systemd --user instance.
9cc5e2
-         * As an example: We need a PATH for some of the launched subprocesses
9cc5e2
-         * to work, but if the user (or the distributor) has customized the PATH
9cc5e2
-         * via one of systemds user-environment-generators, that version should
9cc5e2
-         * be preferred. */
9cc5e2
-        static const char  *fallback_variables[] = { "PATH", NULL };
9cc5e2
 
9cc5e2
         g_debug ("Running X session");
9cc5e2
 
9cc5e2
         launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
9cc5e2
 
9cc5e2
         if (state->environment != NULL) {
9cc5e2
                 size_t i;
9cc5e2
 
9cc5e2
                 for (i = 0; state->environment[i] != NULL; i++) {
9cc5e2
                         g_auto(GStrv) environment_entry = NULL;
9cc5e2
 
9cc5e2
                         if (state->environment[i][0] == '\0') {
9cc5e2
                                 continue;
9cc5e2
                         }
9cc5e2
 
9cc5e2
                         environment_entry = g_strsplit (state->environment[i], "=", 2);
9cc5e2
 
9cc5e2
                         if (environment_entry[0] == NULL || environment_entry[1] == NULL) {
9cc5e2
                                 continue;
9cc5e2
                         }
9cc5e2
 
9cc5e2
-                        /* Merge the environment block imported from systemd --user with the
9cc5e2
-                         * environment we have set for ourselves (and thus pass on to the
9cc5e2
-                         * launcher process). Variables we have set have precedence, as to not
9cc5e2
-                         * import stale data from prior user sessions, with the exception of
9cc5e2
-                         * those listed in fallback_variables. See the comment there for more
9cc5e2
-                         * explanations. */
9cc5e2
-                        g_subprocess_launcher_setenv (launcher,
9cc5e2
-                                                      environment_entry[0],
9cc5e2
-                                                      environment_entry[1],
9cc5e2
-                                                      g_strv_contains (fallback_variables, environment_entry[0]));
9cc5e2
+                        g_subprocess_launcher_setenv (launcher, environment_entry[0], environment_entry[1], FALSE);
9cc5e2
                 }
9cc5e2
 
9cc5e2
                 /* Don't allow session specific environment variables from earlier sessions to
9cc5e2
                  * leak through */
9cc5e2
                 for (i = 0; session_variables[i] != NULL; i++) {
9cc5e2
                         if (g_getenv (session_variables[i]) == NULL) {
9cc5e2
                                 g_subprocess_launcher_unsetenv (launcher, session_variables[i]);
9cc5e2
                         }
9cc5e2
                 }
9cc5e2
         }
9cc5e2
 
9cc5e2
         g_subprocess_launcher_setenv (launcher, "DISPLAY", state->display_name, TRUE);
9cc5e2
         g_subprocess_launcher_setenv (launcher, "XAUTHORITY", state->auth_file, TRUE);
9cc5e2
 
9cc5e2
         if (state->bus_address != NULL) {
9cc5e2
                 g_subprocess_launcher_setenv (launcher, "DBUS_SESSION_BUS_ADDRESS", state->bus_address, TRUE);
9cc5e2
         }
9cc5e2
 
9cc5e2
         vt = g_getenv ("XDG_VTNR");
9cc5e2
 
9cc5e2
         if (vt != NULL) {
9cc5e2
                 g_subprocess_launcher_setenv (launcher, "WINDOWPATH", vt, TRUE);
9cc5e2
         }
9cc5e2
 
9cc5e2
         if (run_script) {
9cc5e2
                 subprocess = g_subprocess_launcher_spawn (launcher,
9cc5e2
                                                           &error,
9cc5e2
                                                           GDMCONFDIR "/Xsession",
9cc5e2
                                                           state->session_command,
9cc5e2
                                                           NULL);
9cc5e2
-- 
9cc5e2
2.30.1
9cc5e2