diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2024-10-07 01:20:43 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2024-10-07 01:20:43 +0200 |
| commit | 748b1681549067f2e27ab2b9102ef9352cfa8a4c (patch) | |
| tree | 1b0bc13cd7a5297747ef600999a63dc0a97e8d06 /coreutils | |
| parent | bb5525613ec109aa30d2cb1db84e18aa0b084576 (diff) | |
libbb: move is_in_supplementary_groups() from test to libbb
function old new delta
is_in_supplementary_groups - 54 +54
nexpr 766 721 -45
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 54/-45) Total: 9 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/test.c | 20 |
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) /*return 1; - NOTREACHED */ } -static void initialize_group_array(void) -{ - group_array = bb_getgroups(&ngroups, NULL); -} - /* Return non-zero if GID is one that we have in our groups list. */ -//XXX: FIXME: duplicate of existing libbb function? -// see toplevel TODO file: -// possible code duplication ingroup() and is_a_group_member() static int is_a_group_member(gid_t gid) { - int i; - /* Short-circuit if possible, maybe saving a call to getgroups(). */ if (gid == getgid() || gid == getegid()) return 1; - if (ngroups == 0) - initialize_group_array(); - - /* Search through the list looking for GID. */ - for (i = 0; i < ngroups; i++) - if (gid == group_array[i]) - return 1; - - return 0; + return is_in_supplementary_groups(&ngroups, &group_array, gid); } /* |
