svn commit: samba r23049 - in branches/SAMBA_3_0_25/source/passdb: .

idra at samba.org idra at samba.org
Mon May 21 20:41:55 GMT 2007


Author: idra
Date: 2007-05-21 20:41:50 +0000 (Mon, 21 May 2007)
New Revision: 23049

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23049

Log:

Short circuit Unix Users and Unix Groups Domain SID checks.
Do not cache to avoid polluting the uid -> Sid cache


Modified:
   branches/SAMBA_3_0_25/source/passdb/lookup_sid.c


Changeset:
Modified: branches/SAMBA_3_0_25/source/passdb/lookup_sid.c
===================================================================
--- branches/SAMBA_3_0_25/source/passdb/lookup_sid.c	2007-05-21 20:36:22 UTC (rev 23048)
+++ branches/SAMBA_3_0_25/source/passdb/lookup_sid.c	2007-05-21 20:41:50 UTC (rev 23049)
@@ -1380,6 +1380,7 @@
 
 BOOL sid_to_uid(const DOM_SID *psid, uid_t *puid)
 {
+	uint32 rid;
 	gid_t gid;
 
 	if (fetch_uid_from_cache(puid, psid))
@@ -1389,6 +1390,18 @@
 		return False;
 	}
 
+	/* Optimize for the Unix Users Domain
+	 * as the conversion is straightforward */
+	if (sid_peek_check_rid(&global_sid_Unix_Users, psid, &rid)) {
+		uid_t uid = rid;
+		*puid = uid;
+
+		/* return here, don't cache */
+		DEBUG(10,("sid %s -> uid %u\n", sid_string_static(psid),
+			(unsigned int)*puid ));
+		return True;
+	}
+
 	if (!winbind_sid_to_uid(puid, psid)) {
 		if (!winbind_ping()) {
 			return legacy_sid_to_uid(psid, puid);
@@ -1416,6 +1429,7 @@
 
 BOOL sid_to_gid(const DOM_SID *psid, gid_t *pgid)
 {
+	uint32 rid;
 	uid_t uid;
 
 	if (fetch_gid_from_cache(pgid, psid))
@@ -1424,6 +1438,18 @@
 	if (fetch_uid_from_cache(&uid, psid))
 		return False;
 
+	/* Optimize for the Unix Groups Domain
+	 * as the conversion is straightforward */
+	if (sid_peek_check_rid(&global_sid_Unix_Groups, psid, &rid)) {
+		gid_t gid = rid;
+		*pgid = gid;
+
+		/* return here, don't cache */
+		DEBUG(10,("sid %s -> gid %u\n", sid_string_static(psid),
+			(unsigned int)*pgid ));
+		return True;
+	}
+
 	/* Ask winbindd if it can map this sid to a gid.
 	 * (Idmap will check it is a valid SID and of the right type) */
 



More information about the samba-cvs mailing list