Blob Blame History Raw
From 4b2db2cf52be75e2eec4aa29f8ee082392ded410 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Thu, 1 Nov 2018 13:03:37 -0400
Subject: [PATCH] manager: ensure is-initial is transfered to autologin display

At the moment, we don't handle transferring the is-initial property to
the autologin display.

That prevents autologin from working if wayland fails and X falls back,
since autologin currently requires an initial display.

This commit makes sure we properly transfer is-initial from greeter to
user display.
---
 daemon/gdm-manager.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
index 1943d89e4..2118c5834 100644
--- a/daemon/gdm-manager.c
+++ b/daemon/gdm-manager.c
@@ -1740,90 +1740,93 @@ start_user_session (GdmManager *manager,
 
                 g_object_get (G_OBJECT (display), "is-connected", &is_connected, NULL);
 
                 if (is_connected) {
                         auth_file = NULL;
                         username = gdm_session_get_username (operation->session);
                         gdm_display_add_user_authorization (display,
                                                             username,
                                                             &auth_file,
                                                             NULL);
 
                         g_assert (auth_file != NULL);
 
                         g_object_set (operation->session,
                                       "user-x11-authority-file", auth_file,
                                       NULL);
 
                         g_free (auth_file);
                 }
         }
 
         gdm_session_start_session (operation->session,
                                    operation->service_name);
 
         destroy_start_user_session_operation (operation);
 }
 
 static void
 create_display_for_user_session (GdmManager *self,
                                  GdmSession *session,
-                                 const char *session_id)
+                                 const char *session_id,
+                                 gboolean    is_initial)
 {
         GdmDisplay *display;
         /* at the moment we only create GdmLocalDisplay objects on seat0 */
         const char *seat_id = "seat0";
 
         display = gdm_local_display_new ();
 
         g_object_set (G_OBJECT (display),
                       "session-class", "user",
                       "seat-id", seat_id,
                       "session-id", session_id,
+                      "is-initial", is_initial,
                       NULL);
         gdm_display_store_add (self->priv->display_store,
                                display);
         g_object_set_data (G_OBJECT (session), "gdm-display", display);
         g_object_set_data_full (G_OBJECT (display),
                                 "gdm-user-session",
                                 g_object_ref (session),
                                 (GDestroyNotify)
                                 clean_user_session);
 }
 
 static gboolean
 on_start_user_session (StartUserSessionOperation *operation)
 {
         GdmManager *self = operation->manager;
         gboolean migrated;
         gboolean fail_if_already_switched = TRUE;
         gboolean doing_initial_setup = FALSE;
+        gboolean should_be_initial = FALSE;
         gboolean starting_user_session_right_away = TRUE;
         GdmDisplay *display;
         const char *session_id;
 
         g_debug ("GdmManager: start or jump to session");
 
         /* If there's already a session running, jump to it.
          * If the only session running is the one we just opened,
          * start a session on it.
          */
         migrated = switch_to_compatible_user_session (operation->manager, operation->session, fail_if_already_switched);
 
         g_debug ("GdmManager: migrated: %d", migrated);
         if (migrated) {
                 /* We don't stop the manager here because
                    when Xorg exits it switches to the VT it was
                    started from.  That interferes with fast
                    user switching. */
                 gdm_session_reset (operation->session);
                 destroy_start_user_session_operation (operation);
                 goto out;
         }
 
         display = get_display_for_user_session (operation->session);
 
         g_object_get (G_OBJECT (display), "doing-initial-setup", &doing_initial_setup, NULL);
 
         session_id = gdm_session_get_conversation_session_id (operation->session,
                                                               operation->service_name);
 
@@ -1839,70 +1842,77 @@ on_start_user_session (StartUserSessionOperation *operation)
         } else {
                 uid_t allowed_uid;
 
                 g_object_ref (display);
                 if (doing_initial_setup) {
                         g_debug ("GdmManager: closing down initial setup display");
                         gdm_display_stop_greeter_session (display);
                         gdm_display_unmanage (display);
                         gdm_display_finish (display);
 
                         /* We can't start the user session until the finished display
                          * starts to respawn (since starting an X server and bringing
                          * one down at the same time is a no go)
                          */
                         g_assert (self->priv->initial_login_operation == NULL);
                         self->priv->initial_login_operation = operation;
                         starting_user_session_right_away = FALSE;
                 } else {
                         g_debug ("GdmManager: session has its display server, reusing our server for another login screen");
                 }
 
                 /* The user session is going to follow the session worker
                  * into the new display. Untie it from this display and
                  * create a new session for a future user login. */
                 allowed_uid = gdm_session_get_allowed_user (operation->session);
                 g_object_set_data (G_OBJECT (display), "gdm-user-session", NULL);
                 g_object_set_data (G_OBJECT (operation->session), "gdm-display", NULL);
                 create_user_session_for_display (operation->manager, display, allowed_uid);
 
                 if (g_strcmp0 (operation->service_name, "gdm-autologin") == 0) {
+                        gboolean was_initial = FALSE;
+
+                        g_object_get (G_OBJECT (display), "is-initial", &was_initial, NULL);
+
                         /* remove the unused prepared greeter display since we're not going
                          * to have a greeter */
                         gdm_display_store_remove (self->priv->display_store, display);
                         g_object_unref (display);
+
+                        should_be_initial = was_initial;
                 }
 
                 /* Give the user session a new display object for bookkeeping purposes */
                 create_display_for_user_session (operation->manager,
                                                  operation->session,
-                                                 session_id);
+                                                 session_id,
+                                                 should_be_initial);
         }
 
         if (starting_user_session_right_away) {
                 start_user_session (operation->manager, operation);
         }
 
  out:
         return G_SOURCE_REMOVE;
 }
 
 static void
 queue_start_user_session (GdmManager *manager,
                           GdmSession *session,
                           const char *service_name)
 {
         StartUserSessionOperation *operation;
 
         operation = g_slice_new0 (StartUserSessionOperation);
         operation->manager = manager;
         operation->session = g_object_ref (session);
         operation->service_name = g_strdup (service_name);
 
         operation->idle_id = g_idle_add ((GSourceFunc) on_start_user_session, operation);
         g_object_set_data (G_OBJECT (session), "start-user-session-operation", operation);
 }
 
 static void
 start_user_session_if_ready (GdmManager *manager,
                              GdmSession *session,
                              const char *service_name)
-- 
2.19.1