Blame SOURCES/0004-daemon-handle-upgrades-from-RHEL-7.patch

890c66
From c673a7dd781da5ae0d64e13eb83c17e130231931 Mon Sep 17 00:00:00 2001
890c66
From: Ray Strode <rstrode@redhat.com>
890c66
Date: Mon, 20 Aug 2018 14:30:59 -0400
890c66
Subject: [PATCH 4/4] daemon: handle upgrades from RHEL 7
890c66
890c66
RHEL 7 users need to stay on X if they were using X,
890c66
and they need to stay on gnome-classic if they were using
890c66
gnome-classic.
890c66
890c66
This commit examines the user's config to deduce whether
890c66
or not they were using RHEL 7 and in the event they were
890c66
try to get the right settings.
890c66
---
890c66
 daemon/gdm-session-settings.c | 19 +++++++++++++++++++
890c66
 1 file changed, 19 insertions(+)
890c66
890c66
diff --git a/daemon/gdm-session-settings.c b/daemon/gdm-session-settings.c
890c66
index 921e4d501..0ce2e7de2 100644
890c66
--- a/daemon/gdm-session-settings.c
890c66
+++ b/daemon/gdm-session-settings.c
890c66
@@ -270,95 +270,114 @@ gdm_session_settings_get_property (GObject    *object,
890c66
 
890c66
                 default:
890c66
                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
890c66
     }
890c66
 }
890c66
 
890c66
 GdmSessionSettings *
890c66
 gdm_session_settings_new (void)
890c66
 {
890c66
         GdmSessionSettings *settings;
890c66
 
890c66
         settings = g_object_new (GDM_TYPE_SESSION_SETTINGS,
890c66
                                  NULL);
890c66
 
890c66
         return settings;
890c66
 }
890c66
 
890c66
 gboolean
890c66
 gdm_session_settings_is_loaded (GdmSessionSettings  *settings)
890c66
 {
890c66
         if (settings->priv->user == NULL) {
890c66
                 return FALSE;
890c66
         }
890c66
 
890c66
         return act_user_is_loaded (settings->priv->user);
890c66
 }
890c66
 
890c66
 static void
890c66
 load_settings_from_user (GdmSessionSettings *settings)
890c66
 {
890c66
+        const char *system_id = NULL, *system_version_id = NULL;
890c66
         const char *object_path;
890c66
         const char *session_name;
890c66
         const char *session_type;
890c66
         const char *language_name;
890c66
 
890c66
         if (!act_user_is_loaded (settings->priv->user)) {
890c66
                 g_warning ("GdmSessionSettings: trying to load user settings from unloaded user");
890c66
                 return;
890c66
         }
890c66
 
890c66
         object_path = act_user_get_object_path (settings->priv->user);
890c66
 
890c66
         if (object_path != NULL) {
890c66
                 g_autoptr (GError) error = NULL;
890c66
                 settings->priv->user_system_proxy = gdm_accounts_service_user_system_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
890c66
                                                                                                              G_DBUS_PROXY_FLAGS_NONE,
890c66
                                                                                                              "org.freedesktop.Accounts",
890c66
                                                                                                              object_path,
890c66
                                                                                                              NULL,
890c66
                                                                                                              &error);
890c66
                 if (error != NULL) {
890c66
                         g_debug ("GdmSessionSettings: couldn't retrieve user system proxy from accountsservice: %s",
890c66
                                  error->message);
890c66
+                } else {
890c66
+                        system_id = gdm_accounts_service_user_system_get_id (settings->priv->user_system_proxy);
890c66
+                        system_version_id = gdm_accounts_service_user_system_get_version_id (settings->priv->user_system_proxy);
890c66
                 }
890c66
         }
890c66
 
890c66
         /* if the user doesn't have saved state, they don't have any settings worth reading */
890c66
         if (!act_user_get_saved (settings->priv->user))
890c66
                 goto out;
890c66
 
890c66
         session_type = act_user_get_session_type (settings->priv->user);
890c66
         session_name = act_user_get_session (settings->priv->user);
890c66
 
890c66
         g_debug ("GdmSessionSettings: saved session is %s (type %s)", session_name, session_type);
890c66
 
890c66
+        if (system_id == NULL || (g_strcmp0 (system_id, "rhel") == 0 && g_str_has_prefix (system_version_id, "7."))) {
890c66
+                /* if there's also no session name in the file and we're coming from RHEL 7,
890c66
+                 * then we should assume classic session
890c66
+                 */
890c66
+                if (session_name == NULL || session_name[0] == '\0')
890c66
+                        session_name = "gnome-classic";
890c66
+
890c66
+                /* only presume wayland if the user specifically picked it in RHEL 7
890c66
+                 */
890c66
+                if (g_strcmp0 (session_name, "gnome-wayland") == 0)
890c66
+                        session_type = "wayland";
890c66
+                else
890c66
+                        session_type = "x11";
890c66
+        }
890c66
+
890c66
         if (session_type != NULL && session_type[0] != '\0') {
890c66
                 gdm_session_settings_set_session_type (settings, session_type);
890c66
         }
890c66
 
890c66
         if (session_name != NULL && session_name[0] != '\0') {
890c66
                 gdm_session_settings_set_session_name (settings, session_name);
890c66
         }
890c66
 
890c66
         language_name = act_user_get_language (settings->priv->user);
890c66
 
890c66
         g_debug ("GdmSessionSettings: saved language is %s", language_name);
890c66
         if (language_name != NULL && language_name[0] != '\0') {
890c66
                 gdm_session_settings_set_language_name (settings, language_name);
890c66
         }
890c66
 
890c66
 out:
890c66
         g_object_notify (G_OBJECT (settings), "is-loaded");
890c66
 }
890c66
 
890c66
 static void
890c66
 on_user_is_loaded_changed (ActUser            *user,
890c66
                            GParamSpec         *pspec,
890c66
                            GdmSessionSettings *settings)
890c66
 {
890c66
         if (act_user_is_loaded (settings->priv->user)) {
890c66
                 load_settings_from_user (settings);
890c66
                 g_signal_handlers_disconnect_by_func (G_OBJECT (settings->priv->user),
890c66
                                                       G_CALLBACK (on_user_is_loaded_changed),
890c66
                                                       settings);
890c66
         }
890c66
-- 
890c66
2.17.1
890c66