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

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