chiark / gitweb /
trivial coding style clean ups
[elogind.git] / src / libsystemd-bus / bus-objects.c
index 7c8a774e73f7cd8ed46936f09e6bf2c3da91eed9..7cd34c991b004f389c06656e37d1e9eca20fb251 100644 (file)
@@ -135,6 +135,8 @@ static int add_enumerated_to_set(
                         }
 
                         r = set_consume(s, *k);
+                        if (r == -EEXIST)
+                                r = 0;
                 }
 
                 free(children);
@@ -310,6 +312,11 @@ static int method_callbacks_run(
                                 "Invalid arguments '%s' to call %s.%s(), expecting '%s'.",
                                 signature, c->interface, c->member, strempty(c->vtable->x.method.signature));
 
+        /* Keep track what the signature of the reply to this message
+         * should be, so that this can be enforced when sealing the
+         * reply. */
+        m->enforced_reply_signature = strempty(c->vtable->x.method.result);
+
         if (c->vtable->x.method.handler) {
                 r = c->vtable->x.method.handler(bus, m, u, &error);
                 return bus_maybe_reply_error(m, r, &error);
@@ -1120,7 +1127,7 @@ static int object_find_and_run(
 
                         r = sd_bus_message_read(m, "ss", &vtable_key.interface, &vtable_key.member);
                         if (r < 0)
-                                return r;
+                                return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Expected interface and member parameters");
 
                         v = hashmap_get(bus->vtable_properties, &vtable_key);
                         if (v) {
@@ -1138,7 +1145,7 @@ static int object_find_and_run(
 
                         r = sd_bus_message_read(m, "s", &iface);
                         if (r < 0)
-                                return r;
+                                return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Expected interface parameter");
 
                         if (iface[0] == 0)
                                 iface = NULL;
@@ -1150,12 +1157,18 @@ static int object_find_and_run(
 
         } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
 
+                if (!isempty(sd_bus_message_get_signature(m, true)))
+                        return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Expected no parameters");
+
                 r = process_introspect(bus, m, n, require_fallback, found_object);
                 if (r != 0)
                         return r;
 
         } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus.ObjectManager", "GetManagedObjects")) {
 
+                if (!isempty(sd_bus_message_get_signature(m, true)))
+                        return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_INVALID_ARGS, "Expected no parameters");
+
                 r = process_get_managed_objects(bus, m, n, require_fallback, found_object);
                 if (r != 0)
                         return r;