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>
This commit is contained in:
parent
bb5525613e
commit
748b168154
3 changed files with 26 additions and 19 deletions
|
@ -45,3 +45,23 @@ gid_t* FAST_FUNC bb_getgroups(int *ngroups, gid_t *group_array)
|
|||
*ngroups = n;
|
||||
return group_array;
|
||||
}
|
||||
|
||||
/* Return non-zero if GID is in our supplementary group list. */
|
||||
int FAST_FUNC is_in_supplementary_groups(int *pngroups, gid_t **pgroup_array, gid_t gid)
|
||||
{
|
||||
int i;
|
||||
int ngroups;
|
||||
gid_t *group_array;
|
||||
|
||||
if (*pngroups == 0)
|
||||
*pgroup_array = bb_getgroups(pngroups, NULL);
|
||||
ngroups = *pngroups;
|
||||
group_array = *pgroup_array;
|
||||
|
||||
/* Search through the list looking for GID. */
|
||||
for (i = 0; i < ngroups; i++)
|
||||
if (gid == group_array[i])
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue