From: David Dykstra Date: Tue, 2 Mar 1999 16:42:46 +0000 (+0000) Subject: Change getgroups to use GETGROUPS_T as the type of the group array returned, X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/9422bb3fdf16ae5a3d726e41435ba405b4c22a8e Change getgroups to use GETGROUPS_T as the type of the group array returned, 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. --- diff --git a/configure.in b/configure.in index be39200e..5b913ea5 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/rsync.c b/rsync.c index 1d62abc4..02dd8373 100644 --- 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); } }