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

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