r17954: Avoid including \n in error strings (left over from DEBUG() conversion).
authorAndrew Bartlett <abartlet@samba.org>
Thu, 31 Aug 2006 08:15:23 +0000 (08:15 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:16:56 +0000 (14:16 -0500)
Make it easier to debug CrackNames failures.

Andrew Bartlett
(This used to be commit 5dd07074db0b25ea2e929bbdcf89f26e3665bd1c)

source4/libnet/libnet_join.c
source4/torture/rpc/testjoin.c

index ce6cca9b4946f8249d0837cf151547471dced136..50f60123b8978ccb64712e5241200a438e1ca387 100644 (file)
@@ -135,14 +135,14 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
                if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
                        r->out.error_string
                                = talloc_asprintf(r,
-                                                 "dcerpc_drsuapi_DsBind failed - %s\n", 
+                                                 "dcerpc_drsuapi_DsBind failed - %s", 
                                                  dcerpc_errstr(tmp_ctx, drsuapi_pipe->last_fault_code));
                        talloc_free(tmp_ctx);
                        return status;
                } else {
                        r->out.error_string
                                = talloc_asprintf(r,
-                                                 "dcerpc_drsuapi_DsBind failed - %s\n", 
+                                                 "dcerpc_drsuapi_DsBind failed - %s", 
                                                  nt_errstr(status));
                        talloc_free(tmp_ctx);
                        return status;
@@ -150,7 +150,7 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
        } else if (!W_ERROR_IS_OK(r_drsuapi_bind.out.result)) {
                r->out.error_string
                                = talloc_asprintf(r,
-                                                 "DsBind failed - %s\n", 
+                                                 "DsBind failed - %s", 
                                                  win_errstr(r_drsuapi_bind.out.result));
                        talloc_free(tmp_ctx);
                return NT_STATUS_UNSUCCESSFUL;
@@ -179,7 +179,7 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
                if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
                        r->out.error_string
                                = talloc_asprintf(r,
-                                                 "dcerpc_drsuapi_DsCrackNames for [%s] failed - %s\n", 
+                                                 "dcerpc_drsuapi_DsCrackNames for [%s] failed - %s", 
                                                  names[0].str,
                                                  dcerpc_errstr(tmp_ctx, drsuapi_pipe->last_fault_code));
                        talloc_free(tmp_ctx);
@@ -187,7 +187,7 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
                } else {
                        r->out.error_string
                                = talloc_asprintf(r,
-                                                 "dcerpc_drsuapi_DsCrackNames for [%s] failed - %s\n", 
+                                                 "dcerpc_drsuapi_DsCrackNames for [%s] failed - %s", 
                                                  names[0].str,
                                                  nt_errstr(status));
                        talloc_free(tmp_ctx);
@@ -196,17 +196,23 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
        } else if (!W_ERROR_IS_OK(r_crack_names.out.result)) {
                r->out.error_string
                                = talloc_asprintf(r,
-                                                 "DsCrackNames failed - %s\n", win_errstr(r_crack_names.out.result));
+                                                 "DsCrackNames failed - %s", win_errstr(r_crack_names.out.result));
                talloc_free(tmp_ctx);
                return NT_STATUS_UNSUCCESSFUL;
        } else if (r_crack_names.out.level != 1 
                   || !r_crack_names.out.ctr.ctr1 
-                  || r_crack_names.out.ctr.ctr1->count != 1 
-                  || !r_crack_names.out.ctr.ctr1->array[0].result_name
-                  || r_crack_names.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
-               r->out.error_string = talloc_asprintf(r, "DsCrackNames failed\n");
+                  || r_crack_names.out.ctr.ctr1->count != 1) {
+               r->out.error_string = talloc_asprintf(r, "DsCrackNames failed");
+               talloc_free(tmp_ctx);
+               return NT_STATUS_INVALID_PARAMETER;
+       } else if (r_crack_names.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
+               r->out.error_string = talloc_asprintf(r, "DsCrackNames failed: %d", r_crack_names.out.ctr.ctr1->array[0].status);
                talloc_free(tmp_ctx);
                return NT_STATUS_UNSUCCESSFUL;
+       } else if (r_crack_names.out.ctr.ctr1->array[0].result_name == NULL) {
+               r->out.error_string = talloc_asprintf(r, "DsCrackNames failed: no result name");
+               talloc_free(tmp_ctx);
+               return NT_STATUS_INVALID_PARAMETER;
        }
 
        /* Store the DN of our machine account. */
@@ -346,7 +352,7 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
        } else if (!W_ERROR_IS_OK(r_crack_names.out.result)) {
                r->out.error_string
                        = talloc_asprintf(r,
-                                         "DsCrackNames failed - %s\n", win_errstr(r_crack_names.out.result));
+                                         "DsCrackNames failed - %s", win_errstr(r_crack_names.out.result));
                talloc_free(tmp_ctx);
                return NT_STATUS_UNSUCCESSFUL;
        } else if (r_crack_names.out.level != 1 
@@ -354,7 +360,7 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
                   || r_crack_names.out.ctr.ctr1->count != 1
                   || !r_crack_names.out.ctr.ctr1->array[0].result_name           
                   || r_crack_names.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
-               r->out.error_string = talloc_asprintf(r, "DsCrackNames failed\n");
+               r->out.error_string = talloc_asprintf(r, "DsCrackNames failed");
                talloc_free(tmp_ctx);
                return NT_STATUS_UNSUCCESSFUL;
        }
index fb3c6c3d2a130aeb43e79dfad591d1a95cbd9842..16060851b25cdd6fbb0385616afea98eedbce684 100644 (file)
@@ -327,9 +327,9 @@ struct test_join *torture_join_domain(const char *machine_name,
        status = libnet_JoinDomain(libnet_ctx, libnet_r, libnet_r);
        if (!NT_STATUS_IS_OK(status)) {
                if (libnet_r->out.error_string) {
-                       DEBUG(0, ("Domain join failed - %s.\n", libnet_r->out.error_string));
+                       DEBUG(0, ("Domain join failed - %s\n", libnet_r->out.error_string));
                } else {
-                       DEBUG(0, ("Domain join failed - %s.\n", nt_errstr(status)));
+                       DEBUG(0, ("Domain join failed - %s\n", nt_errstr(status)));
                }
                talloc_free(tj);
                 return NULL;