[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Wed May 23 19:33:02 MDT 2012


The branch, master has been updated
       via  f52afa9 dlz_bind9: Make the talloc destructor static and return 0.
       via  34eab45 dlz_bind9: Fix the named crash on reloading named
      from  e8601c0 s3-configure: Fix configure version information.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit f52afa955ecdf856b730a0855bf001293fdd8f0c
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed May 23 11:53:59 2012 +1000

    dlz_bind9: Make the talloc destructor static and return 0.
    
    Autobuild-User: Amitay Isaacs <amitay at samba.org>
    Autobuild-Date: Thu May 24 03:32:50 CEST 2012 on sn-devel-104

commit 34eab45cba6989b66d37c7eb74d97846014ec4eb
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed May 23 11:52:16 2012 +1000

    dlz_bind9: Fix the named crash on reloading named
    
    When reloading zones, named first creates new zone instance and then shuts down
    the old instance. Since ldb layer, keeps the same LDB open, talloc_free() on samdb
    handle, causes talloc "access after use" error.
    
    This patch keeps only single context (dlz_bind9_data) and uses reference counting
    to decide when to actually free the context. Since samdb handle is reused, use
    talloc_unlink() instead of talloc_free() on samdb handle.

-----------------------------------------------------------------------

Summary of changes:
 source4/dns_server/dlz_bind9.c |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dns_server/dlz_bind9.c b/source4/dns_server/dlz_bind9.c
index 224f242..c3c4172 100644
--- a/source4/dns_server/dlz_bind9.c
+++ b/source4/dns_server/dlz_bind9.c
@@ -65,6 +65,8 @@ struct dlz_bind9_data {
 	dns_dlz_writeablezone_t *writeable_zone;
 };
 
+static struct dlz_bind9_data *dlz_bind9_state = NULL;
+static int dlz_bind9_state_ref_count = 0;
 
 static const char *zone_prefixes[] = {
 	"CN=MicrosoftDNS,DC=DomainDnsZones",
@@ -550,10 +552,11 @@ static void b9_debug(void *private_ptr, int msg_level, const char *msg)
 	state->log(isc_log_level, "samba_dlz: %s", msg);
 }
 
-int dlz_state_debug_unregister(struct dlz_bind9_data *state)
+static int dlz_state_debug_unregister(struct dlz_bind9_data *state)
 {
 	/* Stop logging (to the bind9 logs) */
 	debug_set_callback(NULL, NULL);
+	return 0;
 }
 
 /*
@@ -570,6 +573,12 @@ _PUBLIC_ isc_result_t dlz_create(const char *dlzname,
 	struct ldb_dn *dn;
 	NTSTATUS nt_status;
 
+	if (dlz_bind9_state != NULL) {
+		*dbdata = dlz_bind9_state;
+		dlz_bind9_state_ref_count++;
+		return ISC_R_SUCCESS;
+	}
+
 	state = talloc_zero(NULL, struct dlz_bind9_data);
 	if (state == NULL) {
 		return ISC_R_NOMEMORY;
@@ -664,6 +673,8 @@ _PUBLIC_ isc_result_t dlz_create(const char *dlzname,
 	state->auth_context->generate_session_info_pac = b9_generate_session_info_pac;
 
 	*dbdata = state;
+	dlz_bind9_state = state;
+	dlz_bind9_state_ref_count++;
 
 	return ISC_R_SUCCESS;
 
@@ -679,7 +690,13 @@ _PUBLIC_ void dlz_destroy(void *dbdata)
 {
 	struct dlz_bind9_data *state = talloc_get_type_abort(dbdata, struct dlz_bind9_data);
 	state->log(ISC_LOG_INFO, "samba_dlz: shutting down");
-	talloc_free(state);
+
+	dlz_bind9_state_ref_count--;
+	if (dlz_bind9_state_ref_count == 0) {
+		talloc_unlink(state, state->samdb);
+		talloc_free(state);
+		dlz_bind9_state = NULL;
+	}
 }
 
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list