diff options
author | Ralph Boehme <slow@samba.org> | 2019-02-22 11:00:00 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2019-02-23 07:54:10 +0100 |
commit | 62f54229fced20102e11ad1da02faef45c2a7c2e (patch) | |
tree | 634cb0cd1a6b8a51d449345e02ab26b56871a3f6 /source3/winbindd | |
parent | 8e9c2a1f6ceb06d695a6572701b96a3e3821ac42 (diff) | |
download | samba-62f54229fced20102e11ad1da02faef45c2a7c2e.tar.gz |
winbindd: track whether a result from xid2sid was coming from the cache
This is needed in preparation of moving the step to update the idmap
cache from the per-idmap-domain callback wb_xids2sids_dom_done() to the
top-level callback wb_xids2sids_done().
Currently the sequence of action is:
* check cache, if not found:
* ask backends
* cache result from backend
* return results
Iow, if we got something from the cache, we don't write the cache.
The next commit defers updating the cache to the top-level callback, so
the sequence becomes
* check cache, if not found:
* ask backends
* cache results
* return results
This has two problems:
* it needlessly writes to the cache what we just got from it
* it possibly overwrites the ID_TYPE_BOTH for a SID-to-xid mapping in
the following case:
- existing ID_TYPE_BOTH mapping in the cache, eg:
IDMAP/SID2XID/S-1-5-21-2180672342-2513613279-2566592647-512 -> Value: 3000000:B
- someone calls wb_xids2sids_send() with xid.id=3000000,xid.type=ID_TYPE_GID
- cache lookup with idmap_cache_find_gid2sid() succeeds
- when caching results we'd call idmap_cache_set_sid2unixid() with the
callers xid.type=ID_TYPE_GID, so idmap_cache_set_sid2unixid() will
overwrite the SID-to-xid mapping with ID_TYPE_GID
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13802
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3/winbindd')
-rw-r--r-- | source3/winbindd/wb_xids2sids.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/source3/winbindd/wb_xids2sids.c b/source3/winbindd/wb_xids2sids.c index 331a04c4fb0..9dd8f22da26 100644 --- a/source3/winbindd/wb_xids2sids.c +++ b/source3/winbindd/wb_xids2sids.c @@ -432,6 +432,7 @@ struct wb_xids2sids_state { struct unixid *xids; size_t num_xids; struct dom_sid *sids; + bool *cached; size_t dom_idx; }; @@ -466,6 +467,11 @@ struct tevent_req *wb_xids2sids_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } + state->cached = talloc_zero_array(state, bool, num_xids); + if (tevent_req_nomem(state->cached, req)) { + return tevent_req_post(req, ev); + } + if (winbindd_use_idmap_cache()) { uint32_t i; @@ -493,6 +499,7 @@ struct tevent_req *wb_xids2sids_send(TALLOC_CTX *mem_ctx, dom_sid_str_buf(&sid, &buf)); sid_copy(&state->sids[i], &sid); + state->cached[i] = true; } } } |