site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=content-transfer-encoding:mime-version:subject:from:in-reply-to:cc :date:message-id:references:to; bh=kZT7ul/p77O8x/l5g49Tc08DVr2OUgBfAu78v4rMT08=; b=ElgkAFL8WV9xOPyvWUkqRyFgVmFzNKwuP8jCPmlD31ybwOpgfYOT7oPGjsdVfOZU5v DbAGFMemkMKttlWyCwovFA3IggXlRMRno1HMtIuya1QVqzYDx9ZvtuqkVpPTTQoX5A/s ucTeBzCtcJXQ/9zHdUCB53q3snwgSnsxIzS2oKYQSdOM+RI3SSNX6MeyPvuDK+lcauBC SSt4v88VSZu8IlPcG2r0InuQ09soxIGpDRQt+GqQAkfWxbNWX8b6O5yMQqGY1aEXb5dQ mrKWpphdGxL/FO8FcsCDRdG9vlBMTUhymDuFhP1daFEg170tqiKAw5P5mIOqRVv2yXuS BeAw== 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 <sur.pignard@wanadoo.fr> wrote:
Le 17 févr. 2020 à 19:23, Sandor Szatmari <admin.szatmari.net@gmail.com> 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/... 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/...
And an example: http://www.qnx.com/developers/docs/6.5.0/index.jsp?topic=%2Fcom.qnx.doc.neut...
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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.app... This email sent to site_archiver@lists.apple.com