From be3eb7e3ed1333a3ab69ba5f24597224a6047188 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Fri, 7 Apr 2017 14:21:06 -0400 Subject: [PATCH] work around getgrouplist signature difference on osx --- src/gidcache.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gidcache.cpp b/src/gidcache.cpp index 3bace59a..14be6d67 100644 --- a/src/gidcache.cpp +++ b/src/gidcache.cpp @@ -22,6 +22,8 @@ #if defined __linux__ and UGID_USE_RWLOCK == 0 # include +#elif __APPLE__ +# include #endif #include @@ -90,6 +92,20 @@ gid_t_cache::lower_bound(gid_t_rec *begin, return begin; } +static +int +_getgrouplist(const char *user, + const gid_t group, + gid_t *groups, + int *ngroups) +{ +#if __APPLE__ + return ::getgrouplist(user,group,(int*)groups,ngroups); +#else + return ::getgrouplist(user,group,groups,ngroups); +#endif +} + gid_t_rec * gid_t_cache::cache(const uid_t uid, const gid_t gid) @@ -107,9 +123,9 @@ gid_t_cache::cache(const uid_t uid, if(pwdrv != NULL && rv == 0) { rec->size = 0; - ::getgrouplist(pwd.pw_name,gid,NULL,&rec->size); + ::_getgrouplist(pwd.pw_name,gid,NULL,&rec->size); rec->size = std::min(MAXGIDS,rec->size); - rv = ::getgrouplist(pwd.pw_name,gid,rec->gids,&rec->size); + rv = ::_getgrouplist(pwd.pw_name,gid,rec->gids,&rec->size); if(rv == -1) { rec->gids[0] = gid;