diff --git a/src/common/group_cache.c b/src/common/group_cache.c index a62a922046c276b70efea75a7075c5574f6f1358..94e7b3569019ea93e80f4c242b1c3566ae7d980f 100644 --- a/src/common/group_cache.c +++ b/src/common/group_cache.c @@ -166,8 +166,17 @@ static int _group_cache_lookup_internal(gids_cache_needle_t *needle, gid_t **gid /* Cache lookup failed or entry value was too old, fetch new * value and insert it into cache. */ +#if defined(__APPLE__) + /* + * macOS has (int *) for the third argument instead + * of (gid_t *) like FreeBSD, NetBSD, and Linux. + */ + while (getgrouplist(entry->username, entry->gid, + (int *)entry->gids, &entry->ngids) == -1) { +#else while (getgrouplist(entry->username, entry->gid, entry->gids, &entry->ngids) == -1) { +#endif /* group list larger than array, resize array to fit */ entry->gids = xrealloc(entry->gids, entry->ngids * sizeof(gid_t)); diff --git a/src/plugins/mcs/group/mcs_group.c b/src/plugins/mcs/group/mcs_group.c index 30f9760e593b32161c774cbb9b941f5d6464e41c..80f20a0fb3b798a89c5f5150baeeb029904fbced 100644 --- a/src/plugins/mcs/group/mcs_group.c +++ b/src/plugins/mcs/group/mcs_group.c @@ -127,7 +127,15 @@ static int _get_user_groups(uint32_t user_id, uint32_t group_id, user_name = uid_to_string((uid_t) user_id); *ngroups = max_groups; +#if defined(__APPLE__) + /* + * macOS has (int *) for the third argument instead + * of (gid_t *) like FreeBSD, NetBSD, and Linux. + */ + rc = getgrouplist(user_name, (gid_t) group_id, (int *) groups, ngroups); +#else rc = getgrouplist(user_name, (gid_t) group_id, groups, ngroups); +#endif if (rc < 0) { error("getgrouplist(%s): %m", user_name);