summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/torture/rpc/drsuapi.c58
-rw-r--r--source4/torture/rpc/drsuapi_cracknames.c316
2 files changed, 166 insertions, 208 deletions
diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c
index 88d6b78124..2075fa7a80 100644
--- a/source4/torture/rpc/drsuapi.c
+++ b/source4/torture/rpc/drsuapi.c
@@ -57,7 +57,7 @@ bool test_DsBind(struct dcerpc_pipe *p, struct torture_context *tctx,
return true;
}
-static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture_context *torture,
+static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture_context *torture,
struct DsPrivate *priv)
{
NTSTATUS status;
@@ -747,13 +747,16 @@ bool torture_rpc_drsuapi(struct torture_context *torture)
torture_fail(torture, "Unable to connect to DRSUAPI pipe");
}
+ /* cache pipe handle */
+ priv.pipe = p;
+
ret &= test_DsBind(p, torture, &priv);
#if 0
ret &= test_QuerySitesByCost(p, torture, &priv);
#endif
ret &= test_DsGetDomainControllerInfo(p, torture, &priv);
- ret &= test_DsCrackNames(torture, p, torture, &priv);
+ ret &= test_DsCrackNames(torture, &priv);
ret &= test_DsWriteAccountSpn(p, torture, &priv);
@@ -851,9 +854,16 @@ bool torture_rpc_drsuapi_tcase_setup(struct torture_context *tctx, void **data)
torture_fail(tctx, "Failed execute test_DsBind()");
}
+ /* try collect some information for testing */
+ torture_rpc_drsuapi_get_dcinfo(tctx, priv);
+
return true;
}
+/**
+ * Common test case teardown function to be used
+ * in DRS suit of test when appropriate
+ */
bool torture_rpc_drsuapi_tcase_teardown(struct torture_context *tctx, void *data)
{
struct DsPrivate *priv = (struct DsPrivate *)data;
@@ -867,47 +877,3 @@ bool torture_rpc_drsuapi_tcase_teardown(struct torture_context *tctx, void *data
return true;
}
-
-/*
-bool torture_rpc_drsuapi_cracknames(struct torture_context *torture)
-{
- NTSTATUS status;
- struct dcerpc_pipe *p;
- bool ret = true;
- struct DsPrivate priv;
- struct cli_credentials *machine_credentials;
-
- torture_comment(torture, "Connected to DRSUAPI pipe\n");
-
- ZERO_STRUCT(priv);
-
- priv.join = torture_join_domain(torture, TEST_MACHINE_NAME, ACB_SVRTRUST,
- &machine_credentials);
- if (!priv.join) {
- torture_fail(torture, "Failed to join as BDC\n");
- }
-
- status = torture_rpc_connection(torture,
- &p,
- &ndr_table_drsuapi);
- if (!NT_STATUS_IS_OK(status)) {
- torture_leave_domain(torture, priv.join);
- torture_fail(torture, "Unable to connect to DRSUAPI pipe");
- }
-
- ret &= test_DsBind(p, torture, &priv);
-
- if (ret) {
- /* We don't care if this fails, we just need some info from it */
- test_DsGetDomainControllerInfo(p, torture, &priv);
-
- ret &= test_DsCrackNames(torture, p, torture, &priv);
-
- ret &= test_DsUnbind(p, torture, &priv);
- }
-
- torture_leave_domain(torture, priv.join);
-
- return ret;
-}
-
diff --git a/source4/torture/rpc/drsuapi_cracknames.c b/source4/torture/rpc/drsuapi_cracknames.c
index 65a15c97e0..42373a8c4f 100644
--- a/source4/torture/rpc/drsuapi_cracknames.c
+++ b/source4/torture/rpc/drsuapi_cracknames.c
@@ -28,18 +28,18 @@
#include "ldb/include/ldb.h"
#include "libcli/security/security.h"
-static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_DsCrackNamesMatrix(struct torture_context *tctx,
struct DsPrivate *priv, const char *dn,
const char *user_principal_name, const char *service_principal_name)
{
-
-
NTSTATUS status;
- bool ret = true;
+ const char *err_msg;
struct drsuapi_DsCrackNames r;
union drsuapi_DsNameRequest req;
int32_t level_out;
union drsuapi_DsNameCtr ctr;
+ struct dcerpc_pipe *p = priv->pipe;
+ TALLOC_CTX *mem_ctx = priv;
enum drsuapi_DsNameFormat formats[] = {
DRSUAPI_DS_NAME_FORMAT_UNKNOWN,
@@ -85,52 +85,52 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
- printf("testing DsCrackNames (matrix prep) with name '%s' from format: %d desired format:%d ",
- names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired);
-
- printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "testing DsCrackNames (matrix prep) with name '%s' from format: %d desired format:%d failed - %s",
+ names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired, errstr);
+ torture_fail(tctx, err_msg);
} else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("testing DsCrackNames (matrix prep) with name '%s' from format: %d desired format:%d ",
- names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired);
-
- printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "testing DsCrackNames (matrix prep) with name '%s' from format: %d desired format:%d failed - %s",
+ names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired, win_errstr(r.out.result));
+ torture_fail(tctx, err_msg);
}
- if (!ret) {
- return ret;
- }
switch (formats[i]) {
case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL:
if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE) {
- printf(__location__ ": Unexpected error (%d): This name lookup should fail\n",
- r.out.ctr->ctr1->array[0].status);
- return false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "Unexpected error (%d): This name lookup should fail",
+ r.out.ctr->ctr1->array[0].status);
+ torture_fail(tctx, err_msg);
}
- printf ("(expected) error\n");
+ torture_comment(tctx, __location__ ": (expected) error\n");
break;
case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL:
if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NO_MAPPING) {
- printf(__location__ ": Unexpected error (%d): This name lookup should fail\n",
- r.out.ctr->ctr1->array[0].status);
- return false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "Unexpected error (%d): This name lookup should fail",
+ r.out.ctr->ctr1->array[0].status);
+ torture_fail(tctx, err_msg);
}
- printf ("(expected) error\n");
+ torture_comment(tctx, __location__ ": (expected) error\n");
break;
case DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN:
case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY:
if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR) {
- printf(__location__ ": Unexpected error (%d): This name lookup should fail\n",
- r.out.ctr->ctr1->array[0].status);
- return false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "Unexpected error (%d): This name lookup should fail",
+ r.out.ctr->ctr1->array[0].status);
+ torture_fail(tctx, err_msg);
}
- printf ("(expected) error\n");
+ torture_comment(tctx, __location__ ": (expected) error\n");
break;
default:
if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
- printf("Error: %d\n", r.out.ctr->ctr1->array[0].status);
- return false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "DsCrackNames error: %d",
+ r.out.ctr->ctr1->array[0].status);
+ torture_fail(tctx, err_msg);
}
}
@@ -166,19 +166,18 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
- printf("testing DsCrackNames (matrix) with name '%s' from format: %d desired format:%d failed - %s",
- names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired, errstr);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "testing DsCrackNames (matrix) with name '%s' from format: %d desired format:%d failed - %s",
+ names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired, errstr);
+ torture_fail(tctx, err_msg);
} else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("testing DsCrackNames (matrix) with name '%s' from format: %d desired format:%d failed - %s",
- names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired,
- win_errstr(r.out.result));
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "testing DsCrackNames (matrix) with name '%s' from format: %d desired format:%d failed - %s",
+ names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired,
+ win_errstr(r.out.result));
+ torture_fail(tctx, err_msg);
}
- if (!ret) {
- return ret;
- }
if (r.out.ctr->ctr1->array[0].status == DRSUAPI_DS_NAME_STATUS_OK) {
n_matrix[i][j] = r.out.ctr->ctr1->array[0].result_name;
} else {
@@ -198,31 +197,37 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
} else if (n_matrix[i][j] == NULL && formats[j] == DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL) {
} else if (n_matrix[i][j] == NULL && formats[j] == DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL) {
} else if (n_matrix[i][j] == NULL && n_from[j] != NULL) {
- printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s",
+ formats[i], formats[j], n_matrix[i][j], n_from[j]);
+ torture_fail(tctx, err_msg);
} else if (n_matrix[i][j] != NULL && n_from[j] == NULL) {
- printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s",
+ formats[i], formats[j], n_matrix[i][j], n_from[j]);
+ torture_fail(tctx, err_msg);
} else if (strcmp(n_matrix[i][j], n_from[j]) != 0) {
- printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s",
+ formats[i], formats[j], n_matrix[i][j], n_from[j]);
+ torture_fail(tctx, err_msg);
}
}
}
- return ret;
+
+ return true;
}
bool test_DsCrackNames(struct torture_context *tctx,
- struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct DsPrivate *priv)
{
NTSTATUS status;
+ const char *err_msg;
struct drsuapi_DsCrackNames r;
union drsuapi_DsNameRequest req;
int32_t level_out;
union drsuapi_DsNameCtr ctr;
struct drsuapi_DsNameString names[1];
- bool ret = true;
const char *dns_domain;
const char *nt4_domain;
const char *FQDN_1779_name;
@@ -239,6 +244,8 @@ bool test_DsCrackNames(struct torture_context *tctx,
const char *canonical_ex_name;
const char *dom_sid;
const char *test_dc = torture_join_netbios_name(priv->join);
+ struct dcerpc_pipe *p = priv->pipe;
+ TALLOC_CTX *mem_ctx = priv;
ZERO_STRUCT(r);
r.in.bind_handle = &priv->bind_handle;
@@ -260,7 +267,7 @@ bool test_DsCrackNames(struct torture_context *tctx,
names[0].str = dom_sid;
- printf("testing DsCrackNames with name '%s' desired format:%d\n",
+ torture_comment(tctx, "testing DsCrackNames with name '%s' desired format:%d\n",
names[0].str, r.in.req->req1.format_desired);
status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
@@ -269,18 +276,15 @@ bool test_DsCrackNames(struct torture_context *tctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
- printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx, "dcerpc_drsuapi_DsCrackNames failed - %s", errstr);
+ torture_fail(tctx, err_msg);
} else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx, "DsCrackNames failed - %s", win_errstr(r.out.result));
+ torture_fail(tctx, err_msg);
} else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
- printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status);
- ret = false;
- }
-
- if (!ret) {
- return ret;
+ err_msg = talloc_asprintf(mem_ctx, "DsCrackNames failed on name - %d",
+ r.out.ctr->ctr1->array[0].status);
+ torture_fail(tctx, err_msg);
}
dns_domain = r.out.ctr->ctr1->array[0].dns_domain_name;
@@ -288,7 +292,7 @@ bool test_DsCrackNames(struct torture_context *tctx,
r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_GUID;
- printf("testing DsCrackNames with name '%s' desired format:%d\n",
+ torture_comment(tctx, "testing DsCrackNames with name '%s' desired format:%d\n",
names[0].str, r.in.req->req1.format_desired);
status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
@@ -297,18 +301,15 @@ bool test_DsCrackNames(struct torture_context *tctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
- printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx, "dcerpc_drsuapi_DsCrackNames failed - %s", errstr);
+ torture_fail(tctx, err_msg);
} else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx, "DsCrackNames failed - %s", win_errstr(r.out.result));
+ torture_fail(tctx, err_msg);
} else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
- printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status);
- ret = false;
- }
-
- if (!ret) {
- return ret;
+ err_msg = talloc_asprintf(mem_ctx, "DsCrackNames failed on name - %d",
+ r.out.ctr->ctr1->array[0].status);
+ torture_fail(tctx, err_msg);
}
priv->domain_dns_name = r.out.ctr->ctr1->array[0].dns_domain_name;
@@ -317,7 +318,7 @@ bool test_DsCrackNames(struct torture_context *tctx,
r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
- printf("testing DsCrackNames with name '%s' desired format:%d\n",
+ torture_comment(tctx, "testing DsCrackNames with name '%s' desired format:%d\n",
names[0].str, r.in.req->req1.format_desired);
status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
@@ -326,18 +327,15 @@ bool test_DsCrackNames(struct torture_context *tctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
- printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx, "dcerpc_drsuapi_DsCrackNames failed - %s", errstr);
+ torture_fail(tctx, err_msg);
} else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx, "DsCrackNames failed - %s", win_errstr(r.out.result));
+ torture_fail(tctx, err_msg);
} else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
- printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status);
- ret = false;
- }
-
- if (!ret) {
- return ret;
+ err_msg = talloc_asprintf(mem_ctx, "DsCrackNames failed on name - %d",
+ r.out.ctr->ctr1->array[0].status);
+ torture_fail(tctx, err_msg);
}
ldb = ldb_init(mem_ctx, tctx->ev);
@@ -346,29 +344,29 @@ bool test_DsCrackNames(struct torture_context *tctx,
realm_dn = ldb_dn_new(mem_ctx, ldb, realm_dn_str);
realm_canonical = ldb_dn_canonical_string(mem_ctx, realm_dn);
- if (strcmp(realm_canonical,
+ if (strcmp(realm_canonical,
talloc_asprintf(mem_ctx, "%s/", dns_domain))!= 0) {
- printf("local Round trip on canonical name failed: %s != %s!\n",
- realm_canonical,
- talloc_asprintf(mem_ctx, "%s/", dns_domain));
- return false;
+ err_msg = talloc_asprintf(mem_ctx, "local Round trip on canonical name failed: %s != %s!",
+ realm_canonical,
+ talloc_asprintf(mem_ctx, "%s/", dns_domain));
+ torture_fail(tctx, err_msg);
};
realm_canonical_ex = ldb_dn_canonical_ex_string(mem_ctx, realm_dn);
if (strcmp(realm_canonical_ex,
talloc_asprintf(mem_ctx, "%s\n", dns_domain))!= 0) {
- printf("local Round trip on canonical ex name failed: %s != %s!\n",
- realm_canonical,
- talloc_asprintf(mem_ctx, "%s\n", dns_domain));
- return false;
+ err_msg = talloc_asprintf(mem_ctx, "local Round trip on canonical ex name failed: %s != %s!",
+ realm_canonical,
+ talloc_asprintf(mem_ctx, "%s\n", dns_domain));
+ torture_fail(tctx, err_msg);
};
r.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT;
r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
names[0].str = nt4_domain;
- printf("testing DsCrackNames with name '%s' desired format:%d\n",
+ torture_comment(tctx, "testing DsCrackNames with name '%s' desired format:%d\n",
names[0].str, r.in.req->req1.format_desired);
status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
@@ -377,18 +375,15 @@ bool test_DsCrackNames(struct torture_context *tctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
- printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx, "dcerpc_drsuapi_DsCrackNames failed - %s", errstr);
+ torture_fail(tctx, err_msg);
} else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx, "DsCrackNames failed - %s", win_errstr(r.out.result));
+ torture_fail(tctx, err_msg);
} else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
- printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status);
- ret = false;
- }
-
- if (!ret) {
- return ret;
+ err_msg = talloc_asprintf(mem_ctx, "DsCrackNames failed on name - %d",
+ r.out.ctr->ctr1->array[0].status);
+ torture_fail(tctx, err_msg);
}
priv->domain_obj_dn = r.out.ctr->ctr1->array[0].result_name;
@@ -397,8 +392,8 @@ bool test_DsCrackNames(struct torture_context *tctx,
r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
names[0].str = talloc_asprintf(mem_ctx, "%s%s$", nt4_domain, test_dc);
- printf("testing DsCrackNames with name '%s' desired format:%d\n",
- names[0].str, r.in.req->req1.format_desired);
+ torture_comment(tctx, "testing DsCrackNames with name '%s' desired format:%d\n",
+ names[0].str, r.in.req->req1.format_desired);
status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
@@ -406,18 +401,15 @@ bool test_DsCrackNames(struct torture_context *tctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
- printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx, "dcerpc_drsuapi_DsCrackNames failed - %s", errstr);
+ torture_fail(tctx, err_msg);
} else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx, "DsCrackNames failed - %s", win_errstr(r.out.result));
+ torture_fail(tctx, err_msg);
} else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
- printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status);
- ret = false;
- }
-
- if (!ret) {
- return ret;
+ err_msg = talloc_asprintf(mem_ctx, "DsCrackNames failed on name - %d",
+ r.out.ctr->ctr1->array[0].status);
+ torture_fail(tctx, err_msg);
}
FQDN_1779_name = r.out.ctr->ctr1->array[0].result_name;
@@ -426,8 +418,8 @@ bool test_DsCrackNames(struct torture_context *tctx,
r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
names[0].str = priv->domain_guid_str;
- printf("testing DsCrackNames with name '%s' desired format:%d\n",
- names[0].str, r.in.req->req1.format_desired);
+ torture_comment(tctx, "testing DsCrackNames with name '%s' desired format:%d\n",
+ names[0].str, r.in.req->req1.format_desired);
status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
@@ -435,23 +427,22 @@ bool test_DsCrackNames(struct torture_context *tctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
- printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx, "dcerpc_drsuapi_DsCrackNames failed - %s", errstr);
+ torture_fail(tctx, err_msg);
} else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx, "DsCrackNames failed - %s", win_errstr(r.out.result));
+ torture_fail(tctx, err_msg);
} else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
- printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status);
- ret = false;
- }
-
- if (!ret) {
- return ret;
+ err_msg = talloc_asprintf(mem_ctx, "DsCrackNames failed on name - %d",
+ r.out.ctr->ctr1->array[0].status);
+ torture_fail(tctx, err_msg);
}
if (strcmp(priv->domain_dns_name, r.out.ctr->ctr1->array[0].dns_domain_name) != 0) {
- printf("DsCrackNames failed to return same DNS name - expected %s got %s\n", priv->domain_dns_name, r.out.ctr->ctr1->array[0].dns_domain_name);
- return false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "DsCrackNames failed to return same DNS name - expected %s got %s",
+ priv->domain_dns_name, r.out.ctr->ctr1->array[0].dns_domain_name);
+ torture_fail(tctx, err_msg);
}
FQDN_1779_dn = ldb_dn_new(mem_ctx, ldb, FQDN_1779_name);
@@ -947,7 +938,7 @@ bool test_DsCrackNames(struct torture_context *tctx,
names[0].str, r.in.req->req1.format_desired);
}
if (crack[i].skip) {
- printf("skipping: %s", comment);
+ torture_comment(tctx, "skipping: %s", comment);
continue;
}
status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
@@ -956,57 +947,58 @@ bool test_DsCrackNames(struct torture_context *tctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
}
- printf("dcerpc_drsuapi_DsCrackNames failed on %s - %s\n", comment, errstr);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx, "dcerpc_drsuapi_DsCrackNames failed - %s", errstr);
+ torture_fail(tctx, err_msg);
} else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx, "DsCrackNames failed - %s", win_errstr(r.out.result));
+ torture_fail(tctx, err_msg);
} else if (r.out.ctr->ctr1->array[0].status != crack[i].status) {
if (crack[i].alternate_status) {
if (r.out.ctr->ctr1->array[0].status != crack[i].alternate_status) {
- printf("DsCrackNames unexpected status %d, wanted %d or %d on: %s\n",
- r.out.ctr->ctr1->array[0].status,
- crack[i].status,
- crack[i].alternate_status,
- comment);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "DsCrackNames unexpected status %d, wanted %d or %d on: %s",
+ r.out.ctr->ctr1->array[0].status,
+ crack[i].status,
+ crack[i].alternate_status,
+ comment);
+ torture_fail(tctx, err_msg);
}
} else {
- printf("DsCrackNames unexpected status %d, wanted %d on: %s\n",
- r.out.ctr->ctr1->array[0].status,
- crack[i].status,
- comment);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "DsCrackNames unexpected status %d, wanted %d on: %s\n",
+ r.out.ctr->ctr1->array[0].status,
+ crack[i].status,
+ comment);
+ torture_fail(tctx, err_msg);
}
} else if (crack[i].expected_str
&& (strcmp(r.out.ctr->ctr1->array[0].result_name,
crack[i].expected_str) != 0)) {
if (strcasecmp(r.out.ctr->ctr1->array[0].result_name,
crack[i].expected_str) != 0) {
- printf("DsCrackNames failed - got %s, expected %s on %s\n",
- r.out.ctr->ctr1->array[0].result_name,
- crack[i].expected_str, comment);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "DsCrackNames failed - got %s, expected %s on %s",
+ r.out.ctr->ctr1->array[0].result_name,
+ crack[i].expected_str, comment);
+ torture_fail(tctx, err_msg);
} else {
- printf("(warning) DsCrackNames returned different case - got %s, expected %s on %s\n",
- r.out.ctr->ctr1->array[0].result_name,
- crack[i].expected_str, comment);
+ torture_comment(tctx,
+ "(warning) DsCrackNames returned different case - got %s, expected %s on %s\n",
+ r.out.ctr->ctr1->array[0].result_name,
+ crack[i].expected_str, comment);
}
} else if (crack[i].expected_dns
&& (strcmp(r.out.ctr->ctr1->array[0].dns_domain_name,
crack[i].expected_dns) != 0)) {
- printf("DsCrackNames failed - got DNS name %s, expected %s on %s\n",
- r.out.ctr->ctr1->array[0].result_name,
- crack[i].expected_str, comment);
- ret = false;
+ err_msg = talloc_asprintf(mem_ctx,
+ "DsCrackNames failed - got DNS name %s, expected %s on %s",
+ r.out.ctr->ctr1->array[0].result_name,
+ crack[i].expected_str, comment);
+ torture_fail(tctx, err_msg);
}
}
}
- if (!test_DsCrackNamesMatrix(p, mem_ctx, priv, FQDN_1779_name,
- user_principal_name, service_principal_name)) {
- ret = false;
- }
-
- return ret;
+ return test_DsCrackNamesMatrix(tctx, priv, FQDN_1779_name,
+ user_principal_name, service_principal_name);
}