Skip to content
Snippets Groups Projects
Commit 5042bab5 authored by Tim Wickberg's avatar Tim Wickberg
Browse files

Add macOS block to fix warning for differences in getgrouplist().

getgrouplist() is not POSIX, so it varies between platforms.
parent 3095d9aa
No related branches found
No related tags found
No related merge requests found
......@@ -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));
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment