diff options
Diffstat (limited to 'src/libsystemd-bus/bus-kernel.c')
-rw-r--r-- | src/libsystemd-bus/bus-kernel.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c index 2bb1b9a19a..5172b32113 100644 --- a/src/libsystemd-bus/bus-kernel.c +++ b/src/libsystemd-bus/bus-kernel.c @@ -540,6 +540,7 @@ int bus_kernel_read_message(sd_bus *bus, sd_bus_message **m) { int bus_kernel_create(const char *name, char **s) { struct kdbus_cmd_bus_make *make; + struct kdbus_cmd_make_item *n, *cg; size_t l; int fd; char *p; @@ -552,16 +553,27 @@ int bus_kernel_create(const char *name, char **s) { return -errno; l = strlen(name); - make = alloca0(offsetof(struct kdbus_cmd_bus_make, name) + DECIMAL_STR_MAX(uid_t) + 1 + l + 1); - sprintf(make->name, "%lu-%s", (unsigned long) getuid(), name); - make->size = offsetof(struct kdbus_cmd_bus_make, name) + strlen(make->name) + 1; + make = alloca0(offsetof(struct kdbus_cmd_bus_make, items) + + sizeof(struct kdbus_cmd_make_item) + sizeof(uint64_t) + + sizeof(struct kdbus_cmd_make_item) + DECIMAL_STR_MAX(uid_t) + 1 + l + 1); + + cg = make->items; + cg->type = KDBUS_CMD_MAKE_CGROUP; + cg->data64[0] = 1; + cg->size = sizeof(struct kdbus_cmd_make_item) + sizeof(uint64_t); + + n = KDBUS_ITEM_NEXT(cg); + n->type = KDBUS_CMD_MAKE_NAME; + sprintf(n->str, "%lu-%s", (unsigned long) getuid(), name); + n->size = sizeof(struct kdbus_cmd_make_item) + strlen(n->str) + 1; + + make->size = offsetof(struct kdbus_cmd_bus_make, items) + cg->size + n->size; make->flags = KDBUS_ACCESS_WORLD | KDBUS_POLICY_OPEN; make->bus_flags = 0; make->bloom_size = BLOOM_SIZE; - make->cgroup_id = 1; assert_cc(BLOOM_SIZE % 8 == 0); - p = strjoin("/dev/kdbus/", make->name, "/bus", NULL); + p = strjoin("/dev/kdbus/", n->str, "/bus", NULL); if (!p) return -ENOMEM; |