summaryrefslogtreecommitdiff
path: root/source3/nsswitch/winbindd_cache.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-06-04 03:44:04 +0000
committerTim Potter <tpot@samba.org>2002-06-04 03:44:04 +0000
commit984806f959f6740cb93497cf9b2efc5d2c839796 (patch)
treebd7799007b0dbf4ac5e4c3a5037b796004b6c164 /source3/nsswitch/winbindd_cache.c
parent8e9a8b29f2b86c327cc570a1c7e97eee314e66ca (diff)
downloadsamba-984806f959f6740cb93497cf9b2efc5d2c839796.tar.gz
samba-984806f959f6740cb93497cf9b2efc5d2c839796.tar.bz2
samba-984806f959f6740cb93497cf9b2efc5d2c839796.zip
Store the key for a name to sid cache entry in upper case rather than
whatever case the request was made in. This gets rid of duplicate cache entries. Also when doing a sid to name, prime the cache with the name to sid mapping result. We can't do the reverse as we don't know the correct case of the name to store in the cache. (This used to be commit f268b0d5fb811b364578b11a66ca69973717eea8)
Diffstat (limited to 'source3/nsswitch/winbindd_cache.c')
-rw-r--r--source3/nsswitch/winbindd_cache.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/source3/nsswitch/winbindd_cache.c b/source3/nsswitch/winbindd_cache.c
index 282a37230b..407bd60f8a 100644
--- a/source3/nsswitch/winbindd_cache.c
+++ b/source3/nsswitch/winbindd_cache.c
@@ -423,6 +423,7 @@ static void wcache_save_name_to_sid(struct winbindd_domain *domain, NTSTATUS sta
{
struct cache_entry *centry;
uint32 len;
+ fstring uname;
centry = centry_start(domain, status);
if (!centry) return;
@@ -431,7 +432,9 @@ static void wcache_save_name_to_sid(struct winbindd_domain *domain, NTSTATUS sta
centry_put_uint32(centry, type);
sid_linearize(centry->data + centry->ofs, len, sid);
centry->ofs += len;
- centry_end(centry, "NS/%s/%s", domain->name, name);
+ fstrcpy(uname, name);
+ strupper(uname);
+ centry_end(centry, "NS/%s/%s", domain->name, uname);
centry_free(centry);
}
@@ -610,10 +613,13 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
NTSTATUS status;
+ fstring uname;
if (!cache->tdb) goto do_query;
- centry = wcache_fetch(cache, domain, "NS/%s/%s", domain->name, name);
+ fstrcpy(uname, name);
+ strupper(uname);
+ centry = wcache_fetch(cache, domain, "NS/%s/%s", domain->name, uname);
if (!centry) goto do_query;
*type = centry_uint32(centry);
sid_parse(centry->data + centry->ofs, centry->len - centry->ofs, sid);
@@ -633,6 +639,9 @@ do_query:
/* and save it */
wcache_save_name_to_sid(domain, status, name, sid, *type);
+ /* We can't save the sid to name mapping as we don't know the
+ correct case of the name without looking it up */
+
return status;
}
@@ -674,6 +683,7 @@ do_query:
/* and save it */
refresh_sequence_number(domain, True);
wcache_save_sid_to_name(domain, status, sid, *name, *type, rid);
+ wcache_save_name_to_sid(domain, status, *name, sid, *type);
return status;
}
@@ -891,5 +901,3 @@ struct winbindd_methods cache_methods = {
trusted_domains,
domain_sid
};
-
-