diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-01-29 21:23:41 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-01-29 21:26:57 +0100 |
commit | 7b217f41d2e31330b47aeaadbd3bf93c9eb1ce46 (patch) | |
tree | 2b6945533ce7798f068ace75df88982ba3bf6947 /src/bus-proxyd | |
parent | e7b251913e8a2189de14778b6e92c08764ab2012 (diff) |
bus: when proxying messages from the bus driver patch the driver's well-known name into the sender
Diffstat (limited to 'src/bus-proxyd')
-rw-r--r-- | src/bus-proxyd/bus-proxyd.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c index b03845921f..ab9b836ff0 100644 --- a/src/bus-proxyd/bus-proxyd.c +++ b/src/bus-proxyd/bus-proxyd.c @@ -395,6 +395,36 @@ static int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, bool *got_hell return 1; } +static int patch_sender(sd_bus *a, sd_bus_message *m) { + char **well_known = NULL; + sd_bus_creds *c; + int r; + + assert(a); + assert(m); + + if (!a->is_kernel) + return 0; + + /* We will change the sender of messages from the bus driver + * so that they originate from the bus driver. This is a + * speciality originating from dbus1, where the bus driver did + * not have a unique id, but only the well-known name. */ + + c = sd_bus_message_get_creds(m); + if (!c) + return 0; + + r = sd_bus_creds_get_well_known_names(c, &well_known); + if (r < 0) + return r; + + if (strv_contains(well_known, "org.freedesktop.DBus")) + m->sender = "org.freedesktop.DBus"; + + return 0; +} + int main(int argc, char *argv[]) { _cleanup_bus_unref_ sd_bus *a = NULL, *b = NULL; @@ -612,6 +642,8 @@ int main(int argc, char *argv[]) { goto finish; } + patch_sender(a, m); + k = sd_bus_send(b, m, NULL); if (k < 0) { if (k == -ECONNRESET) |