Logo Search packages:      
Sourcecode: dbus version File versions

dbus_bool_t _dbus_user_database_get_groups ( DBusUserDatabase db,
dbus_uid_t  uid,
dbus_gid_t **  group_ids,
int *  n_group_ids,
DBusError error 

Gets all groups for a particular user. Returns FALSE if no memory, or user isn't known, but always initializes group_ids to a NULL array. Sets error to the reason for returning FALSE.

db the user database object
uid the user ID
group_ids return location for array of group IDs
n_group_ids return location for length of returned array
error return location for error
TRUE on success

Definition at line 735 of file dbus-userdb.c.

References dbus_new, dbus_set_error(), FALSE, DBusUserInfo::group_ids, DBusUserInfo::n_group_ids, NULL, and TRUE.

  DBusUserInfo *info;

  *group_ids = NULL;
  *n_group_ids = 0;
  info = _dbus_user_database_lookup (db, uid, NULL, error);
  if (info == NULL)
      _DBUS_ASSERT_ERROR_IS_SET (error);
      return FALSE;

  if (info->n_group_ids > 0)
      *group_ids = dbus_new (dbus_gid_t, info->n_group_ids);
      if (*group_ids == NULL)
          dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
          return FALSE;

      *n_group_ids = info->n_group_ids;

      memcpy (*group_ids, info->group_ids, info->n_group_ids * sizeof (dbus_gid_t));

  return TRUE;

Generated by  Doxygen 1.6.0   Back to index