From b170894d7e1b95eb9dd485cbf051e0d3ca89076b Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 16 May 2018 12:31:48 +0100 Subject: [PATCH] local-display-factory: Create transient display if there is no active session Now that we stop the greeter session when it is no longer necessary, the following can happen: 1) Log in as user a. 2) User-switch to user b. 3) Log out user b. 4) The logout takes you back to VT1, but there is no greeter session running. The problem here is that the create_display() call from gdm_local_display_factory_sync_seats() does not create a new display because there already is a display on the seat for user a. We can detect being on a VT which does not have an active session, by calling sd_seat_get_active() to get the active session, which will return an error in this case. This commit fixes the problem of the user being taken to a black VT1 in the above scenario by starting a transitient display if the create_display() in gdm_local_display_factory_sync_seats() returns NULL and sd_seat_get_active() returns -ENODATA. --- daemon/gdm-local-display-factory.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c index cd95d4a2..214ea172 100644 --- a/daemon/gdm-local-display-factory.c +++ b/daemon/gdm-local-display-factory.c @@ -28,6 +28,8 @@ #include #include +#include + #include "gdm-common.h" #include "gdm-manager.h" #include "gdm-display-factory.h" @@ -461,6 +463,9 @@ gdm_local_display_factory_sync_seats (GdmLocalDisplayFactory *factory) while (g_variant_iter_loop (&iter, "(&so)", &seat, NULL)) { gboolean is_initial; const char *session_type = NULL; + char *session_id = NULL; + char *id = NULL; + GdmDisplay *display; if (g_strcmp0 (seat, "seat0") == 0) { is_initial = TRUE; @@ -470,7 +475,16 @@ gdm_local_display_factory_sync_seats (GdmLocalDisplayFactory *factory) is_initial = FALSE; } - create_display (factory, seat, session_type, is_initial); + display = create_display (factory, seat, session_type, is_initial); + /* + * If the seat has no active session, start a transient display + * to allow the user to choose one. + */ + if (!display && sd_seat_get_active (seat, &session_id, NULL) == -ENODATA) { + gdm_local_display_factory_create_transient_display (factory, &id, &error); + g_clear_error (&error); + g_free (id); + } } g_variant_unref (result);