mirror of
https://github.com/trapexit/mergerfs.git
synced 2025-02-21 17:56:42 +08:00
Merge pull request #394 from trapexit/getgrouplist
work around getgrouplist signature difference on osx
This commit is contained in:
commit
8cfb1cbee4
@ -22,6 +22,8 @@
|
||||
|
||||
#if defined __linux__ and UGID_USE_RWLOCK == 0
|
||||
# include <sys/syscall.h>
|
||||
#elif __APPLE__
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user