diff options
author | Simo Sorce <idra@samba.org> | 2008-09-03 11:52:54 -0400 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2008-09-03 11:52:54 -0400 |
commit | c5894e14771562bccd153a98610722632ca3956a (patch) | |
tree | 5ea00141df4ffa12bad3475fdafc525ffa4d92af /source3/passdb/lookup_sid.c | |
parent | a1de4e988d7780f687bb7ed2288faf3dfbb9da71 (diff) | |
parent | 84fca380f2040c53d20fff41972d2f4102183766 (diff) | |
download | samba-c5894e14771562bccd153a98610722632ca3956a.tar.gz |
Merge branch 'v3-devel' of ssh://git.samba.org/data/git/samba into v3-devel
(This used to be commit 8e4dca3b9416d9b5e535bda5e4befc073bfc1641)
Diffstat (limited to 'source3/passdb/lookup_sid.c')
-rw-r--r-- | source3/passdb/lookup_sid.c | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c index 706df48923c..9813101bc1f 100644 --- a/source3/passdb/lookup_sid.c +++ b/source3/passdb/lookup_sid.c @@ -1311,7 +1311,16 @@ void uid_to_sid(DOM_SID *psid, uid_t uid) /* Check the winbindd cache directly. */ ret = idmap_cache_find_uid2sid(uid, psid, &expired); - if (!ret || expired || (ret && is_null_sid(psid))) { + if (ret && !expired && is_null_sid(psid)) { + /* + * Negative cache entry, we already asked. + * do legacy. + */ + legacy_uid_to_sid(psid, uid); + return; + } + + if (!ret || expired) { /* Not in cache. Ask winbindd. */ if (!winbind_uid_to_sid(psid, uid)) { if (!winbind_ping()) { @@ -1348,7 +1357,16 @@ void gid_to_sid(DOM_SID *psid, gid_t gid) /* Check the winbindd cache directly. */ ret = idmap_cache_find_gid2sid(gid, psid, &expired); - if (!ret || expired || (ret && is_null_sid(psid))) { + if (ret && !expired && is_null_sid(psid)) { + /* + * Negative cache entry, we already asked. + * do legacy. + */ + legacy_gid_to_sid(psid, gid); + return; + } + + if (!ret || expired) { /* Not in cache. Ask winbindd. */ if (!winbind_gid_to_sid(psid, gid)) { if (!winbind_ping()) { @@ -1402,7 +1420,15 @@ bool sid_to_uid(const DOM_SID *psid, uid_t *puid) /* Check the winbindd cache directly. */ ret = idmap_cache_find_sid2uid(psid, puid, &expired); - if (!ret || expired || (ret && (*puid == (uid_t)-1))) { + if (ret && !expired && (*puid == (uid_t)-1)) { + /* + * Negative cache entry, we already asked. + * do legacy. + */ + return legacy_sid_to_uid(psid, puid); + } + + if (!ret || expired) { /* Not in cache. Ask winbindd. */ if (!winbind_sid_to_uid(puid, psid)) { if (!winbind_ping()) { @@ -1458,7 +1484,15 @@ bool sid_to_gid(const DOM_SID *psid, gid_t *pgid) /* Check the winbindd cache directly. */ ret = idmap_cache_find_sid2gid(psid, pgid, &expired); - if (!ret || expired || (ret && (*pgid == (gid_t)-1))) { + if (ret && !expired && (*pgid == (gid_t)-1)) { + /* + * Negative cache entry, we already asked. + * do legacy. + */ + return legacy_sid_to_gid(psid, pgid); + } + + if (!ret || expired) { /* Not in cache or negative. Ask winbindd. */ /* Ask winbindd if it can map this sid to a gid. * (Idmap will check it is a valid SID and of the right type) */ |