gdm/SOURCES/0019-local-display-factory-don-t-jump-to-failed-display.patch
2021-09-09 17:04:10 +00:00

169 lines
6.4 KiB
Diff

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