svn commit: samba r19249 - in branches/SAMBA_3_0/source/libsmb: .

jra at samba.org jra at samba.org
Wed Oct 11 18:54:40 GMT 2006


Author: jra
Date: 2006-10-11 18:54:40 +0000 (Wed, 11 Oct 2006)
New Revision: 19249

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19249

Log:
Attempt to fix a site lookup bug found by Guenther.

- "The problem is, with a fresh system, we don't know our sitename,
therefor we do a stupid DNS query for all DCs. The reply we get is a
round-robin list of all 21 PSA DCs, we just pick the first, contact that
and safe that INET.COM#1C query in the name cache for later use...
What we need to do if we don't yet know our sitename, is to contact to
any DC, get the CLDAP reply to tell us in which site we are, then flush
the namecache and requery DNS including the sitename"

Implement the flushing of the #1C entries for a given NetBIOS name/realm
when looking up the site value.

Jeremy.

Modified:
   branches/SAMBA_3_0/source/libsmb/namecache.c
   branches/SAMBA_3_0/source/libsmb/namequery_dc.c


Changeset:
Modified: branches/SAMBA_3_0/source/libsmb/namecache.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/namecache.c	2006-10-11 15:27:21 UTC (rev 19248)
+++ branches/SAMBA_3_0/source/libsmb/namecache.c	2006-10-11 18:54:40 UTC (rev 19249)
@@ -142,6 +142,10 @@
 	}
 	
 	key = namecache_key(name, name_type);
+	if (!key) {
+		return False;
+	}
+
 	expiry = time(NULL) + lp_name_cache_timeout();
 
 	/*
@@ -198,6 +202,9 @@
 	 * 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,7 +225,32 @@
 	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
  * gencache_iterate definition.

Modified: branches/SAMBA_3_0/source/libsmb/namequery_dc.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/namequery_dc.c	2006-10-11 15:27:21 UTC (rev 19248)
+++ branches/SAMBA_3_0/source/libsmb/namequery_dc.c	2006-10-11 18:54:40 UTC (rev 19249)
@@ -72,6 +72,9 @@
 			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;
 		}
 



More information about the samba-cvs mailing list