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