mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 10:51:20 +03:00
sd-bus: unify logic how we patch the message source of driver messages
This commit is contained in:
parent
ac653862e0
commit
7d31d92400
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user