chiark / gitweb /
macro: log assertion at debug level in assert_return()
[elogind.git] / src / libsystemd-bus / bus-control.c
index 7a772ff49f87d3f55eca6fde817a772a96a14f80..47e91118a43905db6c36a869dbbc4dde35190e49 100644 (file)
@@ -27,7 +27,6 @@
 #include <errno.h>
 
 #include "strv.h"
-
 #include "sd-bus.h"
 #include "bus-internal.h"
 #include "bus-message.h"
@@ -208,7 +207,6 @@ static int kernel_get_list(sd_bus *bus, uint64_t flags, char ***x) {
 
         /* Caller will free half-constructed list on failure... */
 
-        cmd.size = sizeof(struct kdbus_cmd_name_list);
         cmd.flags = flags;
 
         r = ioctl(bus->input_fd, KDBUS_CMD_NAME_LIST, &cmd);
@@ -217,7 +215,7 @@ static int kernel_get_list(sd_bus *bus, uint64_t flags, char ***x) {
 
         name_list = (struct kdbus_name_list *) ((uint8_t *) bus->kdbus_buffer + cmd.offset);
 
-        KDBUS_PART_FOREACH(name, name_list, names) {
+        KDBUS_ITEM_FOREACH(name, name_list, names) {
 
                 if (name->size > sizeof(*name)) {
                         r = strv_extend(x, name->name);
@@ -364,6 +362,7 @@ static int bus_get_owner_kdbus(
                 cmd = alloca0(size);
                 strcpy(cmd->name, name);
         }
+        cmd->flags = KDBUS_ATTACH_NAMES;
 
         cmd->size = size;
         r = ioctl(bus->input_fd, KDBUS_CMD_CONN_INFO, cmd);
@@ -383,7 +382,7 @@ static int bus_get_owner_kdbus(
                 c->mask |= SD_BUS_CREDS_UNIQUE_NAME;
         }
 
-        KDBUS_PART_FOREACH(item, conn_info, items) {
+        KDBUS_ITEM_FOREACH(item, conn_info, items) {
 
                 switch (item->type) {
 
@@ -439,7 +438,7 @@ static int bus_get_owner_kdbus(
 
                 case KDBUS_ITEM_CMDLINE:
                         if (mask & SD_BUS_CREDS_CMDLINE) {
-                                c->cmdline_size = item->size - KDBUS_PART_HEADER_SIZE;
+                                c->cmdline_size = item->size - KDBUS_ITEM_HEADER_SIZE;
                                 c->cmdline = memdup(item->data, c->cmdline_size);
                                 if (!c->cmdline) {
                                         r = -ENOMEM;
@@ -471,7 +470,7 @@ static int bus_get_owner_kdbus(
                              SD_BUS_CREDS_INHERITABLE_CAPS | SD_BUS_CREDS_BOUNDING_CAPS) & mask;
 
                         if (m) {
-                                c->capability_size = item->size - KDBUS_PART_HEADER_SIZE;
+                                c->capability_size = item->size - KDBUS_ITEM_HEADER_SIZE;
                                 c->capability = memdup(item->data, c->capability_size);
                                 if (!c->capability) {
                                         r = -ENOMEM;
@@ -504,14 +503,11 @@ static int bus_get_owner_kdbus(
                         }
                         break;
 
-                case KDBUS_ITEM_NAMES:
+                case KDBUS_ITEM_NAME:
                         if (mask & SD_BUS_CREDS_WELL_KNOWN_NAMES) {
-                                c->well_known_names_size = item->size - KDBUS_PART_HEADER_SIZE;
-                                c->well_known_names = memdup(item->data, c->well_known_names_size);
-                                if (!c->well_known_names) {
-                                        r = -ENOMEM;
+                                r = strv_extend(&c->well_known_names, item->name.name);
+                                if (r < 0)
                                         goto fail;
-                                }
 
                                 c->mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES;
                         }
@@ -1013,7 +1009,7 @@ static int bus_add_match_internal_kernel(
                 item->type = KDBUS_MATCH_BLOOM;
                 memcpy(item->data64, bloom, BLOOM_SIZE);
 
-                item = KDBUS_PART_NEXT(item);
+                item = KDBUS_ITEM_NEXT(item);
         }
 
         if (sender) {