Blame SOURCES/0002-main-Also-clear-error-when-running-under-GDM.patch

52a515
From d39c345191f83ba37d24c07a831c9bb91cdde079 Mon Sep 17 00:00:00 2001
52a515
From: Benjamin Berg <bberg@redhat.com>
52a515
Date: Sun, 17 Apr 2022 15:58:13 +0200
52a515
Subject: [PATCH 2/2] main: Also clear error when running under GDM
52a515
52a515
Commit 0349a77ad875 ("main: Lower fallback warning when running in GDM")
52a515
removed error logging when running under GDM. However, the error was not
52a515
cleared afterwards, leaking it to later operations and causing other
52a515
issues.
52a515
52a515
Closes: #105
52a515
---
52a515
 gnome-session/main.c | 10 ++++------
52a515
 1 file changed, 4 insertions(+), 6 deletions(-)
52a515
52a515
diff --git a/gnome-session/main.c b/gnome-session/main.c
52a515
index 45ec6597..6a683ae0 100644
52a515
--- a/gnome-session/main.c
52a515
+++ b/gnome-session/main.c
52a515
@@ -512,88 +512,86 @@ main (int argc, char **argv)
52a515
                 exit (1);
52a515
         }
52a515
 
52a515
         env_override_autostart_dirs = g_getenv ("GNOME_SESSION_AUTOSTART_DIR");
52a515
 
52a515
         if (env_override_autostart_dirs != NULL && env_override_autostart_dirs[0] != '\0') {
52a515
                 env_override_autostart_dirs_v = g_strsplit (env_override_autostart_dirs, ":", 0);
52a515
                 gsm_util_set_autostart_dirs (env_override_autostart_dirs_v);
52a515
         } else {
52a515
                 gsm_util_set_autostart_dirs (override_autostart_dirs);
52a515
 
52a515
                 /* Export the override autostart dirs parameter to the environment
52a515
                  * in case we are running on systemd. */
52a515
                 if (override_autostart_dirs) {
52a515
                         g_autofree char *autostart_dirs = NULL;
52a515
                         autostart_dirs = g_strjoinv (":", override_autostart_dirs);
52a515
                         g_setenv ("GNOME_SESSION_AUTOSTART_DIR", autostart_dirs, TRUE);
52a515
                 }
52a515
         }
52a515
 
52a515
         gsm_util_export_activation_environment (&error);
52a515
         if (error) {
52a515
                 g_warning ("Failed to upload environment to DBus: %s", error->message);
52a515
                 g_clear_error (&error);
52a515
         }
52a515
 
52a515
         session_name = opt_session_name;
52a515
 
52a515
 #ifdef HAVE_SYSTEMD
52a515
         gsm_util_export_user_environment (&error);
52a515
-        if (error && !g_getenv ("RUNNING_UNDER_GDM")) {
52a515
+        if (error && !g_getenv ("RUNNING_UNDER_GDM"))
52a515
                 g_warning ("Failed to upload environment to systemd: %s", error->message);
52a515
-                g_clear_error (&error);
52a515
-        }
52a515
+        g_clear_error (&error);
52a515
 #endif
52a515
 
52a515
 #ifdef ENABLE_SYSTEMD_SESSION
52a515
         if (use_systemd && !systemd_service) {
52a515
                 g_autofree gchar *gnome_session_target;
52a515
                 const gchar *session_type;
52a515
 
52a515
                 session_type = g_getenv ("XDG_SESSION_TYPE");
52a515
 
52a515
                 /* We really need to resolve the session name at this point,
52a515
                  * which requires talking to GSettings internally. */
52a515
                 if (IS_STRING_EMPTY (session_name)) {
52a515
                         session_name = _gsm_manager_get_default_session (NULL);
52a515
                 }
52a515
 
52a515
                 /* Reset all failed units; we are going to start a lof ot things and
52a515
                  * really do not want to run into errors because units have failed
52a515
                  * in a previous session
52a515
                  */
52a515
                 gsm_util_systemd_reset_failed (&error);
52a515
-                if (error && !g_getenv ("RUNNING_UNDER_GDM")) {
52a515
+                if (error && !g_getenv ("RUNNING_UNDER_GDM"))
52a515
                         g_warning ("Failed to reset failed state of units: %s", error->message);
52a515
-                        g_clear_error (&error);
52a515
-                }
52a515
+                g_clear_error (&error);
52a515
 
52a515
                 /* We don't escape the name (i.e. we leave any '-' intact). */
52a515
                 gnome_session_target = g_strdup_printf ("gnome-session-%s@%s.target", session_type, session_name);
52a515
                 if (gsm_util_start_systemd_unit (gnome_session_target, "fail", &error)) {
52a515
                         /* We started the unit, open fifo and sleep forever. */
52a515
                         systemd_leader_run ();
52a515
                         exit(0);
52a515
                 }
52a515
 
52a515
                 /* We could not start the unit, fall back. */
52a515
                 if (g_getenv ("RUNNING_UNDER_GDM"))
52a515
                         g_message ("Falling back to non-systemd startup procedure. This is expected to happen for GDM sessions.");
52a515
                 else
52a515
                         g_warning ("Falling back to non-systemd startup procedure due to error: %s", error->message);
52a515
                 g_clear_error (&error);
52a515
         }
52a515
 #endif /* ENABLE_SYSTEMD_SESSION */
52a515
 
52a515
         {
52a515
                 gchar *ibus_path;
52a515
 
52a515
                 ibus_path = g_find_program_in_path("ibus-daemon");
52a515
 
52a515
                 if (ibus_path) {
52a515
                         const gchar *p;
52a515
                         p = g_getenv ("QT_IM_MODULE");
52a515
                         if (!p || !*p)
52a515
                                 p = "ibus";
52a515
                         gsm_util_setenv ("QT_IM_MODULE", p);
52a515
                         p = g_getenv ("XMODIFIERS");
52a515
-- 
52a515
2.35.1
52a515