chiark / gitweb /
bus-kernel: when installing an activator, ask for any kind of metadata to be attached...
[elogind.git] / src / libsystemd / sd-bus / bus-kernel.c
index aa4b4240dcd0df052047f992f9a9c3c7ffa2cf1c..2bfce933e3877f0cca534d9efa1c4ab934be90d9 100644 (file)
@@ -1514,20 +1514,29 @@ int bus_kernel_open_bus_fd(const char *bus, char **path) {
         int fd;
         size_t len;
 
+        assert(bus);
+
         len = strlen("/sys/fs/kdbus/") + DECIMAL_STR_MAX(uid_t) + 1 + strlen(bus) + strlen("/bus") + 1;
 
         if (path) {
-                p = malloc(len);
+                p = new(char, len);
                 if (!p)
                         return -ENOMEM;
-                *path = p;
         } else
-                p = alloca(len);
+                p = newa(char, len);
+
         sprintf(p, "/sys/fs/kdbus/" UID_FMT "-%s/bus", getuid(), bus);
 
         fd = open(p, O_RDWR|O_NOCTTY|O_CLOEXEC);
-        if (fd < 0)
+        if (fd < 0) {
+                if (path)
+                        free(p);
+
                 return -errno;
+        }
+
+        if (path)
+                *path = p;
 
         return fd;
 }
@@ -1680,7 +1689,7 @@ int bus_kernel_make_starter(
                 (accept_fd ? KDBUS_HELLO_ACCEPT_FD : 0);
         hello->pool_size = KDBUS_POOL_SIZE;
         hello->attach_flags_send = _KDBUS_ATTACH_ANY;
-        hello->attach_flags_recv = _KDBUS_ATTACH_ALL;
+        hello->attach_flags_recv = _KDBUS_ATTACH_ANY;
 
         if (ioctl(fd, KDBUS_CMD_HELLO, hello) < 0)
                 return -errno;