abuild-sudo: fix determining number of groups

Musl _SC_NGROUPS_MAX is fixed at 32. The kernel can support more.
Query the kernel for number of groups needed.
This commit is contained in:
Timo Teräs 2023-06-07 12:42:00 +03:00
parent 69d15d3225
commit 8d6fb8b45f

View File

@ -62,7 +62,7 @@ void check_option(const char *opt)
int is_in_group(gid_t group)
{
int ngroups_max = sysconf(_SC_NGROUPS_MAX) + 1;
int ngroups_max = getgroups(0, 0);
gid_t *buf = malloc(ngroups_max * sizeof(gid_t));
int ngroups;
int i;