1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-11 09:18:07 +03:00

sd-bus: unify how we set the sender of synthetic messages

This commit is contained in:
Lennart Poettering 2015-01-07 20:25:30 +01:00
parent 76877fb9cc
commit d29ae2914e
4 changed files with 23 additions and 21 deletions

View File

@ -379,15 +379,6 @@ 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;
@ -1274,7 +1265,6 @@ static int translate_reply(
if (r < 0)
return r;
bus_message_set_sender_driver(bus, m);
message_set_timestamp(bus, m, ts);
r = bus_seal_synthetic_message(bus, m);

View File

@ -754,6 +754,24 @@ _public_ int sd_bus_message_new_method_errnof(
return sd_bus_message_new_method_error(call, m, &berror);
}
void bus_message_set_sender_local(sd_bus *bus, sd_bus_message *m) {
assert(bus);
assert(m);
m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus.Local";
m->creds.well_known_names_local = true;
m->creds.mask |= (SD_BUS_CREDS_UNIQUE_NAME|SD_BUS_CREDS_WELL_KNOWN_NAMES) & bus->creds_mask;
}
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;
}
int bus_message_new_synthetic_error(
sd_bus *bus,
uint64_t cookie,
@ -796,6 +814,8 @@ int bus_message_new_synthetic_error(
t->error._need_free = -1;
bus_message_set_sender_driver(bus, t);
*m = t;
return 0;

View File

@ -235,3 +235,6 @@ int bus_message_new_synthetic_error(sd_bus *bus, uint64_t serial, const sd_bus_e
int bus_message_remarshal(sd_bus *bus, sd_bus_message **m);
int bus_message_append_sender(sd_bus_message *m, const char *sender);
void bus_message_set_sender_driver(sd_bus *bus, sd_bus_message *m);
void bus_message_set_sender_local(sd_bus *bus, sd_bus_message *m);

View File

@ -2140,8 +2140,6 @@ static int process_timeout(sd_bus *bus) {
if (r < 0)
return r;
m->sender = "org.freedesktop.DBus";
r = bus_seal_synthetic_message(bus, m);
if (r < 0)
return r;
@ -2544,15 +2542,6 @@ null_message:
return r;
}
static void bus_message_set_sender_local(sd_bus *bus, sd_bus_message *m) {
assert(bus);
assert(m);
m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus.Local";
m->creds.well_known_names_local = true;
m->creds.mask |= (SD_BUS_CREDS_UNIQUE_NAME|SD_BUS_CREDS_WELL_KNOWN_NAMES) & bus->creds_mask;
}
static int process_closing(sd_bus *bus, sd_bus_message **ret) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
struct reply_callback *c;