summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-control.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-26 14:59:12 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-26 14:59:12 +0100
commite12d81ae80214ef05ddedafd016bdd604ce17d12 (patch)
tree55d8b2a5dd356154b24ab8c8a5c5287196d5176a /src/libsystemd/sd-bus/bus-control.c
parent8514b67754c5ff7fa628929b3d27131010c21842 (diff)
sd-bus: given that the kernel now passes the auxgroups list as 32bit array to us, no need to convert to uid_t manually
This way, we can save one allocation and avoid copying the array unnecesarily.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-control.c')
-rw-r--r--src/libsystemd/sd-bus/bus-control.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c
index 9cd5cd5fb6..758715d74e 100644
--- a/src/libsystemd/sd-bus/bus-control.c
+++ b/src/libsystemd/sd-bus/bus-control.c
@@ -402,6 +402,10 @@ static int bus_populate_creds_from_items(
uint64_t m;
int r;
+ assert(bus);
+ assert(info);
+ assert(c);
+
KDBUS_ITEM_FOREACH(item, info, items) {
switch (item->type) {
@@ -590,18 +594,18 @@ static int bus_populate_creds_from_items(
case KDBUS_ITEM_AUXGROUPS:
if (mask & SD_BUS_CREDS_SUPPLEMENTARY_GIDS) {
- size_t i, n;
- uid_t *u;
+ size_t n;
+ uid_t *g;
- n = (item->size - offsetof(struct kdbus_item, data64)) / sizeof(uint64_t);
- u = new(uid_t, n);
- if (!u)
- return -ENOMEM;
+ assert_cc(sizeof(gid_t) == sizeof(uint32_t));
- for (i = 0; i < n; i++)
- u[i] = (uid_t) item->data64[i];
+ n = (item->size - offsetof(struct kdbus_item, data32)) / sizeof(uint32_t);
+ g = newdup(gid_t, item->data32, n);
+ if (!g)
+ return -ENOMEM;
- c->supplementary_gids = u;
+ free(c->supplementary_gids);
+ c->supplementary_gids = g;
c->n_supplementary_gids = n;
c->mask |= SD_BUS_CREDS_SUPPLEMENTARY_GIDS;