summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-kernel.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-28 15:58:03 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-28 16:17:33 +0100
commit52cfc0379a9d63f99cdb3d9f63c839bbc8889b4c (patch)
tree412a2a9c36bf13a36fe6d7ad38bca762e641b32b /src/libsystemd/sd-bus/bus-kernel.c
parent279d3c9cead3a7ffb657fedbab0e2bc90db45667 (diff)
sd-bus: rework credential query logic
Also, make the call to free kdbus slices generic and use it everywhere
Diffstat (limited to 'src/libsystemd/sd-bus/bus-kernel.c')
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 5b4bbfd1ea..c86ed6ae42 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -954,24 +954,37 @@ int bus_kernel_connect(sd_bus *b) {
return bus_kernel_take_fd(b);
}
+int bus_kernel_cmd_free(sd_bus *bus, uint64_t offset) {
+ struct kdbus_cmd_free cmd = {
+ .flags = 0,
+ .offset = offset,
+ };
+ int r;
+
+ assert(bus);
+ assert(bus->is_kernel);
+
+ r = ioctl(bus->input_fd, KDBUS_CMD_FREE, &cmd);
+ if (r < 0)
+ return -errno;
+
+ return 0;
+}
+
static void close_kdbus_msg(sd_bus *bus, struct kdbus_msg *k) {
- struct kdbus_cmd_free cmd = {};
struct kdbus_item *d;
assert(bus);
assert(k);
- cmd.offset = (uint8_t *)k - (uint8_t *)bus->kdbus_buffer;
-
KDBUS_ITEM_FOREACH(d, k, items) {
-
if (d->type == KDBUS_ITEM_FDS)
close_many(d->fds, (d->size - offsetof(struct kdbus_item, fds)) / sizeof(int));
else if (d->type == KDBUS_ITEM_PAYLOAD_MEMFD)
safe_close(d->memfd.fd);
}
- (void) ioctl(bus->input_fd, KDBUS_CMD_FREE, &cmd);
+ bus_kernel_cmd_free(bus, (uint8_t*) k - (uint8_t*) bus->kdbus_buffer);
}
int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call) {