From 929f3d7ad723742df83dd160c91856caaefa9c16 Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Sun, 17 Oct 2010 17:50:31 +0200 Subject: [PATCH] policy: check against primary group as well, not just auxiliary groups (fd.o#30938) Mail-Followup-To: For some use cases the group a policy wants to match against is the primary group of the user, not an auxiliary one. Signed-off-by: Sascha Silbe --- dbus/dbus-userdb-util.c | 19 ++++++++++--------- 1 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dbus/dbus-userdb-util.c b/dbus/dbus-userdb-util.c index c44c014..54dc1f1 100644 --- a/dbus/dbus-userdb-util.c +++ b/dbus/dbus-userdb-util.c @@ -379,18 +379,19 @@ _dbus_groups_from_uid (dbus_uid_t uid, _dbus_assert (info->uid == uid); - if (info->n_group_ids > 0) + *group_ids = dbus_new (dbus_gid_t, info->n_group_ids+1); + if (*group_ids == NULL) { - *group_ids = dbus_new (dbus_gid_t, info->n_group_ids); - if (*group_ids == NULL) - { - _dbus_user_database_unlock_system (); - return FALSE; - } + _dbus_user_database_unlock_system (); + return FALSE; + } - *n_group_ids = info->n_group_ids; + *n_group_ids = info->n_group_ids+1; + **group_ids = info->primary_gid; - memcpy (*group_ids, info->group_ids, info->n_group_ids * sizeof (dbus_gid_t)); + if (info->n_group_ids > 0) + { + memcpy (&(*group_ids)[1], info->group_ids, (info->n_group_ids) * sizeof (dbus_gid_t)); } _dbus_user_database_unlock_system (); -- 1.7.1