From c0d987984fd709b4c1cf3cfdab08f813c7b119ee Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 26 Apr 2018 11:41:54 +0200 Subject: [PATCH] service-client: Refuse access without an agent To avoid races between clients and agents, make sure that an agent is required for each UID that wants its applications to be able to access location services. This will mean that desktop environments (and DIY ones) will need to have an agent running in the background to be able to ask authorisation questions. https://bugs.freedesktop.org/show_bug.cgi?id=106236 --- src/gclue-service-client.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/gclue-service-client.c b/src/gclue-service-client.c index 57e98d7..9873ad9 100644 --- a/src/gclue-service-client.c +++ b/src/gclue-service-client.c @@ -459,19 +459,19 @@ gclue_service_client_handle_start (GClueDBusClient *client, GCLUE_ACCURACY_LEVEL_COUNTRY, GCLUE_ACCURACY_LEVEL_EXACT); - /* No agent == No authorization needed */ - if (priv->agent_proxy == NULL || - gclue_config_is_system_component (config, desktop_id) || - app_perm == GCLUE_APP_PERM_ALLOWED) { - complete_start (data); - + /* No agent == No authorization */ + if (priv->agent_proxy == NULL) { + g_dbus_method_invocation_return_error (invocation, + G_DBUS_ERROR, + G_DBUS_ERROR_ACCESS_DENIED, + "'%s' disallowed, no agent " + "for UID %u", + desktop_id, + uid); return TRUE; } - if (priv->agent_proxy != NULL) - max_accuracy = gclue_agent_get_max_accuracy_level (priv->agent_proxy); - else - max_accuracy = GCLUE_ACCURACY_LEVEL_EXACT; + max_accuracy = gclue_agent_get_max_accuracy_level (priv->agent_proxy); if (max_accuracy == 0) { g_dbus_method_invocation_return_error (invocation, @@ -488,6 +488,13 @@ gclue_service_client_handle_start (GClueDBusClient *client, data->accuracy_level, max_accuracy); data->accuracy_level = CLAMP (data->accuracy_level, 0, max_accuracy); + if (gclue_config_is_system_component (config, desktop_id) || + app_perm == GCLUE_APP_PERM_ALLOWED) { + complete_start (data); + + return TRUE; + } + gclue_agent_call_authorize_app (priv->agent_proxy, desktop_id, data->accuracy_level, -- 2.14.3