Obeying primary group in /etc/passwd ?

Volker.Lendecke at SerNet.DE Volker.Lendecke at SerNet.DE
Mon Sep 23 13:47:00 GMT 2002


Hi!

What do you think about the following patch? More consistent would be
to remove the group_sid from SAM_ACCOUNT completely, as we can always
get this from /etc/passwd.

Volker

Index: pdb_get_set.c
===================================================================
RCS file: /data/cvs/samba/source/passdb/pdb_get_set.c,v
retrieving revision 1.17
diff -u -r1.17 pdb_get_set.c
--- pdb_get_set.c	24 Jul 2002 05:04:18 -0000	1.17
+++ pdb_get_set.c	23 Sep 2002 13:43:09 -0000
@@ -166,11 +166,24 @@
 
 const DOM_SID *pdb_get_group_sid(const SAM_ACCOUNT *sampass)
 {
-	if (sampass)
-		return &sampass->private.group_sid;
-	else	
+	struct passwd *pwd;
+	static GROUP_MAP map;
+
+	if (!sampass)
 		return (NULL);
-}	
+
+	/* If the user's unix primary group is mapped to a NT SID, use
+           that. Otherwise use the pdb-stored SID. Unix is still boss
+           here :-) */
+
+	if ((pwd = getpwuid(sampass->private.uid)) == NULL)
+		return &sampass->private.group_sid;
+
+	if (!get_group_map_from_gid(pwd->pw_gid, &map, False))
+		return &sampass->private.group_sid;
+
+	return &map.sid;
+}
 
 /**
  * Get flags showing what is initalised in the SAM_ACCOUNT




More information about the samba-technical mailing list