1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

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.
This commit is contained in:
Kamen Mazdrashki 2010-09-07 21:22:47 +03:00
parent 81e97c09c3
commit 3fa3bc7eba

View File

@ -220,12 +220,20 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
struct dreplsrv_service *service = talloc_get_type(msg->private_data, struct dreplsrv_service *service = talloc_get_type(msg->private_data,
struct dreplsrv_service); 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) { if (r->in.level != 1) {
DEBUG(0,("%s: Level %d is not supported yet.\n", REPLICA_SYNC_FAIL("Unsupported level",
__FUNCTION__, r->in.level)); WERR_DS_DRA_INVALID_PARAMETER);
REPLICA_SYNC_FAIL(WERR_DS_DRA_INVALID_PARAMETER);
} }
req1 = &r->in.req->req1; req1 = &r->in.req->req1;
@ -233,7 +241,8 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
/* Check input parameters */ /* Check input parameters */
if (!nc) { 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 */ /* Find Naming context to be synchronized */
@ -241,12 +250,8 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
&nc->guid, &nc->sid, nc->dn, &nc->guid, &nc->sid, nc->dn,
&p); &p);
if (!W_ERROR_IS_OK(werr)) { if (!W_ERROR_IS_OK(werr)) {
DEBUG(0,("%s: failed to find NC for (%s, %s) - %s\n", REPLICA_SYNC_FAIL("Failed to find requested Naming Context",
__FUNCTION__, werr);
GUID_string(msg, &nc->guid),
nc->dn,
win_errstr(werr)));
REPLICA_SYNC_FAIL(werr);
} }
/* should we process it asynchronously? */ /* should we process it asynchronously? */
@ -255,8 +260,8 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
} else { } else {
cb_data = talloc_zero(msg, struct drepl_replica_sync_cb_data); cb_data = talloc_zero(msg, struct drepl_replica_sync_cb_data);
if (!cb_data) { if (!cb_data) {
DEBUG(0,(__location__ ": Not enought memory!")); REPLICA_SYNC_FAIL("Not enought memory",
REPLICA_SYNC_FAIL(WERR_DS_DRA_INTERNAL_ERROR); WERR_DS_DRA_INTERNAL_ERROR);
} }
cb_data->msg = msg; cb_data->msg = msg;
@ -270,14 +275,16 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
/* schedule replication item */ /* schedule replication item */
werr = _drepl_schedule_replication(service, dsa, nc, cb_data, msg); werr = _drepl_schedule_replication(service, dsa, nc, cb_data, msg);
if (!W_ERROR_IS_OK(werr)) { if (!W_ERROR_IS_OK(werr)) {
REPLICA_SYNC_FAIL(werr); REPLICA_SYNC_FAIL("_drepl_schedule_replication() failed",
werr);
} }
} }
} else { } else {
if (req1->options & DRSUAPI_DRS_SYNC_BYNAME) { if (req1->options & DRSUAPI_DRS_SYNC_BYNAME) {
/* client should pass at least valid string */ /* client should pass at least valid string */
if (!req1->source_dsa_dns) { 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, werr = dreplsrv_partition_source_dsa_by_dns(p,
@ -286,7 +293,8 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
} else { } else {
/* client should pass at least some GUID */ /* client should pass at least some GUID */
if (GUID_all_zero(&req1->source_dsa_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, werr = dreplsrv_partition_source_dsa_by_guid(p,
@ -294,19 +302,15 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
&dsa); &dsa);
} }
if (!W_ERROR_IS_OK(werr)) { if (!W_ERROR_IS_OK(werr)) {
DEBUG(0,("%s: Failed to locate source DSA %s for NC %s.\n", REPLICA_SYNC_FAIL("Failed to locate source DSA for given NC",
__FUNCTION__, WERR_DS_DRA_NO_REPLICA);
(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);
} }
/* schedule replication item */ /* schedule replication item */
werr = _drepl_schedule_replication(service, dsa, nc, cb_data, msg); werr = _drepl_schedule_replication(service, dsa, nc, cb_data, msg);
if (!W_ERROR_IS_OK(werr)) { if (!W_ERROR_IS_OK(werr)) {
REPLICA_SYNC_FAIL(werr); REPLICA_SYNC_FAIL("_drepl_schedule_replication() failed",
werr);
} }
} }