[PATCHES] winbindd: use idmap cache in getpwuid and getgrgid
Volker Lendecke
vl at samba.org
Tue Dec 27 09:44:15 UTC 2016
Hi, Uri!
On Sun, Dec 25, 2016 at 08:48:23PM +0200, Uri Simchoni wrote:
> The attached patch set makes sure that the winbindd getpwuid() and
> getgrgid() implementations use the idmap cache if available (this seems
> to be a 4.5.x regression due to the xids->sids cleanup).
That might well be the case. I wonder if this could be done directly
in the xids2sids call without the wrappers.
While there -- attached find two patches that also prime the cache in
the xids2sids calls, which was lost also.
Volker
-------------- next part --------------
>From cc5b421e7dd74609c5b68bf472a6153806d5b67a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 21 Dec 2016 11:29:08 +0100
Subject: [PATCH 1/2] idmap: Pass up the xid2sids unix-ids from the idmap child
When asking for gid2sid with an idmap backend that does ID_TYPE_BOTH
and the sid in question is actually a user, the parent winbind needs
to know about it. The next commit will prime the gencache also after
xid2sid calls, and if we filled it with a ID_TYPE_GID entry, a later
sid2uid call would fail.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
librpc/idl/winbind.idl | 2 +-
source3/winbindd/winbindd_dual_srv.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/librpc/idl/winbind.idl b/librpc/idl/winbind.idl
index 60c875b..ec472c5 100644
--- a/librpc/idl/winbind.idl
+++ b/librpc/idl/winbind.idl
@@ -59,7 +59,7 @@ interface winbind
NTSTATUS wbint_UnixIDs2Sids(
[in,string,charset(UTF8)] char *domain_name,
[in] uint32 num_ids,
- [in] unixid xids[num_ids],
+ [in,out] unixid xids[num_ids],
[out] dom_sid sids[num_ids]
);
diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c
index 4a581d33..7b80418 100644
--- a/source3/winbindd/winbindd_dual_srv.c
+++ b/source3/winbindd/winbindd_dual_srv.c
@@ -233,6 +233,7 @@ NTSTATUS _wbint_UnixIDs2Sids(struct pipes_struct *p,
}
for (i=0; i<r->in.num_ids; i++) {
+ r->out.xids[i] = maps[i]->xid;
sid_copy(&r->out.sids[i], maps[i]->sid);
}
--
2.1.4
>From 2a53233087ffb7098982cf461cc118ab99cfde00 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 20 Dec 2016 16:22:48 +0100
Subject: [PATCH 2/2] idmap: Prime gencache after xids2sids calls
This fixes a performance regression for "hide unreadable". With an empty
gencache, we only do xid2sid calls when reading a large number of acls. We
lost caching the xid2sid calls while implmenting the multiple-id calls,
probably because at that time the bug with ID_TYPE_BOTH backends was still
pending. This patch restores the xid2sid caching hopefully correctly.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/winbindd/wb_xids2sids.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/source3/winbindd/wb_xids2sids.c b/source3/winbindd/wb_xids2sids.c
index 7fc8a72..e154c3b 100644
--- a/source3/winbindd/wb_xids2sids.c
+++ b/source3/winbindd/wb_xids2sids.c
@@ -262,7 +262,20 @@ static void wb_xids2sids_dom_done(struct tevent_req *subreq)
continue;
}
- sid_copy(&state->all_sids[i], &state->dom_sids[dom_sid_idx++]);
+ sid_copy(&state->all_sids[i], &state->dom_sids[dom_sid_idx]);
+
+ /*
+ * Prime the cache after an xid2sid call. It's
+ * important that we use state->dom_xids for the xid
+ * value, not state->all_xids: state->all_xids carries
+ * what we asked for, e.g. a
+ * ID_TYPE_UID. state->dom_xids holds something the
+ * idmap child possibly changed to ID_TYPE_BOTH.
+ */
+ idmap_cache_set_sid2unixid(
+ &state->all_sids[i], &state->dom_xids[dom_sid_idx]);
+
+ dom_sid_idx += 1;
}
tevent_req_done(req);
--
2.1.4
More information about the samba-technical
mailing list