[PATCH 4/4] Update setgroups comments for BSDs.
James Peach
jpeach at samba.org
Fri Jun 8 03:37:51 GMT 2007
Update the comments that describe BSD setgroups semantics. Apply
the setgroups fix to Darwin as well as FreeBSD.
---
source/smbd/sec_ctx.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/source/smbd/sec_ctx.c b/source/smbd/sec_ctx.c
index d7a229e..ffbfa64 100644
--- a/source/smbd/sec_ctx.c
+++ b/source/smbd/sec_ctx.c
@@ -193,8 +193,15 @@ static BOOL apply_unix_token(const
UNIX_USER_TOKEN *ut)
{
int ngroups = 0;
-#ifdef FREEBSD
- /* Most (all?) BSD systems expect that the first element in the groups
+#if defined(FREEBSD) || defined(DARWINOS)
+ /* Most BSD systems return the effective gid as the first gid in the
+ * list returned by getgroups(2), but only not all expect the
+ * first gid in the list passed to setgroups(2) to always contain the
+ * effective gid.
+ *
+ * FreeBSD will ignore the first gid in the setgroups array, and
Darwin
+ * will use it as the effective gid.
+ *
* list passed to setgroups(2) is the effective gid. See also bugzilla
* bug #3990.
*/
@@ -219,7 +226,7 @@ static BOOL apply_unix_token(const
UNIX_USER_TOKEN *ut)
ut->groups[0] = ut->gid;
}
-#endif /* FREEBSD */
+#endif /* FREEBSD || DARWINOS */
/* Always truncate the groups list at the system maximum. On most
* systems, setgroups(2) will fail with EINVAL otherwise.
--
1.5.2.1
--
James Peach | jpeach at samba.org
More information about the samba-technical
mailing list