summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/libsmb/namecache.c32
-rw-r--r--source3/libsmb/namequery_dc.c3
2 files changed, 35 insertions, 0 deletions
diff --git a/source3/libsmb/namecache.c b/source3/libsmb/namecache.c
index bd4b3caeb7..02956fa137 100644
--- a/source3/libsmb/namecache.c
+++ b/source3/libsmb/namecache.c
@@ -142,6 +142,10 @@ BOOL namecache_store(const char *name, int name_type,
}
key = namecache_key(name, name_type);
+ if (!key) {
+ return False;
+ }
+
expiry = time(NULL) + lp_name_cache_timeout();
/*
@@ -198,6 +202,9 @@ BOOL namecache_fetch(const char *name, int name_type, struct ip_service **ip_lis
* Use gencache interface - lookup the key
*/
key = namecache_key(name, name_type);
+ if (!key) {
+ return False;
+ }
if (!gencache_get(key, &value, &timeout)) {
DEBUG(5, ("no entry for %s#%02X found.\n", name, name_type));
@@ -218,6 +225,31 @@ BOOL namecache_fetch(const char *name, int name_type, struct ip_service **ip_lis
return *num_names > 0; /* true only if some ip has been fetched */
}
+/**
+ * Remove a namecache entry. Needed for site support.
+ *
+ **/
+
+BOOL namecache_delete(const char *name, int name_type)
+{
+ BOOL ret;
+ char *key;
+
+ if (!gencache_init())
+ return False;
+
+ if (name_type > 255) {
+ return False; /* Don't fetch non-real name types. */
+ }
+
+ key = namecache_key(name, name_type);
+ if (!key) {
+ return False;
+ }
+ ret = gencache_del(key);
+ SAFE_FREE(key);
+ return ret;
+}
/**
* Delete single namecache entry. Look at the
diff --git a/source3/libsmb/namequery_dc.c b/source3/libsmb/namequery_dc.c
index cf01fb269e..5280118ab8 100644
--- a/source3/libsmb/namequery_dc.c
+++ b/source3/libsmb/namequery_dc.c
@@ -72,6 +72,9 @@ static BOOL ads_dc_name(const char *domain,
SAFE_FREE(sitename);
sitename = sitename_fetch();
ads_destroy(&ads);
+ /* Ensure we don't cache the DC we just connected to. */
+ namecache_delete(realm, 0x1C);
+ namecache_delete(domain, 0x1C);
continue;
}