summaryrefslogtreecommitdiff
path: root/source4/torture/libnet/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture/libnet/utils.c')
-rw-r--r--source4/torture/libnet/utils.c117
1 files changed, 69 insertions, 48 deletions
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;