Blame SOURCES/0036-local-display-factory-Remove-same-VT-so-don-t-switch.patch

400dab
From f5acee2766c05403235c06da6b1bb68af744da79 Mon Sep 17 00:00:00 2001
400dab
From: Ray Strode <rstrode@redhat.com>
400dab
Date: Tue, 25 Sep 2018 14:30:16 -0400
400dab
Subject: [PATCH 36/51] local-display-factory: Remove same VT so don't switch
400dab
 check
400dab
400dab
We avoid changing to the login screen vt if we're already on it,
400dab
but the call is racy since we react to vt changes concurrently
400dab
with logind (who we query for the active vt).
400dab
400dab
This check drops the active vt check since it's pointless and
400dab
getting in the way.
400dab
---
400dab
 daemon/gdm-local-display-factory.c | 39 ++++++++++--------------------
400dab
 1 file changed, 13 insertions(+), 26 deletions(-)
400dab
400dab
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
400dab
index 8e46dbca2..be7b43cff 100644
400dab
--- a/daemon/gdm-local-display-factory.c
400dab
+++ b/daemon/gdm-local-display-factory.c
400dab
@@ -410,103 +410,90 @@ lookup_by_seat_id (const char *id,
400dab
         res = g_strcmp0 (current, looking_for) == 0;
400dab
 
400dab
         g_free(current);
400dab
 
400dab
         return res;
400dab
 }
400dab
 
400dab
 static gboolean
400dab
 lookup_prepared_display_by_seat_id (const char *id,
400dab
                                     GdmDisplay *display,
400dab
                                     gpointer    user_data)
400dab
 {
400dab
         int status;
400dab
 
400dab
         status = gdm_display_get_status (display);
400dab
 
400dab
         if (status != GDM_DISPLAY_PREPARED)
400dab
                 return FALSE;
400dab
 
400dab
         return lookup_by_seat_id (id, display, user_data);
400dab
 }
400dab
 
400dab
 static GdmDisplay *
400dab
 create_display (GdmLocalDisplayFactory *factory,
400dab
                 const char             *seat_id,
400dab
                 const char             *session_type,
400dab
                 gboolean                initial)
400dab
 {
400dab
         GdmDisplayStore *store;
400dab
         GdmDisplay      *display = NULL;
400dab
-        char            *active_session_id = NULL;
400dab
-        int              ret;
400dab
+        g_autofree char *login_session_id = NULL;
400dab
 
400dab
         g_debug ("GdmLocalDisplayFactory: %s login display for seat %s requested",
400dab
                  session_type? : "X11", seat_id);
400dab
         store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
400dab
 
400dab
         if (sd_seat_can_multi_session (seat_id))
400dab
                 display = gdm_display_store_find (store, lookup_prepared_display_by_seat_id, (gpointer) seat_id);
400dab
         else
400dab
                 display = gdm_display_store_find (store, lookup_by_seat_id, (gpointer) seat_id);
400dab
 
400dab
         /* Ensure we don't create the same display more than once */
400dab
         if (display != NULL) {
400dab
                 g_debug ("GdmLocalDisplayFactory: display already created");
400dab
                 return NULL;
400dab
         }
400dab
 
400dab
-        ret = sd_seat_get_active (seat_id, &active_session_id, NULL);
400dab
-
400dab
-        if (ret == 0) {
400dab
-                char *login_session_id = NULL;
400dab
-
400dab
-                /* If we already have a login window, switch to it */
400dab
-                if (gdm_get_login_window_session_id (seat_id, &login_session_id)) {
400dab
-                        GdmDisplay *display;
400dab
-
400dab
-                        display = gdm_display_store_find (store,
400dab
-                                                          lookup_by_session_id,
400dab
-                                                          (gpointer) login_session_id);
400dab
-                        if (display != NULL && gdm_display_get_status (display) == GDM_DISPLAY_MANAGED) {
400dab
-                                if (g_strcmp0 (active_session_id, login_session_id) != 0) {
400dab
-                                        g_debug ("GdmLocalDisplayFactory: session %s found, activating.",
400dab
-                                                 login_session_id);
400dab
-                                        gdm_activate_session_by_id (factory->priv->connection, seat_id, login_session_id);
400dab
-                                }
400dab
-                                g_clear_pointer (&login_session_id, g_free);
400dab
-                                g_clear_pointer (&active_session_id, g_free);
400dab
-                                return NULL;
400dab
-                        }
400dab
-                        g_clear_pointer (&login_session_id, g_free);
400dab
+        /* If we already have a login window, switch to it */
400dab
+        if (gdm_get_login_window_session_id (seat_id, &login_session_id)) {
400dab
+                GdmDisplay *display;
400dab
+
400dab
+                display = gdm_display_store_find (store,
400dab
+                                                  lookup_by_session_id,
400dab
+                                                  (gpointer) login_session_id);
400dab
+                if (display != NULL && gdm_display_get_status (display) == GDM_DISPLAY_MANAGED) {
400dab
+                        g_debug ("GdmLocalDisplayFactory: session %s found, activating.",
400dab
+                                 login_session_id);
400dab
+                        gdm_activate_session_by_id (factory->priv->connection, seat_id, login_session_id);
400dab
+                        return NULL;
400dab
                 }
400dab
-                g_clear_pointer (&active_session_id, g_free);
400dab
         }
400dab
 
400dab
         g_debug ("GdmLocalDisplayFactory: Adding display on seat %s", seat_id);
400dab
 
400dab
 #ifdef ENABLE_USER_DISPLAY_SERVER
400dab
         if (g_strcmp0 (seat_id, "seat0") == 0) {
400dab
                 display = gdm_local_display_new ();
400dab
                 if (session_type != NULL) {
400dab
                         g_object_set (G_OBJECT (display), "session-type", session_type, NULL);
400dab
                 }
400dab
         }
400dab
 #endif
400dab
 
400dab
         if (display == NULL) {
400dab
                 guint32 num;
400dab
 
400dab
                 num = take_next_display_number (factory);
400dab
 
400dab
                 display = gdm_legacy_display_new (num);
400dab
         }
400dab
 
400dab
         g_object_set (display, "seat-id", seat_id, NULL);
400dab
         g_object_set (display, "is-initial", initial, NULL);
400dab
 
400dab
         store_display (factory, display);
400dab
 
400dab
         /* let store own the ref */
400dab
         g_object_unref (display);
400dab
 
400dab
         if (! gdm_display_manage (display)) {
400dab
-- 
400dab
2.27.0
400dab