Blame SOURCES/0001-main-don-t-call-into-gdbus-before-setting-all-enviro.patch

d379a5
From 6294629686aed366210806a911016facd82a7fa7 Mon Sep 17 00:00:00 2001
244a5d
From: rpm-build <rpm-build>
244a5d
Date: Wed, 14 Feb 2018 09:50:56 -0500
244a5d
Subject: [PATCH] main: don't call into gdbus before setting all environment
244a5d
 variables
244a5d
244a5d
setenv () is not multi-thread safe so we need to avoid gsm_util_setenv
244a5d
calls (which fire off the glib worker thread) before we finish
244a5d
doing all our setenv() work.
244a5d
---
244a5d
 gnome-session/main.c | 9 +++++++--
244a5d
 1 file changed, 7 insertions(+), 2 deletions(-)
244a5d
244a5d
diff --git a/gnome-session/main.c b/gnome-session/main.c
d379a5
index b1ac385..bfcce83 100644
244a5d
--- a/gnome-session/main.c
244a5d
+++ b/gnome-session/main.c
244a5d
@@ -244,91 +244,96 @@ initialize_gio (void)
244a5d
         disable_fuse = g_strdup (g_getenv ("GVFS_DISABLE_FUSE"));
244a5d
         use_vfs = g_strdup (g_getenv ("GIO_USE_VFS"));
244a5d
 
244a5d
         g_setenv ("GVFS_DISABLE_FUSE", "1", TRUE);
244a5d
         g_setenv ("GIO_USE_VFS", "local", TRUE);
244a5d
         g_vfs_get_default ();
244a5d
 
244a5d
         if (use_vfs) {
244a5d
                 g_setenv ("GIO_USE_VFS", use_vfs, TRUE);
244a5d
                 g_free (use_vfs);
244a5d
         } else {
244a5d
                 g_unsetenv ("GIO_USE_VFS");
244a5d
         }
244a5d
 
244a5d
         if (disable_fuse) {
244a5d
                 g_setenv ("GVFS_DISABLE_FUSE", disable_fuse, TRUE);
244a5d
                 g_free (disable_fuse);
244a5d
         } else {
244a5d
                 g_unsetenv ("GVFS_DISABLE_FUSE");
244a5d
         }
244a5d
 }
244a5d
 
244a5d
 int
244a5d
 main (int argc, char **argv)
244a5d
 {
244a5d
         GError           *error = NULL;
244a5d
         static char     **override_autostart_dirs = NULL;
244a5d
         static char      *opt_session_name = NULL;
244a5d
         const char       *debug_string = NULL;
244a5d
         gboolean          gl_failed = FALSE;
244a5d
+        gboolean          needs_current_desktop_setenv = FALSE;
244a5d
         guint             name_owner_id;
244a5d
         GOptionContext   *options;
244a5d
         static GOptionEntry entries[] = {
244a5d
                 { "autostart", 'a', 0, G_OPTION_ARG_STRING_ARRAY, &override_autostart_dirs, N_("Override standard autostart directories"), N_("AUTOSTART_DIR") },
244a5d
                 { "session", 0, 0, G_OPTION_ARG_STRING, &opt_session_name, N_("Session to use"), N_("SESSION_NAME") },
244a5d
                 { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL },
244a5d
                 { "failsafe", 'f', 0, G_OPTION_ARG_NONE, &failsafe, N_("Do not load user-specified applications"), NULL },
244a5d
                 { "version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL },
244a5d
                 /* Translators: the 'fail whale' is the black dialog we show when something goes seriously wrong */
244a5d
                 { "whale", 0, 0, G_OPTION_ARG_NONE, &please_fail, N_("Show the fail whale dialog for testing"), NULL },
244a5d
                 { "disable-acceleration-check", 0, 0, G_OPTION_ARG_NONE, &disable_acceleration_check, N_("Disable hardware acceleration check"), NULL },
244a5d
                 { NULL, 0, 0, 0, NULL, NULL, NULL }
244a5d
         };
244a5d
 
244a5d
         /* Make sure that we have a session bus */
244a5d
         if (!require_dbus_session (argc, argv, &error)) {
244a5d
                 gsm_util_init_error (TRUE, "%s", error->message);
244a5d
         }
244a5d
 
244a5d
         /* From 3.14 GDM sets XDG_CURRENT_DESKTOP. For compatibility with
244a5d
          * older versions of GDM,  other display managers, and startx,
244a5d
          * set a fallback value if we don't find it set.
244a5d
          */
244a5d
         if (g_getenv ("XDG_CURRENT_DESKTOP") == NULL) {
244a5d
-            g_setenv("XDG_CURRENT_DESKTOP", "GNOME", TRUE);
244a5d
-            gsm_util_setenv ("XDG_CURRENT_DESKTOP", "GNOME");
244a5d
+                g_setenv ("XDG_CURRENT_DESKTOP", "GNOME", TRUE);
244a5d
+                needs_current_desktop_setenv = TRUE;
244a5d
         }
244a5d
 
244a5d
         /* Make sure we initialize gio in a way that does not autostart any daemon */
244a5d
         initialize_gio ();
244a5d
 
244a5d
+        if (needs_current_desktop_setenv) {
244a5d
+                gsm_util_setenv ("XDG_CURRENT_DESKTOP", "GNOME");
244a5d
+        }
244a5d
+
244a5d
         setlocale (LC_ALL, "");
244a5d
         bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
244a5d
         bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
244a5d
         textdomain (GETTEXT_PACKAGE);
244a5d
 
244a5d
         debug_string = g_getenv ("GNOME_SESSION_DEBUG");
244a5d
         if (debug_string != NULL) {
d379a5
                 debug = atoi (debug_string) == 1;
244a5d
         }
244a5d
 
244a5d
         error = NULL;
244a5d
         options = g_option_context_new (_(" — the GNOME session manager"));
244a5d
         g_option_context_add_main_entries (options, entries, GETTEXT_PACKAGE);
244a5d
         g_option_context_parse (options, &argc, &argv, &error);
244a5d
         if (error != NULL) {
244a5d
                 g_warning ("%s", error->message);
244a5d
                 exit (1);
244a5d
         }
244a5d
 
244a5d
         g_option_context_free (options);
244a5d
 
244a5d
         /* Rebind stdout/stderr to the journal explicitly, so that
244a5d
          * journald picks ups the nicer "gnome-session" as the program
244a5d
          * name instead of whatever shell script GDM happened to use.
244a5d
          */
d379a5
 #ifdef ENABLE_SYSTEMD_JOURNAL
244a5d
         if (!debug) {
244a5d
                 int journalfd;
244a5d
 
244a5d
                 journalfd = sd_journal_stream_fd (PACKAGE, LOG_INFO, 0);
244a5d
-- 
244a5d
2.14.3
244a5d