chiark / gitweb /
bus: never report nodes as children that do not have the right prefix
[elogind.git] / src / libsystemd-bus / bus-objects.c
index 31d761e2154a98b18ef3e7432fb57b5481f15bc6..93bd3ad86c01dc1775ad90330c731ba7e03fe7c4 100644 (file)
@@ -114,12 +114,17 @@ static int add_enumerated_to_set(
                                 continue;
                         }
 
-                        if (!object_path_is_valid(*k) && object_path_startswith(*k, prefix)) {
+                        if (!object_path_is_valid(*k)){
                                 free(*k);
                                 r = -EINVAL;
                                 continue;
                         }
 
+                        if (!object_path_startswith(*k, prefix)) {
+                                free(*k);
+                                continue;
+                        }
+
                         r = set_consume(s, *k);
                 }
 
@@ -154,6 +159,9 @@ static int add_subtree_to_set(
         LIST_FOREACH(siblings, i, n->child) {
                 char *t;
 
+                if (!object_path_startswith(i->path, prefix))
+                        continue;
+
                 t = strdup(i->path);
                 if (!t)
                         return -ENOMEM;
@@ -312,7 +320,6 @@ static int invoke_property_get(
                 sd_bus_error *error,
                 void *userdata) {
 
-        int r;
         const void *p;
 
         assert(bus);
@@ -327,6 +334,9 @@ static int invoke_property_get(
 
         /* Automatic handling if no callback is defined. */
 
+        if (streq(v->x.property.signature, "as"))
+                return sd_bus_message_append_strv(m, *(char***) userdata);
+
         assert(signature_is_single(v->x.property.signature, false));
         assert(bus_type_is_basic(v->x.property.signature[0]));
 
@@ -347,11 +357,7 @@ static int invoke_property_get(
                 break;
         }
 
-        r = sd_bus_message_append_basic(m, v->x.property.signature[0], p);
-        if (r < 0)
-                return r;
-
-        return 1;
+        return sd_bus_message_append_basic(m, v->x.property.signature[0], p);
 }
 
 static int invoke_property_set(
@@ -585,7 +591,7 @@ static int property_get_all_callbacks_run(
 
         _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
         struct node_vtable *c;
-        bool found_interface = false;
+        bool found_interface;
         int r;
 
         assert(bus);
@@ -600,6 +606,11 @@ static int property_get_all_callbacks_run(
         if (r < 0)
                 return r;
 
+        found_interface = !iface ||
+                streq(iface, "org.freedesktop.DBus.Properties") ||
+                streq(iface, "org.freedesktop.DBus.Peer") ||
+                streq(iface, "org.freedesktop.DBus.Introspectable");
+
         LIST_FOREACH(vtables, c, first) {
                 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
                 void *u;
@@ -1582,7 +1593,7 @@ static int add_object_vtable_internal(
 
                         if (!member_name_is_valid(v->x.property.member) ||
                             !signature_is_single(v->x.property.signature, false) ||
-                            !(v->x.property.get || bus_type_is_basic(v->x.property.signature[0])) ||
+                            !(v->x.property.get || bus_type_is_basic(v->x.property.signature[0]) || streq(v->x.property.signature, "as")) ||
                             v->flags & SD_BUS_VTABLE_METHOD_NO_REPLY ||
                             (v->flags & SD_BUS_VTABLE_PROPERTY_INVALIDATE_ONLY && !(v->flags & SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE))) {
                                 r = -EINVAL;
@@ -1614,7 +1625,7 @@ static int add_object_vtable_internal(
                 case _SD_BUS_VTABLE_SIGNAL:
 
                         if (!member_name_is_valid(v->x.signal.member) ||
-                            !signature_is_single(strempty(v->x.signal.signature), false)) {
+                            !signature_is_valid(strempty(v->x.signal.signature), false)) {
                                 r = -EINVAL;
                                 goto fail;
                         }