svn commit: samba r6876 - in branches/SAMBA_4_0/source/cldap_server: .

tridge at samba.org tridge at samba.org
Wed May 18 04:18:19 GMT 2005


Author: tridge
Date: 2005-05-18 04:18:19 +0000 (Wed, 18 May 2005)
New Revision: 6876

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

Log:
- fixed a memory leak in the cldap server

- keep the samdb open between requests

Modified:
   branches/SAMBA_4_0/source/cldap_server/cldap_server.c
   branches/SAMBA_4_0/source/cldap_server/cldap_server.h
   branches/SAMBA_4_0/source/cldap_server/netlogon.c


Changeset:
Modified: branches/SAMBA_4_0/source/cldap_server/cldap_server.c
===================================================================
--- branches/SAMBA_4_0/source/cldap_server/cldap_server.c	2005-05-18 04:17:24 UTC (rev 6875)
+++ branches/SAMBA_4_0/source/cldap_server/cldap_server.c	2005-05-18 04:18:19 UTC (rev 6876)
@@ -130,6 +130,7 @@
 	}
 
 	cldapd->task = task;
+	cldapd->samctx = NULL;
 
 	/* start listening on the configured network interfaces */
 	status = cldapd_startup_interfaces(cldapd);

Modified: branches/SAMBA_4_0/source/cldap_server/cldap_server.h
===================================================================
--- branches/SAMBA_4_0/source/cldap_server/cldap_server.h	2005-05-18 04:17:24 UTC (rev 6875)
+++ branches/SAMBA_4_0/source/cldap_server/cldap_server.h	2005-05-18 04:18:19 UTC (rev 6876)
@@ -27,5 +27,5 @@
 */
 struct cldapd_server {
 	struct task_server *task;
-	const char *dns_domain;
+	struct ldb_context *samctx;
 };

Modified: branches/SAMBA_4_0/source/cldap_server/netlogon.c
===================================================================
--- branches/SAMBA_4_0/source/cldap_server/netlogon.c	2005-05-18 04:17:24 UTC (rev 6875)
+++ branches/SAMBA_4_0/source/cldap_server/netlogon.c	2005-05-18 04:18:19 UTC (rev 6876)
@@ -30,7 +30,7 @@
 /*
   fill in the cldap netlogon union for a given version
 */
-static NTSTATUS cldapd_netlogon_fill(struct cldap_socket *cldap,
+static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
 				     TALLOC_CTX *mem_ctx,
 				     const char *domain,
 				     const char *domain_guid,
@@ -39,7 +39,6 @@
 				     uint32_t version,
 				     union nbt_cldap_netlogon *netlogon)
 {
-	struct ldb_context *samctx;
 	const char *attrs[] = {"realm", "dnsDomain", "objectGUID", "name", NULL};
 	struct ldb_message **res;
 	int ret;
@@ -55,10 +54,12 @@
 	const char *site_name2;
 	const char *pdc_ip;
 
-	samctx = samdb_connect(mem_ctx);
-	if (samctx == NULL) {
-		DEBUG(2,("Unable to open sam in cldap netlogon reply\n"));
-		return NT_STATUS_INTERNAL_DB_CORRUPTION;
+	if (cldapd->samctx == NULL) {
+		cldapd->samctx = samdb_connect(mem_ctx);
+		if (cldapd->samctx == NULL) {
+			DEBUG(2,("Unable to open sam in cldap netlogon reply\n"));
+			return NT_STATUS_INTERNAL_DB_CORRUPTION;
+		}
 	}
 
 	/* the domain has an optional trailing . */
@@ -67,7 +68,7 @@
 	}
 
 	/* try and find the domain */
-	ret = gendb_search(samctx, samctx, NULL, &res, attrs, 
+	ret = gendb_search(cldapd->samctx, mem_ctx, NULL, &res, attrs, 
 			   "(&(objectClass=domainDNS)(|(dnsDomain=%s)(objectGUID=%s)))", 
 			   domain?domain:"", 
 			   domain_guid?domain_guid:"");
@@ -177,6 +178,7 @@
 			     const char *filter,
 			     const char *src_address, int src_port)
 {
+	struct cldapd_server *cldapd = talloc_get_type(cldap->incoming.private, struct cldapd_server);
 	struct ldap_parse_tree *tree;
 	int i;
 	const char *domain = NULL;
@@ -191,7 +193,7 @@
 
 	TALLOC_CTX *tmp_ctx = talloc_new(cldap);
 
-	DEBUG(0,("cldap filter='%s'\n", filter));
+	DEBUG(5,("cldap filter='%s'\n", filter));
 
 	tree = ldap_parse_filter_string(tmp_ctx, filter);
 	if (tree == NULL) goto failed;
@@ -249,10 +251,10 @@
 		goto failed;
 	}
 
-	DEBUG(0,("cldap netlogon query domain=%s host=%s user=%s version=%d guid=%s\n",
+	DEBUG(5,("cldap netlogon query domain=%s host=%s user=%s version=%d guid=%s\n",
 		 domain, host, user, version, domain_guid));
 
-	status = cldapd_netlogon_fill(cldap, tmp_ctx, domain, domain_guid, 
+	status = cldapd_netlogon_fill(cldapd, tmp_ctx, domain, domain_guid, 
 				      user, src_address, 
 				      version, &netlogon);
 	if (!NT_STATUS_IS_OK(status)) {



More information about the samba-cvs mailing list