[SCM] Samba Shared Repository - branch master updated

Kamen Mazdrashki kamenim at samba.org
Thu Sep 9 11:11:16 MDT 2010


The branch, master has been updated
       via  4f5dd3f s4-dreplsrv: Do allocations on long-living context so that callback gets called
       via  118df59 s4-drs-test: Add 'reset' and 'replace' tests for drsuapi_DsReplicaUpdateRefs
       via  3593298 s4-dreplsrv: Call dreplsrv_out_operation::callback in case we fail to even run the operation
       via  7ee3418 s4-dsdb/repl/drepl_out_pull.c: Remove unused code
       via  ef56945 s4-drepl_service.c: Update (C)
       via  3fa3bc7 s4-drepsrv: Dump more info when drepl_replica_sync() fails
      from  81e97c0 s3-printing: Make missing auth_serversupplied_info const.

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


- Log -----------------------------------------------------------------
commit 4f5dd3f93b96429baa85ec3ef730ea4bdc2b7945
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Thu Sep 9 01:43:01 2010 +0300

    s4-dreplsrv: Do allocations on long-living context so that callback gets called

commit 118df599ce139d72f77692415ab38efaebf0245c
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Thu Sep 9 00:55:51 2010 +0300

    s4-drs-test: Add 'reset' and 'replace' tests for drsuapi_DsReplicaUpdateRefs
    
    At first I got the impression we are not handling those cases,
    but after those tests surprisingly passed I saw that
    we have correct behavior implemented in a helper function.
    
    So I decided to commit those tests in case someone change the
    strange-looking check for DRSUAPI_DRS_ADD_REF flag in
    a function that handles delete operation :)

commit 3593298c7e095b0935bffe05e3b1e190abf91707
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Wed Sep 8 01:07:44 2010 +0300

    s4-dreplsrv: Call dreplsrv_out_operation::callback in case we fail to even run the operation
    
    Operation was scheduled already, so we need to call
    the callback function for it to be able to do its job.
    
    For instance, if we are blocking an rpc call until an
    operation is completed and there is no memory, then
    client will be blocked without knowing what is going on
    with the server.

commit 7ee34182dffdf497bdad5a1e155bc2ca80d71111
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Tue Sep 7 22:24:24 2010 +0300

    s4-dsdb/repl/drepl_out_pull.c: Remove unused code

commit ef56945d0e33aebb089789906b9d037852c9b028
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Tue Sep 7 22:18:53 2010 +0300

    s4-drepl_service.c: Update (C)
    
    and remove few trailing white spaces

commit 3fa3bc7ebaa2f8a5bacb7766329e89ab4e36f644
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Tue Sep 7 21:22:47 2010 +0300

    s4-drepsrv: Dump more info when drepl_replica_sync() fails
    
    There are many spots where this function may fail
    and I find it very useful to know where exactly function
    fails and what are the input parameters during testing.
    
    REPLICA_SYNC_FAIL() macro now dumps an error message
    so we may remove extra DEBUG() dump in implementation.

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

Summary of changes:
 source4/dsdb/kcc/kcc_periodic.c    |    2 +-
 source4/dsdb/repl/drepl_out_pull.c |   51 ++++----------------------
 source4/dsdb/repl/drepl_service.c  |   71 +++++++++++++++++++-----------------
 source4/torture/rpc/drsuapi.c      |   32 ++++++++++++++--
 4 files changed, 75 insertions(+), 81 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/kcc/kcc_periodic.c b/source4/dsdb/kcc/kcc_periodic.c
index 28ff404..a79c848 100644
--- a/source4/dsdb/kcc/kcc_periodic.c
+++ b/source4/dsdb/kcc/kcc_periodic.c
@@ -113,7 +113,7 @@ static void kccsrv_notify_drepl_server(struct kccsrv_service *s,
 	struct dcerpc_binding_handle *irpc_handle;
 	struct tevent_req *subreq;
 
-	state = talloc_zero(mem_ctx, struct kccsrv_notify_drepl_server_state);
+	state = talloc_zero(s, struct kccsrv_notify_drepl_server_state);
 	if (state == NULL) {
 		return;
 	}
diff --git a/source4/dsdb/repl/drepl_out_pull.c b/source4/dsdb/repl/drepl_out_pull.c
index db77a4e..21f986a 100644
--- a/source4/dsdb/repl/drepl_out_pull.c
+++ b/source4/dsdb/repl/drepl_out_pull.c
@@ -89,49 +89,6 @@ WERROR dreplsrv_schedule_pull_replication(struct dreplsrv_service *s, TALLOC_CTX
 }
 
 
-/* force an immediate of the specified partition by GUID  */
-WERROR dreplsrv_schedule_partition_pull_by_guid(struct dreplsrv_service *s, TALLOC_CTX *mem_ctx,
-						struct GUID *guid)
-{
-	struct dreplsrv_partition *p;
-	
-	for (p = s->partitions; p; p = p->next) {
-		if (GUID_compare(&p->nc.guid, guid) == 0) {
-			return dreplsrv_schedule_partition_pull(s, p, mem_ctx);
-		}
-	}
-
-	return WERR_NOT_FOUND;
-}
-
-/* force an immediate of the specified partition by Naming Context */
-WERROR dreplsrv_schedule_partition_pull_by_nc(struct dreplsrv_service *s, TALLOC_CTX *mem_ctx,
-					      struct drsuapi_DsReplicaObjectIdentifier *nc)
-{
-	struct dreplsrv_partition *p;
-	bool valid_sid, valid_guid;
-	struct dom_sid null_sid;
-	ZERO_STRUCT(null_sid);
-
-	valid_sid  = !dom_sid_equal(&null_sid, &nc->sid);
-	valid_guid = !GUID_all_zero(&nc->guid);
-
-	if (!valid_sid && !valid_guid && !nc->dn) {
-		return WERR_DS_DRA_INVALID_PARAMETER;
-	}
-
-	for (p = s->partitions; p; p = p->next) {
-		if ((valid_guid && GUID_equal(&p->nc.guid, &nc->guid))
-		    || strequal(p->nc.dn, nc->dn)
-		    || (valid_sid && dom_sid_equal(&p->nc.sid, &nc->sid))) {
-			return dreplsrv_schedule_partition_pull(s, p, mem_ctx);
-		}
-	}
-
-	return WERR_DS_DRA_BAD_NC;
-}
-
-
 static void dreplsrv_pending_op_callback(struct tevent_req *subreq)
 {
 	struct dreplsrv_out_operation *op = tevent_req_callback_data(subreq,
@@ -206,6 +163,14 @@ void dreplsrv_run_pending_ops(struct dreplsrv_service *s)
 		rf->consecutive_sync_failures++;
 		s->ops.current = NULL;
 
+		/*
+		 * call the callback (if any) so it gets the chance
+		 * to do its job just like in any other failure situation
+		 */
+		if (op->callback) {
+			op->callback(s, rf->result_last_attempt, op->extended_ret, op->cb_data);
+		}
+
 		DEBUG(1,("dreplsrv_op_pull_source(%s/%s) failures[%u]\n",
 			win_errstr(rf->result_last_attempt),
 			nt_errstr(werror_to_ntstatus(rf->result_last_attempt)),
diff --git a/source4/dsdb/repl/drepl_service.c b/source4/dsdb/repl/drepl_service.c
index 7d4a88c..da0d9e5 100644
--- a/source4/dsdb/repl/drepl_service.c
+++ b/source4/dsdb/repl/drepl_service.c
@@ -1,22 +1,23 @@
-/* 
+/*
    Unix SMB/CIFS mplementation.
    DSDB replication service
-   
+
    Copyright (C) Stefan Metzmacher 2007
-    
+   Copyright (C) Kamen Mazdrashki <kamenim at samba.org> 2010
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-   
+
 */
 
 #include "includes.h"
@@ -208,7 +209,7 @@ static WERROR _drepl_schedule_replication(struct dreplsrv_service *service,
 /*
   DsReplicaSync messages from the DRSUAPI server are forwarded here
  */
-static NTSTATUS drepl_replica_sync(struct irpc_message *msg, 
+static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
 				   struct drsuapi_DsReplicaSync *r)
 {
 	WERROR werr;
@@ -220,12 +221,20 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
 	struct dreplsrv_service *service = talloc_get_type(msg->private_data,
 							   struct dreplsrv_service);
 
-#define REPLICA_SYNC_FAIL(_werr) do {r->out.result = _werr; goto done;} while(0)
+#define REPLICA_SYNC_FAIL(_msg, _werr) do {\
+		if (!W_ERROR_IS_OK(werr)) { \
+			DEBUG(0,(__location__ ": Failure - %s. werr = %s\n", \
+				 _msg, win_errstr(_werr))); \
+			NDR_PRINT_IN_DEBUG(drsuapi_DsReplicaSync, r); \
+		} \
+		r->out.result = _werr; \
+		goto done;\
+	} while(0)
+
 
 	if (r->in.level != 1) {
-		DEBUG(0,("%s: Level %d is not supported yet.\n",
-			 __FUNCTION__, r->in.level));
-		REPLICA_SYNC_FAIL(WERR_DS_DRA_INVALID_PARAMETER);
+		REPLICA_SYNC_FAIL("Unsupported level",
+				  WERR_DS_DRA_INVALID_PARAMETER);
 	}
 
 	req1 = &r->in.req->req1;
@@ -233,7 +242,8 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
 
 	/* Check input parameters */
 	if (!nc) {
-		REPLICA_SYNC_FAIL(WERR_DS_DRA_INVALID_PARAMETER);
+		REPLICA_SYNC_FAIL("Invalid Naming Context",
+		                  WERR_DS_DRA_INVALID_PARAMETER);
 	}
 
 	/* Find Naming context to be synchronized */
@@ -241,12 +251,8 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
 	                                      &nc->guid, &nc->sid, nc->dn,
 	                                      &p);
 	if (!W_ERROR_IS_OK(werr)) {
-		DEBUG(0,("%s: failed to find NC for (%s, %s) - %s\n",
-			 __FUNCTION__,
-			 GUID_string(msg, &nc->guid),
-			 nc->dn,
-			 win_errstr(werr)));
-		REPLICA_SYNC_FAIL(werr);
+		REPLICA_SYNC_FAIL("Failed to find requested Naming Context",
+				  werr);
 	}
 
 	/* should we process it asynchronously? */
@@ -255,8 +261,8 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
 	} else {
 		cb_data = talloc_zero(msg, struct drepl_replica_sync_cb_data);
 		if (!cb_data) {
-			DEBUG(0,(__location__ ": Not enought memory!"));
-			REPLICA_SYNC_FAIL(WERR_DS_DRA_INTERNAL_ERROR);
+			REPLICA_SYNC_FAIL("Not enought memory",
+					  WERR_DS_DRA_INTERNAL_ERROR);
 		}
 
 		cb_data->msg = msg;
@@ -270,14 +276,16 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
 			/* schedule replication item */
 			werr = _drepl_schedule_replication(service, dsa, nc, cb_data, msg);
 			if (!W_ERROR_IS_OK(werr)) {
-				REPLICA_SYNC_FAIL(werr);
+				REPLICA_SYNC_FAIL("_drepl_schedule_replication() failed",
+				                  werr);
 			}
 		}
 	} else {
 		if (req1->options & DRSUAPI_DRS_SYNC_BYNAME) {
 			/* client should pass at least valid string */
 			if (!req1->source_dsa_dns) {
-				REPLICA_SYNC_FAIL(WERR_DS_DRA_INVALID_PARAMETER);
+				REPLICA_SYNC_FAIL("'source_dsa_dns' is not valid",
+				                  WERR_DS_DRA_INVALID_PARAMETER);
 			}
 
 			werr = dreplsrv_partition_source_dsa_by_dns(p,
@@ -286,7 +294,8 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
 		} else {
 			/* client should pass at least some GUID */
 			if (GUID_all_zero(&req1->source_dsa_guid)) {
-				REPLICA_SYNC_FAIL(WERR_DS_DRA_INVALID_PARAMETER);
+				REPLICA_SYNC_FAIL("'source_dsa_guid' is not valid",
+				                  WERR_DS_DRA_INVALID_PARAMETER);
 			}
 
 			werr = dreplsrv_partition_source_dsa_by_guid(p,
@@ -294,19 +303,15 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
 			                                             &dsa);
 		}
 		if (!W_ERROR_IS_OK(werr)) {
-			DEBUG(0,("%s: Failed to locate source DSA %s for NC %s.\n",
-				 __FUNCTION__,
-				 (req1->options & DRSUAPI_DRS_SYNC_BYNAME)
-					 ? req1->source_dsa_dns
-					 : GUID_string(r, &req1->source_dsa_guid),
-				 nc->dn));
-			REPLICA_SYNC_FAIL(WERR_DS_DRA_NO_REPLICA);
+			REPLICA_SYNC_FAIL("Failed to locate source DSA for given NC",
+					  WERR_DS_DRA_NO_REPLICA);
 		}
 
 		/* schedule replication item */
 		werr = _drepl_schedule_replication(service, dsa, nc, cb_data, msg);
 		if (!W_ERROR_IS_OK(werr)) {
-			REPLICA_SYNC_FAIL(werr);
+			REPLICA_SYNC_FAIL("_drepl_schedule_replication() failed",
+			                  werr);
 		}
 	}
 
@@ -351,11 +356,11 @@ static void dreplsrv_task_init(struct task_server *task)
 
 	switch (lpcfg_server_role(task->lp_ctx)) {
 	case ROLE_STANDALONE:
-		task_server_terminate(task, "dreplsrv: no DSDB replication required in standalone configuration", 
+		task_server_terminate(task, "dreplsrv: no DSDB replication required in standalone configuration",
 				      false);
 		return;
 	case ROLE_DOMAIN_MEMBER:
-		task_server_terminate(task, "dreplsrv: no DSDB replication required in domain member configuration", 
+		task_server_terminate(task, "dreplsrv: no DSDB replication required in domain member configuration",
 				      false);
 		return;
 	case ROLE_DOMAIN_CONTROLLER:
diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c
index 49202a6..99f101c 100644
--- a/source4/torture/rpc/drsuapi.c
+++ b/source4/torture/rpc/drsuapi.c
@@ -492,7 +492,7 @@ static bool test_DsReplicaUpdateRefs(struct torture_context *tctx,
 					 "dcerpc_drsuapi_DsReplicaUpdateRefs");
 
 	/* 2. hopefully adding random replica dest should succeed */
-	torture_comment(tctx, "add   : %s\n", r.in.req.req1.dest_dsa_dns_name);
+	torture_comment(tctx, "add    : %s\n", r.in.req.req1.dest_dsa_dns_name);
 	r.in.req.req1.options		= DRSUAPI_DRS_ADD_REF;
 	status = dcerpc_drsuapi_DsReplicaUpdateRefs_r(p->binding_handle, tctx, &r);
 	torture_drsuapi_assert_call_werr(tctx, p,
@@ -500,15 +500,39 @@ static bool test_DsReplicaUpdateRefs(struct torture_context *tctx,
 					 "dcerpc_drsuapi_DsReplicaUpdateRefs");
 
 	/* 3. try adding same replica dest - should fail */
-	torture_comment(tctx, "add   : %s\n", r.in.req.req1.dest_dsa_dns_name);
+	torture_comment(tctx, "add    : %s\n", r.in.req.req1.dest_dsa_dns_name);
 	r.in.req.req1.options		= DRSUAPI_DRS_ADD_REF;
 	status = dcerpc_drsuapi_DsReplicaUpdateRefs_r(p->binding_handle, tctx, &r);
 	torture_drsuapi_assert_call_werr(tctx, p,
 					 status, WERR_DS_DRA_REF_ALREADY_EXISTS, &r,
 					 "dcerpc_drsuapi_DsReplicaUpdateRefs");
 
-	/* 4. delete random replicate added at step 2. */
-	torture_comment(tctx, "delete: %s\n", r.in.req.req1.dest_dsa_dns_name);
+	/* 4. try resetting same replica dest - should succeed */
+	torture_comment(tctx, "reset : %s\n", r.in.req.req1.dest_dsa_dns_name);
+	r.in.req.req1.options		= DRSUAPI_DRS_DEL_REF | DRSUAPI_DRS_ADD_REF;
+	status = dcerpc_drsuapi_DsReplicaUpdateRefs_r(p->binding_handle, tctx, &r);
+	torture_drsuapi_assert_call_werr(tctx, p,
+					 status, WERR_OK, &r,
+					 "dcerpc_drsuapi_DsReplicaUpdateRefs");
+
+	/* 5. delete random replicate added at step 2. */
+	torture_comment(tctx, "delete : %s\n", r.in.req.req1.dest_dsa_dns_name);
+	r.in.req.req1.options		= DRSUAPI_DRS_DEL_REF;
+	status = dcerpc_drsuapi_DsReplicaUpdateRefs_r(p->binding_handle, tctx, &r);
+	torture_drsuapi_assert_call_werr(tctx, p,
+					 status, WERR_OK, &r,
+					 "dcerpc_drsuapi_DsReplicaUpdateRefs");
+
+	/* 6. try replace on non-existing replica dest - should succeed */
+	torture_comment(tctx, "replace: %s\n", r.in.req.req1.dest_dsa_dns_name);
+	r.in.req.req1.options		= DRSUAPI_DRS_DEL_REF | DRSUAPI_DRS_ADD_REF;
+	status = dcerpc_drsuapi_DsReplicaUpdateRefs_r(p->binding_handle, tctx, &r);
+	torture_drsuapi_assert_call_werr(tctx, p,
+					 status, WERR_OK, &r,
+					 "dcerpc_drsuapi_DsReplicaUpdateRefs");
+
+	/* 7. delete random replicate added at step 6. */
+	torture_comment(tctx, "delete : %s\n", r.in.req.req1.dest_dsa_dns_name);
 	r.in.req.req1.options		= DRSUAPI_DRS_DEL_REF;
 	status = dcerpc_drsuapi_DsReplicaUpdateRefs_r(p->binding_handle, tctx, &r);
 	torture_drsuapi_assert_call_werr(tctx, p,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list