sd-bus: set creds info for "org.freedesktop.DBus.Local" generated messages, too

This commit is contained in:
Lennart Poettering 2014-11-27 12:52:13 +01:00
parent 38ce47e262
commit fb6d9b77a7
3 changed files with 22 additions and 2 deletions

View File

@ -563,6 +563,16 @@ _public_ int sd_bus_creds_get_well_known_names(sd_bus_creds *c, char ***well_kno
return 0;
}
if (c->well_known_names_local) {
static const char* const wkn[] = {
"org.freedesktop.DBus.Local",
NULL
};
*well_known_names = (char**) wkn;
return 0;
}
*well_known_names = c->well_known_names;
return 0;
}

View File

@ -72,7 +72,8 @@ struct sd_bus_creds {
char *unique_name;
char **well_known_names;
bool well_known_names_driver;
bool well_known_names_driver:1;
bool well_known_names_local:1;
char *cgroup_root;

View File

@ -2505,6 +2505,15 @@ 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;
@ -2573,7 +2582,7 @@ static int process_closing(sd_bus *bus, sd_bus_message **ret) {
if (r < 0)
return r;
m->sender = "org.freedesktop.DBus.Local";
bus_message_set_sender_local(bus, m);
r = bus_seal_synthetic_message(bus, m);
if (r < 0)