mgetgroups: reduce duplicate listings
authorEric Blake <ebb9@byu.net>
Fri, 4 Dec 2009 21:07:58 +0000 (14:07 -0700)
committerEric Blake <ebb9@byu.net>
Mon, 7 Dec 2009 13:24:44 +0000 (06:24 -0700)
commitb1ab442e6db76de2a7315531f6f0ec59c5934368
tree7164daad2a15e91e921af360d790edfdf1fac24d
parent68145a074c0cdc9eff8364a62530da01a5f39bcd
mgetgroups: reduce duplicate listings

POSIX doesn't guarantee whether the effective gid is included in
the list of supplementary groups returned by getgroups.  On the
other hand, some platforms include the effective gid twice in
the list.  Meanwhile, mgetgroups can independently add a duplicate.
Rather than spend a full-blown O(n log n) cleanup, we just remove
the most common forms of duplicate groups with an O(n) pass.

* lib/mgetgroups.c (mgetgroups): Reduce duplicates from the
resulting array.
* tests/test-chown.h (test_chown): Simplify client.
* tests/test-lchown.h (test_lchown): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/mgetgroups.c
tests/test-chown.h
tests/test-lchown.h