Re: group_member missing.
Re: group_member missing.
- Subject: Re: group_member missing.
- From: Sandor Szatmari via Darwin-dev <email@hidden>
- Date: Wed, 19 Feb 2020 16:17:11 -0500
Pascal,
Thanks for sharing your solution! Might I suggest… based on my read of the
group_member() man page, it does not specify the value returned, merely that
upon success it is non-zero. My thought is why continue the loop once success
is determined. See below.
Sandor
NOTE: I read the first man page google showed me so this may not be current.
> On Feb 19, 2020, at 14:37, Pascal <email@hidden> wrote:
>
>
>>> 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 = 1; // or i++, 42, handle match on first iteration
break;
}
> }
> 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