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

c0d9a4
From 738a10ca78e154ad4c3df9a1298eaad01516457e Mon Sep 17 00:00:00 2001
7b586f
From: Ray Strode <rstrode@redhat.com>
7b586f
Date: Mon, 20 Aug 2018 14:30:59 -0400
7b586f
Subject: [PATCH 4/4] daemon: handle upgrades from RHEL 7
7b586f
7b586f
RHEL 7 users need to stay on X if they were using X,
7b586f
and they need to stay on gnome-classic if they were using
7b586f
gnome-classic.
7b586f
7b586f
This commit examines the user's config to deduce whether
7b586f
or not they were using RHEL 7 and in the event they were
7b586f
try to get the right settings.
7b586f
---
7b586f
 daemon/gdm-session-settings.c | 19 +++++++++++++++++++
9cc5e2
 daemon/gdm-session.c          | 19 ++++++++-----------
9cc5e2
 2 files changed, 27 insertions(+), 11 deletions(-)
7b586f
7b586f
diff --git a/daemon/gdm-session-settings.c b/daemon/gdm-session-settings.c
9cc5e2
index a4b7f1a6..a84b2ffa 100644
7b586f
--- a/daemon/gdm-session-settings.c
7b586f
+++ b/daemon/gdm-session-settings.c
7b586f
@@ -270,95 +270,114 @@ gdm_session_settings_get_property (GObject    *object,
7b586f
 
7b586f
                 default:
7b586f
                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
7b586f
     }
7b586f
 }
7b586f
 
7b586f
 GdmSessionSettings *
7b586f
 gdm_session_settings_new (void)
7b586f
 {
7b586f
         GdmSessionSettings *settings;
7b586f
 
7b586f
         settings = g_object_new (GDM_TYPE_SESSION_SETTINGS,
7b586f
                                  NULL);
7b586f
 
7b586f
         return settings;
7b586f
 }
7b586f
 
7b586f
 gboolean
7b586f
 gdm_session_settings_is_loaded (GdmSessionSettings  *settings)
7b586f
 {
7b586f
         if (settings->priv->user == NULL) {
7b586f
                 return FALSE;
7b586f
         }
7b586f
 
7b586f
         return act_user_is_loaded (settings->priv->user);
7b586f
 }
7b586f
 
7b586f
 static void
7b586f
 load_settings_from_user (GdmSessionSettings *settings)
7b586f
 {
7b586f
+        const char *system_id = NULL, *system_version_id = NULL;
7b586f
         const char *object_path;
7b586f
         const char *session_name;
7b586f
         const char *session_type;
7b586f
         const char *language_name;
7b586f
 
7b586f
         if (!act_user_is_loaded (settings->priv->user)) {
7b586f
                 g_warning ("GdmSessionSettings: trying to load user settings from unloaded user");
7b586f
                 return;
7b586f
         }
7b586f
 
7b586f
         object_path = act_user_get_object_path (settings->priv->user);
7b586f
 
7b586f
         if (object_path != NULL) {
7b586f
                 g_autoptr (GError) error = NULL;
7b586f
                 settings->priv->user_system_proxy = gdm_accounts_service_user_system_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
7b586f
                                                                                                              G_DBUS_PROXY_FLAGS_NONE,
7b586f
                                                                                                              "org.freedesktop.Accounts",
7b586f
                                                                                                              object_path,
7b586f
                                                                                                              NULL,
7b586f
                                                                                                              &error);
7b586f
                 if (error != NULL) {
7b586f
                         g_debug ("GdmSessionSettings: couldn't retrieve user system proxy from accountsservice: %s",
7b586f
                                  error->message);
7b586f
+                } else {
7b586f
+                        system_id = gdm_accounts_service_user_system_get_id (settings->priv->user_system_proxy);
7b586f
+                        system_version_id = gdm_accounts_service_user_system_get_version_id (settings->priv->user_system_proxy);
7b586f
                 }
7b586f
         }
7b586f
 
9cc5e2
 
9cc5e2
 
9cc5e2
 
7b586f
 
7b586f
         session_type = act_user_get_session_type (settings->priv->user);
7b586f
         session_name = act_user_get_session (settings->priv->user);
7b586f
 
7b586f
         g_debug ("GdmSessionSettings: saved session is %s (type %s)", session_name, session_type);
7b586f
 
7b586f
+        if (system_id == NULL || (g_strcmp0 (system_id, "rhel") == 0 && g_str_has_prefix (system_version_id, "7."))) {
7b586f
+                /* if there's also no session name in the file and we're coming from RHEL 7,
7b586f
+                 * then we should assume classic session
7b586f
+                 */
7b586f
+                if (session_name == NULL || session_name[0] == '\0')
7b586f
+                        session_name = "gnome-classic";
7b586f
+
7b586f
+                /* only presume wayland if the user specifically picked it in RHEL 7
7b586f
+                 */
7b586f
+                if (g_strcmp0 (session_name, "gnome-wayland") == 0)
7b586f
+                        session_type = "wayland";
7b586f
+                else
7b586f
+                        session_type = "x11";
7b586f
+        }
7b586f
+
7b586f
         if (session_type != NULL && session_type[0] != '\0') {
7b586f
                 gdm_session_settings_set_session_type (settings, session_type);
7b586f
         }
7b586f
 
7b586f
         if (session_name != NULL && session_name[0] != '\0') {
7b586f
                 gdm_session_settings_set_session_name (settings, session_name);
7b586f
         }
7b586f
 
7b586f
         language_name = act_user_get_language (settings->priv->user);
7b586f
 
7b586f
         g_debug ("GdmSessionSettings: saved language is %s", language_name);
7b586f
         if (language_name != NULL && language_name[0] != '\0') {
7b586f
                 gdm_session_settings_set_language_name (settings, language_name);
7b586f
         }
7b586f
 
7b586f
 out:
7b586f
         g_object_notify (G_OBJECT (settings), "is-loaded");
7b586f
 }
7b586f
 
7b586f
 static void
7b586f
 on_user_is_loaded_changed (ActUser            *user,
7b586f
                            GParamSpec         *pspec,
7b586f
                            GdmSessionSettings *settings)
7b586f
 {
7b586f
         if (act_user_is_loaded (settings->priv->user)) {
7b586f
                 load_settings_from_user (settings);
7b586f
                 g_signal_handlers_disconnect_by_func (G_OBJECT (settings->priv->user),
7b586f
                                                       G_CALLBACK (on_user_is_loaded_changed),
7b586f
                                                       settings);
7b586f
         }
9cc5e2
diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
c0d9a4
index d1e2c301..d4a46d87 100644
9cc5e2
--- a/daemon/gdm-session.c
9cc5e2
+++ b/daemon/gdm-session.c
c0d9a4
@@ -3207,98 +3207,95 @@ gdm_session_get_session_id (GdmSession *self)
9cc5e2
         return conversation->session_id;
9cc5e2
 }
9cc5e2
 
9cc5e2
 const char *
9cc5e2
 gdm_session_get_conversation_session_id (GdmSession *self,
9cc5e2
                                          const char *service_name)
9cc5e2
 {
9cc5e2
         GdmSessionConversation *conversation;
9cc5e2
 
9cc5e2
         g_return_val_if_fail (GDM_IS_SESSION (self), NULL);
9cc5e2
 
9cc5e2
         conversation = find_conversation_by_name (self, service_name);
9cc5e2
 
9cc5e2
         if (conversation == NULL) {
9cc5e2
                 return NULL;
9cc5e2
         }
9cc5e2
 
9cc5e2
         return conversation->session_id;
9cc5e2
 }
9cc5e2
 
9cc5e2
 static char *
9cc5e2
 get_session_filename (GdmSession *self)
9cc5e2
 {
9cc5e2
         return g_strdup_printf ("%s.desktop", get_session_name (self));
9cc5e2
 }
9cc5e2
 
9cc5e2
 #ifdef ENABLE_WAYLAND_SUPPORT
9cc5e2
 static gboolean
9cc5e2
 gdm_session_is_wayland_session (GdmSession *self)
9cc5e2
 {
9cc5e2
-        GKeyFile   *key_file;
9cc5e2
+        g_autoptr (GKeyFile) key_file = NULL;
9cc5e2
         gboolean    is_wayland_session = FALSE;
9cc5e2
-        char       *filename;
9cc5e2
-        char       *full_path = NULL;
9cc5e2
+        g_autofree char       *filename = NULL;
9cc5e2
+        g_autofree char       *full_path = NULL;
9cc5e2
 
9cc5e2
         g_return_val_if_fail (self != NULL, FALSE);
9cc5e2
         g_return_val_if_fail (GDM_IS_SESSION (self), FALSE);
9cc5e2
 
9cc5e2
         filename = get_session_filename (self);
9cc5e2
 
9cc5e2
         if (supports_session_type (self, "wayland")) {
9cc5e2
                 key_file = load_key_file_for_file (self, filename, NULL, &full_path);
9cc5e2
 
9cc5e2
                 if (key_file == NULL) {
9cc5e2
                         goto out;
9cc5e2
                 }
9cc5e2
-        }
9cc5e2
 
9cc5e2
-        if (full_path != NULL && strstr (full_path, "/wayland-sessions/") != NULL) {
9cc5e2
-                is_wayland_session = TRUE;
9cc5e2
+                if (full_path != NULL && strstr (full_path, "/wayland-sessions/") != NULL) {
9cc5e2
+                        is_wayland_session = TRUE;
9cc5e2
+                }
9cc5e2
         }
9cc5e2
-        g_debug ("GdmSession: checking if file '%s' is wayland session: %s", filename, is_wayland_session? "yes" : "no");
9cc5e2
 
9cc5e2
 out:
9cc5e2
-        g_clear_pointer (&key_file, g_key_file_free);
9cc5e2
-        g_free (filename);
9cc5e2
+        g_debug ("GdmSession: checking if file '%s' is wayland session: %s", filename, is_wayland_session? "yes" : "no");
9cc5e2
         return is_wayland_session;
9cc5e2
 }
9cc5e2
 #endif
9cc5e2
 
9cc5e2
 static void
9cc5e2
 update_session_type (GdmSession *self)
9cc5e2
 {
9cc5e2
 #ifdef ENABLE_WAYLAND_SUPPORT
9cc5e2
         gboolean is_wayland_session = FALSE;
9cc5e2
 
9cc5e2
-        if (supports_session_type (self, "wayland"))
9cc5e2
-                is_wayland_session = gdm_session_is_wayland_session (self);
9cc5e2
+        is_wayland_session = gdm_session_is_wayland_session (self);
9cc5e2
 
9cc5e2
         if (is_wayland_session) {
9cc5e2
                 set_session_type (self, "wayland");
9cc5e2
         } else {
9cc5e2
                 set_session_type (self, NULL);
9cc5e2
         }
9cc5e2
 #endif
9cc5e2
 }
9cc5e2
 
9cc5e2
 gboolean
9cc5e2
 gdm_session_session_registers (GdmSession *self)
9cc5e2
 {
9cc5e2
         g_autoptr(GError) error = NULL;
9cc5e2
         g_autoptr(GKeyFile) key_file = NULL;
9cc5e2
         gboolean session_registers = FALSE;
9cc5e2
         g_autofree char *filename = NULL;
9cc5e2
 
9cc5e2
         g_return_val_if_fail (self != NULL, FALSE);
9cc5e2
         g_return_val_if_fail (GDM_IS_SESSION (self), FALSE);
9cc5e2
 
9cc5e2
         filename = get_session_filename (self);
9cc5e2
 
9cc5e2
         key_file = load_key_file_for_file (self, filename, NULL, NULL);
9cc5e2
 
9cc5e2
         session_registers = g_key_file_get_boolean (key_file,
9cc5e2
                                                     G_KEY_FILE_DESKTOP_GROUP,
9cc5e2
                                                     "X-GDM-SessionRegisters",
9cc5e2
                                                     &error);
9cc5e2
         if (!session_registers &&
9cc5e2
             error != NULL &&
7b586f
-- 
c0d9a4
2.33.1
7b586f