Blob Blame History Raw
From b9f38b65417923624bf97a18daf1c2ede5e8651e Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sun, 15 Dec 2019 14:51:44 -0500
Subject: [PATCH] daemon: fix wayland detection when deciding to bypass
 Xsession

At the moment if there's a session file with the same name in
both /usr/share/xsessions and /usr/share/wayland-sessions, GDM
will think the wayland is getting used when deciding whether or
not to bypass the /etc/gdm/Xsession script, even if wayland is
explicitly being ignored.

This commit fixes the check.
---
 daemon/gdm-session.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
index a8263ba11..ecb2b3cac 100644
--- a/daemon/gdm-session.c
+++ b/daemon/gdm-session.c
@@ -3145,96 +3145,96 @@ gdm_session_get_session_id (GdmSession *self)
         return conversation->session_id;
 }
 
 const char *
 gdm_session_get_conversation_session_id (GdmSession *self,
                                          const char *service_name)
 {
         GdmSessionConversation *conversation;
 
         g_return_val_if_fail (GDM_IS_SESSION (self), NULL);
 
         conversation = find_conversation_by_name (self, service_name);
 
         if (conversation == NULL) {
                 return NULL;
         }
 
         return conversation->session_id;
 }
 
 static char *
 get_session_filename (GdmSession *self)
 {
         return g_strdup_printf ("%s.desktop", get_session_name (self));
 }
 
 #ifdef ENABLE_WAYLAND_SUPPORT
 static gboolean
 gdm_session_is_wayland_session (GdmSession *self)
 {
-        GKeyFile   *key_file;
+        g_autoptr (GKeyFile) key_file = NULL;
         gboolean    is_wayland_session = FALSE;
-        char       *filename;
-        char       *full_path = NULL;
+        g_autofree char       *filename = NULL;
+        g_autofree char       *full_path = NULL;
 
         g_return_val_if_fail (self != NULL, FALSE);
         g_return_val_if_fail (GDM_IS_SESSION (self), FALSE);
 
         filename = get_session_filename (self);
 
-        key_file = load_key_file_for_file (self, filename, "wayland", &full_path);
+        if (!self->priv->ignore_wayland) {
+                key_file = load_key_file_for_file (self, filename, "wayland", &full_path);
 
-        if (key_file == NULL) {
-                goto out;
-        }
+                if (key_file == NULL) {
+                        goto out;
+                }
 
-        if (full_path != NULL && strstr (full_path, "/wayland-sessions/") != NULL) {
-                is_wayland_session = TRUE;
+                if (full_path != NULL && strstr (full_path, "/wayland-sessions/") != NULL) {
+                        is_wayland_session = TRUE;
+                }
         }
-        g_debug ("GdmSession: checking if file '%s' is wayland session: %s", filename, is_wayland_session? "yes" : "no");
 
 out:
-        g_clear_pointer (&key_file, (GDestroyNotify) g_key_file_free);
-        g_free (filename);
+        g_debug ("GdmSession: checking if file '%s' is wayland session: %s", filename, is_wayland_session? "yes" : "no");
+
         return is_wayland_session;
 }
 #endif
 
 static void
 update_session_type (GdmSession *self)
 {
 #ifdef ENABLE_WAYLAND_SUPPORT
         gboolean is_wayland_session = FALSE;
 
-        if (!self->priv->ignore_wayland)
-                is_wayland_session = gdm_session_is_wayland_session (self);
+        is_wayland_session = gdm_session_is_wayland_session (self);
 
         if (is_wayland_session) {
                 set_session_type (self, "wayland");
         } else {
                 set_session_type (self, NULL);
         }
 #endif
 }
 
 gboolean
 gdm_session_bypasses_xsession (GdmSession *self)
 {
         GError     *error;
         GKeyFile   *key_file;
         gboolean    res;
         gboolean    bypasses_xsession = FALSE;
         char       *filename = NULL;
 
         g_return_val_if_fail (self != NULL, FALSE);
         g_return_val_if_fail (GDM_IS_SESSION (self), FALSE);
 
 #ifdef ENABLE_WAYLAND_SUPPORT
         if (gdm_session_is_wayland_session (self)) {
                 bypasses_xsession = TRUE;
                 goto out;
         }
 #endif
 
         filename = get_session_filename (self);
 
-- 
2.18.1