core: refuse accepting a scope controller unless we are called on the API bus
authorLennart Poettering <lennart@poettering.net>
Thu, 23 Nov 2017 19:02:00 +0000 (20:02 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 23 Nov 2017 20:47:48 +0000 (21:47 +0100)
Let's make sure clients get early errors if they try something weird.

src/core/dbus-scope.c

index 2d5baab..46222ef 100644 (file)
@@ -119,6 +119,11 @@ static int bus_scope_set_transient_property(
                 const char *controller;
                 char *c;
 
+                /* We can't support direct connections with this, as direct connections know no service or unique name
+                 * concept, but the Controller field stores exactly that. */
+                if (sd_bus_message_get_bus(message) != UNIT(s)->manager->api_bus)
+                        return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Sorry, Controller= logic only supported via the bus.");
+
                 r = sd_bus_message_read(message, "s", &controller);
                 if (r < 0)
                         return r;