Blame SOURCES/0027-manager-start-initial-setup-right-away.patch

c90517
From 0eada264dbce111730a8859152a7821a9df9c692 Mon Sep 17 00:00:00 2001
c90517
From: Ray Strode <rstrode@redhat.com>
c90517
Date: Fri, 31 Aug 2018 14:33:58 -0400
c90517
Subject: [PATCH 27/48] manager: start initial setup right away
c90517
c90517
We no longer restart the greeter as soon as it dies, since we
c90517
start the greeter on demand.  This means, we no longer need to
c90517
defer starting initial setup until after the greeter respawns.
c90517
c90517
Furthermore, it doesn't work anymore since it relied on the
c90517
respawn to trigger.
c90517
c90517
This commit removes that code and scaffolding and just starts
c90517
initial setup directly.
c90517
c90517
https://gitlab.gnome.org/GNOME/gdm/issues/415
c90517
---
c90517
 daemon/gdm-manager.c | 66 +-------------------------------------------
c90517
 1 file changed, 1 insertion(+), 65 deletions(-)
c90517
c90517
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
c90517
index c8197a043..fb7b1ec4b 100644
c90517
--- a/daemon/gdm-manager.c
c90517
+++ b/daemon/gdm-manager.c
c90517
@@ -62,62 +62,60 @@
c90517
 #define GDM_MANAGER_DISPLAYS_PATH GDM_DBUS_PATH "/Displays"
c90517
 
c90517
 #define INITIAL_SETUP_USERNAME "gnome-initial-setup"
c90517
 
c90517
 typedef struct
c90517
 {
c90517
         GdmManager *manager;
c90517
         GdmSession *session;
c90517
         char *service_name;
c90517
         guint idle_id;
c90517
 } StartUserSessionOperation;
c90517
 
c90517
 struct GdmManagerPrivate
c90517
 {
c90517
         GdmDisplayStore        *display_store;
c90517
         GdmLocalDisplayFactory *local_factory;
c90517
 #ifdef HAVE_LIBXDMCP
c90517
         GdmXdmcpDisplayFactory *xdmcp_factory;
c90517
 #endif
c90517
         GList                  *user_sessions;
c90517
         GHashTable             *transient_sessions;
c90517
         GHashTable             *open_reauthentication_requests;
c90517
         gboolean                xdmcp_enabled;
c90517
 
c90517
         gboolean                started;
c90517
         gboolean                show_local_greeter;
c90517
 
c90517
         GDBusConnection          *connection;
c90517
         GDBusObjectManagerServer *object_manager;
c90517
 
c90517
-        StartUserSessionOperation *initial_login_operation;
c90517
-
c90517
 #ifdef  WITH_PLYMOUTH
c90517
         guint                     plymouth_is_running : 1;
c90517
 #endif
c90517
         guint                     ran_once : 1;
c90517
 };
c90517
 
c90517
 enum {
c90517
         PROP_0,
c90517
         PROP_XDMCP_ENABLED,
c90517
         PROP_SHOW_LOCAL_GREETER
c90517
 };
c90517
 
c90517
 enum {
c90517
         DISPLAY_ADDED,
c90517
         DISPLAY_REMOVED,
c90517
         LAST_SIGNAL
c90517
 };
c90517
 
c90517
 typedef enum {
c90517
         SESSION_RECORD_LOGIN,
c90517
         SESSION_RECORD_LOGOUT,
c90517
         SESSION_RECORD_FAILED,
c90517
 } SessionRecord;
c90517
 
c90517
 static guint signals [LAST_SIGNAL] = { 0, };
c90517
 
c90517
 static void     gdm_manager_class_init  (GdmManagerClass *klass);
c90517
 static void     gdm_manager_init        (GdmManager      *manager);
c90517
 static void     gdm_manager_dispose     (GObject         *object);
c90517
 
c90517
@@ -1286,96 +1284,60 @@ get_automatic_login_details (GdmManager *manager,
c90517
         if (res && enabled) {
c90517
             res = gdm_settings_direct_get_string (GDM_KEY_AUTO_LOGIN_USER, &username);
c90517
         }
c90517
 
c90517
         if (enabled && res && username != NULL && username[0] != '\0') {
c90517
                 goto out;
c90517
         }
c90517
 
c90517
         g_free (username);
c90517
         username = NULL;
c90517
         enabled = FALSE;
c90517
 
c90517
  out:
c90517
         if (enabled) {
c90517
                 g_debug ("GdmDisplay: Got automatic login details for display: %d %s",
c90517
                          enabled,
c90517
                          username);
c90517
         } else {
c90517
                 g_debug ("GdmDisplay: Got automatic login details for display: 0");
c90517
         }
c90517
 
c90517
         if (usernamep != NULL) {
c90517
                 *usernamep = username;
c90517
         } else {
c90517
                 g_free (username);
c90517
         }
c90517
 
c90517
         return enabled;
c90517
 }
c90517
 
c90517
-static void
c90517
-maybe_start_pending_initial_login (GdmManager *manager,
c90517
-                                   GdmDisplay *greeter_display)
c90517
-{
c90517
-        StartUserSessionOperation *operation;
c90517
-        char *greeter_seat_id = NULL;
c90517
-        char *user_session_seat_id = NULL;
c90517
-
c90517
-        /* There may be a user session waiting to be started.
c90517
-         * This would happen if we couldn't start it earlier because
c90517
-         * the login screen X server was coming up and two X servers
c90517
-         * can't be started on the same seat at the same time.
c90517
-         */
c90517
-
c90517
-        if (manager->priv->initial_login_operation == NULL) {
c90517
-                return;
c90517
-        }
c90517
-
c90517
-        operation = manager->priv->initial_login_operation;
c90517
-
c90517
-        g_object_get (G_OBJECT (greeter_display),
c90517
-                      "seat-id", &greeter_seat_id,
c90517
-                      NULL);
c90517
-        g_object_get (G_OBJECT (operation->session),
c90517
-                      "display-seat-id", &user_session_seat_id,
c90517
-                      NULL);
c90517
-
c90517
-        if (g_strcmp0 (greeter_seat_id, user_session_seat_id) == 0) {
c90517
-                start_user_session (manager, operation);
c90517
-                manager->priv->initial_login_operation = NULL;
c90517
-        }
c90517
-
c90517
-        g_free (greeter_seat_id);
c90517
-        g_free (user_session_seat_id);
c90517
-}
c90517
-
c90517
 static const char *
c90517
 get_username_for_greeter_display (GdmManager *manager,
c90517
                                   GdmDisplay *display)
c90517
 {
c90517
         gboolean doing_initial_setup = FALSE;
c90517
 
c90517
         g_object_get (G_OBJECT (display),
c90517
                       "doing-initial-setup", &doing_initial_setup,
c90517
                       NULL);
c90517
 
c90517
         if (doing_initial_setup) {
c90517
                 return INITIAL_SETUP_USERNAME;
c90517
         } else {
c90517
                 return GDM_USERNAME;
c90517
         }
c90517
 }
c90517
 
c90517
 static void
c90517
 set_up_automatic_login_session (GdmManager *manager,
c90517
                                 GdmDisplay *display)
c90517
 {
c90517
         GdmSession *session;
c90517
         char       *display_session_type = NULL;
c90517
         gboolean is_initial;
c90517
 
c90517
         /* 0 is root user; since the daemon talks to the session object
c90517
          * directly, itself, for automatic login
c90517
          */
c90517
         session = create_user_session_for_display (manager, display, 0);
c90517
 
c90517
@@ -1498,131 +1460,115 @@ set_up_session (GdmManager *manager,
c90517
                         return;
c90517
                 }
c90517
 #endif
c90517
 
c90517
                 set_up_greeter_session (manager, display);
c90517
                 return;
c90517
         }
c90517
 
c90517
         /* Check whether the user really exists before committing to autologin. */
c90517
         user_manager = act_user_manager_get_default ();
c90517
         user = act_user_manager_get_user (user_manager, username);
c90517
         g_object_get (user_manager, "is-loaded", &loaded, NULL);
c90517
 
c90517
         if (loaded) {
c90517
                 set_up_automatic_login_session_if_user_exists (manager, display, user);
c90517
         } else {
c90517
                 UsernameLookupOperation *operation;
c90517
 
c90517
                 operation = g_new (UsernameLookupOperation, 1);
c90517
                 operation->manager = g_object_ref (manager);
c90517
                 operation->display = g_object_ref (display);
c90517
                 operation->username = username;
c90517
 
c90517
                 g_signal_connect (user,
c90517
                                   "notify::is-loaded",
c90517
                                   G_CALLBACK (on_user_is_loaded_changed),
c90517
                                   operation);
c90517
         }
c90517
 }
c90517
 
c90517
-static void
c90517
-greeter_display_started (GdmManager *manager,
c90517
-                         GdmDisplay *display)
c90517
-{
c90517
-        if (manager->priv->ran_once) {
c90517
-                return;
c90517
-        }
c90517
-
c90517
-        maybe_start_pending_initial_login (manager, display);
c90517
-}
c90517
-
c90517
 static void
c90517
 on_display_status_changed (GdmDisplay *display,
c90517
                            GParamSpec *arg1,
c90517
                            GdmManager *manager)
c90517
 {
c90517
         int         status;
c90517
         int         display_number = -1;
c90517
         char       *session_type = NULL;
c90517
 #ifdef WITH_PLYMOUTH
c90517
         gboolean    display_is_local = FALSE;
c90517
         gboolean    doing_initial_setup = FALSE;
c90517
         gboolean    quit_plymouth = FALSE;
c90517
 
c90517
         g_object_get (display,
c90517
                       "is-local", &display_is_local,
c90517
                       "doing-initial-setup", &doing_initial_setup,
c90517
                       NULL);
c90517
         quit_plymouth = display_is_local && manager->priv->plymouth_is_running;
c90517
 #endif
c90517
 
c90517
         g_object_get (display,
c90517
                       "x11-display-number", &display_number,
c90517
                       "session-type", &session_type,
c90517
                       NULL);
c90517
 
c90517
         status = gdm_display_get_status (display);
c90517
 
c90517
         switch (status) {
c90517
                 case GDM_DISPLAY_PREPARED:
c90517
                 case GDM_DISPLAY_MANAGED:
c90517
                         if ((display_number == -1 && status == GDM_DISPLAY_PREPARED) ||
c90517
                             (display_number != -1 && status == GDM_DISPLAY_MANAGED)) {
c90517
                                 char *session_class;
c90517
 
c90517
                                 g_object_get (display,
c90517
                                               "session-class", &session_class,
c90517
                                               NULL);
c90517
                                 if (g_strcmp0 (session_class, "greeter") == 0)
c90517
                                         set_up_session (manager, display);
c90517
                                 g_free (session_class);
c90517
                         }
c90517
-
c90517
-                        if (status == GDM_DISPLAY_MANAGED) {
c90517
-                                greeter_display_started (manager, display);
c90517
-                        }
c90517
                         break;
c90517
                 case GDM_DISPLAY_FAILED:
c90517
                 case GDM_DISPLAY_UNMANAGED:
c90517
                 case GDM_DISPLAY_FINISHED:
c90517
 #ifdef WITH_PLYMOUTH
c90517
                         if (quit_plymouth) {
c90517
                                 plymouth_quit_without_transition ();
c90517
                                 manager->priv->plymouth_is_running = FALSE;
c90517
                         }
c90517
 #endif
c90517
 
c90517
                         if (!doing_initial_setup && (status == GDM_DISPLAY_FINISHED || g_strcmp0 (session_type, "x11") == 0)) {
c90517
                                 manager->priv->ran_once = TRUE;
c90517
                         }
c90517
-                        maybe_start_pending_initial_login (manager, display);
c90517
                         break;
c90517
                 default:
c90517
                         break;
c90517
         }
c90517
 
c90517
 }
c90517
 
c90517
 static void
c90517
 on_display_removed (GdmDisplayStore *display_store,
c90517
                     GdmDisplay      *display,
c90517
                     GdmManager      *manager)
c90517
 {
c90517
         char    *id;
c90517
 
c90517
         gdm_display_get_id (display, &id, NULL);
c90517
         g_dbus_object_manager_server_unexport (manager->priv->object_manager, id);
c90517
         g_free (id);
c90517
 
c90517
         g_signal_handlers_disconnect_by_func (display, G_CALLBACK (on_display_status_changed), manager);
c90517
 
c90517
         g_signal_emit (manager, signals[DISPLAY_REMOVED], 0, display);
c90517
 }
c90517
 
c90517
 static void
c90517
 destroy_start_user_session_operation (StartUserSessionOperation *operation)
c90517
 {
c90517
         g_object_set_data (G_OBJECT (operation->session),
c90517
                            "start-user-session-operation",
c90517
                            NULL);
c90517
         g_object_unref (operation->session);
c90517
@@ -1723,97 +1669,87 @@ on_start_user_session (StartUserSessionOperation *operation)
c90517
                 gdm_session_reset (operation->session);
c90517
                 destroy_start_user_session_operation (operation);
c90517
                 goto out;
c90517
         }
c90517
 
c90517
         display = get_display_for_user_session (operation->session);
c90517
 
c90517
         g_object_get (G_OBJECT (display), "doing-initial-setup", &doing_initial_setup, NULL);
c90517
 
c90517
         session_id = gdm_session_get_conversation_session_id (operation->session,
c90517
                                                               operation->service_name);
c90517
 
c90517
         if (gdm_session_get_display_mode (operation->session) == GDM_SESSION_DISPLAY_MODE_REUSE_VT) {
c90517
                 /* In this case, the greeter's display is morphing into
c90517
                  * the user session display. Kill the greeter on this session
c90517
                  * and let the user session follow the same display. */
c90517
                 gdm_display_stop_greeter_session (display);
c90517
                 g_object_set (G_OBJECT (display),
c90517
                                 "session-class", "user",
c90517
                                 "session-id", session_id,
c90517
                                 NULL);
c90517
         } else {
c90517
                 uid_t allowed_uid;
c90517
 
c90517
                 g_object_ref (display);
c90517
                 if (doing_initial_setup) {
c90517
                         g_debug ("GdmManager: closing down initial setup display");
c90517
                         gdm_display_stop_greeter_session (display);
c90517
                         gdm_display_unmanage (display);
c90517
                         gdm_display_finish (display);
c90517
-
c90517
-                        /* We can't start the user session until the finished display
c90517
-                         * starts to respawn (since starting an X server and bringing
c90517
-                         * one down at the same time is a no go)
c90517
-                         */
c90517
-                        g_assert (self->priv->initial_login_operation == NULL);
c90517
-                        self->priv->initial_login_operation = operation;
c90517
-                        starting_user_session_right_away = FALSE;
c90517
                 } else {
c90517
                         g_debug ("GdmManager: session has its display server, reusing our server for another login screen");
c90517
                 }
c90517
 
c90517
                 /* The user session is going to follow the session worker
c90517
                  * into the new display. Untie it from this display and
c90517
                  * create a new session for a future user login. */
c90517
                 allowed_uid = gdm_session_get_allowed_user (operation->session);
c90517
                 g_object_set_data (G_OBJECT (display), "gdm-user-session", NULL);
c90517
                 g_object_set_data (G_OBJECT (operation->session), "gdm-display", NULL);
c90517
                 create_user_session_for_display (operation->manager, display, allowed_uid);
c90517
 
c90517
                 if ((g_strcmp0 (operation->service_name, "gdm-autologin") == 0) &&
c90517
                     !gdm_session_client_is_connected (operation->session)) {
c90517
                         /* remove the unused prepared greeter display since we're not going
c90517
                          * to have a greeter */
c90517
                         gdm_display_store_remove (self->priv->display_store, display);
c90517
                         g_object_unref (display);
c90517
                 }
c90517
 
c90517
                 /* Give the user session a new display object for bookkeeping purposes */
c90517
                 create_display_for_user_session (operation->manager,
c90517
                                                  operation->session,
c90517
                                                  session_id);
c90517
         }
c90517
 
c90517
-        if (starting_user_session_right_away) {
c90517
-                start_user_session (operation->manager, operation);
c90517
-        }
c90517
+        start_user_session (operation->manager, operation);
c90517
 
c90517
  out:
c90517
         return G_SOURCE_REMOVE;
c90517
 }
c90517
 
c90517
 static void
c90517
 queue_start_user_session (GdmManager *manager,
c90517
                           GdmSession *session,
c90517
                           const char *service_name)
c90517
 {
c90517
         StartUserSessionOperation *operation;
c90517
 
c90517
         operation = g_slice_new0 (StartUserSessionOperation);
c90517
         operation->manager = manager;
c90517
         operation->session = g_object_ref (session);
c90517
         operation->service_name = g_strdup (service_name);
c90517
 
c90517
         operation->idle_id = g_idle_add ((GSourceFunc) on_start_user_session, operation);
c90517
         g_object_set_data (G_OBJECT (session), "start-user-session-operation", operation);
c90517
 }
c90517
 
c90517
 static void
c90517
 start_user_session_if_ready (GdmManager *manager,
c90517
                              GdmSession *session,
c90517
                              const char *service_name)
c90517
 {
c90517
         gboolean start_when_ready;
c90517
 
c90517
         start_when_ready = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (session), "start-when-ready"));
c90517
         if (start_when_ready) {
c90517
-- 
c90517
2.26.0
c90517