Blame SOURCES/0005-daemon-fix-wayland-detection-when-deciding-to-bypass.patch

ffa191
From 4862efc8bb38e97a785bd9c368d9b701c2acba68 Mon Sep 17 00:00:00 2001
f83012
From: Ray Strode <rstrode@redhat.com>
f83012
Date: Sun, 15 Dec 2019 14:51:44 -0500
ffa191
Subject: [PATCH 5/5] daemon: fix wayland detection when deciding to bypass
f83012
 Xsession
f83012
f83012
At the moment if there's a session file with the same name in
f83012
both /usr/share/xsessions and /usr/share/wayland-sessions, GDM
f83012
will think the wayland is getting used when deciding whether or
f83012
not to bypass the /etc/gdm/Xsession script, even if wayland is
f83012
explicitly being ignored.
f83012
f83012
This commit fixes the check.
f83012
---
ffa191
 daemon/gdm-session.c | 31 +++++++++++++++----------------
ffa191
 1 file changed, 15 insertions(+), 16 deletions(-)
f83012
f83012
diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
ffa191
index 2d471ec46..38a32fdab 100644
f83012
--- a/daemon/gdm-session.c
f83012
+++ b/daemon/gdm-session.c
ffa191
@@ -2898,61 +2898,61 @@ gdm_session_start_session (GdmSession *self,
ffa191
         char                   *command;
ffa191
         char                   *program;
ffa191
         gboolean               register_session;
ffa191
 
ffa191
         g_return_if_fail (GDM_IS_SESSION (self));
ffa191
         g_return_if_fail (self->session_conversation == NULL);
ffa191
 
ffa191
         conversation = find_conversation_by_name (self, service_name);
ffa191
 
ffa191
         if (conversation == NULL) {
ffa191
                 g_warning ("GdmSession: Tried to start session of "
ffa191
                            "nonexistent conversation %s", service_name);
ffa191
                 return;
ffa191
         }
ffa191
 
ffa191
         stop_all_other_conversations (self, conversation, FALSE);
ffa191
 
ffa191
         display_mode = gdm_session_get_display_mode (self);
ffa191
 
ffa191
 #ifdef ENABLE_WAYLAND_SUPPORT
ffa191
         is_x11 = g_strcmp0 (self->session_type, "wayland") != 0;
ffa191
 #endif
ffa191
 
ffa191
         if (display_mode == GDM_SESSION_DISPLAY_MODE_LOGIND_MANAGED ||
ffa191
             display_mode == GDM_SESSION_DISPLAY_MODE_NEW_VT) {
ffa191
                 run_launcher = TRUE;
ffa191
         }
ffa191
 
ffa191
         register_session = !gdm_session_session_registers (self);
ffa191
 
ffa191
-        if (g_strcmp0 (priv->display_seat_id, "seat0") != 0 && !run_launcher) {
ffa191
+        if (g_strcmp0 (self->display_seat_id, "seat0") != 0 && !run_launcher) {
ffa191
                 run_separate_bus = TRUE;
ffa191
         }
ffa191
 
ffa191
         if (self->selected_program == NULL) {
ffa191
                 gboolean run_xsession_script;
ffa191
 
ffa191
                 command = get_session_command (self);
ffa191
 
ffa191
                 run_xsession_script = !gdm_session_bypasses_xsession (self);
ffa191
 
ffa191
                 if (self->display_is_local) {
ffa191
                         gboolean disallow_tcp = TRUE;
ffa191
                         gdm_settings_direct_get_boolean (GDM_KEY_DISALLOW_TCP, &disallow_tcp);
ffa191
                         allow_remote_connections = !disallow_tcp;
ffa191
                 } else {
ffa191
                         allow_remote_connections = TRUE;
ffa191
                 }
ffa191
 
ffa191
                 if (run_launcher) {
ffa191
                         if (is_x11) {
ffa191
                                 program = g_strdup_printf (LIBEXECDIR "/gdm-x-session %s%s %s\"%s\"",
ffa191
                                                            register_session ? "--register-session " : "",
ffa191
                                                            run_xsession_script? "--run-script " : "",
ffa191
                                                            allow_remote_connections? "--allow-remote-connections " : "",
ffa191
                                                            command);
ffa191
                         } else {
ffa191
                                 program = g_strdup_printf (LIBEXECDIR "/gdm-wayland-session %s\"%s\"",
ffa191
                                                            register_session ? "--register-session " : "",
ffa191
                                                            command);
ffa191
                         }
ffa191
@@ -3192,119 +3192,118 @@ gdm_session_get_session_id (GdmSession *self)
f83012
         return conversation->session_id;
f83012
 }
f83012
 
f83012
 const char *
f83012
 gdm_session_get_conversation_session_id (GdmSession *self,
f83012
                                          const char *service_name)
f83012
 {
f83012
         GdmSessionConversation *conversation;
f83012
 
f83012
         g_return_val_if_fail (GDM_IS_SESSION (self), NULL);
f83012
 
f83012
         conversation = find_conversation_by_name (self, service_name);
f83012
 
f83012
         if (conversation == NULL) {
f83012
                 return NULL;
f83012
         }
f83012
 
f83012
         return conversation->session_id;
f83012
 }
f83012
 
f83012
 static char *
f83012
 get_session_filename (GdmSession *self)
f83012
 {
f83012
         return g_strdup_printf ("%s.desktop", get_session_name (self));
f83012
 }
f83012
 
f83012
 #ifdef ENABLE_WAYLAND_SUPPORT
f83012
 static gboolean
f83012
 gdm_session_is_wayland_session (GdmSession *self)
f83012
 {
f83012
-        GKeyFile   *key_file;
f83012
+        g_autoptr (GKeyFile) key_file = NULL;
f83012
         gboolean    is_wayland_session = FALSE;
f83012
-        char       *filename;
f83012
-        char       *full_path = NULL;
f83012
+        g_autofree char       *filename = NULL;
f83012
+        g_autofree char       *full_path = NULL;
f83012
 
f83012
         g_return_val_if_fail (self != NULL, FALSE);
f83012
         g_return_val_if_fail (GDM_IS_SESSION (self), FALSE);
f83012
 
f83012
         filename = get_session_filename (self);
f83012
 
f83012
-        key_file = load_key_file_for_file (self, filename, "wayland", &full_path);
ffa191
+        if (!self->ignore_wayland) {
f83012
+                key_file = load_key_file_for_file (self, filename, "wayland", &full_path);
f83012
 
f83012
-        if (key_file == NULL) {
f83012
-                goto out;
f83012
-        }
f83012
+                if (key_file == NULL) {
f83012
+                        goto out;
f83012
+                }
f83012
 
f83012
-        if (full_path != NULL && strstr (full_path, "/wayland-sessions/") != NULL) {
f83012
-                is_wayland_session = TRUE;
f83012
+                if (full_path != NULL && strstr (full_path, "/wayland-sessions/") != NULL) {
f83012
+                        is_wayland_session = TRUE;
f83012
+                }
f83012
         }
f83012
-        g_debug ("GdmSession: checking if file '%s' is wayland session: %s", filename, is_wayland_session? "yes" : "no");
f83012
 
f83012
 out:
ffa191
-        g_clear_pointer (&key_file, g_key_file_free);
f83012
-        g_free (filename);
f83012
+        g_debug ("GdmSession: checking if file '%s' is wayland session: %s", filename, is_wayland_session? "yes" : "no");
f83012
         return is_wayland_session;
f83012
 }
f83012
 #endif
f83012
 
f83012
 static void
f83012
 update_session_type (GdmSession *self)
f83012
 {
f83012
 #ifdef ENABLE_WAYLAND_SUPPORT
f83012
         gboolean is_wayland_session = FALSE;
f83012
 
ffa191
-        if (!self->ignore_wayland)
f83012
-                is_wayland_session = gdm_session_is_wayland_session (self);
f83012
+        is_wayland_session = gdm_session_is_wayland_session (self);
f83012
 
f83012
         if (is_wayland_session) {
f83012
                 set_session_type (self, "wayland");
f83012
         } else {
f83012
                 set_session_type (self, NULL);
f83012
         }
f83012
 #endif
f83012
 }
f83012
 
f83012
 gboolean
ffa191
 gdm_session_session_registers (GdmSession *self)
ffa191
 {
ffa191
         g_autoptr(GError) error = NULL;
ffa191
         g_autoptr(GKeyFile) key_file = NULL;
ffa191
         gboolean session_registers = FALSE;
ffa191
         g_autofree char *filename = NULL;
ffa191
 
ffa191
         g_return_val_if_fail (self != NULL, FALSE);
ffa191
         g_return_val_if_fail (GDM_IS_SESSION (self), FALSE);
ffa191
 
ffa191
         filename = get_session_filename (self);
ffa191
 
ffa191
-        key_file = load_key_file_for_file (self, filename, NULL);
ffa191
+        key_file = load_key_file_for_file (self, filename, NULL, NULL);
ffa191
 
ffa191
         session_registers = g_key_file_get_boolean (key_file,
ffa191
                                                     G_KEY_FILE_DESKTOP_GROUP,
ffa191
                                                     "X-GDM-SessionRegisters",
ffa191
                                                     &error);
ffa191
         if (!session_registers &&
ffa191
             error != NULL &&
ffa191
             !g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND)) {
ffa191
                 g_warning ("GdmSession: Couldn't read session file '%s'", filename);
ffa191
                 return FALSE;
ffa191
         }
ffa191
 
ffa191
         g_debug ("GdmSession: '%s' %s self", filename,
ffa191
                  session_registers ? "registers" : "does not register");
ffa191
 
ffa191
         return session_registers;
ffa191
 }
ffa191
 
ffa191
 gboolean
f83012
 gdm_session_bypasses_xsession (GdmSession *self)
f83012
 {
f83012
         GError     *error;
f83012
         GKeyFile   *key_file;
f83012
         gboolean    res;
f83012
         gboolean    bypasses_xsession = FALSE;
f83012
         char       *filename = NULL;
f83012
 
f83012
         g_return_val_if_fail (self != NULL, FALSE);
f83012
         g_return_val_if_fail (GDM_IS_SESSION (self), FALSE);
f83012
 
f83012
-- 
ffa191
2.31.1
f83012