diff options
-rw-r--r-- | src/libsystemd/sd-bus/bus-creds.c | 12 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-creds.h | 1 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-kernel.c | 10 |
3 files changed, 21 insertions, 2 deletions
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c index ad0e2e1ba7..e3bdda83de 100644 --- a/src/libsystemd/sd-bus/bus-creds.c +++ b/src/libsystemd/sd-bus/bus-creds.c @@ -551,6 +551,18 @@ _public_ int sd_bus_creds_get_well_known_names(sd_bus_creds *c, char ***well_kno if (!(c->mask & SD_BUS_CREDS_WELL_KNOWN_NAMES)) return -ENODATA; + /* As a special hack we return the bus driver as well-known + * names list when this is requested. */ + if (c->well_known_names_driver) { + static const char* const wkn[] = { + "org.freedesktop.DBus", + NULL + }; + + *well_known_names = (char**) wkn; + return 0; + } + *well_known_names = c->well_known_names; return 0; } diff --git a/src/libsystemd/sd-bus/bus-creds.h b/src/libsystemd/sd-bus/bus-creds.h index 882110bb69..9d6a5bfc9c 100644 --- a/src/libsystemd/sd-bus/bus-creds.h +++ b/src/libsystemd/sd-bus/bus-creds.h @@ -72,6 +72,7 @@ struct sd_bus_creds { char *unique_name; char **well_known_names; + bool well_known_names_driver; char *cgroup_root; diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c index 1276cd841a..9349c1d79d 100644 --- a/src/libsystemd/sd-bus/bus-kernel.c +++ b/src/libsystemd/sd-bus/bus-kernel.c @@ -737,9 +737,11 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) { } /* Override information from the user header with data from the kernel */ - if (k->src_id == KDBUS_SRC_ID_KERNEL) + if (k->src_id == KDBUS_SRC_ID_KERNEL) { m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus"; - else { + m->creds.well_known_names_driver = true; + m->creds.mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES & bus->creds_mask; + } else { snprintf(m->sender_buffer, sizeof(m->sender_buffer), ":1.%llu", (unsigned long long) k->src_id); m->sender = m->creds.unique_name = m->sender_buffer; } @@ -1074,6 +1076,8 @@ static int push_name_owner_changed(sd_bus *bus, const char *name, const char *ol return r; m->sender = "org.freedesktop.DBus"; + m->creds.well_known_names_driver = true; + m->creds.mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES & bus->creds_mask; r = bus_seal_synthetic_message(bus, m); if (r < 0) @@ -1143,6 +1147,8 @@ static int translate_reply(sd_bus *bus, struct kdbus_msg *k, struct kdbus_item * return r; m->sender = "org.freedesktop.DBus"; + m->creds.well_known_names_driver = true; + m->creds.mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES & bus->creds_mask; r = bus_seal_synthetic_message(bus, m); if (r < 0) |