summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-05-28 05:04:56 +0300
committerKamen Mazdrashki <kamenim@samba.org>2010-05-28 22:30:08 +0300
commit8e3a433f93618d6cadc58c19b54b9255acccec6e (patch)
treeebc23918358eef170437c1b4b7037fec2e0f59fa /source4
parent3a899e24d513de7c56363e39efb74b2c88c29854 (diff)
downloadsamba-8e3a433f93618d6cadc58c19b54b9255acccec6e.tar.gz
samba-8e3a433f93618d6cadc58c19b54b9255acccec6e.tar.bz2
samba-8e3a433f93618d6cadc58c19b54b9255acccec6e.zip
s4/test: Refactor test_opendomain to address following
- param names made more clear what they stand for - dom_sid out param is now optional, so that this function may be used in cases where we don't need dom_sid - SAMR connection handle is closed as it is not used further
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/libnet/utils.c49
1 files changed, 33 insertions, 16 deletions
diff --git a/source4/torture/libnet/utils.c b/source4/torture/libnet/utils.c
index cbd6d045f4..27dae51194 100644
--- a/source4/torture/libnet/utils.c
+++ b/source4/torture/libnet/utils.c
@@ -28,12 +28,22 @@
#include "librpc/gen_ndr/ndr_samr_c.h"
#include "torture/libnet/utils.h"
+/**
+ * Opens handle on Domain using SAMR
+ *
+ * @param _domain_handle [out] Ptr to storage to store Domain handle
+ * @param _dom_sid [out] If NULL, Domain SID won't be returned
+ * @return
+ */
bool test_opendomain(struct torture_context *tctx,
- struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle, struct lsa_String *domname,
- struct dom_sid2 *sid_p)
+ struct dcerpc_binding_handle *b,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *_domain_handle,
+ struct lsa_String *domname,
+ struct dom_sid2 *_dom_sid)
{
- struct policy_handle h, domain_handle;
+ struct policy_handle connect_handle;
+ struct policy_handle domain_handle;
struct samr_Connect r1;
struct samr_LookupDomain r2;
struct dom_sid2 *sid = NULL;
@@ -43,7 +53,7 @@ bool test_opendomain(struct torture_context *tctx,
r1.in.system_name = 0;
r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r1.out.connect_handle = &h;
+ r1.out.connect_handle = &connect_handle;
torture_assert_ntstatus_ok(tctx,
dcerpc_samr_Connect_r(b, mem_ctx, &r1),
@@ -51,33 +61,40 @@ bool test_opendomain(struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, r1.out.result,
"Connect failed");
- r2.in.connect_handle = &h;
+ r2.in.connect_handle = &connect_handle;
r2.in.domain_name = domname;
r2.out.sid = &sid;
torture_comment(tctx, "domain lookup on %s\n", domname->string);
torture_assert_ntstatus_ok(tctx,
- dcerpc_samr_LookupDomain_r(b, mem_ctx, &r2),
- "LookupDomain failed");
+ dcerpc_samr_LookupDomain_r(b, mem_ctx, &r2),
+ "LookupDomain failed");
torture_assert_ntstatus_ok(tctx, r2.out.result,
- "LookupDomain failed");
+ "LookupDomain failed");
- r3.in.connect_handle = &h;
+ r3.in.connect_handle = &connect_handle;
r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
r3.in.sid = *r2.out.sid;
r3.out.domain_handle = &domain_handle;
- torture_comment(tctx, "opening domain\n");
+ torture_comment(tctx, "opening domain %s\n", domname->string);
torture_assert_ntstatus_ok(tctx,
- dcerpc_samr_OpenDomain_r(b, mem_ctx, &r3),
- "OpenDomain failed");
+ dcerpc_samr_OpenDomain_r(b, mem_ctx, &r3),
+ "OpenDomain failed");
torture_assert_ntstatus_ok(tctx, r3.out.result,
- "OpenDomain failed");
- *handle = domain_handle;
+ "OpenDomain failed");
+
+ *_domain_handle = domain_handle;
+
+ if (_dom_sid) {
+ *_dom_sid = **r2.out.sid;
+ }
+
+ /* Close connect_handle, we don't need it anymore */
+ test_samr_close_handle(tctx, b, mem_ctx, &connect_handle);
- *sid_p = **r2.out.sid;
return true;
}