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

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