summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-03-31 12:52:21 +0000
committerAndrew Tridgell <tridge@samba.org>2004-03-31 12:52:21 +0000
commite5b5c1be45a68afaea867694301256ad0cc69e99 (patch)
tree9cbfea0bac6031edd2c1345a710bee1f6b25c19b /source4/torture
parent4258c7f27ff628b93e296fd0fc0f7a5a5bf2efeb (diff)
downloadsamba-e5b5c1be45a68afaea867694301256ad0cc69e99.tar.gz
samba-e5b5c1be45a68afaea867694301256ad0cc69e99.tar.bz2
samba-e5b5c1be45a68afaea867694301256ad0cc69e99.zip
added lsaCreateAccount() and a test in the RPC-LSA test suite
also tested lsa_Delete() to delete the newly created account (This used to be commit c4d5d0e9eba6b564e2ce6885d66d644b6612d721)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/rpc/lsa.c135
1 files changed, 114 insertions, 21 deletions
diff --git a/source4/torture/rpc/lsa.c b/source4/torture/rpc/lsa.c
index feb7a32140..7f49e4cef6 100644
--- a/source4/torture/rpc/lsa.c
+++ b/source4/torture/rpc/lsa.c
@@ -230,6 +230,116 @@ static BOOL test_EnumPrivsAccount(struct dcerpc_pipe *p,
return True;
}
+static BOOL test_Delete(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle)
+{
+ NTSTATUS status;
+ struct lsa_Delete r;
+
+ printf("\ntesting Delete\n");
+
+ r.in.handle = handle;
+ status = dcerpc_lsa_Delete(p, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Delete failed - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ printf("\n");
+
+ return True;
+}
+
+
+static BOOL find_domain_sid(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ struct dom_sid2 **sid)
+{
+ struct lsa_QueryInfoPolicy r;
+ NTSTATUS status;
+
+ r.in.handle = handle;
+ r.in.level = LSA_POLICY_INFO_DOMAIN;
+
+ status = dcerpc_lsa_QueryInfoPolicy(p, mem_ctx, &r);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("LSA_POLICY_INFO_DOMAIN failed - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ *sid = r.out.info->domain.sid;
+
+ return True;
+}
+
+static struct dom_sid *sid_add_auth(TALLOC_CTX *mem_ctx,
+ const struct dom_sid *sid,
+ uint32 sub_auth)
+{
+ struct dom_sid *ret;
+
+ ret = talloc_p(mem_ctx, struct dom_sid);
+ if (!ret) {
+ return NULL;
+ }
+
+ *ret = *sid;
+
+ ret->sub_auths = talloc_array_p(mem_ctx, uint32, ret->num_auths+1);
+ if (!ret->sub_auths) {
+ return NULL;
+ }
+
+ memcpy(ret->sub_auths, sid->sub_auths,
+ ret->num_auths * sizeof(sid->sub_auths[0]));
+ ret->sub_auths[ret->num_auths] = sub_auth;
+ ret->num_auths++;
+
+ return ret;
+}
+
+static BOOL test_CreateAccount(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle)
+{
+ NTSTATUS status;
+ struct lsa_CreateAccount r;
+ struct dom_sid2 *domsid, *newsid;
+ struct policy_handle acct_handle;
+
+ if (!find_domain_sid(p, mem_ctx, handle, &domsid)) {
+ return False;
+ }
+
+ newsid = sid_add_auth(mem_ctx, domsid, 0x1234abcd);
+ if (!newsid) {
+ printf("Failed to create newsid\n");
+ return False;
+ }
+
+ printf("Testing CreateAccount\n");
+
+ r.in.handle = handle;
+ r.in.sid = newsid;
+ r.in.access = SEC_RIGHTS_MAXIMUM_ALLOWED;
+ r.out.acct_handle = &acct_handle;
+
+ status = dcerpc_lsa_CreateAccount(p, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("CreateAccount failed - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ if (!test_Delete(p, mem_ctx, &acct_handle)) {
+ return False;
+ }
+
+ return True;
+}
+
static BOOL test_EnumAccountRights(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *acct_handle,
@@ -464,27 +574,6 @@ static BOOL test_QueryInfoPolicy(struct dcerpc_pipe *p,
return ret;
}
-static BOOL test_Delete(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx,
- struct policy_handle *handle)
-{
- NTSTATUS status;
- struct lsa_Delete r;
-
- printf("\ntesting Delete - but what does it do?\n");
-
- r.in.handle = handle;
- status = dcerpc_lsa_Delete(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Delete failed - %s\n", nt_errstr(status));
- return False;
- }
-
- printf("\n");
-
- return True;
-}
-
static BOOL test_Close(struct dcerpc_pipe *p,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
@@ -542,6 +631,10 @@ BOOL torture_rpc_lsa(int dummy)
ret = False;
}
+ if (!test_CreateAccount(p, mem_ctx, &handle)) {
+ ret = False;
+ }
+
if (!test_EnumAccounts(p, mem_ctx, &handle)) {
ret = False;
}