diff options
author | Günther Deschner <gd@samba.org> | 2010-03-23 15:20:16 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2010-03-29 15:35:48 +0200 |
commit | 1248adb2c5716d26323e6e9bb1ac81103701d908 (patch) | |
tree | 448d5da0fd87d7f957fe3cf149bd4ab4b3bdc211 /source4/torture | |
parent | 2d35523f24f7806d41d785028e09f9cb6bbfaf56 (diff) | |
download | samba-1248adb2c5716d26323e6e9bb1ac81103701d908.tar.gz samba-1248adb2c5716d26323e6e9bb1ac81103701d908.tar.bz2 samba-1248adb2c5716d26323e6e9bb1ac81103701d908.zip |
s4:torture/libnet:add explicit check for NTSTATUS r.out.result
Guenther
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/libnet/domain.c | 11 | ||||
-rw-r--r-- | source4/torture/libnet/libnet_domain.c | 71 | ||||
-rw-r--r-- | source4/torture/libnet/libnet_group.c | 111 | ||||
-rw-r--r-- | source4/torture/libnet/libnet_user.c | 120 | ||||
-rw-r--r-- | source4/torture/libnet/utils.c | 117 |
5 files changed, 223 insertions, 207 deletions
diff --git a/source4/torture/libnet/domain.c b/source4/torture/libnet/domain.c index 8c880be7fc..110a2e8f99 100644 --- a/source4/torture/libnet/domain.c +++ b/source4/torture/libnet/domain.c @@ -52,7 +52,6 @@ static bool test_cleanup(struct torture_context *tctx, struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle) { - NTSTATUS status; struct samr_Close r; struct policy_handle handle; @@ -61,11 +60,11 @@ static bool test_cleanup(struct torture_context *tctx, torture_comment(tctx, "closing domain handle\n"); - status = dcerpc_samr_Close_r(b, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "Close failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_Close_r(b, mem_ctx, &r), + "Close failed"); + torture_assert_ntstatus_ok(tctx, r.out.result, + "Close failed"); return true; } diff --git a/source4/torture/libnet/libnet_domain.c b/source4/torture/libnet/libnet_domain.c index bd0e1fa223..a8e0842bd2 100644 --- a/source4/torture/libnet/libnet_domain.c +++ b/source4/torture/libnet/libnet_domain.c @@ -33,7 +33,6 @@ static bool test_opendomain_samr(struct torture_context *tctx, struct policy_handle *handle, struct lsa_String *domname, uint32_t *access_mask, struct dom_sid **sid_p) { - NTSTATUS status; struct policy_handle h, domain_handle; struct samr_Connect r1; struct samr_LookupDomain r2; @@ -48,11 +47,11 @@ static bool test_opendomain_samr(struct torture_context *tctx, r1.in.access_mask = *access_mask; r1.out.connect_handle = &h; - status = dcerpc_samr_Connect_r(b, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "Connect failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_Connect_r(b, mem_ctx, &r1), + "Connect failed"); + torture_assert_ntstatus_ok(tctx, r1.out.result, + "Connect failed"); r2.in.connect_handle = &h; r2.in.domain_name = domname; @@ -60,11 +59,11 @@ static bool test_opendomain_samr(struct torture_context *tctx, torture_comment(tctx, "domain lookup on %s\n", domname->string); - status = dcerpc_samr_LookupDomain_r(b, mem_ctx, &r2); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "LookupDomain failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_LookupDomain_r(b, mem_ctx, &r2), + "LookupDomain failed"); + torture_assert_ntstatus_ok(tctx, r2.out.result, + "LookupDomain failed"); r3.in.connect_handle = &h; r3.in.access_mask = *access_mask; @@ -73,23 +72,23 @@ static bool test_opendomain_samr(struct torture_context *tctx, torture_comment(tctx, "opening domain\n"); - status = dcerpc_samr_OpenDomain_r(b, mem_ctx, &r3); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "OpenDomain failed - %s\n", nt_errstr(status)); - return false; - } else { - *handle = domain_handle; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_OpenDomain_r(b, mem_ctx, &r3), + "OpenDomain failed"); + torture_assert_ntstatus_ok(tctx, r3.out.result, + "OpenDomain failed"); + + *handle = domain_handle; return true; } -static bool test_opendomain_lsa(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, +static bool test_opendomain_lsa(struct torture_context *tctx, + struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_String *domname, uint32_t *access_mask) { - NTSTATUS status; struct lsa_OpenPolicy2 open; struct lsa_ObjectAttribute attr; struct lsa_QosInfo qos; @@ -111,10 +110,11 @@ static bool test_opendomain_lsa(struct dcerpc_binding_handle *b, TALLOC_CTX *mem open.in.access_mask = *access_mask; open.out.handle = handle; - status = dcerpc_lsa_OpenPolicy2_r(b, mem_ctx, &open); - if (!NT_STATUS_IS_OK(status)) { - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_lsa_OpenPolicy2_r(b, mem_ctx, &open), + "OpenPolicy2 failed"); + torture_assert_ntstatus_ok(tctx, open.out.result, + "OpenPolicy2 failed"); return true; } @@ -158,11 +158,11 @@ bool torture_domain_open_lsa(struct torture_context *torture) lsa_close.in.handle = &ctx->lsa.handle; lsa_close.out.handle = &h; - status = dcerpc_lsa_Close_r(ctx->lsa.pipe->binding_handle, ctx, &lsa_close); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(torture, "failed to close domain on lsa service: %s\n", nt_errstr(status)); - ret = false; - } + torture_assert_ntstatus_ok(torture, + dcerpc_lsa_Close_r(ctx->lsa.pipe->binding_handle, ctx, &lsa_close), + "failed to close domain on lsa service"); + torture_assert_ntstatus_ok(torture, lsa_close.out.result, + "failed to close domain on lsa service"); done: talloc_free(ctx); @@ -208,7 +208,7 @@ bool torture_domain_close_lsa(struct torture_context *torture) domain_name.string = lp_workgroup(torture->lp_ctx); - if (!test_opendomain_lsa(p->binding_handle, torture, &h, &domain_name, &access_mask)) { + if (!test_opendomain_lsa(torture, p->binding_handle, torture, &h, &domain_name, &access_mask)) { torture_comment(torture, "failed to open domain on lsa service\n"); ret = false; goto done; @@ -283,12 +283,11 @@ bool torture_domain_open_samr(struct torture_context *torture) torture_comment(torture, "closing domain handle\n"); - status = dcerpc_samr_Close_r(ctx->samr.pipe->binding_handle, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(torture, "Close failed - %s\n", nt_errstr(status)); - ret = false; - goto done; - } + torture_assert_ntstatus_ok(torture, + dcerpc_samr_Close_r(ctx->samr.pipe->binding_handle, mem_ctx, &r), + "Close failed"); + torture_assert_ntstatus_ok(torture, r.out.result, + "Close failed"); done: talloc_free(mem_ctx); diff --git a/source4/torture/libnet/libnet_group.c b/source4/torture/libnet/libnet_group.c index db711916df..d1148f0d23 100644 --- a/source4/torture/libnet/libnet_group.c +++ b/source4/torture/libnet/libnet_group.c @@ -35,7 +35,6 @@ static bool test_cleanup(struct torture_context *tctx, struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, const char *groupname) { - NTSTATUS status; struct samr_LookupNames r1; struct samr_OpenGroup r2; struct samr_DeleteDomainGroup r3; @@ -54,11 +53,11 @@ static bool test_cleanup(struct torture_context *tctx, torture_comment(tctx, "group account lookup '%s'\n", groupname); - status = dcerpc_samr_LookupNames_r(b, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "LookupNames failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_LookupNames_r(b, mem_ctx, &r1), + "LookupNames failed"); + torture_assert_ntstatus_ok(tctx, r1.out.result, + "LookupNames failed"); rid = r1.out.rids->ids[0]; @@ -69,22 +68,22 @@ static bool test_cleanup(struct torture_context *tctx, torture_comment(tctx, "opening group account\n"); - status = dcerpc_samr_OpenGroup_r(b, mem_ctx, &r2); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "OpenGroup failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_OpenGroup_r(b, mem_ctx, &r2), + "OpenGroup failed"); + torture_assert_ntstatus_ok(tctx, r2.out.result, + "OpenGroup failed"); r3.in.group_handle = &group_handle; r3.out.group_handle = &group_handle; torture_comment(tctx, "deleting group account\n"); - status = dcerpc_samr_DeleteDomainGroup_r(b, mem_ctx, &r3); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "DeleteGroup failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_DeleteDomainGroup_r(b, mem_ctx, &r3), + "DeleteGroup failed"); + torture_assert_ntstatus_ok(tctx, r3.out.result, + "DeleteGroup failed"); return true; } @@ -94,7 +93,6 @@ static bool test_creategroup(struct torture_context *tctx, struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, struct policy_handle *handle, const char *name) { - NTSTATUS status; struct lsa_String groupname; struct samr_CreateDomainGroup r; struct policy_handle group_handle; @@ -110,11 +108,14 @@ static bool test_creategroup(struct torture_context *tctx, torture_comment(tctx, "creating group account %s\n", name); - status = dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "CreateGroup failed - %s\n", nt_errstr(status)); + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r), + "CreateGroup failed"); - if (NT_STATUS_EQUAL(status, NT_STATUS_GROUP_EXISTS)) { + if (!NT_STATUS_IS_OK(r.out.result)) { + torture_comment(tctx, "CreateGroup failed - %s\n", nt_errstr(r.out.result)); + + if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_GROUP_EXISTS)) { torture_comment(tctx, "Group (%s) already exists - attempting to delete and recreate group again\n", name); if (!test_cleanup(tctx, b, mem_ctx, handle, TEST_GROUPNAME)) { return false; @@ -122,11 +123,12 @@ static bool test_creategroup(struct torture_context *tctx, torture_comment(tctx, "creating group account\n"); - status = dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "CreateGroup failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r), + "CreateGroup failed"); + torture_assert_ntstatus_ok(tctx, r.out.result, + "CreateGroup failed"); + return true; } return false; @@ -140,7 +142,6 @@ static bool test_opendomain(struct torture_context *tctx, struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_String *domname) { - NTSTATUS status; struct policy_handle h, domain_handle; struct samr_Connect r1; struct samr_LookupDomain r2; @@ -153,11 +154,11 @@ static bool test_opendomain(struct torture_context *tctx, r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; r1.out.connect_handle = &h; - status = dcerpc_samr_Connect_r(b, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "Connect failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_Connect_r(b, mem_ctx, &r1), + "Connect failed"); + torture_assert_ntstatus_ok(tctx, r1.out.result, + "Connect failed"); r2.in.connect_handle = &h; r2.in.domain_name = domname; @@ -165,11 +166,11 @@ static bool test_opendomain(struct torture_context *tctx, torture_comment(tctx, "domain lookup on %s\n", domname->string); - status = dcerpc_samr_LookupDomain_r(b, mem_ctx, &r2); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "LookupDomain failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_LookupDomain_r(b, mem_ctx, &r2), + "LookupDomain failed"); + torture_assert_ntstatus_ok(tctx, r2.out.result, + "LookupDomain failed"); r3.in.connect_handle = &h; r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -178,13 +179,13 @@ static bool test_opendomain(struct torture_context *tctx, torture_comment(tctx, "opening domain\n"); - status = dcerpc_samr_OpenDomain_r(b, mem_ctx, &r3); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "OpenDomain failed - %s\n", nt_errstr(status)); - return false; - } else { - *handle = domain_handle; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_OpenDomain_r(b, mem_ctx, &r3), + "OpenDomain failed"); + torture_assert_ntstatus_ok(tctx, r3.out.result, + "OpenDomain failed"); + + *handle = domain_handle; return true; } @@ -194,17 +195,16 @@ static bool test_samr_close(struct torture_context *tctx, struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle) { - NTSTATUS status; struct samr_Close r; r.in.handle = domain_handle; r.out.handle = domain_handle; - status = dcerpc_samr_Close_r(b, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "Close samr domain failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_Close_r(b, mem_ctx, &r), + "Close samr domain failed"); + torture_assert_ntstatus_ok(tctx, r.out.result, + "Close samr domain failed"); return true; } @@ -214,17 +214,16 @@ static bool test_lsa_close(struct torture_context *tctx, struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle) { - NTSTATUS status; struct lsa_Close r; r.in.handle = domain_handle; r.out.handle = domain_handle; - status = dcerpc_lsa_Close_r(b, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "Close lsa domain failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_lsa_Close_r(b, mem_ctx, &r), + "Close lsa domain failed"); + torture_assert_ntstatus_ok(tctx, r.out.result, + "Close lsa domain failed"); return true; } diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c index 3f7ea5494f..89367b90a3 100644 --- a/source4/torture/libnet/libnet_user.c +++ b/source4/torture/libnet/libnet_user.c @@ -33,7 +33,6 @@ static bool test_cleanup(struct torture_context *tctx, struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, const char *username) { - NTSTATUS status; struct samr_LookupNames r1; struct samr_OpenUser r2; struct samr_DeleteUser r3; @@ -52,11 +51,11 @@ static bool test_cleanup(struct torture_context *tctx, torture_comment(tctx, "user account lookup '%s'\n", username); - status = dcerpc_samr_LookupNames_r(b, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "LookupNames failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_LookupNames_r(b, mem_ctx, &r1), + "LookupNames failed"); + torture_assert_ntstatus_ok(tctx, r1.out.result, + "LookupNames failed"); rid = r1.out.rids->ids[0]; @@ -67,22 +66,22 @@ static bool test_cleanup(struct torture_context *tctx, torture_comment(tctx, "opening user account\n"); - status = dcerpc_samr_OpenUser_r(b, mem_ctx, &r2); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "OpenUser failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_OpenUser_r(b, mem_ctx, &r2), + "OpenUser failed"); + torture_assert_ntstatus_ok(tctx, r2.out.result, + "OpenUser failed"); r3.in.user_handle = &user_handle; r3.out.user_handle = &user_handle; torture_comment(tctx, "deleting user account\n"); - status = dcerpc_samr_DeleteUser_r(b, mem_ctx, &r3); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "DeleteUser failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_DeleteUser_r(b, mem_ctx, &r3), + "DeleteUser failed"); + torture_assert_ntstatus_ok(tctx, r3.out.result, + "DeleteUser failed"); return true; } @@ -92,7 +91,6 @@ static bool test_opendomain(struct torture_context *tctx, struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_String *domname) { - NTSTATUS status; struct policy_handle h, domain_handle; struct samr_Connect r1; struct samr_LookupDomain r2; @@ -105,11 +103,11 @@ static bool test_opendomain(struct torture_context *tctx, r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; r1.out.connect_handle = &h; - status = dcerpc_samr_Connect_r(b, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "Connect failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_Connect_r(b, mem_ctx, &r1), + "Connect failed"); + torture_assert_ntstatus_ok(tctx, r1.out.result, + "Connect failed"); r2.in.connect_handle = &h; r2.in.domain_name = domname; @@ -117,11 +115,11 @@ static bool test_opendomain(struct torture_context *tctx, torture_comment(tctx, "domain lookup on %s\n", domname->string); - status = dcerpc_samr_LookupDomain_r(b, mem_ctx, &r2); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "LookupDomain failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_LookupDomain_r(b, mem_ctx, &r2), + "LookupDomain failed"); + torture_assert_ntstatus_ok(tctx, r2.out.result, + "LookupDomain failed"); r3.in.connect_handle = &h; r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -130,13 +128,13 @@ static bool test_opendomain(struct torture_context *tctx, torture_comment(tctx, "opening domain\n"); - status = dcerpc_samr_OpenDomain_r(b, mem_ctx, &r3); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "OpenDomain failed - %s\n", nt_errstr(status)); - return false; - } else { - *handle = domain_handle; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_OpenDomain_r(b, mem_ctx, &r3), + "OpenDomain failed"); + torture_assert_ntstatus_ok(tctx, r3.out.result, + "OpenDomain failed"); + + *handle = domain_handle; return true; } @@ -146,17 +144,16 @@ static bool test_samr_close(struct torture_context *tctx, struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle) { - NTSTATUS status; struct samr_Close r; r.in.handle = domain_handle; r.out.handle = domain_handle; - status = dcerpc_samr_Close_r(b, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "Close samr domain failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_Close_r(b, mem_ctx, &r), + "Close samr domain failed"); + torture_assert_ntstatus_ok(tctx, r.out.result, + "Close samr domain failed"); return true; } @@ -166,17 +163,16 @@ static bool test_lsa_close(struct torture_context *tctx, struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle) { - NTSTATUS status; struct lsa_Close r; r.in.handle = domain_handle; r.out.handle = domain_handle; - status = dcerpc_lsa_Close_r(b, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "Close lsa domain failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_lsa_Close_r(b, mem_ctx, &r), + "Close lsa domain failed"); + torture_assert_ntstatus_ok(tctx, r.out.result, + "Close lsa domain failed"); return true; } @@ -186,7 +182,6 @@ static bool test_createuser(struct torture_context *tctx, struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, struct policy_handle *handle, const char* user) { - NTSTATUS status; struct policy_handle user_handle; struct lsa_String username; struct samr_CreateUser r1; @@ -203,11 +198,13 @@ static bool test_createuser(struct torture_context *tctx, torture_comment(tctx, "creating user '%s'\n", username.string); - status = dcerpc_samr_CreateUser_r(b, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "CreateUser failed - %s\n", nt_errstr(status)); + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_CreateUser_r(b, mem_ctx, &r1), + "CreateUser failed"); + if (!NT_STATUS_IS_OK(r1.out.result)) { + torture_comment(tctx, "CreateUser failed - %s\n", nt_errstr(r1.out.result)); - if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { + if (NT_STATUS_EQUAL(r1.out.result, NT_STATUS_USER_EXISTS)) { torture_comment(tctx, "User (%s) already exists - attempting to delete and recreate account again\n", user); if (!test_cleanup(tctx, b, mem_ctx, handle, TEST_USERNAME)) { return false; @@ -215,11 +212,12 @@ static bool test_createuser(struct torture_context *tctx, torture_comment(tctx, "creating user account\n"); - status = dcerpc_samr_CreateUser_r(b, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "CreateUser failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_CreateUser_r(b, mem_ctx, &r1), + "CreateUser failed"); + torture_assert_ntstatus_ok(tctx, r1.out.result, + "CreateUser failed"); + return true; } return false; @@ -230,11 +228,11 @@ static bool test_createuser(struct torture_context *tctx, torture_comment(tctx, "closing user '%s'\n", username.string); - status = dcerpc_samr_Close_r(b, mem_ctx, &r2); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "Close failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_Close_r(b, mem_ctx, &r2), + "Close failed"); + torture_assert_ntstatus_ok(tctx, r2.out.result, + "Close failed"); return true; } diff --git a/source4/torture/libnet/utils.c b/source4/torture/libnet/utils.c index 6c1638bb58..606d218bba 100644 --- a/source4/torture/libnet/utils.c +++ b/source4/torture/libnet/utils.c @@ -33,7 +33,6 @@ bool test_opendomain(struct torture_context *tctx, struct policy_handle *handle, struct lsa_String *domname, struct dom_sid2 *sid_p) { - NTSTATUS status; struct policy_handle h, domain_handle; struct samr_Connect r1; struct samr_LookupDomain r2; @@ -46,8 +45,11 @@ bool test_opendomain(struct torture_context *tctx, r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; r1.out.connect_handle = &h; - status = dcerpc_samr_Connect_r(b, mem_ctx, &r1); - torture_assert_ntstatus_ok(tctx, status, "Connect failed"); + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_Connect_r(b, mem_ctx, &r1), + "Connect failed"); + torture_assert_ntstatus_ok(tctx, r1.out.result, + "Connect failed"); r2.in.connect_handle = &h; r2.in.domain_name = domname; @@ -55,8 +57,11 @@ bool test_opendomain(struct torture_context *tctx, torture_comment(tctx, "domain lookup on %s\n", domname->string); - status = dcerpc_samr_LookupDomain_r(b, mem_ctx, &r2); - torture_assert_ntstatus_ok(tctx, status, "LookupDomain failed"); + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_LookupDomain_r(b, mem_ctx, &r2), + "LookupDomain failed"); + torture_assert_ntstatus_ok(tctx, r2.out.result, + "LookupDomain failed"); r3.in.connect_handle = &h; r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -65,8 +70,11 @@ bool test_opendomain(struct torture_context *tctx, torture_comment(tctx, "opening domain\n"); - status = dcerpc_samr_OpenDomain_r(b, mem_ctx, &r3); - torture_assert_ntstatus_ok(tctx, status, "OpenDomain failed"); + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_OpenDomain_r(b, mem_ctx, &r3), + "OpenDomain failed"); + torture_assert_ntstatus_ok(tctx, r3.out.result, + "OpenDomain failed"); *handle = domain_handle; *sid_p = **r2.out.sid; @@ -79,7 +87,6 @@ bool test_user_cleanup(struct torture_context *tctx, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, const char *name) { - NTSTATUS status; struct samr_LookupNames r1; struct samr_OpenUser r2; struct samr_DeleteUser r3; @@ -98,8 +105,11 @@ bool test_user_cleanup(struct torture_context *tctx, torture_comment(tctx, "user account lookup '%s'\n", name); - status = dcerpc_samr_LookupNames_r(b, mem_ctx, &r1); - torture_assert_ntstatus_ok(tctx, status, "LookupNames failed"); + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_LookupNames_r(b, mem_ctx, &r1), + "LookupNames failed"); + torture_assert_ntstatus_ok(tctx, r1.out.result, + "LookupNames failed"); rid = r1.out.rids->ids[0]; @@ -110,16 +120,22 @@ bool test_user_cleanup(struct torture_context *tctx, torture_comment(tctx, "opening user account\n"); - status = dcerpc_samr_OpenUser_r(b, mem_ctx, &r2); - torture_assert_ntstatus_ok(tctx, status, "OpenUser failed"); + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_OpenUser_r(b, mem_ctx, &r2), + "OpenUser failed"); + torture_assert_ntstatus_ok(tctx, r2.out.result, + "OpenUser failed"); r3.in.user_handle = &user_handle; r3.out.user_handle = &user_handle; torture_comment(tctx, "deleting user account\n"); - status = dcerpc_samr_DeleteUser_r(b, mem_ctx, &r3); - torture_assert_ntstatus_ok(tctx, status, "DeleteUser failed"); + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_DeleteUser_r(b, mem_ctx, &r3), + "DeleteUser failed"); + torture_assert_ntstatus_ok(tctx, r3.out.result, + "DeleteUser failed"); return true; } @@ -131,7 +147,6 @@ bool test_user_create(struct torture_context *tctx, struct policy_handle *handle, const char *name, uint32_t *rid) { - NTSTATUS status; struct lsa_String username; struct samr_CreateUser r; struct policy_handle user_handle; @@ -146,11 +161,12 @@ bool test_user_create(struct torture_context *tctx, torture_comment(tctx, "creating user account %s\n", name); - status = dcerpc_samr_CreateUser_r(b, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "CreateUser failed - %s\n", nt_errstr(status)); - - if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_CreateUser_r(b, mem_ctx, &r), + "CreateUser failed"); + if (!NT_STATUS_IS_OK(r.out.result)) { + printf("CreateUser failed - %s\n", nt_errstr(r.out.result)); + if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_USER_EXISTS)) { torture_comment(tctx, "User (%s) already exists - attempting to delete and recreate account again\n", name); if (!test_user_cleanup(tctx, b, mem_ctx, handle, name)) { return false; @@ -158,8 +174,12 @@ bool test_user_create(struct torture_context *tctx, torture_comment(tctx, "creating user account\n"); - status = dcerpc_samr_CreateUser_r(b, mem_ctx, &r); - torture_assert_ntstatus_ok(tctx, status, "CreateUser failed"); + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_CreateUser_r(b, mem_ctx, &r), + "CreateUser failed"); + torture_assert_ntstatus_ok(tctx, r.out.result, + "CreateUser failed"); + return true; } return false; @@ -174,7 +194,6 @@ bool test_group_cleanup(struct torture_context *tctx, struct policy_handle *domain_handle, const char *name) { - NTSTATUS status; struct samr_LookupNames r1; struct samr_OpenGroup r2; struct samr_DeleteDomainGroup r3; @@ -193,11 +212,11 @@ bool test_group_cleanup(struct torture_context *tctx, torture_comment(tctx, "group account lookup '%s'\n", name); - status = dcerpc_samr_LookupNames_r(b, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "LookupNames failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_LookupNames_r(b, mem_ctx, &r1), + "LookupNames failed"); + torture_assert_ntstatus_ok(tctx, r1.out.result, + "LookupNames failed"); rid = r1.out.rids->ids[0]; @@ -208,22 +227,22 @@ bool test_group_cleanup(struct torture_context *tctx, torture_comment(tctx, "opening group account\n"); - status = dcerpc_samr_OpenGroup_r(b, mem_ctx, &r2); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "OpenGroup failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_OpenGroup_r(b, mem_ctx, &r2), + "OpenGroup failed"); + torture_assert_ntstatus_ok(tctx, r2.out.result, + "OpenGroup failed"); r3.in.group_handle = &group_handle; r3.out.group_handle = &group_handle; torture_comment(tctx, "deleting group account\n"); - status = dcerpc_samr_DeleteDomainGroup_r(b, mem_ctx, &r3); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "DeleteGroup failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_DeleteDomainGroup_r(b, mem_ctx, &r3), + "DeleteGroup failed"); + torture_assert_ntstatus_ok(tctx, r3.out.result, + "DeleteGroup failed"); return true; } @@ -234,7 +253,6 @@ bool test_group_create(struct torture_context *tctx, struct policy_handle *handle, const char *name, uint32_t *rid) { - NTSTATUS status; struct lsa_String groupname; struct samr_CreateDomainGroup r; struct policy_handle group_handle; @@ -249,11 +267,13 @@ bool test_group_create(struct torture_context *tctx, torture_comment(tctx, "creating group account %s\n", name); - status = dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "CreateGroup failed - %s\n", nt_errstr(status)); + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r), + "CreateGroup failed"); + if (!NT_STATUS_IS_OK(r.out.result)) { + torture_comment(tctx, "CreateGroup failed - %s\n", nt_errstr(r.out.result)); - if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { + if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_USER_EXISTS)) { torture_comment(tctx, "Group (%s) already exists - attempting to delete and recreate account again\n", name); if (!test_group_cleanup(tctx, b, mem_ctx, handle, name)) { return false; @@ -261,11 +281,12 @@ bool test_group_create(struct torture_context *tctx, torture_comment(tctx, "creating group account\n"); - status = dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - torture_comment(tctx, "CreateGroup failed - %s\n", nt_errstr(status)); - return false; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r), + "CreateGroup failed"); + torture_assert_ntstatus_ok(tctx, r.out.result, + "CreateGroup failed"); + return true; } return false; |