aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/test.c20
1 files changed, 1 insertions, 19 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index c02c92745..874285704 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -637,32 +637,14 @@ static int binop(void)
637 /*return 1; - NOTREACHED */ 637 /*return 1; - NOTREACHED */
638} 638}
639 639
640static void initialize_group_array(void)
641{
642 group_array = bb_getgroups(&ngroups, NULL);
643}
644
645/* Return non-zero if GID is one that we have in our groups list. */ 640/* Return non-zero if GID is one that we have in our groups list. */
646//XXX: FIXME: duplicate of existing libbb function?
647// see toplevel TODO file:
648// possible code duplication ingroup() and is_a_group_member()
649static int is_a_group_member(gid_t gid) 641static int is_a_group_member(gid_t gid)
650{ 642{
651 int i;
652
653 /* Short-circuit if possible, maybe saving a call to getgroups(). */ 643 /* Short-circuit if possible, maybe saving a call to getgroups(). */
654 if (gid == getgid() || gid == getegid()) 644 if (gid == getgid() || gid == getegid())
655 return 1; 645 return 1;
656 646
657 if (ngroups == 0) 647 return is_in_supplementary_groups(&ngroups, &group_array, gid);
658 initialize_group_array();
659
660 /* Search through the list looking for GID. */
661 for (i = 0; i < ngroups; i++)
662 if (gid == group_array[i])
663 return 1;
664
665 return 0;
666} 648}
667 649
668/* 650/*