[SCM] Samba Shared Repository - branch master updated - tevent-0-9-8-262-g0be268b

Andrew Tridgell tridge at samba.org
Sat Sep 12 02:13:18 MDT 2009


The branch, master has been updated
       via  0be268bf5538dcf57f9534d864be1960dfab0f72 (commit)
       via  5c0cf012a746228aa17524e5e153b833028f284b (commit)
       via  1820f4bdafc1aaf58c4166d266e71996672fd8d6 (commit)
       via  ca6e15f2f985d5ea1e907c05ae585152d385938e (commit)
       via  5c33042498763ce814c0539e0a96f73a06a76dfd (commit)
      from  a8ab1e2570ac2a2e772295cd0cc46b7e60398043 (commit)

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


- Log -----------------------------------------------------------------
commit 0be268bf5538dcf57f9534d864be1960dfab0f72
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sat Sep 12 16:08:07 2009 +1000

    s4-scripts: allow setup_dns.sh to take a PRIVATEDIR

commit 5c0cf012a746228aa17524e5e153b833028f284b
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sat Sep 12 15:24:31 2009 +1000

    s4-samdb: make it possible to ask for the sequence number of a partition
    
    The partition module normally makes the sequence number extended op
    operate across all partitions. It will be useful in the repl task to
    be able to ask for the sequence number of one partition

commit 1820f4bdafc1aaf58c4166d266e71996672fd8d6
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sat Sep 12 15:23:30 2009 +1000

    s4-drs: change debug level
    
    It's useful seeing the object count without as much detail

commit ca6e15f2f985d5ea1e907c05ae585152d385938e
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sat Sep 12 15:22:26 2009 +1000

    s4-repl: fixed memory leaks
    
    These memory leaks were mostly caused by the fact that
    refresh_partitions is now called periodically

commit 5c33042498763ce814c0539e0a96f73a06a76dfd
Author: Andrew Tridgell <tridge at samba.org>
Date:   Sat Sep 12 15:21:33 2009 +1000

    s4-ndr: fixed memory leaks in ndr_pull_*_blob()
    
    We needed to free the ndr structures, both on error and normal return

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

Summary of changes:
 librpc/ndr/libndr.h                        |   10 ++++++++
 librpc/ndr/ndr.c                           |   25 +++++++++++++-------
 source4/dsdb/repl/drepl_out_helpers.c      |    6 +---
 source4/dsdb/repl/drepl_partitions.c       |   34 ++++++++++++++++++++++-----
 source4/dsdb/repl/drepl_periodic.c         |    3 +-
 source4/dsdb/samdb/ldb_modules/partition.c |    9 +++++++
 source4/rpc_server/drsuapi/getncchanges.c  |    2 +-
 source4/scripting/bin/setup_dns.sh         |    4 ++-
 8 files changed, 70 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index 7b981f9..d01b68e 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -254,6 +254,16 @@ enum ndr_compression_alg {
 	} \
 } while (0)
 
+/* if the call fails then free the ndr pointer */
+#define NDR_CHECK_FREE(call) do { \
+	enum ndr_err_code _status; \
+	_status = call; \
+	if (!NDR_ERR_CODE_IS_SUCCESS(_status)) { \
+		talloc_free(ndr);		 \
+		return _status; \
+	} \
+} while (0)
+
 #define NDR_PULL_GET_MEM_CTX(ndr) (ndr->current_mem_ctx)
 
 #define NDR_PULL_SET_MEM_CTX(ndr, mem_ctx, flgs) do {\
diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c
index 837690b..2b3493b 100644
--- a/librpc/ndr/ndr.c
+++ b/librpc/ndr/ndr.c
@@ -846,7 +846,8 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CT
 	struct ndr_pull *ndr;
 	ndr = ndr_pull_init_blob(blob, mem_ctx, iconv_convenience);
 	NDR_ERR_HAVE_NO_MEMORY(ndr);
-	NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
+	NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
+	talloc_free(ndr);
 	return NDR_ERR_SUCCESS;
 }
 
@@ -860,12 +861,13 @@ _PUBLIC_ enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLO
 	struct ndr_pull *ndr;
 	ndr = ndr_pull_init_blob(blob, mem_ctx, iconv_convenience);
 	NDR_ERR_HAVE_NO_MEMORY(ndr);
-	NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
+	NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
 	if (ndr->offset < ndr->data_size) {
 		return ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
 				      "not all bytes consumed ofs[%u] size[%u]",
 				      ndr->offset, ndr->data_size);
 	}
+	talloc_free(ndr);
 	return NDR_ERR_SUCCESS;
 }
 
@@ -879,8 +881,9 @@ _PUBLIC_ enum ndr_err_code ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX
 	struct ndr_pull *ndr;
 	ndr = ndr_pull_init_blob(blob, mem_ctx, iconv_convenience);
 	NDR_ERR_HAVE_NO_MEMORY(ndr);
-	NDR_CHECK(ndr_pull_set_switch_value(ndr, p, level));
-	NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
+	NDR_CHECK_FREE(ndr_pull_set_switch_value(ndr, p, level));
+	NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
+	talloc_free(ndr);
 	return NDR_ERR_SUCCESS;
 }
 
@@ -895,13 +898,17 @@ _PUBLIC_ enum ndr_err_code ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC
 	struct ndr_pull *ndr;
 	ndr = ndr_pull_init_blob(blob, mem_ctx, iconv_convenience);
 	NDR_ERR_HAVE_NO_MEMORY(ndr);
-	NDR_CHECK(ndr_pull_set_switch_value(ndr, p, level));
-	NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
+	NDR_CHECK_FREE(ndr_pull_set_switch_value(ndr, p, level));
+	NDR_CHECK_FREE(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p));
 	if (ndr->offset < ndr->data_size) {
-		return ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
-				      "not all bytes consumed ofs[%u] size[%u]",
-				      ndr->offset, ndr->data_size);
+		enum ndr_err_code ret;
+		ret = ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
+				     "not all bytes consumed ofs[%u] size[%u]",
+				     ndr->offset, ndr->data_size);
+		talloc_free(ndr);
+		return ret;
 	}
+	talloc_free(ndr);
 	return NDR_ERR_SUCCESS;
 }
 
diff --git a/source4/dsdb/repl/drepl_out_helpers.c b/source4/dsdb/repl/drepl_out_helpers.c
index 59b3176..e90f278 100644
--- a/source4/dsdb/repl/drepl_out_helpers.c
+++ b/source4/dsdb/repl/drepl_out_helpers.c
@@ -464,10 +464,8 @@ static void dreplsrv_update_refs_recv(struct rpc_request *req)
 
 	c->status = dcerpc_ndr_request_recv(req);
 	if (!composite_is_ok(c)) {
-		DEBUG(0,("UpdateRefs failed with %s for %s %s\n", 
-			 nt_errstr(c->status),
-			 r->in.req.req1.dest_dsa_dns_name,
-			 r->in.req.req1.naming_context->dn));
+		DEBUG(0,("UpdateRefs failed with %s\n", 
+			 nt_errstr(c->status)));
 		return;
 	}
 
diff --git a/source4/dsdb/repl/drepl_partitions.c b/source4/dsdb/repl/drepl_partitions.c
index 88c4bbf..85412a7 100644
--- a/source4/dsdb/repl/drepl_partitions.c
+++ b/source4/dsdb/repl/drepl_partitions.c
@@ -148,7 +148,7 @@ static WERROR dreplsrv_partition_add_source_dsa(struct dreplsrv_service *s,
 {
 	WERROR status;
 	enum ndr_err_code ndr_err;
-	struct dreplsrv_partition_source_dsa *source;
+	struct dreplsrv_partition_source_dsa *source, *s2;
 
 	source = talloc_zero(p, struct dreplsrv_partition_source_dsa);
 	W_ERROR_HAVE_NO_MEMORY(source);
@@ -158,10 +158,12 @@ static WERROR dreplsrv_partition_add_source_dsa(struct dreplsrv_service *s,
 				       (ndr_pull_flags_fn_t)ndr_pull_repsFromToBlob);
 	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
 		NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
+		talloc_free(source);
 		return ntstatus_to_werror(nt_status);
 	}
 	/* NDR_PRINT_DEBUG(repsFromToBlob, &source->_repsFromBlob); */
 	if (source->_repsFromBlob.version != 1) {
+		talloc_free(source);
 		return WERR_DS_DRA_INTERNAL_ERROR;
 	}
 
@@ -171,13 +173,24 @@ static WERROR dreplsrv_partition_add_source_dsa(struct dreplsrv_service *s,
 	status = dreplsrv_out_connection_attach(s, source->repsFrom1, &source->conn);
 	W_ERROR_NOT_OK_RETURN(status);
 
+	/* remove any existing source with the same GUID */
+	for (s2=p->sources; s2; s2=s2->next) {
+		if (GUID_compare(&s2->repsFrom1->source_dsa_obj_guid, 
+				 &source->repsFrom1->source_dsa_obj_guid) == 0) {
+			talloc_free(s2->repsFrom1->other_info);
+			*s2->repsFrom1 = *source->repsFrom1;
+			talloc_steal(s2, s2->repsFrom1->other_info);
+			talloc_free(source);
+			return WERR_OK;
+		}
+	}
+
 	DLIST_ADD_END(p->sources, source, struct dreplsrv_partition_source_dsa *);
 	return WERR_OK;
 }
 
 static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
-					 struct dreplsrv_partition *p,
-					 TALLOC_CTX *mem_ctx)
+					 struct dreplsrv_partition *p)
 {
 	WERROR status;
 	const struct ldb_val *ouv_value;
@@ -187,6 +200,7 @@ static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
 	struct ldb_result *r;
 	uint32_t i;
 	int ret;
+	TALLOC_CTX *mem_ctx = talloc_new(p);
 	static const char *attrs[] = {
 		"objectSid",
 		"objectGUID",
@@ -201,12 +215,14 @@ static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
 	ret = ldb_search(s->samdb, mem_ctx, &r, p->dn, LDB_SCOPE_BASE, attrs,
 			 "(objectClass=*)");
 	if (ret != LDB_SUCCESS) {
+		talloc_free(mem_ctx);
 		return WERR_FOOBAR;
 	} else if (r->count != 1) {
-		talloc_free(r);
+		talloc_free(mem_ctx);
 		return WERR_FOOBAR;
 	}
-
+	
+	talloc_free(discard_const(p->nc.dn));
 	ZERO_STRUCT(p->nc);
 	p->nc.dn	= ldb_dn_alloc_linearized(p, p->dn);
 	W_ERROR_HAVE_NO_MEMORY(p->nc.dn);
@@ -214,6 +230,7 @@ static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
 	nc_sid		= samdb_result_dom_sid(p, r->msgs[0], "objectSid");
 	if (nc_sid) {
 		p->nc.sid	= *nc_sid;
+		talloc_free(nc_sid);
 	}
 
 	ouv_value = ldb_msg_find_ldb_val(r->msgs[0], "replUpToDateVector");
@@ -224,15 +241,18 @@ static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
 					       (ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob);
 		if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
 			NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
+			talloc_free(mem_ctx);
 			return ntstatus_to_werror(nt_status);
 		}
 		/* NDR_PRINT_DEBUG(replUpToDateVectorBlob, &ouv); */
 		if (ouv.version != 2) {
+			talloc_free(mem_ctx);
 			return WERR_DS_DRA_INTERNAL_ERROR;
 		}
 
 		p->uptodatevector.count		= ouv.ctr.ctr2.count;
 		p->uptodatevector.reserved	= ouv.ctr.ctr2.reserved;
+		talloc_free(p->uptodatevector.cursors);
 		p->uptodatevector.cursors	= talloc_steal(p, ouv.ctr.ctr2.cursors);
 	}
 
@@ -249,7 +269,7 @@ static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
 		}
 	}
 
-	talloc_free(r);
+	talloc_free(mem_ctx);
 
 	return WERR_OK;
 }
@@ -260,7 +280,7 @@ WERROR dreplsrv_refresh_partitions(struct dreplsrv_service *s)
 	struct dreplsrv_partition *p;
 
 	for (p = s->partitions; p; p = p->next) {
-		status = dreplsrv_refresh_partition(s, p, p);
+		status = dreplsrv_refresh_partition(s, p);
 		W_ERROR_NOT_OK_RETURN(status);
 	}
 
diff --git a/source4/dsdb/repl/drepl_periodic.c b/source4/dsdb/repl/drepl_periodic.c
index 36d5f92..2cfcb31 100644
--- a/source4/dsdb/repl/drepl_periodic.c
+++ b/source4/dsdb/repl/drepl_periodic.c
@@ -103,7 +103,8 @@ static void dreplsrv_periodic_run(struct dreplsrv_service *service)
 	dreplsrv_schedule_pull_replication(service, mem_ctx);
 	talloc_free(mem_ctx);
 
-	DEBUG(2,("dreplsrv_periodic_run(): run pending_ops\n"));
+	DEBUG(2,("dreplsrv_periodic_run(): run pending_ops memory=%u\n", 
+		 (unsigned)talloc_total_blocks(service)));
 
 	/* the KCC might have changed repsFrom */
 	dreplsrv_refresh_partitions(service);
diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c
index dec905e..d4a6995 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.c
+++ b/source4/dsdb/samdb/ldb_modules/partition.c
@@ -763,6 +763,15 @@ static int partition_sequence_number(struct ldb_module *module, struct ldb_reque
 	struct ldb_seqnum_result *tseqr;
 	struct ldb_extended *ext;
 	struct ldb_result *res;
+	struct dsdb_partition *p;
+
+	p = find_partition(NULL, NULL, req);
+	if (p != NULL) {
+		/* the caller specified what partition they want the
+		 * sequence number operation on - just pass it on
+		 */
+		return ldb_next_request(p->module, req);		
+	}
 
 	seq = talloc_get_type(req->op.extended.data, struct ldb_seqnum_request);
 
diff --git a/source4/rpc_server/drsuapi/getncchanges.c b/source4/rpc_server/drsuapi/getncchanges.c
index 4dce07e..6f7637a 100644
--- a/source4/rpc_server/drsuapi/getncchanges.c
+++ b/source4/rpc_server/drsuapi/getncchanges.c
@@ -391,7 +391,7 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_
 	}
 
 
-	DEBUG(4,("DsGetNCChanges with uSNChanged >= %llu on %s gave %u objects\n", 
+	DEBUG(3,("DsGetNCChanges with uSNChanged >= %llu on %s gave %u objects\n", 
 		 (unsigned long long)(r->in.req->req8.highwatermark.highest_usn+1),
 		 ncRoot->dn, r->out.ctr->ctr6.object_count));
 
diff --git a/source4/scripting/bin/setup_dns.sh b/source4/scripting/bin/setup_dns.sh
index e6a4281..f296de2 100755
--- a/source4/scripting/bin/setup_dns.sh
+++ b/source4/scripting/bin/setup_dns.sh
@@ -12,7 +12,9 @@ IP="$3"
 
 RSUFFIX=$(echo $DOMAIN | sed s/[\.]/,DC=/g)
 
-PRIVATEDIR=$(bin/testparm --section-name=global --parameter-name='private dir' --suppress-prompt 2> /dev/null)
+[ -z "$PRIVATEDIR" ] && {
+    PRIVATEDIR=$(bin/testparm --section-name=global --parameter-name='private dir' --suppress-prompt 2> /dev/null)
+}
 
 OBJECTGUID=$(bin/ldbsearch -H "$PRIVATEDIR/sam.ldb" -b "CN=NTDS Settings,CN=$HOSTNAME,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=$RSUFFIX" objectguid|grep ^objectGUID| cut -d: -f2)
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list