include <grp.h> for setgroups in a few places
authorMichael Tokarev <mjt@tls.msk.ru>
Fri, 29 Nov 2024 06:34:42 +0000 (09:34 +0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Sun, 12 Jan 2025 20:16:00 +0000 (23:16 +0300)
setgroups(), unlike getgroups(), is not in <unistd.h> but in <grp.h>.
Recent compilers require function declaration before using a function
(or more and more distributions treat lack of declaration as error),
so all configure-time tests fails with source3/lib/util_sec.c:

source3/../lib/util/setid.c: In function 'samba_setgroups':
source3/../lib/util/setid.c:244:16: error: implicit declaration of function \
  'setgroups'; did you mean 'getgroups'? [-Wimplicit-function-declaration]
  244 |         return setgroups(setlen, gidset);

Add the missing include so configuration finds the existing system
functions instead of failing.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Gbp-Pq: Name include-grp.h-for-setgroups-in-a-few-places.patch

lib/util/setid.c
source3/lib/util_sec.c

index 10014618defaf397a9cbcd9035d71d772622dbc0..f6c881efb48fe060c6c867456fdd5c3f8350dd53 100644 (file)
@@ -29,6 +29,9 @@
 #if defined(HAVE_UNISTD_H)
 #include <unistd.h>
 #endif
+#if defined(HAVE_GRP_H)
+#include <grp.h> /* setgroups() */
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/types.h>
index 5569df4e9b73e7709e9c5a278a5946718969d997..91b728b6d6528f56750b962b56145a0d0b4af592 100644 (file)
@@ -28,6 +28,9 @@
 #if defined(HAVE_UNISTD_H)
 #include <unistd.h>
 #endif
+#if defined(HAVE_GRP_H)
+#include <grp.h> /* setgroups() */
+#endif
 #include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>