Blob Blame History Raw
From f30e557a8afcdfe5d571a625b4c99606315ed3b4 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Mon, 11 Feb 2019 10:32:55 -0500
Subject: [PATCH 3/3] session: ensure login screen over XDMCP connects to its
 session

Right now GTK preferentially picks the wayland display over an
X11 display if it finds one.

That causes a problem for XDMCP sessions, since there may be a
wayland display running on the local console for the GDM user.

This commit addresses the issue by forcing the X11 backend if
the session is X11.
---
 daemon/gdm-session.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
index f13b54af..9f68166e 100644
--- a/daemon/gdm-session.c
+++ b/daemon/gdm-session.c
@@ -2739,60 +2739,79 @@ set_up_session_environment (GdmSession *self)
 }
 
 static void
 send_display_mode (GdmSession *self,
                    GdmSessionConversation *conversation)
 {
         GdmSessionDisplayMode mode;
 
         mode = gdm_session_get_display_mode (self);
         gdm_dbus_worker_call_set_session_display_mode (conversation->worker_proxy,
                                                        gdm_session_display_mode_to_string (mode),
                                                        conversation->worker_cancellable,
                                                        NULL, NULL);
 }
 
 static void
 send_session_type (GdmSession *self,
                    GdmSessionConversation *conversation)
 {
         const char *session_type = "x11";
 
         if (self->session_type != NULL) {
                 session_type = self->session_type;
         }
 
         gdm_dbus_worker_call_set_environment_variable (conversation->worker_proxy,
                                                        "XDG_SESSION_TYPE",
                                                        session_type,
                                                        conversation->worker_cancellable,
                                                        NULL, NULL);
+
+        /* If the session type is x11, then set GDK_BACKEND to x11 as well.
+         * This is so gnome-session-check-accelerated from an XDMCP connection doesn't
+         * try to use the wayland display running on the local console for the gdm
+         * user login screen session.
+         *
+         * That's the only case where we let a user log in more than once, so it's
+         * the only situation that matters.
+         *
+         * We can drop this code if we ever switch the login screen to use systemd's
+         * DynamicUser feature.
+         */
+        if (g_strcmp0 (session_type, "x11") == 0) {
+                gdm_dbus_worker_call_set_environment_variable (conversation->worker_proxy,
+                                                               "GDK_BACKEND",
+                                                               "x11",
+                                                               conversation->worker_cancellable,
+                                                               NULL, NULL);
+        }
 }
 
 void
 gdm_session_open_session (GdmSession *self,
                           const char *service_name)
 {
         GdmSessionConversation *conversation;
 
         g_return_if_fail (GDM_IS_SESSION (self));
 
         conversation = find_conversation_by_name (self, service_name);
 
         if (conversation != NULL) {
                 send_display_mode (self, conversation);
                 send_session_type (self, conversation);
 
                 gdm_dbus_worker_call_open (conversation->worker_proxy,
                                            conversation->worker_cancellable,
                                            (GAsyncReadyCallback) on_opened, conversation);
         }
 }
 
 static void
 stop_all_other_conversations (GdmSession             *self,
                               GdmSessionConversation *conversation_to_keep,
                               gboolean                now)
 {
         GHashTableIter iter;
         gpointer key, value;
 
-- 
2.32.0