Blame SOURCES/0035-local-display-factory-Remove-initial-VT-is-in-use-ch.patch

400dab
From 2843a951ef826afd01fa3c7340780b1929db38c7 Mon Sep 17 00:00:00 2001
400dab
From: Hans de Goede <hdegoede@redhat.com>
400dab
Date: Tue, 4 Sep 2018 08:12:34 +0200
400dab
Subject: [PATCH 35/51] local-display-factory: Remove initial VT is in use
400dab
 check
400dab
400dab
The initial VT is in use check in on_vt_changed() is racy, when switching
400dab
to VT1 from an active session, on_vt_changed() may run before logind has
400dab
processed the VT change and then sd_seat_get_active() will return the
400dab
active session which we are switching away from. This results in the greeter
400dab
not being started on VT1.
400dab
400dab
On my system gdm reliably wins the race resulting in not getting a greeter
400dab
when manually switching from an active session to VT1.
400dab
400dab
gdm already starts the greeter unconditionally from
400dab
gdm_local_display_factory_sync_seats() on both startup and when an user
400dab
session exits. gdm also starts it unconditionally when selecting
400dab
"Switch user" from an user session.
400dab
400dab
Now autologin sessions avoid the initial VT as well.
400dab
400dab
So we now can assume that the initial VT is free for the login screen's
400dab
use. And create_display already checks for and re-uses
400dab
an existing greeter, so we can safely remove the racy check.
400dab
---
400dab
 daemon/gdm-local-display-factory.c | 13 -------------
400dab
 1 file changed, 13 deletions(-)
400dab
400dab
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
400dab
index 13d56dcff..8e46dbca2 100644
400dab
--- a/daemon/gdm-local-display-factory.c
400dab
+++ b/daemon/gdm-local-display-factory.c
400dab
@@ -752,73 +752,60 @@ on_vt_changed (GIOChannel    *source,
400dab
 
400dab
                         g_debug ("GdmLocalDisplayFactory: tty of login window is %s", tty_of_login_window_vt);
400dab
                         if (g_strcmp0 (tty_of_login_window_vt, tty_of_previous_vt) == 0) {
400dab
                                 GdmDisplayStore *store;
400dab
                                 GdmDisplay *display;
400dab
 
400dab
                                 g_debug ("GdmLocalDisplayFactory: VT switched from login window");
400dab
 
400dab
                                 store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
400dab
                                 display = gdm_display_store_find (store,
400dab
                                                                   lookup_by_session_id,
400dab
                                                                   (gpointer) login_session_id);
400dab
 
400dab
                                 if (display != NULL)
400dab
                                         maybe_stop_greeter_in_background (factory, display);
400dab
                         } else {
400dab
                                 g_debug ("GdmLocalDisplayFactory: VT not switched from login window");
400dab
                         }
400dab
                 }
400dab
         }
400dab
 
400dab
         /* if user jumped back to initial vt and it's empty put a login screen
400dab
          * on it (unless a login screen is already running elsewhere, then
400dab
          * jump to that login screen)
400dab
          */
400dab
         if (strcmp (factory->priv->tty_of_active_vt, tty_of_initial_vt) != 0) {
400dab
                 g_debug ("GdmLocalDisplayFactory: active VT is not initial VT, so ignoring");
400dab
                 return G_SOURCE_CONTINUE;
400dab
         }
400dab
 
400dab
-        ret = sd_seat_get_active ("seat0", &active_session_id, NULL);
400dab
-
400dab
-        if (ret == 0) {
400dab
-                g_autofree char *state = NULL;
400dab
-                ret = sd_session_get_state (active_session_id, &state);
400dab
-
400dab
-                /* if there's something already running on the active VT then bail */
400dab
-                if (ret == 0 && g_strcmp0 (state, "closing") != 0) {
400dab
-                        g_debug ("GdmLocalDisplayFactory: initial VT is in use, so ignoring");
400dab
-                        return G_SOURCE_CONTINUE;
400dab
-                }
400dab
-        }
400dab
-
400dab
         if (gdm_local_display_factory_use_wayland ())
400dab
                 session_type = "wayland";
400dab
 
400dab
         g_debug ("GdmLocalDisplayFactory: creating new display on seat0 because of VT change");
400dab
 
400dab
         create_display (factory, "seat0", session_type, TRUE);
400dab
 
400dab
         return G_SOURCE_CONTINUE;
400dab
 }
400dab
 #endif
400dab
 
400dab
 static void
400dab
 gdm_local_display_factory_start_monitor (GdmLocalDisplayFactory *factory)
400dab
 {
400dab
         g_autoptr (GIOChannel) io_channel = NULL;
400dab
 
400dab
         factory->priv->seat_new_id = g_dbus_connection_signal_subscribe (factory->priv->connection,
400dab
                                                                          "org.freedesktop.login1",
400dab
                                                                          "org.freedesktop.login1.Manager",
400dab
                                                                          "SeatNew",
400dab
                                                                          "/org/freedesktop/login1",
400dab
                                                                          NULL,
400dab
                                                                          G_DBUS_SIGNAL_FLAGS_NONE,
400dab
                                                                          on_seat_new,
400dab
                                                                          g_object_ref (factory),
400dab
                                                                          g_object_unref);
400dab
         factory->priv->seat_removed_id = g_dbus_connection_signal_subscribe (factory->priv->connection,
400dab
                                                                              "org.freedesktop.login1",
400dab
                                                                              "org.freedesktop.login1.Manager",
400dab
                                                                              "SeatRemoved",
400dab
-- 
400dab
2.27.0
400dab