Blob Blame History Raw
From b8c942b5f191eaa39ac1e578fa019b32a516cd5c Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Mon, 11 Feb 2019 10:32:55 -0500
Subject: [PATCH] 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 e6640aac7..0f821e390 100644
--- a/daemon/gdm-session.c
+++ b/daemon/gdm-session.c
@@ -2614,60 +2614,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->priv->session_type != NULL) {
                 session_type = self->priv->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.18.1