summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-27 02:57:22 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-27 22:02:12 +0100
commit7d31d92400bab9648016136da1b1e8c5cff1bfcf (patch)
treeaf31f59a8eecb69603725e47141a340e6b6bb743
parentac653862e0a99505727dc8861e734d8d6f2b0afd (diff)
sd-bus: unify logic how we patch the message source of driver messages
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 9349c1d79d..3a3ed200a0 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -348,6 +348,15 @@ fail:
return r;
}
+static void bus_message_set_sender_driver(sd_bus *bus, sd_bus_message *m) {
+ assert(bus);
+ assert(m);
+
+ m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus";
+ m->creds.well_known_names_driver = true;
+ m->creds.mask |= (SD_BUS_CREDS_UNIQUE_NAME|SD_BUS_CREDS_WELL_KNOWN_NAMES) & bus->creds_mask;
+}
+
static void unset_memfds(struct sd_bus_message *m) {
struct bus_body_part *part;
unsigned i;
@@ -737,11 +746,9 @@ 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) {
- m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus";
- m->creds.well_known_names_driver = true;
- m->creds.mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES & bus->creds_mask;
- } else {
+ if (k->src_id == KDBUS_SRC_ID_KERNEL)
+ bus_message_set_sender_driver(bus, m);
+ 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;
}
@@ -1075,9 +1082,7 @@ static int push_name_owner_changed(sd_bus *bus, const char *name, const char *ol
if (r < 0)
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;
+ bus_message_set_sender_driver(bus, m);
r = bus_seal_synthetic_message(bus, m);
if (r < 0)
@@ -1146,9 +1151,7 @@ static int translate_reply(sd_bus *bus, struct kdbus_msg *k, struct kdbus_item *
if (r < 0)
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;
+ bus_message_set_sender_driver(bus, m);
r = bus_seal_synthetic_message(bus, m);
if (r < 0)