-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Eric Blake on 11/12/2009 11:41 AM: > getgroups replaces a library function, so it should not exit(). On the other > hand, the mgetgroups interface from coreutils is much nicer to use (one call, > instead of 2); that would be a reasonable place to add an xalloc-die > dependency, but this patch does not do that.
On at least FreeBSD, even if you belong to exactly one group, getgroups() returns both the effective gid and the entire list of supplemental gids; if the effective gid is part of the list of supplemental gids, that means the same group is listed twice. For example: $ /usr/bin/id uid=84137(blake) gid=84137(blake) groups=84137(blake) $ ./gltests/test-getgroups a 84137 84137 Should we make mgetgroups smarter to sort and/or eliminate duplicate entries? Maybe make it conditional via the addition of a bool flag? Without sorting, it's O(n^2) unless we use a hash; with sorting, it is O(n log n); or we can just do pairwise duplicate elimination with an O(n) pass. Then there's the issue of whether there will ever be enough groups to notice scaling effects if we do make the decision to reduce or avoid duplicates. - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkr9yacACgkQ84KuGfSFAYBEdwCg1hzN57eRbuiFJrb9P56pH1tw zpEAn1yPSwOXH9fdsg1kVFOp3FUPHsbt =eu2L -----END PGP SIGNATURE-----