bus-kernel.c revision 34a5d5e52661212c7a145cbab45e70a6df7ba284
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering This file is part of systemd.
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering Copyright 2013 Lennart Poettering
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering systemd is free software; you can redistribute it and/or modify it
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering under the terms of the GNU Lesser General Public License as published by
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering (at your option) any later version.
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering systemd is distributed in the hope that it will be useful, but
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering Lesser General Public License for more details.
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering You should have received a copy of the GNU Lesser General Public License
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering#define UNIQUE_NAME_MAX (3+DECIMAL_STR_MAX(uint64_t))
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringint bus_kernel_parse_unique_name(const char *s, uint64_t *id) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic void append_payload_vec(struct kdbus_item **d, const void *p, size_t sz) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering /* Note that p can be NULL, which encodes a region full of
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering * zeroes, which is useful to optimize certain padding
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering * conditions */
39883f622f392d8579f4428fc5a789a102efbb10Lennart Poettering (*d)->size = offsetof(struct kdbus_item, vec) + sizeof(struct kdbus_vec);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering *d = (struct kdbus_item *) ((uint8_t*) *d + (*d)->size);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic void append_payload_memfd(struct kdbus_item **d, int memfd, size_t start, size_t sz) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering (*d)->size = offsetof(struct kdbus_item, memfd) + sizeof(struct kdbus_memfd);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering *d = (struct kdbus_item *) ((uint8_t*) *d + (*d)->size);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic void append_destination(struct kdbus_item **d, const char *s, size_t length) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering (*d)->size = offsetof(struct kdbus_item, str) + length + 1;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering *d = (struct kdbus_item *) ((uint8_t*) *d + (*d)->size);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic struct kdbus_bloom_filter *append_bloom(struct kdbus_item **d, size_t length) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering i->size = offsetof(struct kdbus_item, bloom_filter) +
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering offsetof(struct kdbus_bloom_filter, data) +
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering *d = (struct kdbus_item *) ((uint8_t*) i + i->size);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic void append_fds(struct kdbus_item **d, const int fds[], unsigned n_fds) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering (*d)->size = offsetof(struct kdbus_item, fds) + sizeof(int) * n_fds;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering memcpy((*d)->fds, fds, sizeof(int) * n_fds);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering *d = (struct kdbus_item *) ((uint8_t*) *d + (*d)->size);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic void add_bloom_arg(void *data, size_t size, unsigned n_hash, unsigned i, const char *t) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering char buf[sizeof("arg")-1 + 2 + sizeof("-slash-prefix")];
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering *(e++) = '0' + (char) i;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering bloom_add_pair(data, size, n_hash, buf, t);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering bloom_add_prefixes(data, size, n_hash, buf, t, '.');
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering bloom_add_prefixes(data, size, n_hash, buf, t, '/');
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic int bus_message_setup_bloom(sd_bus_message *m, struct kdbus_bloom_filter *bloom) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering bloom_add_pair(data, m->bus->bloom_size, m->bus->bloom_n_hash, "message-type", bus_message_type_to_string(m->header->type));
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering bloom_add_pair(data, m->bus->bloom_size, m->bus->bloom_n_hash, "interface", m->interface);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering bloom_add_pair(data, m->bus->bloom_size, m->bus->bloom_n_hash, "member", m->member);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering bloom_add_pair(data, m->bus->bloom_size, m->bus->bloom_n_hash, "path", m->path);
938d2699d2e818bd996614e89ea3d668200ad2a8Zbigniew Jędrzejewski-Szmek bloom_add_pair(data, m->bus->bloom_size, m->bus->bloom_n_hash, "path-slash-prefix", m->path);
938d2699d2e818bd996614e89ea3d668200ad2a8Zbigniew Jędrzejewski-Szmek bloom_add_prefixes(data, m->bus->bloom_size, m->bus->bloom_n_hash, "path-slash-prefix", m->path, '/');
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering for (i = 0; i < 64; i++) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering const char *t, *contents;
938d2699d2e818bd996614e89ea3d668200ad2a8Zbigniew Jędrzejewski-Szmek r = sd_bus_message_peek_type(m, &type, &contents);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering if (IN_SET(type, SD_BUS_TYPE_STRING, SD_BUS_TYPE_OBJECT_PATH, SD_BUS_TYPE_SIGNATURE)) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering /* The bloom filter includes simple strings of any kind */
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering r = sd_bus_message_read_basic(m, type, &t);
7b909d7407965c03caaba30daae7aee113627a83Josh Triplett add_bloom_arg(data, m->bus->bloom_size, m->bus->bloom_n_hash, i, t);
3cadce7d33e263ec7a6a83c00c11144930258b22Thomas Bächler } if (type == SD_BUS_TYPE_ARRAY && STR_IN_SET(contents, "s", "o", "g")) {
7b909d7407965c03caaba30daae7aee113627a83Josh Triplett /* As well as array of simple strings of any kinds */
7b909d7407965c03caaba30daae7aee113627a83Josh Triplett r = sd_bus_message_enter_container(m, type, contents);
7b909d7407965c03caaba30daae7aee113627a83Josh Triplett while ((r = sd_bus_message_read_basic(m, contents[0], &t)) > 0)
3cadce7d33e263ec7a6a83c00c11144930258b22Thomas Bächler add_bloom_arg(data, m->bus->bloom_size, m->bus->bloom_n_hash, i, t);
7b909d7407965c03caaba30daae7aee113627a83Josh Triplett /* Stop adding to bloom filter as soon as we
7b909d7407965c03caaba30daae7aee113627a83Josh Triplett * run into the first argument we cannot add
4cd2b2cf8ca585d15ebc859701b346658262b5bbDenis Tikhomirovstatic int bus_message_setup_kmsg(sd_bus *b, sd_bus_message *m) {
4cd2b2cf8ca585d15ebc859701b346658262b5bbDenis Tikhomirov /* We put this together only once, if this message is reused
4cd2b2cf8ca585d15ebc859701b346658262b5bbDenis Tikhomirov * we reuse the earlier-built version */
7b909d7407965c03caaba30daae7aee113627a83Josh Triplett destination = m->destination ?: m->destination_ptr;
7b909d7407965c03caaba30daae7aee113627a83Josh Triplett r = bus_kernel_parse_unique_name(destination, &unique);
0c9d8f1d4b5018199cb5a9b57580dc1480a7f915Jani Nikula /* Add in fixed header, fields header and payload */
7b909d7407965c03caaba30daae7aee113627a83Josh Triplett sz += (1 + m->n_body_parts) * ALIGN8(offsetof(struct kdbus_item, vec) +
7b909d7407965c03caaba30daae7aee113627a83Josh Triplett sizeof(struct kdbus_memfd)));
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering /* Add space for bloom filter */
1ca208fb4f93e5869704af1812cbff7130a2fc03Zbigniew Jędrzejewski-Szmek sz += ALIGN8(offsetof(struct kdbus_item, bloom_filter) +
1ca208fb4f93e5869704af1812cbff7130a2fc03Zbigniew Jędrzejewski-Szmek offsetof(struct kdbus_bloom_filter, data) +
3cadce7d33e263ec7a6a83c00c11144930258b22Thomas Bächler /* Add in well-known destination header */
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering sz += ALIGN8(offsetof(struct kdbus_item, str) + dl + 1);
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering /* Add space for unix fds */
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering sz += ALIGN8(offsetof(struct kdbus_item, fds) + sizeof(int)*m->n_fds);
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering ((m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) ? 0 : KDBUS_MSG_EXPECT_REPLY) |
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering ((m->header->flags & BUS_MESSAGE_NO_AUTO_START) ? KDBUS_MSG_NO_AUTO_START : 0);
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering /* verify_destination_id will usually be 0, which makes the kernel driver only look
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering * at the provided well-known name. Otherwise, the kernel will make sure the provided
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering * destination id matches the owner of the provided weel-known-name, and fail if they
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering * differ. Currently, this is only needed for bus-proxyd. */
938d2699d2e818bd996614e89ea3d668200ad2a8Zbigniew Jędrzejewski-Szmek m->kdbus->dst_id = m->verify_destination_id;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering m->kdbus->dst_id = destination ? unique : KDBUS_DST_ID_BROADCAST;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering m->kdbus->payload_type = KDBUS_PAYLOAD_DBUS;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering m->kdbus->cookie = (uint64_t) m->header->serial;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering if (m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED)
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering m->kdbus->cookie_reply = m->reply_cookie;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering assert_se(clock_gettime(CLOCK_MONOTONIC_COARSE, &now) == 0);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering m->kdbus->timeout_ns = now.tv_sec * NSEC_PER_SEC + now.tv_nsec +
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering append_payload_vec(&d, m->header, BUS_MESSAGE_BODY_BEGIN(m));
1ca208fb4f93e5869704af1812cbff7130a2fc03Zbigniew Jędrzejewski-Szmek MESSAGE_FOREACH_PART(part, i, m) {
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering /* If this is padding then simply send a
3cadce7d33e263ec7a6a83c00c11144930258b22Thomas Bächler * vector with a NULL data pointer which the
3cadce7d33e263ec7a6a83c00c11144930258b22Thomas Bächler * kernel will just pass through. This is the
3cadce7d33e263ec7a6a83c00c11144930258b22Thomas Bächler * most efficient way to encode zeroes */
be3f52f4ed02a9256b1577719677b32a17b525acLennart Poettering if (part->memfd >= 0 && part->sealed && destination) {
be3f52f4ed02a9256b1577719677b32a17b525acLennart Poettering /* Try to send a memfd, if the part is
be3f52f4ed02a9256b1577719677b32a17b525acLennart Poettering * sealed and this is not a broadcast. Since we can only */
be3f52f4ed02a9256b1577719677b32a17b525acLennart Poettering append_payload_memfd(&d, part->memfd, part->memfd_offset, part->size);
be3f52f4ed02a9256b1577719677b32a17b525acLennart Poettering /* Otherwise, let's send a vector to the actual data.
be3f52f4ed02a9256b1577719677b32a17b525acLennart Poettering * For that, we need to map it first. */
be3f52f4ed02a9256b1577719677b32a17b525acLennart Poettering append_payload_vec(&d, part->data, part->size);
be3f52f4ed02a9256b1577719677b32a17b525acLennart Poettering if (m->kdbus->dst_id == KDBUS_DST_ID_BROADCAST) {
be3f52f4ed02a9256b1577719677b32a17b525acLennart Poettering bloom = append_bloom(&d, m->bus->bloom_size);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering m->kdbus->size = (uint8_t*) d - (uint8_t*) m->kdbus;
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poetteringstatic void bus_message_set_sender_driver(sd_bus *bus, sd_bus_message *m) {
b76388e123e8d73ded1fd53937d816b314948517Michael Biebl m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus";
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering m->creds.mask |= (SD_BUS_CREDS_UNIQUE_NAME|SD_BUS_CREDS_WELL_KNOWN_NAMES) & bus->creds_mask;
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poetteringstatic void unset_memfds(struct sd_bus_message *m) {
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidt /* Make sure the memfds are not freed twice */
1ca208fb4f93e5869704af1812cbff7130a2fc03Zbigniew Jędrzejewski-Szmek MESSAGE_FOREACH_PART(part, i, m)
bca81be7755d15e7369d764bfa94a7ca6c595c76Topi Miettinenstatic int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering const char *destination = NULL, *seclabel = NULL;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering assert(k->payload_type == KDBUS_PAYLOAD_DBUS);
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering l = d->size - offsetof(struct kdbus_item, data);
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering h = (struct bus_header *)((uint8_t *)bus->kdbus_buffer + d->vec.offset);
1ca208fb4f93e5869704af1812cbff7130a2fc03Zbigniew Jędrzejewski-Szmek if (!bus_header_is_complete(h, d->vec.size))
case KDBUS_ITEM_FDS: {
return -ENOMEM;
fds = f;
n_fds += j;
case KDBUS_ITEM_SECLABEL:
return -EBADMSG;
return -EBADMSG;
return -EPROTOTYPE;
size_t l;
switch (d->type) {
case KDBUS_ITEM_PAYLOAD_OFF: {
if (!part) {
r = -ENOMEM;
goto fail;
case KDBUS_ITEM_PAYLOAD_MEMFD: {
r = -EBADMSG;
goto fail;
if (!part) {
r = -ENOMEM;
goto fail;
case KDBUS_ITEM_PIDS:
case KDBUS_ITEM_CREDS:
case KDBUS_ITEM_TIMESTAMP:
case KDBUS_ITEM_PID_COMM:
case KDBUS_ITEM_TID_COMM:
case KDBUS_ITEM_EXE:
case KDBUS_ITEM_CMDLINE:
case KDBUS_ITEM_CGROUP:
m->creds.mask |= (SD_BUS_CREDS_CGROUP|SD_BUS_CREDS_UNIT|SD_BUS_CREDS_USER_UNIT|SD_BUS_CREDS_SLICE|SD_BUS_CREDS_SESSION|SD_BUS_CREDS_OWNER_UID) & bus->creds_mask;
goto fail;
case KDBUS_ITEM_AUDIT:
case KDBUS_ITEM_CAPS:
r = -EBADMSG;
goto fail;
m->creds.mask |= (SD_BUS_CREDS_EFFECTIVE_CAPS|SD_BUS_CREDS_PERMITTED_CAPS|SD_BUS_CREDS_INHERITABLE_CAPS|SD_BUS_CREDS_BOUNDING_CAPS) & bus->creds_mask;
case KDBUS_ITEM_DST_NAME:
r = -EBADMSG;
goto fail;
case KDBUS_ITEM_OWNED_NAME:
r = -EBADMSG;
goto fail;
char **wkn;
size_t n;
if (!wkn) {
r = -ENOMEM;
goto fail;
case KDBUS_ITEM_AUXGROUPS:
case KDBUS_ITEM_FDS:
case KDBUS_ITEM_SECLABEL:
r = bus_message_parse_fields(m);
goto fail;
r = -EBADMSG;
goto fail;
r = -EBADMSG;
goto fail;
r = -EBADMSG;
goto fail;
r = -EBADMSG;
goto fail;
if (destination)
snprintf(m->destination_buffer, sizeof(m->destination_buffer), ":1.%llu", (unsigned long long) k->dst_id);
m->kdbus = k;
m->release_kdbus = true;
m->free_fds = true;
fail:
unset_memfds(m);
.flags = 0,
const char *name;
assert(b);
if (b->is_server)
return -EINVAL;
if (b->description) {
return -ENOMEM;
name = g;
return -ENOMEM;
return -ENOMEM;
name = g;
if (!b->description)
return -ENOMEM;
if (b->fake_creds_valid)
if (b->fake_pids_valid)
if (b->fake_label) {
if (b->fake_creds_valid) {
if (b->fake_pids_valid) {
if (b->fake_label) {
return -errno;
if (!b->kdbus_buffer) {
r = -errno;
goto fail;
r = -ENOTSUP;
goto fail;
r = -ENOTSUP;
goto fail;
r = -ENOMEM;
goto fail;
b->is_kernel = true;
b->bus_client = true;
return bus_start_running(b);
fail:
assert(b);
if (b->is_server)
return -EINVAL;
if (b->input_fd < 0)
return -errno;
return bus_kernel_take_fd(b);
.flags = 0,
return -errno;
struct kdbus_item *d;
assert(k);
assert(m);
* kernel, so that it can pass CPU time/scheduling to the
if (hint_sync_call) {
sd_bus_error_setf(&error, SD_BUS_ERROR_SERVICE_UNKNOWN, "Destination %s not known", m->destination);
log_debug("Could not deliver message to %s as destination is not known. Ignoring.", m->destination);
sd_bus_error_setf(&error, SD_BUS_ERROR_SERVICE_UNKNOWN, "Activation of %s not requested", m->destination);
log_debug("Could not deliver message to %s as destination is not activated. Ignoring.", m->destination);
return -errno;
bus,
&error,
&reply);
} else if (hint_sync_call) {
struct kdbus_msg *k;
assert(k);
log_debug("Ignoring message with unknown payload type %llu.", (unsigned long long) k->payload_type);
static int push_name_owner_changed(sd_bus *bus, const char *name, const char *old_owner, const char *new_owner) {
bus,
"/org/freedesktop/DBus",
m = NULL;
assert(k);
assert(d);
if (d->type == KDBUS_ITEM_NAME_ADD || (d->name_change.old_id.flags & (KDBUS_NAME_IN_QUEUE|KDBUS_NAME_ACTIVATOR)))
old_owner[0] = 0;
if (d->type == KDBUS_ITEM_NAME_REMOVE || (d->name_change.new_id.flags & (KDBUS_NAME_IN_QUEUE|KDBUS_NAME_ACTIVATOR))) {
new_owner[0] = 0;
assert(k);
assert(d);
return push_name_owner_changed(
assert(k);
assert(d);
bus,
k->cookie_reply,
m = NULL;
assert(k);
if (d->type >= _KDBUS_ITEM_KERNEL_BASE && d->type < _KDBUS_ITEM_KERNEL_BASE + ELEMENTSOF(translate)) {
if (found)
return -EBADMSG;
found = d;
if (!found) {
struct kdbus_msg *k;
if (hint_priority) {
log_debug("%s: kdbus reports %" PRIu64 " dropped broadcast messages, ignoring.", strna(bus->description), (uint64_t) recv.dropped_msgs);
return -errno;
log_debug("Ignoring message with unknown payload type %llu.", (unsigned long long) k->payload_type);
struct memfd_cache *c;
int fd;
return -ENOTSUP;
*mapped = 0;
*allocated = 0;
return fd;
if (size > 0)
struct memfd_cache *c;
assert(b);
for (i = 0; i < b->n_memfd_cache; i++)
uint64_t f = 0;
f |= KDBUS_NAME_QUEUE;
uint64_t m = 0;
m |= KDBUS_ATTACH_CREDS;
m |= KDBUS_ATTACH_PIDS;
m |= KDBUS_ATTACH_PID_COMM;
m |= KDBUS_ATTACH_TID_COMM;
m |= KDBUS_ATTACH_EXE;
m |= KDBUS_ATTACH_CMDLINE;
if (mask & (SD_BUS_CREDS_CGROUP|SD_BUS_CREDS_UNIT|SD_BUS_CREDS_USER_UNIT|SD_BUS_CREDS_SLICE|SD_BUS_CREDS_SESSION|SD_BUS_CREDS_OWNER_UID))
m |= KDBUS_ATTACH_CGROUP;
if (mask & (SD_BUS_CREDS_EFFECTIVE_CAPS|SD_BUS_CREDS_PERMITTED_CAPS|SD_BUS_CREDS_INHERITABLE_CAPS|SD_BUS_CREDS_BOUNDING_CAPS))
m |= KDBUS_ATTACH_CAPS;
m |= KDBUS_ATTACH_SECLABEL;
m |= KDBUS_ATTACH_AUDIT;
m |= KDBUS_ATTACH_NAMES;
m |= KDBUS_ATTACH_AUXGROUPS;
struct kdbus_item *n;
size_t l;
int fd;
assert(s);
if (fd < 0)
return -errno;
sizeof(struct kdbus_bloom_parameter);
n = KDBUS_ITEM_NEXT(n);
n = KDBUS_ITEM_NEXT(n);
n = KDBUS_ITEM_NEXT(n);
return -errno;
return -ENOMEM;
return fd;
int fd;
if (path) {
return -ENOMEM;
if (fd < 0) {
if (path)
free(p);
return -errno;
if (path)
*path = p;
return fd;
struct kdbus_item *n;
const char *name;
int fd;
if (fd < 0)
return fd;
return -errno;
if (ep_path) {
return -ENOMEM;
*ep_path = p;
return fd;
return -errno;
return -errno;
struct kdbus_item *n;
return -errno;
int bus_kernel_fix_attach_mask(void) {
if (mask) {
const char *p = mask;
return log_full_errno(
char *n = NULL;
return -errno;
return -EIO;
*name = n;