[SCM] Samba Shared Repository - branch master updated
Kamen Mazdrashki
kamenim at samba.org
Fri Jun 11 08:47:33 MDT 2010
The branch, master has been updated
via c65eb48... s4/test-libnet: Re-align code a bit - more readable this way IMO
via 9baa730... s4/test-libnet: Refactor test_group_create() a little to:
via 6eecb96... s4/test-libnet: Refactor test_user_create() little bit to:
via a735c1a... s4/test-libnet: add few comments for utility functions
via 84fb3ed... s4/test-libnet: Move LSA close handle function to a common location
via 8714f13... s4/test-libnet: remove unused code
via 7168b1c... s4/test-libnet: Fix compile-time warning
from e3c9594... Adjusted ACL tests to use encripted connection.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit c65eb4852c2c401149b840884e76a21ff7cd37c7
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Fri Jun 11 16:02:10 2010 +0300
s4/test-libnet: Re-align code a bit - more readable this way IMO
commit 9baa73053e9119991d3ad6c72b153a006e153b89
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Fri Jun 11 15:44:34 2010 +0300
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
commit 6eecb968cb0eeea7212477dcee8148f093d8c88f
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Fri Jun 11 15:37:12 2010 +0300
s4/test-libnet: Refactor test_user_create() little bit to:
- fix a flaw that user RID is not returned in case
user is recreated
- close unused policy handle to created user
- do not take into account the result from
test_samr_close_handle - we don't case
commit a735c1ade2573fadc84a0aae03cdaa1bddd43f90
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Fri Jun 11 15:30:09 2010 +0300
s4/test-libnet: add few comments for utility functions
commit 84fb3ed8a5e6cb253ec1e461185b0b68e57cf21a
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Fri Jun 11 15:11:01 2010 +0300
s4/test-libnet: Move LSA close handle function to a common location
commit 8714f130e5de2738e8fd430385f236f2e360967e
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Fri Jun 11 15:01:07 2010 +0300
s4/test-libnet: remove unused code
Pre-connecting SAMR and LSA pipes is implemented in
test_libnet_context_init() function
commit 7168b1c99ffa093fd62597762aef2dfc129875fa
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Fri Jun 11 14:59:57 2010 +0300
s4/test-libnet: Fix compile-time warning
-----------------------------------------------------------------------
Summary of changes:
source4/torture/libnet/libnet.c | 2 +-
source4/torture/libnet/libnet_group.c | 30 ++------
source4/torture/libnet/libnet_user.c | 51 +------------
source4/torture/libnet/utils.c | 127 +++++++++++++++++++++-----------
4 files changed, 95 insertions(+), 115 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/torture/libnet/libnet.c b/source4/torture/libnet/libnet.c
index 3dbd777..545f636 100644
--- a/source4/torture/libnet/libnet.c
+++ b/source4/torture/libnet/libnet.c
@@ -21,7 +21,7 @@
#include "torture/smbtorture.h"
#include "librpc/rpc/dcerpc.h"
#include "librpc/gen_ndr/lsa.h"
-#include "libnet/composite.h"
+#include "libnet/libnet.h"
#include "torture/libnet/proto.h"
NTSTATUS torture_net_init(void)
diff --git a/source4/torture/libnet/libnet_group.c b/source4/torture/libnet/libnet_group.c
index 0d8249f..6acb3d2 100644
--- a/source4/torture/libnet/libnet_group.c
+++ b/source4/torture/libnet/libnet_group.c
@@ -32,25 +32,6 @@
#define TEST_GROUPNAME "libnetgrouptest"
-static bool test_lsa_close(struct torture_context *tctx,
- struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
- struct policy_handle *domain_handle)
-{
- struct lsa_Close r;
-
- r.in.handle = domain_handle;
- r.out.handle = domain_handle;
-
- 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;
-}
-
-
bool torture_groupinfo_api(struct torture_context *torture)
{
const char *name = TEST_GROUPNAME;
@@ -102,7 +83,8 @@ bool torture_groupinfo_api(struct torture_context *torture)
goto done;
}
- if (!test_group_cleanup(torture, ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle, TEST_GROUPNAME)) {
+ if (!test_group_cleanup(torture, ctx->samr.pipe->binding_handle,
+ mem_ctx, &ctx->samr.handle, TEST_GROUPNAME)) {
torture_comment(torture, "cleanup failed\n");
ret = false;
goto done;
@@ -152,7 +134,7 @@ bool torture_grouplist(struct torture_context *torture)
for (i = 0; i < req.out.count; i++) {
torture_comment(torture, "\tgroup: %s, sid=%s\n",
- req.out.groups[i].groupname, req.out.groups[i].sid);
+ req.out.groups[i].groupname, req.out.groups[i].sid);
}
} while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES));
@@ -170,7 +152,8 @@ bool torture_grouplist(struct torture_context *torture)
ret = false;
}
- if (!test_lsa_close(torture, ctx->lsa.pipe->binding_handle, mem_ctx, &ctx->lsa.handle)) {
+ if (!test_lsa_close_handle(torture,
+ ctx->lsa.pipe->binding_handle, mem_ctx, &ctx->lsa.handle)) {
torture_comment(torture, "lsa domain close failed\n");
ret = false;
}
@@ -207,7 +190,8 @@ bool torture_creategroup(struct torture_context *torture)
goto done;
}
- if (!test_group_cleanup(torture, ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle, TEST_GROUPNAME)) {
+ if (!test_group_cleanup(torture, ctx->samr.pipe->binding_handle,
+ mem_ctx, &ctx->samr.handle, TEST_GROUPNAME)) {
torture_comment(torture, "cleanup failed\n");
ret = false;
goto done;
diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c
index 84a642a..9dfb1b0 100644
--- a/source4/torture/libnet/libnet_user.c
+++ b/source4/torture/libnet/libnet_user.c
@@ -31,25 +31,6 @@
-static bool test_lsa_close(struct torture_context *tctx,
- struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
- struct policy_handle *domain_handle)
-{
- struct lsa_Close r;
-
- r.in.handle = domain_handle;
- r.out.handle = domain_handle;
-
- 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;
-}
-
-
bool torture_createuser(struct torture_context *torture)
{
NTSTATUS status;
@@ -289,31 +270,6 @@ static void set_test_changes(struct torture_context *tctx,
}
-static bool _libnet_context_init_pipes(struct torture_context *tctx,
- struct libnet_context *libnet_ctx)
-{
- NTSTATUS status;
-
- /* connect SAMR pipe */
- status = torture_rpc_connection(tctx,
- &libnet_ctx->samr.pipe,
- &ndr_table_samr);
- torture_assert_ntstatus_ok(tctx, status, "Failed to open SAMR pipe");
-
- libnet_ctx->samr.samr_handle = libnet_ctx->samr.pipe->binding_handle;
-
-
- /* connect LSARPC pipe */
- status = torture_rpc_connection(tctx,
- &libnet_ctx->lsa.pipe,
- &ndr_table_lsarpc);
- torture_assert_ntstatus_ok(tctx, status, "Failed to open LSA pipe");
-
- libnet_ctx->lsa.lsa_handle = libnet_ctx->lsa.pipe->binding_handle;
-
- return true;
-}
-
bool torture_modifyuser(struct torture_context *torture)
{
NTSTATUS status;
@@ -413,7 +369,7 @@ bool torture_modifyuser(struct torture_context *torture)
cleanup:
if (!test_user_cleanup(torture, ctx->samr.pipe->binding_handle,
- torture, &ctx->samr.handle, TEST_USERNAME)) {
+ torture, &ctx->samr.handle, TEST_USERNAME)) {
torture_comment(torture, "cleanup failed\n");
ret = false;
goto done;
@@ -537,7 +493,7 @@ bool torture_userlist(struct torture_context *torture)
for (i = 0; i < req.out.count; i++) {
torture_comment(torture, "\tuser: %s, sid=%s\n",
- req.out.users[i].username, req.out.users[i].sid);
+ req.out.users[i].username, req.out.users[i].sid);
}
} while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES));
@@ -556,7 +512,8 @@ bool torture_userlist(struct torture_context *torture)
goto done;
}
- if (!test_lsa_close(torture, ctx->lsa.pipe->binding_handle, mem_ctx, &ctx->lsa.handle)) {
+ if (!test_lsa_close_handle(torture,
+ ctx->lsa.pipe->binding_handle, mem_ctx, &ctx->lsa.handle)) {
torture_comment(torture, "lsa domain close failed\n");
ret = false;
}
diff --git a/source4/torture/libnet/utils.c b/source4/torture/libnet/utils.c
index 486f044..dcf284b 100644
--- a/source4/torture/libnet/utils.c
+++ b/source4/torture/libnet/utils.c
@@ -36,14 +36,13 @@
*
* @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_domain_open(struct torture_context *tctx,
- struct dcerpc_binding_handle *b,
- struct lsa_String *domname,
- TALLOC_CTX *mem_ctx,
- struct policy_handle *_domain_handle,
- struct dom_sid2 *_dom_sid)
+ struct dcerpc_binding_handle *b,
+ struct lsa_String *domname,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *_domain_handle,
+ struct dom_sid2 *_dom_sid)
{
struct policy_handle connect_handle;
struct policy_handle domain_handle;
@@ -59,10 +58,10 @@ bool test_domain_open(struct torture_context *tctx,
r1.out.connect_handle = &connect_handle;
torture_assert_ntstatus_ok(tctx,
- dcerpc_samr_Connect_r(b, mem_ctx, &r1),
- "Connect failed");
+ dcerpc_samr_Connect_r(b, mem_ctx, &r1),
+ "Connect failed");
torture_assert_ntstatus_ok(tctx, r1.out.result,
- "Connect failed");
+ "Connect failed");
r2.in.connect_handle = &connect_handle;
r2.in.domain_name = domname;
@@ -162,12 +161,12 @@ done:
* Removes user by RDN through SAMR interface.
*
* @param domain_handle [in] Domain handle
- * @param name
- * @return
+ * @param user_rdn [in] User's RDN in ldap database
*/
bool test_user_cleanup(struct torture_context *tctx,
struct dcerpc_binding_handle *b,
- TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *domain_handle,
const char *user_rdn)
{
struct samr_LookupNames r1;
@@ -255,7 +254,8 @@ bool test_user_create(struct torture_context *tctx,
r.in.account_name = &username;
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
r.out.user_handle = &user_handle;
- r.out.rid = &user_rid;
+ /* return user's RID only if requested */
+ r.out.rid = rid ? rid : &user_rid;
torture_comment(tctx, "creating user '%s'\n", username.string);
@@ -282,28 +282,27 @@ bool test_user_create(struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, r.out.result,
"CreateUser failed");
+ /* be nice and close opened handles */
+ test_samr_close_handle(tctx, b, mem_ctx, &user_handle);
+
return true;
}
return false;
}
- torture_comment(tctx, "closing user '%s'\n", username.string);
-
- if (!test_samr_close_handle(tctx, b, mem_ctx, &user_handle)) {
- return false;
- }
-
- /* return user RID only if requested */
- if (rid) {
- *rid = user_rid;
- }
+ /* be nice and close opened handles */
+ test_samr_close_handle(tctx, b, mem_ctx, &user_handle);
return true;
}
+/**
+ * Deletes a Group using SAMR interface
+ */
bool test_group_cleanup(struct torture_context *tctx,
- struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
+ struct dcerpc_binding_handle *b,
+ TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle,
const char *name)
{
@@ -326,10 +325,10 @@ bool test_group_cleanup(struct torture_context *tctx,
torture_comment(tctx, "group account lookup '%s'\n", name);
torture_assert_ntstatus_ok(tctx,
- dcerpc_samr_LookupNames_r(b, mem_ctx, &r1),
- "LookupNames failed");
+ dcerpc_samr_LookupNames_r(b, mem_ctx, &r1),
+ "LookupNames failed");
torture_assert_ntstatus_ok(tctx, r1.out.result,
- "LookupNames failed");
+ "LookupNames failed");
rid = r1.out.rids->ids[0];
@@ -341,10 +340,10 @@ bool test_group_cleanup(struct torture_context *tctx,
torture_comment(tctx, "opening group account\n");
torture_assert_ntstatus_ok(tctx,
- dcerpc_samr_OpenGroup_r(b, mem_ctx, &r2),
- "OpenGroup failed");
+ dcerpc_samr_OpenGroup_r(b, mem_ctx, &r2),
+ "OpenGroup failed");
torture_assert_ntstatus_ok(tctx, r2.out.result,
- "OpenGroup failed");
+ "OpenGroup failed");
r3.in.group_handle = &group_handle;
r3.out.group_handle = &group_handle;
@@ -352,18 +351,27 @@ bool test_group_cleanup(struct torture_context *tctx,
torture_comment(tctx, "deleting group account\n");
torture_assert_ntstatus_ok(tctx,
- dcerpc_samr_DeleteDomainGroup_r(b, mem_ctx, &r3),
- "DeleteGroup failed");
+ dcerpc_samr_DeleteDomainGroup_r(b, mem_ctx, &r3),
+ "DeleteGroup failed");
torture_assert_ntstatus_ok(tctx, r3.out.result,
- "DeleteGroup failed");
+ "DeleteGroup failed");
return true;
}
+/**
+ * Creates a Group object using SAMR interface
+ *
+ * @param group_name [in] Name of the group to create
+ * @param rid [out] RID of group created. May be NULL in
+ * 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;
@@ -371,7 +379,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;
@@ -381,33 +389,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;
}
@@ -434,6 +451,28 @@ bool test_samr_close_handle(struct torture_context *tctx,
}
/**
+ * Closes LSA handle obtained from Connect, Open Group, etc
+ */
+bool test_lsa_close_handle(struct torture_context *tctx,
+ struct dcerpc_binding_handle *b,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *lsa_handle)
+{
+ struct lsa_Close r;
+
+ r.in.handle = lsa_handle;
+ r.out.handle = lsa_handle;
+
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_lsa_Close_r(b, mem_ctx, &r),
+ "Close LSA handle RPC call failed");
+ torture_assert_ntstatus_ok(tctx, r.out.result,
+ "Close LSA handle failed");
+
+ return true;
+}
+
+/**
* Create and initialize libnet_context Context.
* Use this function in cases where we need to have SAMR and LSA pipes
* of libnet_context to be connected before executing any other
--
Samba Shared Repository
More information about the samba-cvs
mailing list