summaryrefslogtreecommitdiffstats
path: root/configd
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2021-08-30 20:37:35 +0000
committerArne Juul <arnej@verizonmedia.com>2021-08-30 20:37:35 +0000
commit1a469dac6684ad13257c83110f0c0b0f821a1ca6 (patch)
treea3883fd78d29e3d2d3ee1bc4ad0475a8e08474e6 /configd
parent76fcd9e5cf0b9f51f990915b0f92be36814d085c (diff)
try to make it work on Mac OS X also
Diffstat (limited to 'configd')
-rw-r--r--configd/src/apps/su/main.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/configd/src/apps/su/main.cpp b/configd/src/apps/su/main.cpp
index 09bac09ff01..92767710fee 100644
--- a/configd/src/apps/su/main.cpp
+++ b/configd/src/apps/su/main.cpp
@@ -30,7 +30,16 @@ int main(int argc, char** argv)
gid_t grouplist[256];
int group_arr_sz = 256;
+#ifdef __APPLE__
+ int mac_gid = g;
+ int mac_groups[256];
+ int ggl = getgrouplist(username, mac_gid, mac_groups, &group_arr_sz);
+ for (int i = 0; i < group_arr_sz; ++i) {
+ grouplist[i] = (gid_t) mac_groups[i];
+ }
+#else
int ggl = getgrouplist(username, g, grouplist, &group_arr_sz);
+#endif
gid_t oldg = getgid();
uid_t oldu = getuid();
@@ -40,7 +49,7 @@ int main(int argc, char** argv)
return 1;
}
size_t listsize = 1;
- if (ggl > 0) {
+ if (ggl >= 0) {
listsize = group_arr_sz;
} else {
grouplist[0] = g;