summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-11-27 13:49:41 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2014-11-27 13:49:41 +0100
commit342f3005f57fe293d3b43148f8c900f2cbc6f7f7 (patch)
tree7f774372be2c8a0cec95336d1b53dcff4427d180 /src/libsystemd
parent0213a26f656d72ac83eb201f2104726fcfe60eaa (diff)
bus: prefix custom endpoints with "$UID-"
The kdbus module will later get a policy that endpoint-names are restricted to "<uid>-<name>" just like bus-names. Make sure that systemd is already compatible to that.
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 2beaa892bc..651ca4726e 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -1534,25 +1534,25 @@ int bus_kernel_create_endpoint(const char *bus_name, const char *ep_name, char *
_cleanup_free_ char *path = NULL;
struct kdbus_cmd_make *make;
struct kdbus_item *n;
- size_t size;
+ const char *name;
int fd;
fd = bus_kernel_open_bus_fd(bus_name, &path);
if (fd < 0)
return fd;
- size = ALIGN8(offsetof(struct kdbus_cmd_make, items));
- size += ALIGN8(offsetof(struct kdbus_item, str) + strlen(ep_name) + 1);
-
- make = alloca0_align(size, 8);
- make->size = size;
+ make = alloca0_align(ALIGN8(offsetof(struct kdbus_cmd_make, items)) +
+ ALIGN8(offsetof(struct kdbus_item, str) + DECIMAL_STR_MAX(uid_t) + 1 + strlen(ep_name) + 1),
+ 8);
+ make->size = ALIGN8(offsetof(struct kdbus_cmd_make, items));
make->flags = KDBUS_MAKE_ACCESS_WORLD;
n = make->items;
-
+ sprintf(n->str, UID_FMT "-%s", getuid(), ep_name);
+ n->size = offsetof(struct kdbus_item, str) + strlen(n->str) + 1;
n->type = KDBUS_ITEM_MAKE_NAME;
- n->size = offsetof(struct kdbus_item, str) + strlen(ep_name) + 1;
- strcpy(n->str, ep_name);
+ make->size += ALIGN8(n->size);
+ name = n->str;
if (ioctl(fd, KDBUS_CMD_ENDPOINT_MAKE, make) < 0) {
safe_close(fd);
@@ -1562,7 +1562,7 @@ int bus_kernel_create_endpoint(const char *bus_name, const char *ep_name, char *
if (ep_path) {
char *p;
- p = strjoin(dirname(path), "/", ep_name, NULL);
+ p = strjoin(dirname(path), "/", name, NULL);
if (!p) {
safe_close(fd);
return -ENOMEM;