diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-04-21 00:50:43 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-04-21 00:58:56 +0200 |
commit | da634f97ebe1ce83a5bb47f8f78fd85471c5a8db (patch) | |
tree | 0ebdf9b0c4a3371f1d23d346e572cc94ec7d07eb /src | |
parent | 62e3d1aed512d68cab1fc9b509e813a1fa2b3790 (diff) |
sd-bus: when copying creds objects, make sure we copy even the implicit well known names
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd/sd-bus/bus-creds.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c index a5d3574ec5..3ef69b0ea6 100644 --- a/src/libsystemd/sd-bus/bus-creds.c +++ b/src/libsystemd/sd-bus/bus-creds.c @@ -231,7 +231,6 @@ _public_ int sd_bus_creds_get_gid(sd_bus_creds *c, gid_t *gid) { return 0; } - _public_ int sd_bus_creds_get_egid(sd_bus_creds *c, gid_t *egid) { assert_return(c, -EINVAL); assert_return(egid, -EINVAL); @@ -597,10 +596,11 @@ static int has_cap(sd_bus_creds *c, unsigned offset, int capability) { assert(capability >= 0); assert(c->capability); - sz = DIV_ROUND_UP(cap_last_cap(), 32U); - if ((unsigned)capability > cap_last_cap()) + if ((unsigned) capability > cap_last_cap()) return 0; + sz = DIV_ROUND_UP(cap_last_cap(), 32U); + return !!(c->capability[offset * sz + CAP_TO_INDEX(capability)] & CAP_TO_MASK(capability)); } @@ -982,6 +982,16 @@ int bus_creds_extend_by_pid(sd_bus_creds *c, uint64_t mask, sd_bus_creds **ret) /* Copy the original data over */ + if (c->mask & mask & SD_BUS_CREDS_PID) { + n->pid = c->pid; + n->mask |= SD_BUS_CREDS_PID; + } + + if (c->mask & mask & SD_BUS_CREDS_TID) { + n->tid = c->tid; + n->mask |= SD_BUS_CREDS_TID; + } + if (c->mask & mask & SD_BUS_CREDS_UID) { n->uid = c->uid; n->mask |= SD_BUS_CREDS_UID; @@ -1030,16 +1040,6 @@ int bus_creds_extend_by_pid(sd_bus_creds *c, uint64_t mask, sd_bus_creds **ret) n->mask |= SD_BUS_CREDS_SUPPLEMENTARY_GIDS; } - if (c->mask & mask & SD_BUS_CREDS_PID) { - n->pid = c->pid; - n->mask |= SD_BUS_CREDS_PID; - } - - if (c->mask & mask & SD_BUS_CREDS_TID) { - n->tid = c->tid; - n->mask |= SD_BUS_CREDS_TID; - } - if (c->mask & mask & SD_BUS_CREDS_COMM) { n->comm = strdup(c->comm); if (!n->comm) @@ -1120,6 +1120,8 @@ int bus_creds_extend_by_pid(sd_bus_creds *c, uint64_t mask, sd_bus_creds **ret) n->well_known_names = strv_copy(c->well_known_names); if (!n->well_known_names) return -ENOMEM; + n->well_known_names_driver = c->well_known_names_driver; + n->well_known_names_local = c->well_known_names_local; n->mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES; } |