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 /libbb/bb_getgroups.c | |
parent | bb5525613ec109aa30d2cb1db84e18aa0b084576 (diff) | |
download | busybox-w32-748b1681549067f2e27ab2b9102ef9352cfa8a4c.tar.gz busybox-w32-748b1681549067f2e27ab2b9102ef9352cfa8a4c.tar.bz2 busybox-w32-748b1681549067f2e27ab2b9102ef9352cfa8a4c.zip |
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 '')
-rw-r--r-- | libbb/bb_getgroups.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libbb/bb_getgroups.c b/libbb/bb_getgroups.c index 5d83c729a..f030d5eac 100644 --- a/libbb/bb_getgroups.c +++ b/libbb/bb_getgroups.c | |||
@@ -45,3 +45,23 @@ gid_t* FAST_FUNC bb_getgroups(int *ngroups, gid_t *group_array) | |||
45 | *ngroups = n; | 45 | *ngroups = n; |
46 | return group_array; | 46 | return group_array; |
47 | } | 47 | } |
48 | |||
49 | /* Return non-zero if GID is in our supplementary group list. */ | ||
50 | int FAST_FUNC is_in_supplementary_groups(int *pngroups, gid_t **pgroup_array, gid_t gid) | ||
51 | { | ||
52 | int i; | ||
53 | int ngroups; | ||
54 | gid_t *group_array; | ||
55 | |||
56 | if (*pngroups == 0) | ||
57 | *pgroup_array = bb_getgroups(pngroups, NULL); | ||
58 | ngroups = *pngroups; | ||
59 | group_array = *pgroup_array; | ||
60 | |||
61 | /* Search through the list looking for GID. */ | ||
62 | for (i = 0; i < ngroups; i++) | ||
63 | if (gid == group_array[i]) | ||
64 | return 1; | ||
65 | |||
66 | return 0; | ||
67 | } | ||