From 4ea6831800dfaef57418bfc2c20ce7b6e71d3cd3 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 10 Apr 2019 11:27:16 -0700 Subject: [PATCH] getgrouplist() on OSX has different sig. --- examples/Makefile | 3 +++ src/utils/getgroups.cpp | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index 3aef798..44c6f39 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -5,6 +5,9 @@ include $(TOP)/configure/CONFIG PROD_LIBS += pvAccessCA ca pvAccess pvData Com PROD_SYS_LIBS_WIN32 += netapi32 ws2_32 +#TESTPROD_HOST += heinz +#heinz_SRCS += heinz.cpp + TESTPROD_HOST += getme getme_SRCS = getme.cpp diff --git a/src/utils/getgroups.cpp b/src/utils/getgroups.cpp index e3580b5..2bcc0c0 100644 --- a/src/utils/getgroups.cpp +++ b/src/utils/getgroups.cpp @@ -16,6 +16,16 @@ #include #include +// getgrouplist() has a slightly different prototype on OSX. +# ifdef __APPLE__ +// OSX has gid_t, which isn't "int", but doesn't use it here. +// int getgrouplist(const char *name, int basegid, int *groups, int *ngroups); +typedef int osi_gid_t; +# else +// int getgrouplist(const char *user, gid_t group, gid_t *groups, int *ngroups); +typedef gid_t osi_gid_t; +# endif + #elif defined(USE_LANMAN) #include @@ -45,7 +55,7 @@ void osdGetRoles(const std::string& account, PeerInfo::roles_t& roles) // include supplementary groups { - std::vector gtemp(16); + std::vector gtemp(16); int gcount = int(gtemp.size()); if(getgrouplist(user->pw_name, user->pw_gid, >emp[0], &gcount)==-1 && gcount>=0 && gcount<=NGROUPS_MAX) { @@ -103,14 +113,12 @@ void osdGetRoles(const std::string& account, PeerInfo::roles_t& roles) std::vector buf; for(DWORD i=0; i