[PATCH] passdb: Cache output from pdb_[ug]id_to_sid

Volker Lendecke Volker.Lendecke at SerNet.DE
Mon Jan 5 08:55:41 MST 2015


Hi!

Review&push appreciated!

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 68a8bbff9d0c404718281bafccd1576c8cc0a51a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 5 Jan 2015 16:34:29 +0100
Subject: [PATCH] passdb: Cache output from pdb_[ug]id_to_sid

A customer complained that after upgrading to Samba 4.0 fileserver
its LDAP server was flooded with uid2sid and gid2sid request for id
0. With 4.0 we do a lot more user-space ACL checking which involves
uid2sid/gid2sid. This caches the corresponding results.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/passdb/lookup_sid.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c
index 494a840..495290d 100644
--- a/source3/passdb/lookup_sid.c
+++ b/source3/passdb/lookup_sid.c
@@ -1053,6 +1053,13 @@ static void legacy_uid_to_sid(struct dom_sid *psid, uid_t uid)
 	DEBUG(10,("LEGACY: uid %u -> sid %s\n", (unsigned int)uid,
 		  sid_string_dbg(psid)));
 
+	{
+		struct unixid xid = {
+			.id = uid, .type = ID_TYPE_UID
+		};
+		idmap_cache_set_sid2unixid(psid, &xid);
+	}
+
 	return;
 }
 
@@ -1087,6 +1094,13 @@ static void legacy_gid_to_sid(struct dom_sid *psid, gid_t gid)
 	DEBUG(10,("LEGACY: gid %u -> sid %s\n", (unsigned int)gid,
 		  sid_string_dbg(psid)));
 
+	{
+		struct unixid xid = {
+			.id = gid, .type = ID_TYPE_GID
+		};
+		idmap_cache_set_sid2unixid(psid, &xid);
+	}
+
 	return;
 }
 
-- 
1.9.1



More information about the samba-technical mailing list