Blame SOURCES/0019-local-display-factory-don-t-jump-to-failed-display.patch

400dab
From fe680d77cff9272843cb171c7e590c239f7afe5a Mon Sep 17 00:00:00 2001
400dab
From: Ray Strode <rstrode@redhat.com>
400dab
Date: Thu, 9 Aug 2018 12:32:31 -0400
400dab
Subject: [PATCH 19/51] local-display-factory: don't jump to failed display
400dab
400dab
Since commit 5e737a57 `create_display` will jump to any
400dab
already running login screen if it can find one.
400dab
400dab
Right now if a display fails we call `create_display` to
400dab
create a new one.  It will look for any already running
400dab
login screen and find the recently failed display.
400dab
400dab
This commit make sure we never jump to a display that isn't
400dab
in good working order.
400dab
---
400dab
 daemon/gdm-local-display-factory.c | 19 +++++++++++++++----
400dab
 1 file changed, 15 insertions(+), 4 deletions(-)
400dab
400dab
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
400dab
index 9f377ba9a..c58de9c17 100644
400dab
--- a/daemon/gdm-local-display-factory.c
400dab
+++ b/daemon/gdm-local-display-factory.c
400dab
@@ -60,60 +60,63 @@ struct GdmLocalDisplayFactoryPrivate
400dab
         guint            num_failures;
400dab
 
400dab
         guint            seat_new_id;
400dab
         guint            seat_removed_id;
400dab
 
400dab
 #if defined(ENABLE_WAYLAND_SUPPORT) && defined(ENABLE_USER_DISPLAY_SERVER)
400dab
         char            *tty_of_active_vt;
400dab
         guint            active_vt_watch_id;
400dab
 #endif
400dab
 };
400dab
 
400dab
 enum {
400dab
         PROP_0,
400dab
 };
400dab
 
400dab
 static void     gdm_local_display_factory_class_init    (GdmLocalDisplayFactoryClass *klass);
400dab
 static void     gdm_local_display_factory_init          (GdmLocalDisplayFactory      *factory);
400dab
 static void     gdm_local_display_factory_finalize      (GObject                     *object);
400dab
 
400dab
 static GdmDisplay *create_display                       (GdmLocalDisplayFactory      *factory,
400dab
                                                          const char                  *seat_id,
400dab
                                                          const char                  *session_type,
400dab
                                                          gboolean                    initial_display);
400dab
 
400dab
 static void     on_display_status_changed               (GdmDisplay                  *display,
400dab
                                                          GParamSpec                  *arg1,
400dab
                                                          GdmLocalDisplayFactory      *factory);
400dab
 
400dab
 static gboolean gdm_local_display_factory_sync_seats    (GdmLocalDisplayFactory *factory);
400dab
 static gpointer local_display_factory_object = NULL;
400dab
+static gboolean lookup_by_session_id (const char *id,
400dab
+                                      GdmDisplay *display,
400dab
+                                      gpointer    user_data);
400dab
 
400dab
 G_DEFINE_TYPE (GdmLocalDisplayFactory, gdm_local_display_factory, GDM_TYPE_DISPLAY_FACTORY)
400dab
 
400dab
 GQuark
400dab
 gdm_local_display_factory_error_quark (void)
400dab
 {
400dab
         static GQuark ret = 0;
400dab
         if (ret == 0) {
400dab
                 ret = g_quark_from_static_string ("gdm_local_display_factory_error");
400dab
         }
400dab
 
400dab
         return ret;
400dab
 }
400dab
 
400dab
 static void
400dab
 listify_hash (gpointer    key,
400dab
               GdmDisplay *display,
400dab
               GList     **list)
400dab
 {
400dab
         *list = g_list_prepend (*list, key);
400dab
 }
400dab
 
400dab
 static int
400dab
 sort_nums (gpointer a,
400dab
            gpointer b)
400dab
 {
400dab
         guint32 num_a;
400dab
         guint32 num_b;
400dab
 
400dab
         num_a = GPOINTER_TO_UINT (a);
400dab
@@ -370,66 +373,74 @@ lookup_by_seat_id (const char *id,
400dab
 
400dab
         g_object_get (G_OBJECT (display), "seat-id", &current, NULL);
400dab
 
400dab
         res = g_strcmp0 (current, looking_for) == 0;
400dab
 
400dab
         g_free(current);
400dab
 
400dab
         return res;
400dab
 }
400dab
 
400dab
 static GdmDisplay *
400dab
 create_display (GdmLocalDisplayFactory *factory,
400dab
                 const char             *seat_id,
400dab
                 const char             *session_type,
400dab
                 gboolean                initial)
400dab
 {
400dab
         GdmDisplayStore *store;
400dab
         GdmDisplay      *display = NULL;
400dab
         char            *active_session_id = NULL;
400dab
         int              ret;
400dab
 
400dab
         store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
400dab
 
400dab
         ret = sd_seat_get_active (seat_id, &active_session_id, NULL);
400dab
 
400dab
         if (ret == 0) {
400dab
                 char *login_session_id = NULL;
400dab
 
400dab
                 /* If we already have a login window, switch to it */
400dab
                 if (gdm_get_login_window_session_id (seat_id, &login_session_id)) {
400dab
-                        if (g_strcmp0 (active_session_id, login_session_id) != 0) {
400dab
-                                gdm_activate_session_by_id (factory->priv->connection, seat_id, login_session_id);
400dab
+                        GdmDisplay *display;
400dab
+
400dab
+                        display = gdm_display_store_find (store,
400dab
+                                                          lookup_by_session_id,
400dab
+                                                          (gpointer) login_session_id);
400dab
+                        if (display != NULL && gdm_display_get_status (display) == GDM_DISPLAY_MANAGED) {
400dab
+                                if (g_strcmp0 (active_session_id, login_session_id) != 0) {
400dab
+                                        gdm_activate_session_by_id (factory->priv->connection, seat_id, login_session_id);
400dab
+                                }
400dab
+                                g_clear_pointer (&login_session_id, g_free);
400dab
+                                g_clear_pointer (&active_session_id, g_free);
400dab
+                                return NULL;
400dab
                         }
400dab
                         g_clear_pointer (&login_session_id, g_free);
400dab
-                        g_clear_pointer (&active_session_id, g_free);
400dab
-                        return NULL;
400dab
                 }
400dab
                 g_clear_pointer (&active_session_id, g_free);
400dab
         } else if (!sd_seat_can_multi_session (seat_id)) {
400dab
                 /* Ensure we don't create the same display more than once */
400dab
                 display = gdm_display_store_find (store, lookup_by_seat_id, (gpointer) seat_id);
400dab
 
400dab
                 if (display != NULL) {
400dab
                         return NULL;
400dab
                 }
400dab
         }
400dab
 
400dab
         g_debug ("GdmLocalDisplayFactory: Adding display on seat %s", seat_id);
400dab
 
400dab
 #ifdef ENABLE_USER_DISPLAY_SERVER
400dab
         if (g_strcmp0 (seat_id, "seat0") == 0) {
400dab
                 display = gdm_local_display_new ();
400dab
                 if (session_type != NULL) {
400dab
                         g_object_set (G_OBJECT (display), "session-type", session_type, NULL);
400dab
                 }
400dab
         }
400dab
 #endif
400dab
 
400dab
         if (display == NULL) {
400dab
                 guint32 num;
400dab
 
400dab
                 num = take_next_display_number (factory);
400dab
 
400dab
                 display = gdm_legacy_display_new (num);
400dab
         }
400dab
 
400dab
-- 
400dab
2.27.0
400dab