X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flibsystemd-bus%2Fbus-control.c;h=511ca20ee3b4e614ef135dbeef12c99297abb3ff;hp=b1172899d0338b7f05cbd5504d33a801eb76a289;hb=751bc6ac79320bc16e63e8c1bbb713c30a3b7bc9;hpb=f7d8595113c0e2ffe84c760a325dd9c988161d8d diff --git a/src/libsystemd-bus/bus-control.c b/src/libsystemd-bus/bus-control.c index b1172899d..511ca20ee 100644 --- a/src/libsystemd-bus/bus-control.c +++ b/src/libsystemd-bus/bus-control.c @@ -27,13 +27,13 @@ #include #include "strv.h" - #include "sd-bus.h" #include "bus-internal.h" #include "bus-message.h" #include "bus-control.h" #include "bus-bloom.h" #include "bus-util.h" +#include "cgroup-util.h" _public_ int sd_bus_get_unique_name(sd_bus *bus, const char **unique) { int r; @@ -50,17 +50,18 @@ _public_ int sd_bus_get_unique_name(sd_bus *bus, const char **unique) { return 0; } -static int bus_request_name_kernel(sd_bus *bus, const char *name, unsigned flags) { +static int bus_request_name_kernel(sd_bus *bus, const char *name, uint64_t flags) { struct kdbus_cmd_name *n; - size_t l; + size_t size, l; int r; assert(bus); assert(name); l = strlen(name); - n = alloca0(offsetof(struct kdbus_cmd_name, name) + l + 1); - n->size = offsetof(struct kdbus_cmd_name, name) + l + 1; + size = offsetof(struct kdbus_cmd_name, name) + l + 1; + n = alloca0(size); + n->size = size; kdbus_translate_request_name_flags(flags, (uint64_t *) &n->flags); memcpy(n->name, name, l+1); @@ -78,25 +79,32 @@ static int bus_request_name_kernel(sd_bus *bus, const char *name, unsigned flags return 1; } -static int bus_request_name_dbus1(sd_bus *bus, const char *name, unsigned flags) { +static int bus_request_name_dbus1(sd_bus *bus, const char *name, uint64_t flags) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; - uint32_t ret; + uint32_t ret, param = 0; int r; assert(bus); assert(name); + if (flags & SD_BUS_NAME_ALLOW_REPLACEMENT) + param |= BUS_NAME_ALLOW_REPLACEMENT; + if (flags & SD_BUS_NAME_REPLACE_EXISTING) + param |= BUS_NAME_REPLACE_EXISTING; + if (!(flags & SD_BUS_NAME_QUEUE)) + param |= BUS_NAME_DO_NOT_QUEUE; + r = sd_bus_call_method( bus, "org.freedesktop.DBus", - "/", + "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName", NULL, &reply, "su", name, - flags); + param); if (r < 0) return r; @@ -116,13 +124,15 @@ static int bus_request_name_dbus1(sd_bus *bus, const char *name, unsigned flags) return -EIO; } -_public_ int sd_bus_request_name(sd_bus *bus, const char *name, unsigned flags) { +_public_ int sd_bus_request_name(sd_bus *bus, const char *name, uint64_t flags) { assert_return(bus, -EINVAL); assert_return(name, -EINVAL); assert_return(bus->bus_client, -EINVAL); assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); assert_return(!bus_pid_changed(bus), -ECHILD); - assert_return(!(flags & ~(SD_BUS_NAME_ALLOW_REPLACEMENT|SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_DO_NOT_QUEUE)), -EINVAL); + assert_return(!(flags & ~(SD_BUS_NAME_ALLOW_REPLACEMENT|SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_QUEUE)), -EINVAL); + assert_return(service_name_is_valid(name), -EINVAL); + assert_return(name[0] != ':', -EINVAL); if (bus->is_kernel) return bus_request_name_kernel(bus, name, flags); @@ -164,7 +174,7 @@ static int bus_release_name_dbus1(sd_bus *bus, const char *name) { r = sd_bus_call_method( bus, "org.freedesktop.DBus", - "/", + "/org/freedesktop/DBus", "org.freedesktop.DBus", "ReleaseName", NULL, @@ -178,9 +188,9 @@ static int bus_release_name_dbus1(sd_bus *bus, const char *name) { if (r < 0) return r; if (ret == BUS_NAME_NON_EXISTENT) - return -ENOENT; + return -ESRCH; if (ret == BUS_NAME_NOT_OWNER) - return -EADDRNOTAVAIL; + return -EADDRINUSE; if (ret == BUS_NAME_RELEASED) return 0; @@ -193,6 +203,8 @@ _public_ int sd_bus_release_name(sd_bus *bus, const char *name) { assert_return(bus->bus_client, -EINVAL); assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); assert_return(!bus_pid_changed(bus), -ECHILD); + assert_return(service_name_is_valid(name), -EINVAL); + assert_return(name[0] != ':', -EINVAL); if (bus->is_kernel) return bus_release_name_kernel(bus, name); @@ -204,6 +216,7 @@ static int kernel_get_list(sd_bus *bus, uint64_t flags, char ***x) { struct kdbus_cmd_name_list cmd = {}; struct kdbus_name_list *name_list; struct kdbus_cmd_name *name; + uint64_t previous_id = 0; int r; /* Caller will free half-constructed list on failure... */ @@ -216,16 +229,12 @@ 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); - if (r < 0) - return -ENOMEM; - } else { + if ((flags & KDBUS_NAME_LIST_UNIQUE) && name->owner_id != previous_id) { char *n; - if (asprintf(&n, ":1.%llu", (unsigned long long) name->id) < 0) + if (asprintf(&n, ":1.%llu", (unsigned long long) name->owner_id) < 0) return -ENOMEM; r = strv_push(x, n); @@ -233,11 +242,18 @@ static int kernel_get_list(sd_bus *bus, uint64_t flags, char ***x) { free(n); return -ENOMEM; } + + previous_id = name->owner_id; } + if (name->size > sizeof(*name) && service_name_is_valid(name->name)) { + r = strv_extend(x, name->name); + if (r < 0) + return -ENOMEM; + } } - r = ioctl(sd_bus_get_fd(bus), KDBUS_CMD_FREE, &cmd.offset); + r = ioctl(bus->input_fd, KDBUS_CMD_FREE, &cmd.offset); if (r < 0) return -errno; @@ -255,7 +271,7 @@ static int bus_list_names_kernel(sd_bus *bus, char ***acquired, char ***activata } if (activatable) { - r = kernel_get_list(bus, KDBUS_NAME_LIST_STARTERS, &y); + r = kernel_get_list(bus, KDBUS_NAME_LIST_ACTIVATORS, &y); if (r < 0) return r; @@ -280,7 +296,7 @@ static int bus_list_names_dbus1(sd_bus *bus, char ***acquired, char ***activatab r = sd_bus_call_method( bus, "org.freedesktop.DBus", - "/", + "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames", NULL, @@ -300,7 +316,7 @@ static int bus_list_names_dbus1(sd_bus *bus, char ***acquired, char ***activatab r = sd_bus_call_method( bus, "org.freedesktop.DBus", - "/", + "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListActivatableNames", NULL, @@ -372,6 +388,10 @@ static int bus_get_owner_kdbus( conn_info = (struct kdbus_conn_info *) ((uint8_t *) bus->kdbus_buffer + cmd->offset); + /* Non-activated names are considered not available */ + if (conn_info->flags & KDBUS_HELLO_ACTIVATOR) + return name[0] == ':' ? -ENXIO : -ENOENT; + c = bus_creds_new(); if (!c) return -ENOMEM; @@ -383,22 +403,30 @@ 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) { case KDBUS_ITEM_CREDS: - m = (SD_BUS_CREDS_UID | SD_BUS_CREDS_GID | SD_BUS_CREDS_PID | - SD_BUS_CREDS_TID | SD_BUS_CREDS_PID_STARTTIME) & mask; + m = (SD_BUS_CREDS_UID | SD_BUS_CREDS_GID | SD_BUS_CREDS_PID) & mask; if (m) { c->uid = item->creds.uid; c->pid = item->creds.pid; c->gid = item->creds.gid; + c->mask |= m; + } + + if (mask & SD_BUS_CREDS_TID && item->creds.tid > 0) { c->tid = item->creds.tid; + c->mask |= SD_BUS_CREDS_TID; + } + + if (mask & SD_BUS_CREDS_PID_STARTTIME && item->creds.starttime > 0) { c->pid_starttime = item->creds.starttime; - c->mask |= m; + c->mask |= SD_BUS_CREDS_PID_STARTTIME; } + break; case KDBUS_ITEM_PID_COMM: @@ -439,7 +467,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; @@ -462,6 +490,18 @@ static int bus_get_owner_kdbus( goto fail; } + if (!bus->cgroup_root) { + r = cg_get_root_path(&bus->cgroup_root); + if (r < 0) + goto fail; + } + + c->cgroup_root = strdup(bus->cgroup_root); + if (!c->cgroup_root) { + r = -ENOMEM; + goto fail; + } + c->mask |= m; } break; @@ -471,7 +511,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 +544,11 @@ static int bus_get_owner_kdbus( } break; - case KDBUS_ITEM_NAMES: - 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; + case KDBUS_ITEM_NAME: + if ((mask & SD_BUS_CREDS_WELL_KNOWN_NAMES) && service_name_is_valid(item->name.name)) { + r = strv_extend(&c->well_known_names, item->name.name); + if (r < 0) goto fail; - } c->mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES; } @@ -549,7 +586,7 @@ static int bus_get_owner_dbus1( r = sd_bus_call_method( bus, "org.freedesktop.DBus", - "/", + "/org/freedesktop/DBus", "org.freedesktop.DBus", "GetNameOwner", NULL, @@ -587,7 +624,7 @@ static int bus_get_owner_dbus1( r = sd_bus_call_method( bus, "org.freedesktop.DBus", - "/", + "/org/freedesktop/DBus", "org.freedesktop.DBus", "GetConnectionUnixProcessID", NULL, @@ -616,7 +653,7 @@ static int bus_get_owner_dbus1( r = sd_bus_call_method( bus, "org.freedesktop.DBus", - "/", + "/org/freedesktop/DBus", "org.freedesktop.DBus", "GetConnectionUnixUser", NULL, @@ -643,7 +680,7 @@ static int bus_get_owner_dbus1( r = sd_bus_call_method( bus, "org.freedesktop.DBus", - "/", + "/org/freedesktop/DBus", "org.freedesktop.DBus", "GetConnectionSELinuxSecurityContext", NULL, @@ -689,6 +726,8 @@ _public_ int sd_bus_get_owner( assert_return(mask == 0 || creds, -EINVAL); assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); assert_return(!bus_pid_changed(bus), -ECHILD); + assert_return(service_name_is_valid(name), -EINVAL); + assert_return(bus->bus_client, -ENODATA); if (bus->is_kernel) return bus_get_owner_kdbus(bus, name, mask, creds); @@ -702,7 +741,7 @@ static int add_name_change_match(sd_bus *bus, const char *old_owner, const char *new_owner) { - uint64_t name_id = 0, old_owner_id = 0, new_owner_id = 0; + uint64_t name_id = KDBUS_MATCH_ID_ANY, old_owner_id = 0, new_owner_id = 0; int is_name_id = -1, r; struct kdbus_item *item; @@ -710,19 +749,19 @@ static int add_name_change_match(sd_bus *bus, /* If we encounter a match that could match against * NameOwnerChanged messages, then we need to create - * KDBUS_MATCH_NAME_{ADD,REMOVE,CHANGE} and - * KDBUS_MATCH_ID_{ADD,REMOVE} matches for it, possibly + * KDBUS_ITEM_NAME_{ADD,REMOVE,CHANGE} and + * KDBUS_ITEM_ID_{ADD,REMOVE} matches for it, possibly * multiple if the match is underspecified. * * The NameOwnerChanged signals take three parameters with * unique or well-known names, but only some forms actually * exist: * - * WELLKNOWN, "", UNIQUE → KDBUS_MATCH_NAME_ADD - * WELLKNOWN, UNIQUE, "" → KDBUS_MATCH_NAME_REMOVE - * WELLKNOWN, UNIQUE, UNIQUE → KDBUS_MATCH_NAME_CHANGE - * UNIQUE, "", UNIQUE → KDBUS_MATCH_ID_ADD - * UNIQUE, UNIQUE, "" → KDBUS_MATCH_ID_REMOVE + * WELLKNOWN, "", UNIQUE → KDBUS_ITEM_NAME_ADD + * WELLKNOWN, UNIQUE, "" → KDBUS_ITEM_NAME_REMOVE + * WELLKNOWN, UNIQUE, UNIQUE → KDBUS_ITEM_NAME_CHANGE + * UNIQUE, "", UNIQUE → KDBUS_ITEM_ID_ADD + * UNIQUE, UNIQUE, "" → KDBUS_ITEM_ID_REMOVE * * For the latter two the two unique names must be identical. * @@ -734,7 +773,7 @@ static int add_name_change_match(sd_bus *bus, return 0; } - if (old_owner) { + if (!isempty(old_owner)) { r = bus_kernel_parse_unique_name(old_owner, &old_owner_id); if (r < 0) return 0; @@ -742,9 +781,10 @@ static int add_name_change_match(sd_bus *bus, return 0; if (is_name_id > 0 && old_owner_id != name_id) return 0; - } + } else + old_owner_id = KDBUS_MATCH_ID_ANY; - if (new_owner) { + if (!isempty(new_owner)) { r = bus_kernel_parse_unique_name(new_owner, &new_owner_id); if (r < 0) return r; @@ -752,44 +792,44 @@ static int add_name_change_match(sd_bus *bus, return 0; if (is_name_id > 0 && new_owner_id != name_id) return 0; - } + } else + new_owner_id = KDBUS_MATCH_ID_ANY; if (is_name_id <= 0) { struct kdbus_cmd_match *m; size_t sz, l; /* If the name argument is missing or is a well-known - * name, then add KDBUS_MATCH_NAME_{ADD,REMOVE,CHANGE} + * name, then add KDBUS_ITEM_NAME_{ADD,REMOVE,CHANGE} * matches for it */ - l = name ? strlen(name) : 0; + l = name ? strlen(name) + 1 : 0; sz = ALIGN8(offsetof(struct kdbus_cmd_match, items) + offsetof(struct kdbus_item, name_change) + offsetof(struct kdbus_notify_name_change, name) + - l+1); + l); m = alloca0(sz); m->size = sz; m->cookie = cookie; - m->src_id = KDBUS_SRC_ID_KERNEL; item = m->items; item->size = offsetof(struct kdbus_item, name_change) + offsetof(struct kdbus_notify_name_change, name) + - l+1; + l; - item->name_change.old_id = old_owner_id; - item->name_change.new_id = new_owner_id; + item->name_change.old.id = old_owner_id; + item->name_change.new.id = new_owner_id; if (name) - strcpy(item->name_change.name, name); + memcpy(item->name_change.name, name, l); /* If the old name is unset or empty, then * this can match against added names */ if (!old_owner || old_owner[0] == 0) { - item->type = KDBUS_MATCH_NAME_ADD; + item->type = KDBUS_ITEM_NAME_ADD; r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_ADD, m); if (r < 0) @@ -799,24 +839,23 @@ static int add_name_change_match(sd_bus *bus, /* If the new name is unset or empty, then * this can match against removed names */ if (!new_owner || new_owner[0] == 0) { - item->type = KDBUS_MATCH_NAME_REMOVE; + item->type = KDBUS_ITEM_NAME_REMOVE; r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_ADD, m); if (r < 0) return -errno; } - /* If the neither name is explicitly set to - * the empty string, then this can match - * agains changed names */ - if (!(old_owner && old_owner[0] == 0) && - !(new_owner && new_owner[0] == 0)) { - item->type = KDBUS_MATCH_NAME_CHANGE; - - r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_ADD, m); - if (r < 0) - return -errno; - } + /* The CHANGE match we need in either case, because + * what is reported as a name change by the kernel + * might just be an owner change between starter and + * normal clients. For userspace such a change should + * be considered a removal/addition, hence let's + * subscribe to this unconditionally. */ + item->type = KDBUS_ITEM_NAME_CHANGE; + r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_ADD, m); + if (r < 0) + return -errno; } if (is_name_id != 0) { @@ -824,7 +863,7 @@ static int add_name_change_match(sd_bus *bus, uint64_t sz; /* If the name argument is missing or is a unique - * name, then add KDBUS_MATCH_ID_{ADD,REMOVE} matches + * name, then add KDBUS_ITEM_ID_{ADD,REMOVE} matches * for it */ sz = ALIGN8(offsetof(struct kdbus_cmd_match, items) + @@ -834,16 +873,17 @@ static int add_name_change_match(sd_bus *bus, m = alloca0(sz); m->size = sz; m->cookie = cookie; - m->src_id = KDBUS_SRC_ID_KERNEL; item = m->items; - item->size = offsetof(struct kdbus_item, id_change) + sizeof(struct kdbus_notify_id_change); + item->size = + offsetof(struct kdbus_item, id_change) + + sizeof(struct kdbus_notify_id_change); item->id_change.id = name_id; /* If the old name is unset or empty, then this can * match against added ids */ if (!old_owner || old_owner[0] == 0) { - item->type = KDBUS_MATCH_ID_ADD; + item->type = KDBUS_ITEM_ID_ADD; r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_ADD, m); if (r < 0) @@ -851,9 +891,9 @@ static int add_name_change_match(sd_bus *bus, } /* If thew new name is unset or empty, then this can - match against removed ids */ + * match against removed ids */ if (!new_owner || new_owner[0] == 0) { - item->type = KDBUS_MATCH_ID_REMOVE; + item->type = KDBUS_ITEM_ID_REMOVE; r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_ADD, m); if (r < 0) @@ -864,9 +904,9 @@ static int add_name_change_match(sd_bus *bus, return 0; } -static int bus_add_match_internal_kernel( +int bus_add_match_internal_kernel( sd_bus *bus, - const char *match, + uint64_t id, struct bus_match_component *components, unsigned n_components, uint64_t cookie) { @@ -877,7 +917,7 @@ static int bus_add_match_internal_kernel( size_t sz; const char *sender = NULL; size_t sender_length = 0; - uint64_t src_id = KDBUS_MATCH_SRC_ID_ANY; + uint64_t src_id = KDBUS_MATCH_ID_ANY; bool using_bloom = false; unsigned i; bool matches_name_change = true; @@ -885,11 +925,10 @@ static int bus_add_match_internal_kernel( int r; assert(bus); - assert(match); zero(bloom); - sz = offsetof(struct kdbus_cmd_match, items); + sz = ALIGN8(offsetof(struct kdbus_cmd_match, items)); for (i = 0; i < n_components; i++) { struct bus_match_component *c = &components[i]; @@ -903,8 +942,9 @@ static int bus_add_match_internal_kernel( r = bus_kernel_parse_unique_name(c->value_str, &src_id); if (r < 0) return r; - - if (r > 0) { + else if (r > 0) + sz += ALIGN8(offsetof(struct kdbus_item, id) + sizeof(uint64_t)); + else { sender = c->value_str; sender_length = strlen(sender); sz += ALIGN8(offsetof(struct kdbus_item, str) + sender_length + 1); @@ -1004,21 +1044,27 @@ static int bus_add_match_internal_kernel( m = alloca0(sz); m->size = sz; m->cookie = cookie; - m->src_id = src_id; + m->owner_id = id; item = m->items; + if (src_id != KDBUS_MATCH_ID_ANY) { + item->size = offsetof(struct kdbus_item, id) + sizeof(uint64_t); + item->type = KDBUS_ITEM_ID; + item->id = src_id; + item = KDBUS_ITEM_NEXT(item); + } + if (using_bloom) { item->size = offsetof(struct kdbus_item, data64) + BLOOM_SIZE; - item->type = KDBUS_MATCH_BLOOM; + item->type = KDBUS_ITEM_BLOOM; memcpy(item->data64, bloom, BLOOM_SIZE); - - item = KDBUS_PART_NEXT(item); + item = KDBUS_ITEM_NEXT(item); } if (sender) { item->size = offsetof(struct kdbus_item, str) + sender_length + 1; - item->type = KDBUS_MATCH_SRC_NAME; + item->type = KDBUS_ITEM_NAME; memcpy(item->str, sender, sender_length + 1); } @@ -1051,7 +1097,7 @@ static int bus_add_match_internal_dbus1( return sd_bus_call_method( bus, "org.freedesktop.DBus", - "/", + "/org/freedesktop/DBus", "org.freedesktop.DBus", "AddMatch", NULL, @@ -1071,25 +1117,25 @@ int bus_add_match_internal( assert(match); if (bus->is_kernel) - return bus_add_match_internal_kernel(bus, match, components, n_components, cookie); + return bus_add_match_internal_kernel(bus, 0, components, n_components, cookie); else return bus_add_match_internal_dbus1(bus, match); } -static int bus_remove_match_internal_kernel( +int bus_remove_match_internal_kernel( sd_bus *bus, - const char *match, + uint64_t id, uint64_t cookie) { struct kdbus_cmd_match m; int r; assert(bus); - assert(match); zero(m); m.size = offsetof(struct kdbus_cmd_match, items); m.cookie = cookie; + m.owner_id = id; r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_REMOVE, &m); if (r < 0) @@ -1108,7 +1154,7 @@ static int bus_remove_match_internal_dbus1( return sd_bus_call_method( bus, "org.freedesktop.DBus", - "/", + "/org/freedesktop/DBus", "org.freedesktop.DBus", "RemoveMatch", NULL, @@ -1126,7 +1172,7 @@ int bus_remove_match_internal( assert(match); if (bus->is_kernel) - return bus_remove_match_internal_kernel(bus, match, cookie); + return bus_remove_match_internal_kernel(bus, 0, cookie); else return bus_remove_match_internal_dbus1(bus, match); } @@ -1141,6 +1187,7 @@ _public_ int sd_bus_get_owner_machine_id(sd_bus *bus, const char *name, sd_id128 assert_return(machine, -EINVAL); assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); assert_return(!bus_pid_changed(bus), -ECHILD); + assert_return(service_name_is_valid(name), -EINVAL); if (streq_ptr(name, bus->unique_name)) return sd_id128_get_machine(machine);