summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-27 02:37:05 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-27 22:02:12 +0100
commitac653862e0a99505727dc8861e734d8d6f2b0afd (patch)
treed8183f49afbf9800cad1ef165c3b5fa979848303 /src/libsystemd
parent50c4521675e94ade38b8af9e3b0f7fd2f300b6f4 (diff)
sd-bus: fake valid well-known-names metadata for faked bus messages
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-bus/bus-creds.c12
-rw-r--r--src/libsystemd/sd-bus/bus-creds.h1
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c10
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)