summaryrefslogtreecommitdiff
path: root/src/bus-driverd/bus-driverd.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-01-09 08:19:22 +0800
committerLennart Poettering <lennart@poettering.net>2014-01-09 08:19:22 +0800
commit5b590f97640546962b16b3b32684b3ee6b477f93 (patch)
tree09a3a7fa1709552e1d0385f379a7b8d4ad063fbf /src/bus-driverd/bus-driverd.c
parentdd9b67aa3e9476b3a4b3e231006eea6d108c841f (diff)
bus: make the bus driver support the driver interface under both / and /org/freedesktop/DBus
Some clients apparently use the "/" path instead of "/org/freedesktop/DBus". dbus-daemon didn't care, so we need to support both.
Diffstat (limited to 'src/bus-driverd/bus-driverd.c')
-rw-r--r--src/bus-driverd/bus-driverd.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/bus-driverd/bus-driverd.c b/src/bus-driverd/bus-driverd.c
index 0f792038c4..319596a40b 100644
--- a/src/bus-driverd/bus-driverd.c
+++ b/src/bus-driverd/bus-driverd.c
@@ -803,6 +803,45 @@ static const sd_bus_vtable driver_vtable[] = {
SD_BUS_VTABLE_END
};
+static int find_object(
+ sd_bus *bus,
+ const char *path,
+ const char *interface,
+ void *userdata,
+ void **ret_found,
+ sd_bus_error *ret_error) {
+
+ /* We support the driver interface on exactly two different
+ * paths: the root and the entry point object. This is a bit
+ * different from the original dbus-daemon which supported it
+ * on any path. */
+
+ if (streq_ptr(path, "/"))
+ return 1;
+
+ if (streq_ptr(path, "/org/freedesktop/DBus"))
+ return 1;
+
+ return 0;
+}
+
+static int node_enumerator(
+ sd_bus *bus,
+ const char *path,
+ void *userdata,
+ char ***ret_nodes,
+ sd_bus_error *ret_error) {
+
+ char **l;
+
+ l = strv_new("/", "/org/freedesktop/DBus", NULL);
+ if (!l)
+ return -ENOMEM;
+
+ *ret_nodes = l;
+ return 0;
+}
+
static int connect_bus(Context *c) {
int r;
@@ -823,12 +862,18 @@ static int connect_bus(Context *c) {
return -EPERM;
}
- r = sd_bus_add_object_vtable(c->bus, "/org/freedesktop/DBus", "org.freedesktop.DBus", driver_vtable, c);
+ r = sd_bus_add_fallback_vtable(c->bus, "/", "org.freedesktop.DBus", driver_vtable, find_object, c);
if (r < 0) {
log_error("Failed to add manager object vtable: %s", strerror(-r));
return r;
}
+ r = sd_bus_add_node_enumerator(c->bus, "/", node_enumerator, c);
+ if (r < 0) {
+ log_error("Failed to add node enumerator: %s", strerror(-r));
+ return r;
+ }
+
r = sd_bus_request_name(c->bus, "org.freedesktop.DBus", 0);
if (r < 0) {
log_error("Unable to request name: %s", strerror(-r));