Change getgroups to use GETGROUPS_T as the type of the group array returned,
authorDavid Dykstra <dwd@samba.org>
Tue, 2 Mar 1999 16:42:46 +0000 (16:42 +0000)
committerDavid Dykstra <dwd@samba.org>
Tue, 2 Mar 1999 16:42:46 +0000 (16:42 +0000)
as calculated by the configure macro AC_TYPE_GETGROUPS.  Without that, it
doesn't work properly on systems like sunos 4 where gid_t is defined to
be an unsigned short but getgroups is defined to return an array of integers.

configure.in
rsync.c

index be39200..5b913ea 100644 (file)
@@ -37,6 +37,7 @@ AC_TYPE_MODE_T
 AC_TYPE_OFF_T
 AC_TYPE_SIZE_T
 AC_TYPE_PID_T
+AC_TYPE_GETGROUPS
 AC_STRUCT_ST_RDEV
 AC_CHECK_TYPE(ino_t,unsigned)
 
@@ -52,7 +53,7 @@ AC_FUNC_UTIME_NULL
 AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
 AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
 AC_CHECK_FUNCS(memmove getopt_long lchown vsnprintf snprintf setsid glob strpbrk)
-AC_CHECK_FUNCS(strlcat strlcpy getgroups)
+AC_CHECK_FUNCS(strlcat strlcpy)
 
 echo $ac_n "checking for working fnmatch... $ac_c"
 AC_TRY_RUN([#include <fnmatch.h>
diff --git a/rsync.c b/rsync.c
index 1d62abc..02dd837 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -115,10 +115,10 @@ int delete_file(char *fname)
 
 static int is_in_group(gid_t gid)
 {
-#ifdef HAVE_GETGROUPS
+#ifdef GETGROUPS_T
        static gid_t last_in = (gid_t) -2, last_out;
        static int ngroups = -2;
-       static gid_t *gidset;
+       static GETGROUPS_T *gidset;
        int n;
 
        if (gid == last_in)
@@ -127,7 +127,7 @@ static int is_in_group(gid_t gid)
                /* treat failure (-1) as if not member of any group */
                ngroups = getgroups(0, 0);
                if (ngroups > 0) {
-                       gidset = (gid_t *) malloc(ngroups * sizeof(gid_t));
+                       gidset = (GETGROUPS_T *) malloc(ngroups * sizeof(GETGROUPS_T));
                        ngroups = getgroups(ngroups, gidset);
                }
        }