[PATCH] policy: check against primary group as well, not just auxiliary groups (fd.o#30938)

Sascha Silbe sascha-pgp at silbe.org
Sun Oct 17 09:08:25 PDT 2010


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 <sascha-pgp at silbe.org>
---
 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



More information about the dbus mailing list