bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getgroups improvements


From: Eric Blake
Subject: Re: getgroups improvements
Date: Fri, 13 Nov 2009 14:03:35 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

-----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             address@hidden
-----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-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]