From 9baa73053e9119991d3ad6c72b153a006e153b89 Mon Sep 17 00:00:00 2001 From: Kamen Mazdrashki Date: Fri, 11 Jun 2010 15:44:34 +0300 Subject: [PATCH] s4/test-libnet: Refactor test_group_create() a little to: - Close unused policy handle for created group - re-align code - it is more readable this way IMHO --- source4/torture/libnet/utils.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/source4/torture/libnet/utils.c b/source4/torture/libnet/utils.c index b4b2374acf0..09298054dc8 100644 --- a/source4/torture/libnet/utils.c +++ b/source4/torture/libnet/utils.c @@ -366,8 +366,10 @@ bool test_group_cleanup(struct torture_context *tctx, * which case RID is not required by caller */ bool test_group_create(struct torture_context *tctx, - struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, - struct policy_handle *handle, const char *name, + struct dcerpc_binding_handle *b, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle, + const char *group_name, uint32_t *rid) { uint32_t group_rid; @@ -375,7 +377,7 @@ bool test_group_create(struct torture_context *tctx, struct samr_CreateDomainGroup r; struct policy_handle group_handle; - groupname.string = name; + groupname.string = group_name; r.in.domain_handle = handle; r.in.name = &groupname; @@ -385,33 +387,42 @@ bool test_group_create(struct torture_context *tctx, * don't care about the group RID */ r.out.rid = rid ? rid : &group_rid; - torture_comment(tctx, "creating group account %s\n", name); + torture_comment(tctx, "creating group account %s\n", group_name); torture_assert_ntstatus_ok(tctx, - dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r), - "CreateGroup failed"); + 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(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_group_cleanup(tctx, b, mem_ctx, handle, name)) { + torture_comment(tctx, + "Group (%s) already exists - " + "attempting to delete and recreate group again\n", + group_name); + if (!test_group_cleanup(tctx, b, mem_ctx, handle, group_name)) { return false; } torture_comment(tctx, "creating group account\n"); torture_assert_ntstatus_ok(tctx, - dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r), - "CreateGroup failed"); + dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r), + "CreateGroup failed"); torture_assert_ntstatus_ok(tctx, r.out.result, - "CreateGroup failed"); + "CreateGroup failed"); + + /* be nice and close opened handles */ + test_samr_close_handle(tctx, b, mem_ctx, &group_handle); return true; } return false; } + /* be nice and close opened handles */ + test_samr_close_handle(tctx, b, mem_ctx, &group_handle); + return true; } -- 2.11.4.GIT