bus-control.c revision 0aa72be6a02e8bbcb364526b8e1904a94b81a547
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering This file is part of systemd.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering Copyright 2013 Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering systemd is free software; you can redistribute it and/or modify it
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering under the terms of the GNU Lesser General Public License as published by
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering (at your option) any later version.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering systemd is distributed in the hope that it will be useful, but
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering Lesser General Public License for more details.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering You should have received a copy of the GNU Lesser General Public License
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
4cee5eede280b7fd48c18a1942616c4ac896a554Lennart Poettering_public_ int sd_bus_get_unique_name(sd_bus *bus, const char **unique) {
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering assert_return(!bus_pid_changed(bus), -ECHILD);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringstatic int bus_request_name_kernel(sd_bus *bus, const char *name, uint64_t flags) {
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering size = offsetof(struct kdbus_cmd_name, items) + KDBUS_ITEM_SIZE(l);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering n->flags = request_name_flags_to_kdbus(flags);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering n->items[0].size = KDBUS_ITEM_HEADER_SIZE + l;
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering r = ioctl(bus->input_fd, KDBUS_CMD_NAME_ACQUIRE, n);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringstatic int bus_request_name_dbus1(sd_bus *bus, const char *name, uint64_t flags) {
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering if (flags & SD_BUS_NAME_ALLOW_REPLACEMENT)
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering if (flags & SD_BUS_NAME_REPLACE_EXISTING)
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering "org.freedesktop.DBus",
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering "org.freedesktop.DBus",
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering "RequestName",
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering r = sd_bus_message_read(reply, "u", &ret);
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering_public_ int sd_bus_request_name(sd_bus *bus, const char *name, uint64_t flags) {
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering assert_return(!bus_pid_changed(bus), -ECHILD);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering assert_return(!(flags & ~(SD_BUS_NAME_ALLOW_REPLACEMENT|SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_QUEUE)), -EINVAL);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering assert_return(service_name_is_valid(name), -EINVAL);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering return bus_request_name_kernel(bus, name, flags);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering return bus_request_name_dbus1(bus, name, flags);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poetteringstatic int bus_release_name_kernel(sd_bus *bus, const char *name) {
c2ce6a3d82b717c4c1e6245ad8c6ce1173f502d0Lennart Poettering size = offsetof(struct kdbus_cmd_name, items) + KDBUS_ITEM_SIZE(l);
c2ce6a3d82b717c4c1e6245ad8c6ce1173f502d0Lennart Poettering n->items[0].size = KDBUS_ITEM_HEADER_SIZE + l;
c2ce6a3d82b717c4c1e6245ad8c6ce1173f502d0Lennart Poettering r = ioctl(bus->input_fd, KDBUS_CMD_NAME_RELEASE, n);
c2ce6a3d82b717c4c1e6245ad8c6ce1173f502d0Lennart Poetteringstatic int bus_release_name_dbus1(sd_bus *bus, const char *name) {
c2ce6a3d82b717c4c1e6245ad8c6ce1173f502d0Lennart Poettering _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
4e724d9c5ab76c3f8327945317463ef706011082Lennart Poettering "org.freedesktop.DBus",
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering "org.freedesktop.DBus",
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering "ReleaseName",
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering r = sd_bus_message_read(reply, "u", &ret);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering_public_ int sd_bus_release_name(sd_bus *bus, const char *name) {
de0671ee7fe465e108f62dcbbbe9366f81dd9e9aZbigniew Jędrzejewski-Szmek assert_return(!bus_pid_changed(bus), -ECHILD);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering assert_return(service_name_is_valid(name), -EINVAL);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering return bus_release_name_kernel(bus, name);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering return bus_release_name_dbus1(bus, name);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poetteringstatic int kernel_get_list(sd_bus *bus, uint64_t flags, char ***x) {
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering /* Caller will free half-constructed list on failure... */
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering r = ioctl(bus->input_fd, KDBUS_CMD_NAME_LIST, &cmd);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering name_list = (struct kdbus_name_list *) ((uint8_t *) bus->kdbus_buffer + cmd.offset);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering KDBUS_ITEM_FOREACH(name, name_list, names) {
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering if ((flags & KDBUS_NAME_LIST_UNIQUE) && name->owner_id != previous_id) {
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering if (asprintf(&n, ":1.%llu", (unsigned long long) name->owner_id) < 0) {
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering if (entry_name && service_name_is_valid(entry_name)) {
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poetteringstatic int bus_list_names_kernel(sd_bus *bus, char ***acquired, char ***activatable) {
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering _cleanup_strv_free_ char **x = NULL, **y = NULL;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering r = kernel_get_list(bus, KDBUS_NAME_LIST_UNIQUE | KDBUS_NAME_LIST_NAMES, &x);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering r = kernel_get_list(bus, KDBUS_NAME_LIST_ACTIVATORS, &y);
9b5ed6feda08290edce3bf916fa7362733dd30eaLennart Poetteringstatic int bus_list_names_dbus1(sd_bus *bus, char ***acquired, char ***activatable) {
9b5ed6feda08290edce3bf916fa7362733dd30eaLennart Poettering _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
9b5ed6feda08290edce3bf916fa7362733dd30eaLennart Poettering _cleanup_strv_free_ char **x = NULL, **y = NULL;
ebcf1f97de4f6b1580ae55eb56b1a3939fe6b602Lennart Poettering "org.freedesktop.DBus",
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering "org.freedesktop.DBus",
ebcf1f97de4f6b1580ae55eb56b1a3939fe6b602Lennart Poettering "org.freedesktop.DBus",
554604b3073467af75dc94fac9e2343148603289Lennart Poettering "org.freedesktop.DBus",
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering "ListActivatableNames",
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering_public_ int sd_bus_list_names(sd_bus *bus, char ***acquired, char ***activatable) {
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering assert_return(acquired || activatable, -EINVAL);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering assert_return(!bus_pid_changed(bus), -ECHILD);
9b5ed6feda08290edce3bf916fa7362733dd30eaLennart Poettering return bus_list_names_kernel(bus, acquired, activatable);
9b5ed6feda08290edce3bf916fa7362733dd30eaLennart Poettering return bus_list_names_dbus1(bus, acquired, activatable);
89f7c8465cd1ab37347dd0c15920bce31e8225dfLennart Poettering if (mask & SD_BUS_CREDS_PID && item->pids.pid > 0) {
89f7c8465cd1ab37347dd0c15920bce31e8225dfLennart Poettering if (mask & SD_BUS_CREDS_TID && item->pids.tid > 0) {
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering if (mask & SD_BUS_CREDS_PID_STARTTIME && item->pids.starttime > 0) {
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering if (mask & SD_BUS_CREDS_UID && (uid_t) item->creds.uid != UID_INVALID) {
9b5ed6feda08290edce3bf916fa7362733dd30eaLennart Poettering if (mask & SD_BUS_CREDS_EUID && (uid_t) item->creds.euid != UID_INVALID) {
89f7c8465cd1ab37347dd0c15920bce31e8225dfLennart Poettering if (mask & SD_BUS_CREDS_SUID && (uid_t) item->creds.suid != UID_INVALID) {
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering if (mask & SD_BUS_CREDS_FSUID && (uid_t) item->creds.fsuid != UID_INVALID) {
89f7c8465cd1ab37347dd0c15920bce31e8225dfLennart Poettering if (mask & SD_BUS_CREDS_GID && (gid_t) item->creds.gid != GID_INVALID) {
89f7c8465cd1ab37347dd0c15920bce31e8225dfLennart Poettering if (mask & SD_BUS_CREDS_EGID && (gid_t) item->creds.egid != GID_INVALID) {
89f7c8465cd1ab37347dd0c15920bce31e8225dfLennart Poettering if (mask & SD_BUS_CREDS_SGID && (gid_t) item->creds.sgid != GID_INVALID) {
89f7c8465cd1ab37347dd0c15920bce31e8225dfLennart Poettering if (mask & SD_BUS_CREDS_FSGID && (gid_t) item->creds.fsgid != GID_INVALID) {
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering r = free_and_strdup(&c->comm, item->str);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering r = free_and_strdup(&c->tid_comm, item->str);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering c->cmdline_size = item->size - offsetof(struct kdbus_item, data);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering c->cmdline = memdup(item->data, c->cmdline_size);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering m = (SD_BUS_CREDS_CGROUP | SD_BUS_CREDS_UNIT |
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering SD_BUS_CREDS_USER_UNIT | SD_BUS_CREDS_SLICE |
ebcf1f97de4f6b1580ae55eb56b1a3939fe6b602Lennart Poettering SD_BUS_CREDS_SESSION | SD_BUS_CREDS_OWNER_UID) & mask;
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering r = free_and_strdup(&c->cgroup, item->str);
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering r = free_and_strdup(&c->cgroup_root, bus->cgroup_root);
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering m = (SD_BUS_CREDS_EFFECTIVE_CAPS | SD_BUS_CREDS_PERMITTED_CAPS |
878cd7e95ca303f9851d227a22d2022bd49944b0Lennart Poettering SD_BUS_CREDS_INHERITABLE_CAPS | SD_BUS_CREDS_BOUNDING_CAPS) & mask;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering c->capability_size = item->size - offsetof(struct kdbus_item, caps.caps);
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering c->capability = memdup(item->caps.caps, c->capability_size);
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering if (mask & SD_BUS_CREDS_SELINUX_CONTEXT) {
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering r = free_and_strdup(&c->label, item->str);
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering if (mask & SD_BUS_CREDS_AUDIT_SESSION_ID && (uint32_t) item->audit.sessionid != (uint32_t) -1) {
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering c->audit_session_id = (uint32_t) item->audit.sessionid;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering c->mask |= SD_BUS_CREDS_AUDIT_SESSION_ID;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering if (mask & SD_BUS_CREDS_AUDIT_LOGIN_UID && (uid_t) item->audit.loginuid != UID_INVALID) {
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering c->audit_login_uid = (uid_t) item->audit.loginuid;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering if ((mask & SD_BUS_CREDS_WELL_KNOWN_NAMES) && service_name_is_valid(item->name.name)) {
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering r = strv_extend(&c->well_known_names, item->name.name);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering c->mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering r = free_and_strdup(&c->description, item->str);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering if (mask & SD_BUS_CREDS_SUPPLEMENTARY_GIDS) {
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering assert_cc(sizeof(gid_t) == sizeof(uint32_t));
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering n = (item->size - offsetof(struct kdbus_item, data32)) / sizeof(uint32_t);
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poettering c->mask |= SD_BUS_CREDS_SUPPLEMENTARY_GIDS;
40205d706e1210763ff4c98a317556375bd04bcdLennart Poettering _cleanup_bus_creds_unref_ sd_bus_creds *c = NULL;
40205d706e1210763ff4c98a317556375bd04bcdLennart Poettering r = bus_kernel_parse_unique_name(name, &id);
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering size = offsetof(struct kdbus_cmd_info, items);
5f8cc96a0301c1177b11dd2e89370ef0b2ef577bLennart Poettering size = offsetof(struct kdbus_cmd_info, items) + KDBUS_ITEM_SIZE(l);
5f8cc96a0301c1177b11dd2e89370ef0b2ef577bLennart Poettering cmd->items[0].size = KDBUS_ITEM_HEADER_SIZE + l;
5f8cc96a0301c1177b11dd2e89370ef0b2ef577bLennart Poettering cmd->flags = attach_flags_to_kdbus(mask);
5f8cc96a0301c1177b11dd2e89370ef0b2ef577bLennart Poettering /* If augmentation is on, and the bus doesn't didn't allow us
5f8cc96a0301c1177b11dd2e89370ef0b2ef577bLennart Poettering * to get the bits we want, then ask for the PID/TID so that we
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering * can read the rest from /proc. */
5f8cc96a0301c1177b11dd2e89370ef0b2ef577bLennart Poettering (mask & (SD_BUS_CREDS_UID|SD_BUS_CREDS_EUID|SD_BUS_CREDS_SUID|SD_BUS_CREDS_FSUID|
49af9e1368571f4e423cde0fd45ee284451434d1Lennart Poettering SD_BUS_CREDS_GID|SD_BUS_CREDS_EGID|SD_BUS_CREDS_SGID|SD_BUS_CREDS_FSGID|
49af9e1368571f4e423cde0fd45ee284451434d1Lennart Poettering SD_BUS_CREDS_COMM|SD_BUS_CREDS_TID_COMM|SD_BUS_CREDS_EXE|SD_BUS_CREDS_CMDLINE|
49af9e1368571f4e423cde0fd45ee284451434d1Lennart Poettering 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|
49af9e1368571f4e423cde0fd45ee284451434d1Lennart Poettering SD_BUS_CREDS_EFFECTIVE_CAPS|SD_BUS_CREDS_PERMITTED_CAPS|SD_BUS_CREDS_INHERITABLE_CAPS|SD_BUS_CREDS_BOUNDING_CAPS|
49af9e1368571f4e423cde0fd45ee284451434d1Lennart Poettering SD_BUS_CREDS_AUDIT_SESSION_ID|SD_BUS_CREDS_AUDIT_LOGIN_UID)))
49af9e1368571f4e423cde0fd45ee284451434d1Lennart Poettering r = ioctl(bus->input_fd, KDBUS_CMD_CONN_INFO, cmd);
49af9e1368571f4e423cde0fd45ee284451434d1Lennart Poettering conn_info = (struct kdbus_info *) ((uint8_t *) bus->kdbus_buffer + cmd->offset);
49af9e1368571f4e423cde0fd45ee284451434d1Lennart Poettering /* Non-activated names are considered not available */
49af9e1368571f4e423cde0fd45ee284451434d1Lennart Poettering if (!allow_activator && (conn_info->flags & KDBUS_HELLO_ACTIVATOR)) {
90adaa25e894a580930ef2c3e65ab8db8295515aLennart Poettering if (asprintf(&c->unique_name, ":1.%llu", (unsigned long long) conn_info->id) < 0) {
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering /* If KDBUS_ITEM_OWNED_NAME is requested then we'll get 0 of
90adaa25e894a580930ef2c3e65ab8db8295515aLennart Poettering them in case the service has no names. This does not mean
90adaa25e894a580930ef2c3e65ab8db8295515aLennart Poettering however that the list of owned names could not be
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering acquired. Hence, let's explicitly clarify that the data is
0370612e0522191f929e3feb7d4937fff3d421e2Lennart Poettering c->mask |= mask & SD_BUS_CREDS_WELL_KNOWN_NAMES;
0370612e0522191f929e3feb7d4937fff3d421e2Lennart Poettering r = bus_populate_creds_from_items(bus, conn_info, mask, c);
086821244b5113f00a0ef993b78dc56aae2a8f6cLennart Poettering _cleanup_bus_message_unref_ sd_bus_message *reply_unique = NULL, *reply = NULL;
086821244b5113f00a0ef993b78dc56aae2a8f6cLennart Poettering _cleanup_bus_creds_unref_ sd_bus_creds *c = NULL;
086821244b5113f00a0ef993b78dc56aae2a8f6cLennart Poettering /* Only query the owner if the caller wants to know it or if
086821244b5113f00a0ef993b78dc56aae2a8f6cLennart Poettering * the caller just wants to check whether a name exists */
086821244b5113f00a0ef993b78dc56aae2a8f6cLennart Poettering if ((mask & SD_BUS_CREDS_UNIQUE_NAME) || mask == 0) {
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering "org.freedesktop.DBus",
086821244b5113f00a0ef993b78dc56aae2a8f6cLennart Poettering "org.freedesktop.DBus",
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering "GetNameOwner",
ebd93cb684806ac0f352139e69ac8f53eb49f5e4Lennart Poettering r = sd_bus_message_read(reply_unique, "s", &unique);
ebd93cb684806ac0f352139e69ac8f53eb49f5e4Lennart Poettering if ((mask & SD_BUS_CREDS_UNIQUE_NAME) && unique) {
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering SD_BUS_CREDS_EUID|SD_BUS_CREDS_SUID|SD_BUS_CREDS_FSUID|
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering SD_BUS_CREDS_GID|SD_BUS_CREDS_EGID|SD_BUS_CREDS_SGID|SD_BUS_CREDS_FSGID|
1ddb263d21099ae42195c2bc382bdf72a7f24f82Lennart Poettering SD_BUS_CREDS_COMM|SD_BUS_CREDS_EXE|SD_BUS_CREDS_CMDLINE|
ebd93cb684806ac0f352139e69ac8f53eb49f5e4Lennart Poettering 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|
ebd93cb684806ac0f352139e69ac8f53eb49f5e4Lennart Poettering SD_BUS_CREDS_EFFECTIVE_CAPS|SD_BUS_CREDS_PERMITTED_CAPS|SD_BUS_CREDS_INHERITABLE_CAPS|SD_BUS_CREDS_BOUNDING_CAPS|
ebd93cb684806ac0f352139e69ac8f53eb49f5e4Lennart Poettering SD_BUS_CREDS_AUDIT_SESSION_ID|SD_BUS_CREDS_AUDIT_LOGIN_UID)))) {
ebd93cb684806ac0f352139e69ac8f53eb49f5e4Lennart Poettering "org.freedesktop.DBus",
ebd93cb684806ac0f352139e69ac8f53eb49f5e4Lennart Poettering "org.freedesktop.DBus",
70244d1d25eb80b57e160ea004d0e6bf793d4cafLennart Poettering "GetConnectionUnixProcessID",
ebd93cb684806ac0f352139e69ac8f53eb49f5e4Lennart Poettering "org.freedesktop.DBus",
190700621f95160d364f8ec1d3e360246c41ce75Lennart Poettering "org.freedesktop.DBus",
d6ce17c7f02ed3facdb45f65f546e587c2f00950Lennart Poettering "GetConnectionUnixUser",
d6ce17c7f02ed3facdb45f65f546e587c2f00950Lennart Poettering if (mask & SD_BUS_CREDS_SELINUX_CONTEXT) {
d6ce17c7f02ed3facdb45f65f546e587c2f00950Lennart Poettering _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
d6ce17c7f02ed3facdb45f65f546e587c2f00950Lennart Poettering const void *p = NULL;
4cee5eede280b7fd48c18a1942616c4ac896a554Lennart Poettering "org.freedesktop.DBus",
4cee5eede280b7fd48c18a1942616c4ac896a554Lennart Poettering "org.freedesktop.DBus",
26166c88e0b47b83972f32b5057ecbffe06bf904Lennart Poettering "GetConnectionSELinuxSecurityContext",
d6ce17c7f02ed3facdb45f65f546e587c2f00950Lennart Poettering if (!sd_bus_error_has_name(&error, "org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown"))
26166c88e0b47b83972f32b5057ecbffe06bf904Lennart Poettering r = sd_bus_message_read_array(reply, 'y', &p, &sz);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering assert_return((mask & ~SD_BUS_CREDS_AUGMENT) <= _SD_BUS_CREDS_ALL, -ENOTSUP);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering assert_return(mask == 0 || creds, -EINVAL);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering assert_return(!bus_pid_changed(bus), -ECHILD);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering assert_return(service_name_is_valid(name), -EINVAL);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering assert_return(bus->bus_client, -ENODATA);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering return bus_get_name_creds_kdbus(bus, name, mask, false, creds);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering return bus_get_name_creds_dbus1(bus, name, mask, creds);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poetteringstatic int bus_get_owner_creds_kdbus(sd_bus *bus, uint64_t mask, sd_bus_creds **ret) {
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering _cleanup_bus_creds_unref_ sd_bus_creds *c = NULL;
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering /* If augmentation is on, and the bus doesn't didn't allow us
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * to get the bits we want, then ask for the PID/TID so that we
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * can read the rest from /proc. */
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering (mask & (SD_BUS_CREDS_UID|SD_BUS_CREDS_EUID|SD_BUS_CREDS_SUID|SD_BUS_CREDS_FSUID|
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering SD_BUS_CREDS_GID|SD_BUS_CREDS_EGID|SD_BUS_CREDS_SGID|SD_BUS_CREDS_FSGID|
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering SD_BUS_CREDS_COMM|SD_BUS_CREDS_TID_COMM|SD_BUS_CREDS_EXE|SD_BUS_CREDS_CMDLINE|
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering 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|
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering SD_BUS_CREDS_EFFECTIVE_CAPS|SD_BUS_CREDS_PERMITTED_CAPS|SD_BUS_CREDS_INHERITABLE_CAPS|SD_BUS_CREDS_BOUNDING_CAPS|
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering SD_BUS_CREDS_AUDIT_SESSION_ID|SD_BUS_CREDS_AUDIT_LOGIN_UID)))
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering r = ioctl(bus->input_fd, KDBUS_CMD_BUS_CREATOR_INFO, &cmd);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering creator_info = (struct kdbus_info *) ((uint8_t *) bus->kdbus_buffer + cmd.offset);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering r = bus_populate_creds_from_items(bus, creator_info, mask, c);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poetteringstatic int bus_get_owner_creds_dbus1(sd_bus *bus, uint64_t mask, sd_bus_creds **ret) {
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering _cleanup_bus_creds_unref_ sd_bus_creds *c = NULL;
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering if (!bus->ucred_valid && !isempty(bus->label))
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering if (!isempty(bus->label) && (mask & SD_BUS_CREDS_SELINUX_CONTEXT)) {
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering_public_ int sd_bus_get_owner_creds(sd_bus *bus, uint64_t mask, sd_bus_creds **ret) {
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering assert_return((mask & ~SD_BUS_CREDS_AUGMENT) <= _SD_BUS_CREDS_ALL, -ENOTSUP);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering assert_return(!bus_pid_changed(bus), -ECHILD);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering return bus_get_owner_creds_kdbus(bus, mask, ret);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering return bus_get_owner_creds_dbus1(bus, mask, ret);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poetteringstatic int add_name_change_match(sd_bus *bus,
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering uint64_t name_id = KDBUS_MATCH_ID_ANY, old_owner_id = 0, new_owner_id = 0;
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering /* If we encounter a match that could match against
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * NameOwnerChanged messages, then we need to create
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * KDBUS_ITEM_NAME_{ADD,REMOVE,CHANGE} and
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * KDBUS_ITEM_ID_{ADD,REMOVE} matches for it, possibly
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * multiple if the match is underspecified.
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * The NameOwnerChanged signals take three parameters with
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * unique or well-known names, but only some forms actually
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * WELLKNOWN, "", UNIQUE → KDBUS_ITEM_NAME_ADD
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * WELLKNOWN, UNIQUE, "" → KDBUS_ITEM_NAME_REMOVE
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * WELLKNOWN, UNIQUE, UNIQUE → KDBUS_ITEM_NAME_CHANGE
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * UNIQUE, "", UNIQUE → KDBUS_ITEM_ID_ADD
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * UNIQUE, UNIQUE, "" → KDBUS_ITEM_ID_REMOVE
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * For the latter two the two unique names must be identical.
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering is_name_id = bus_kernel_parse_unique_name(name, &name_id);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering r = bus_kernel_parse_unique_name(old_owner, &old_owner_id);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering if (is_name_id > 0 && old_owner_id != name_id)
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering r = bus_kernel_parse_unique_name(new_owner, &new_owner_id);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering if (is_name_id > 0 && new_owner_id != name_id)
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering /* If the name argument is missing or is a well-known
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * name, then add KDBUS_ITEM_NAME_{ADD,REMOVE,CHANGE}
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * matches for it */
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering sz = ALIGN8(offsetof(struct kdbus_cmd_match, items) +
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering offsetof(struct kdbus_item, name_change) +
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering offsetof(struct kdbus_notify_name_change, name) +
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering offsetof(struct kdbus_item, name_change) +
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering offsetof(struct kdbus_notify_name_change, name) +
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering item->name_change.old_id.id = old_owner_id;
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering item->name_change.new_id.id = new_owner_id;
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering /* If the old name is unset or empty, then
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * this can match against added names */
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_ADD, m);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering /* If the new name is unset or empty, then
adacb9575a09981fcf11279f2f661e3fc21e58ffLennart Poettering * this can match against removed names */
b6b1849830f5e4a6065c3b0c993668e500c954d3Lennart Poettering r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_ADD, m);
70244d1d25eb80b57e160ea004d0e6bf793d4cafLennart Poettering /* The CHANGE match we need in either case, because
70244d1d25eb80b57e160ea004d0e6bf793d4cafLennart Poettering * what is reported as a name change by the kernel
3a6fb33c54bc64398e0af1c9d7c74a6b614a849dLennart Poettering * might just be an owner change between starter and
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering * normal clients. For userspace such a change should
40205d706e1210763ff4c98a317556375bd04bcdLennart Poettering * be considered a removal/addition, hence let's
d04c1fb8e215600b4950c6778c6c16ddafc14024Lennart Poettering * subscribe to this unconditionally. */
70244d1d25eb80b57e160ea004d0e6bf793d4cafLennart Poettering r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_ADD, m);
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering /* If the name argument is missing or is a unique
c01ff965b48bb9693dcd77cbc748b5d8676766b0Lennart Poettering * name, then add KDBUS_ITEM_ID_{ADD,REMOVE} matches
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering sz = ALIGN8(offsetof(struct kdbus_cmd_match, items) +
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering /* If the old name is unset or empty, then this can
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering * match against added ids */
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_ADD, m);
6797c324a653f119a3d7133122648aaa4878ddd6Lennart Poettering /* If thew new name is unset or empty, then this can
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering * match against removed ids */
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_ADD, m);
ebcf1f97de4f6b1580ae55eb56b1a3939fe6b602Lennart Poettering sz = ALIGN8(offsetof(struct kdbus_cmd_match, items));
e5f5b5b9c92d59ef3cb5169982cb6f436c9206faLennart Poettering for (i = 0; i < n_components; i++) {
9b420b3cfb8b93daf50e4cdbc92b05f2209ef893Lennart Poettering struct bus_match_component *c = &components[i];
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering if (!streq(c->value_str, "org.freedesktop.DBus"))
9b420b3cfb8b93daf50e4cdbc92b05f2209ef893Lennart Poettering r = bus_kernel_parse_unique_name(c->value_str, &src_id);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering else if (r > 0)
554604b3073467af75dc94fac9e2343148603289Lennart Poettering sz += ALIGN8(offsetof(struct kdbus_item, id) + sizeof(uint64_t));
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering sz += ALIGN8(offsetof(struct kdbus_item, str) + sender_length + 1);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering if (c->value_u8 != SD_BUS_MESSAGE_SIGNAL)
9b420b3cfb8b93daf50e4cdbc92b05f2209ef893Lennart Poettering bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, "message-type", bus_message_type_to_string(c->value_u8));
9b420b3cfb8b93daf50e4cdbc92b05f2209ef893Lennart Poettering if (!streq(c->value_str, "org.freedesktop.DBus"))
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, "interface", c->value_str);
a658cafa98ab55ea948c29bc87eb3945d515fb41Lennart Poettering if (!streq(c->value_str, "NameOwnerChanged"))
554604b3073467af75dc94fac9e2343148603289Lennart Poettering bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, "member", c->value_str);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering if (!streq(c->value_str, "/org/freedesktop/DBus"))
554604b3073467af75dc94fac9e2343148603289Lennart Poettering bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, "path", c->value_str);
554604b3073467af75dc94fac9e2343148603289Lennart Poettering bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, "path-slash-prefix", c->value_str);
554604b3073467af75dc94fac9e2343148603289Lennart Poettering case BUS_MATCH_ARG...BUS_MATCH_ARG_LAST: {
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering name_change_arg[c->type - BUS_MATCH_ARG] = c->value_str;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering snprintf(buf, sizeof(buf), "arg%u", c->type - BUS_MATCH_ARG);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, buf, c->value_str);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering case BUS_MATCH_ARG_PATH...BUS_MATCH_ARG_PATH_LAST: {
554604b3073467af75dc94fac9e2343148603289Lennart Poettering char buf[sizeof("arg")-1 + 2 + sizeof("-slash-prefix")];
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering snprintf(buf, sizeof(buf), "arg%u-slash-prefix", c->type - BUS_MATCH_ARG_PATH);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, buf, c->value_str);
151b9b9662a90455262ce575a8a8ae74bf4ff336Lennart Poettering case BUS_MATCH_ARG_NAMESPACE...BUS_MATCH_ARG_NAMESPACE_LAST: {
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering char buf[sizeof("arg")-1 + 2 + sizeof("-dot-prefix")];
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering snprintf(buf, sizeof(buf), "arg%u-dot-prefix", c->type - BUS_MATCH_ARG_NAMESPACE);
151b9b9662a90455262ce575a8a8ae74bf4ff336Lennart Poettering bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, buf, c->value_str);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering /* The bloom filter does not include
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering the destination, since it is only
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering available for broadcast messages
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering which do not carry a destination
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering since they are undirected. */
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering assert_not_reached("Invalid match type?");
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering sz += ALIGN8(offsetof(struct kdbus_item, data64) + bus->bloom_size);
554604b3073467af75dc94fac9e2343148603289Lennart Poettering item->size = offsetof(struct kdbus_item, id) + sizeof(uint64_t);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering item->size = offsetof(struct kdbus_item, data64) + bus->bloom_size;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering memcpy(item->data64, bloom, bus->bloom_size);
c49b30a23583ff39daaa26696bcab478d2fee0bbLennart Poettering item->size = offsetof(struct kdbus_item, str) + sender_length + 1;
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering memcpy(item->str, sender, sender_length + 1);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_ADD, m);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering /* If this match could theoretically match
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering * NameOwnerChanged messages, we need to
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering * install a second non-bloom filter explitly
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering r = add_name_change_match(bus, cookie, name_change_arg[0], name_change_arg[1], name_change_arg[2]);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering ((bus)->hello_flags & KDBUS_HELLO_MONITOR \
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering ? (isempty(m) ? "eavesdrop='true'" : strappenda((m), ",eavesdrop='true'")) \
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering const char *match) {
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering const char *e;
6797c324a653f119a3d7133122648aaa4878ddd6Lennart Poettering "org.freedesktop.DBus",
6797c324a653f119a3d7133122648aaa4878ddd6Lennart Poettering "org.freedesktop.DBus",
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering return bus_add_match_internal_kernel(bus, components, n_components, cookie);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering return bus_add_match_internal_dbus1(bus, match);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering m.size = offsetof(struct kdbus_cmd_match, items);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_REMOVE, &m);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poetteringstatic int bus_remove_match_internal_dbus1(
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering const char *match) {
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering const char *e;
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering "org.freedesktop.DBus",
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering "org.freedesktop.DBus",
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering "RemoveMatch",
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering return bus_remove_match_internal_kernel(bus, cookie);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering return bus_remove_match_internal_dbus1(bus, match);
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering_public_ int sd_bus_get_name_machine_id(sd_bus *bus, const char *name, sd_id128_t *machine) {
9b420b3cfb8b93daf50e4cdbc92b05f2209ef893Lennart Poettering _cleanup_bus_message_unref_ sd_bus_message *reply = NULL, *m = NULL;
bd16acf35e13a19cd2ded0a0c2ef774a98f73808Zbigniew Jędrzejewski-Szmek assert_return(!bus_pid_changed(bus), -ECHILD);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering assert_return(service_name_is_valid(name), -EINVAL);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering "org.freedesktop.DBus.Peer",
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering "GetMachineId");
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poettering r = sd_bus_message_set_auto_start(m, false);
bd16acf35e13a19cd2ded0a0c2ef774a98f73808Zbigniew Jędrzejewski-Szmek r = sd_bus_call(bus, m, 0, NULL, &reply);