[systemd-commits] src/libsystemd
David Herrmann
dvdhrm at kemper.freedesktop.org
Thu Nov 27 04:51:04 PST 2014
src/libsystemd/sd-bus/bus-kernel.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
New commits:
commit 342f3005f57fe293d3b43148f8c900f2cbc6f7f7
Author: David Herrmann <dh.herrmann at gmail.com>
Date: Thu Nov 27 13:49:41 2014 +0100
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.
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 2beaa89..651ca47 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;
More information about the systemd-commits
mailing list