[tracker/wip/carlosg/portal: 141/141] portal: Handle default object path in lookups



commit 95e01c91e37cf1c55bce7072b54de8b62c68ab9c
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Jan 25 14:26:12 2020 +0100

    portal: Handle default object path in lookups
    
    If the service URI we are asking permissions for has the default
    object path, ensure we look it up with it being implicitly defined.
    This allows the following policies to work the same:
    
    dbus:org.example.Endpoint=*
    dbus:org.example.Endpoint:/org/freedesktop/Tracker1/Endpoint=*

 src/portal/tracker-portal.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/src/portal/tracker-portal.c b/src/portal/tracker-portal.c
index 02098756c..6b76a4fcf 100644
--- a/src/portal/tracker-portal.c
+++ b/src/portal/tracker-portal.c
@@ -64,6 +64,7 @@ G_DEFINE_TYPE_WITH_CODE (TrackerPortal, tracker_portal, G_TYPE_OBJECT,
                          G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, tracker_portal_initable_iface_init))
 
 #define TRACKER_GROUP_NAME "Policy Tracker3"
+#define DEFAULT_URI_SUFFIX ":/org/freedesktop/Tracker1/Endpoint"
 
 static const gchar portal_xml[] =
        "<node>"
@@ -222,7 +223,22 @@ load_client_configuration (GDBusMethodInvocation  *invocation,
        graphs = g_key_file_get_string_list (flatpak_info,
                                             TRACKER_GROUP_NAME,
                                             service_uri,
-                                            NULL, error);
+                                            NULL, NULL);
+
+       if (!graphs && g_str_has_suffix (service_uri, DEFAULT_URI_SUFFIX)) {
+               gchar *default_service_uri;
+
+               default_service_uri = g_strndup (service_uri,
+                                                strlen (service_uri) -
+                                                strlen (DEFAULT_URI_SUFFIX));
+
+               graphs = g_key_file_get_string_list (flatpak_info,
+                                                    TRACKER_GROUP_NAME,
+                                                    default_service_uri,
+                                                    NULL, error);
+               g_free (default_service_uri);
+       }
+
        if (!graphs) {
                g_debug ("Service '%s' not found in Tracker policy", service_uri);
                return NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]