From 8d6fb8b45f0646d3c1b436962f4ed667d862a282 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Wed, 7 Jun 2023 12:42:00 +0300
Subject: [PATCH] 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.
---
 abuild-sudo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/abuild-sudo.c b/abuild-sudo.c
index 450e4add..00d00a51 100644
--- a/abuild-sudo.c
+++ b/abuild-sudo.c
@@ -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;
-- 
GitLab