Re: group_member missing.
Re: group_member missing.
- Subject: Re: group_member missing.
- From: Pascal via Darwin-dev <email@hidden>
- Date: Wed, 19 Feb 2020 20:29:50 +0100
> Le 17 févr. 2020 à 19:23, Sandor Szatmari <email@hidden> a
> écrit :
>
> Ahh, Got it.
>
> This is what I’ve used for that in the past
>
> https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/getpwuid.3.html
>
> Pascal,
>
> Could you emulate your needs with it?
Hello,
I haven't found how to use the previous link for groups.
But after I've found the following link:
https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/getgrouplist.3.html
And an example:
http://www.qnx.com/developers/docs/6.5.0/index.jsp?topic=/com.qnx.doc.neutrino_lib_ref/g/getgrouplist.html
My emulation code is then:
#ifdef __APPLE__
int group_member(gid_t gid) {
int ngroups, i, ret;
int groups[NGROUPS_MAX];
ngroups = NGROUPS_MAX;
if (getgrouplist(getlogin(), -1, groups, &ngroups) == -1) {
printf ("Groups array is too small: %d\n", ngroups);
}
ret = 0;
for (i = 0; i < ngroups; i++) {
if (gid == groups[i])
ret = i;
}
return ret;
}
#endif
Regards, Pascal.
https://blady.pagesperso-orange.fr
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden