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

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