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

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