From 1222ffdce0f175e32eb2d5cdd4c1f36232547442 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Sun, 11 Oct 2020 21:36:44 -0400 Subject: libgdm: Fetch connection synchronously There's a race condition in the client connection code at the moment, where a user verifier could be waiting for its connection when the login screen asks for a greeter synchronously. The greeter will then end up with a different connection that the user verifier which breaks expectations. This commit just makes the connection fetching code synchronous for now to side step the problem. --- libgdm/gdm-client.c | 94 +++++------------------------------------------------ 1 file changed, 9 insertions(+), 85 deletions(-) (limited to 'libgdm') diff --git a/libgdm/gdm-client.c b/libgdm/gdm-client.c index 2c7b8673..93817127 100644 --- a/libgdm/gdm-client.c +++ b/libgdm/gdm-client.c @@ -444,80 +444,6 @@ gdm_client_get_connection_sync (GdmClient *client, return connection; } -static void -on_connected (GObject *source_object, - GAsyncResult *result, - gpointer user_data) -{ - g_autoptr(GTask) task = user_data; - g_autoptr(GDBusConnection) connection = NULL; - g_autoptr(GError) error = NULL; - - connection = g_dbus_connection_new_for_address_finish (result, &error); - if (!connection) { - g_task_return_error (task, g_steal_pointer (&error)); - return; - } - - g_task_return_pointer (task, - g_steal_pointer (&connection), - (GDestroyNotify) g_object_unref); -} - -static void -on_session_opened (GdmManager *manager, - GAsyncResult *result, - gpointer user_data) -{ - GCancellable *cancellable; - g_autoptr(GTask) task = user_data; - g_autoptr(GdmClient) client = NULL; - g_autoptr(GError) error = NULL; - g_autofree char *address = NULL; - - client = GDM_CLIENT (g_async_result_get_source_object (G_ASYNC_RESULT (task))); - - if (!gdm_manager_call_open_session_finish (manager, - &address, - result, - &error)) { - g_task_return_error (task, g_steal_pointer (&error)); - return; - } - - cancellable = g_task_get_cancellable (task); - g_dbus_connection_new_for_address (address, - G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, - NULL, - cancellable, - on_connected, - g_steal_pointer (&task)); -} - -static void -on_got_manager_for_opening_connection (GdmClient *client, - GAsyncResult *result, - gpointer user_data) -{ - GCancellable *cancellable; - g_autoptr(GTask) task = user_data; - g_autoptr(GdmManager) manager = NULL; - g_autoptr(GError) error = NULL; - - manager = g_task_propagate_pointer (G_TASK (result), &error); - if (manager == NULL) { - g_task_return_error (task, g_steal_pointer (&error)); - return; - } - - cancellable = g_task_get_cancellable (task); - gdm_manager_call_open_session (manager, - cancellable, - (GAsyncReadyCallback) - on_session_opened, - g_steal_pointer (&task)); -} - static GDBusConnection * gdm_client_get_connection_finish (GdmClient *client, GAsyncResult *result, @@ -542,6 +468,7 @@ gdm_client_get_connection (GdmClient *client, gpointer user_data) { g_autoptr(GTask) task = NULL; + g_autoptr(GError) error = NULL; GDBusConnection *connection; g_return_if_fail (GDM_IS_CLIENT (client)); @@ -551,19 +478,16 @@ gdm_client_get_connection (GdmClient *client, callback, user_data); - connection = gdm_client_get_open_connection (client); + connection = gdm_client_get_connection_sync (client, + cancellable, + &error); if (connection != NULL) { - g_task_return_pointer (task, - g_object_ref (connection), - (GDestroyNotify) g_object_unref); - return; + g_task_return_pointer (task, + g_object_ref (connection), + (GDestroyNotify) g_object_unref); + } else { + g_task_return_error (task, g_steal_pointer (&error)); } - - get_manager (client, - cancellable, - (GAsyncReadyCallback) - on_got_manager_for_opening_connection, - g_steal_pointer (&task)); } /** -- cgit v1.2.1