mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
s4:torture/rpc/lsa*: make use of dcerpc_binding_handle stubs
metze
This commit is contained in:
parent
ba3b9fa36b
commit
50cc29b3cb
@ -38,7 +38,7 @@ bool torture_rpc_alter_context(struct torture_context *torture)
|
||||
status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc);
|
||||
torture_assert_ntstatus_ok(torture, status, "connecting");
|
||||
|
||||
if (!test_lsa_OpenPolicy2(p, torture, &handle)) {
|
||||
if (!test_lsa_OpenPolicy2(p->binding_handle, torture, &handle)) {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ bool torture_rpc_alter_context(struct torture_context *torture)
|
||||
ret &= test_DsRoleGetPrimaryDomainInformation(torture, p2);
|
||||
|
||||
if (handle) {
|
||||
ret &= test_lsa_Close(p, torture, handle);
|
||||
ret &= test_lsa_Close(p->binding_handle, torture, handle);
|
||||
}
|
||||
|
||||
syntax = p->syntax;
|
||||
@ -70,10 +70,10 @@ bool torture_rpc_alter_context(struct torture_context *torture)
|
||||
torture_comment(torture, "testing DSSETUP pipe operations - should fault\n");
|
||||
ret &= test_DsRoleGetPrimaryDomainInformation_ext(torture, p, NT_STATUS_NET_WRITE_FAULT);
|
||||
|
||||
ret &= test_lsa_OpenPolicy2(p, torture, &handle);
|
||||
ret &= test_lsa_OpenPolicy2(p->binding_handle, torture, &handle);
|
||||
|
||||
if (handle) {
|
||||
ret &= test_lsa_Close(p, torture, handle);
|
||||
ret &= test_lsa_Close(p->binding_handle, torture, handle);
|
||||
}
|
||||
|
||||
torture_comment(torture, "testing DSSETUP pipe operations\n");
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,7 @@
|
||||
#include "librpc/gen_ndr/ndr_lsa_c.h"
|
||||
#include "libcli/security/security.h"
|
||||
|
||||
static bool open_policy(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
|
||||
static bool open_policy(TALLOC_CTX *mem_ctx, struct dcerpc_binding_handle *b,
|
||||
struct policy_handle **handle)
|
||||
{
|
||||
struct lsa_ObjectAttribute attr;
|
||||
@ -53,12 +53,12 @@ static bool open_policy(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
|
||||
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
|
||||
r.out.handle = *handle;
|
||||
|
||||
status = dcerpc_lsa_OpenPolicy2(p, mem_ctx, &r);
|
||||
status = dcerpc_lsa_OpenPolicy2_r(b, mem_ctx, &r);
|
||||
|
||||
return NT_STATUS_IS_OK(status);
|
||||
}
|
||||
|
||||
static bool get_domainsid(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
|
||||
static bool get_domainsid(TALLOC_CTX *mem_ctx, struct dcerpc_binding_handle *b,
|
||||
struct policy_handle *handle,
|
||||
struct dom_sid **sid)
|
||||
{
|
||||
@ -70,7 +70,7 @@ static bool get_domainsid(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
|
||||
r.in.handle = handle;
|
||||
r.out.info = &info;
|
||||
|
||||
status = dcerpc_lsa_QueryInfoPolicy(p, mem_ctx, &r);
|
||||
status = dcerpc_lsa_QueryInfoPolicy_r(b, mem_ctx, &r);
|
||||
if (!NT_STATUS_IS_OK(status)) return false;
|
||||
|
||||
*sid = info->domain.sid;
|
||||
@ -78,7 +78,7 @@ static bool get_domainsid(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
|
||||
}
|
||||
|
||||
static NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, uint16_t level,
|
||||
struct dcerpc_pipe *p,
|
||||
struct dcerpc_binding_handle *b,
|
||||
struct policy_handle *handle,
|
||||
struct dom_sid **sids, uint32_t num_sids,
|
||||
struct lsa_TransNameArray *names)
|
||||
@ -108,7 +108,7 @@ static NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, uint16_t level,
|
||||
r.out.count = &count;
|
||||
r.out.domains = &domains;
|
||||
|
||||
return dcerpc_lsa_LookupSids(p, mem_ctx, &r);
|
||||
return dcerpc_lsa_LookupSids_r(b, mem_ctx, &r);
|
||||
}
|
||||
|
||||
static const char *sid_type_lookup(enum lsa_SidType r)
|
||||
@ -128,7 +128,7 @@ static const char *sid_type_lookup(enum lsa_SidType r)
|
||||
return "Invalid sid type\n";
|
||||
}
|
||||
|
||||
static bool test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
|
||||
static bool test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_binding_handle *b,
|
||||
struct policy_handle *handle,
|
||||
struct dom_sid **sids, uint32_t num_sids,
|
||||
int level, NTSTATUS expected_result,
|
||||
@ -139,7 +139,7 @@ static bool test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
|
||||
uint32_t i;
|
||||
bool ret = true;
|
||||
|
||||
status = lookup_sids(mem_ctx, level, p, handle, sids, num_sids,
|
||||
status = lookup_sids(mem_ctx, level, b, handle, sids, num_sids,
|
||||
&names);
|
||||
if (!NT_STATUS_EQUAL(status, expected_result)) {
|
||||
printf("For level %d expected %s, got %s\n",
|
||||
@ -166,7 +166,7 @@ static bool test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool get_downleveltrust(struct torture_context *tctx, struct dcerpc_pipe *p,
|
||||
static bool get_downleveltrust(struct torture_context *tctx, struct dcerpc_binding_handle *b,
|
||||
struct policy_handle *handle,
|
||||
struct dom_sid **sid)
|
||||
{
|
||||
@ -182,7 +182,7 @@ static bool get_downleveltrust(struct torture_context *tctx, struct dcerpc_pipe
|
||||
r.out.domains = &domains;
|
||||
r.out.resume_handle = &resume_handle;
|
||||
|
||||
status = dcerpc_lsa_EnumTrustDom(p, tctx, &r);
|
||||
status = dcerpc_lsa_EnumTrustDom_r(b, tctx, &r);
|
||||
|
||||
if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES))
|
||||
torture_fail(tctx, "no trusts");
|
||||
@ -203,7 +203,7 @@ static bool get_downleveltrust(struct torture_context *tctx, struct dcerpc_pipe
|
||||
q.in.level = 6;
|
||||
q.out.info = &info;
|
||||
|
||||
status = dcerpc_lsa_QueryTrustedDomainInfoBySid(p, tctx, &q);
|
||||
status = dcerpc_lsa_QueryTrustedDomainInfoBySid_r(b, tctx, &q);
|
||||
if (!NT_STATUS_IS_OK(status)) continue;
|
||||
|
||||
if ((info->info_ex.trust_direction & 2) &&
|
||||
@ -227,19 +227,21 @@ bool torture_rpc_lsa_lookup(struct torture_context *torture)
|
||||
struct dom_sid *dom_sid = NULL;
|
||||
struct dom_sid *trusted_sid = NULL;
|
||||
struct dom_sid *sids[NUM_SIDS];
|
||||
struct dcerpc_binding_handle *b;
|
||||
|
||||
status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
torture_fail(torture, "unable to connect to table");
|
||||
}
|
||||
b = p->binding_handle;
|
||||
|
||||
ret &= open_policy(torture, p, &handle);
|
||||
ret &= open_policy(torture, b, &handle);
|
||||
if (!ret) return false;
|
||||
|
||||
ret &= get_domainsid(torture, p, handle, &dom_sid);
|
||||
ret &= get_domainsid(torture, b, handle, &dom_sid);
|
||||
if (!ret) return false;
|
||||
|
||||
ret &= get_downleveltrust(torture, p, handle, &trusted_sid);
|
||||
ret &= get_downleveltrust(torture, b, handle, &trusted_sid);
|
||||
if (!ret) return false;
|
||||
|
||||
torture_comment(torture, "domain sid: %s\n",
|
||||
@ -254,7 +256,7 @@ bool torture_rpc_lsa_lookup(struct torture_context *torture)
|
||||
sids[6] = dom_sid_dup(torture, trusted_sid);
|
||||
sids[7] = dom_sid_add_rid(torture, trusted_sid, 512);
|
||||
|
||||
ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 0,
|
||||
ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 0,
|
||||
NT_STATUS_INVALID_PARAMETER, NULL);
|
||||
|
||||
{
|
||||
@ -263,7 +265,7 @@ bool torture_rpc_lsa_lookup(struct torture_context *torture)
|
||||
SID_NAME_ALIAS, SID_NAME_DOMAIN, SID_NAME_DOM_GRP,
|
||||
SID_NAME_DOMAIN, SID_NAME_DOM_GRP };
|
||||
|
||||
ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 1,
|
||||
ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 1,
|
||||
NT_STATUS_OK, types);
|
||||
}
|
||||
|
||||
@ -273,7 +275,7 @@ bool torture_rpc_lsa_lookup(struct torture_context *torture)
|
||||
SID_NAME_UNKNOWN, SID_NAME_UNKNOWN,
|
||||
SID_NAME_DOMAIN, SID_NAME_DOM_GRP,
|
||||
SID_NAME_DOMAIN, SID_NAME_DOM_GRP };
|
||||
ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 2,
|
||||
ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 2,
|
||||
STATUS_SOME_UNMAPPED, types);
|
||||
}
|
||||
|
||||
@ -283,7 +285,7 @@ bool torture_rpc_lsa_lookup(struct torture_context *torture)
|
||||
SID_NAME_UNKNOWN, SID_NAME_UNKNOWN,
|
||||
SID_NAME_DOMAIN, SID_NAME_DOM_GRP,
|
||||
SID_NAME_UNKNOWN, SID_NAME_UNKNOWN };
|
||||
ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 3,
|
||||
ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 3,
|
||||
STATUS_SOME_UNMAPPED, types);
|
||||
}
|
||||
|
||||
@ -293,11 +295,11 @@ bool torture_rpc_lsa_lookup(struct torture_context *torture)
|
||||
SID_NAME_UNKNOWN, SID_NAME_UNKNOWN,
|
||||
SID_NAME_DOMAIN, SID_NAME_DOM_GRP,
|
||||
SID_NAME_UNKNOWN, SID_NAME_UNKNOWN };
|
||||
ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 4,
|
||||
ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 4,
|
||||
STATUS_SOME_UNMAPPED, types);
|
||||
}
|
||||
|
||||
ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 5,
|
||||
ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 5,
|
||||
NT_STATUS_NONE_MAPPED, NULL);
|
||||
|
||||
{
|
||||
@ -306,17 +308,17 @@ bool torture_rpc_lsa_lookup(struct torture_context *torture)
|
||||
SID_NAME_UNKNOWN, SID_NAME_UNKNOWN,
|
||||
SID_NAME_DOMAIN, SID_NAME_DOM_GRP,
|
||||
SID_NAME_UNKNOWN, SID_NAME_UNKNOWN };
|
||||
ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 6,
|
||||
ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 6,
|
||||
STATUS_SOME_UNMAPPED, types);
|
||||
}
|
||||
|
||||
ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 7,
|
||||
ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 7,
|
||||
NT_STATUS_INVALID_PARAMETER, NULL);
|
||||
ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 8,
|
||||
ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 8,
|
||||
NT_STATUS_INVALID_PARAMETER, NULL);
|
||||
ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 9,
|
||||
ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 9,
|
||||
NT_STATUS_INVALID_PARAMETER, NULL);
|
||||
ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 10,
|
||||
ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 10,
|
||||
NT_STATUS_INVALID_PARAMETER, NULL);
|
||||
|
||||
return ret;
|
||||
@ -340,8 +342,9 @@ static bool test_LookupSidsReply(struct torture_context *tctx,
|
||||
NTSTATUS status;
|
||||
const char *dom_sid = "S-1-5-21-1111111111-2222222222-3333333333";
|
||||
const char *dom_admin_sid;
|
||||
struct dcerpc_binding_handle *b = p->binding_handle;
|
||||
|
||||
if (!open_policy(tctx, p, &handle)) {
|
||||
if (!open_policy(tctx, b, &handle)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -370,7 +373,7 @@ static bool test_LookupSidsReply(struct torture_context *tctx,
|
||||
r.out.count = &count;
|
||||
r.out.domains = &domains;
|
||||
|
||||
status = dcerpc_lsa_LookupSids(p, tctx, &r);
|
||||
status = dcerpc_lsa_LookupSids_r(b, tctx, &r);
|
||||
|
||||
torture_assert_ntstatus_equal(tctx, status, NT_STATUS_NONE_MAPPED,
|
||||
"unexpected error code");
|
||||
|
@ -4674,7 +4674,7 @@ static bool test_user_ops(struct dcerpc_pipe *p,
|
||||
status = torture_rpc_connection(tctx, &lp, &ndr_table_lsarpc);
|
||||
torture_assert_ntstatus_ok(tctx, status, "Failed to open LSA pipe");
|
||||
|
||||
if (!test_lsa_OpenPolicy2(lp, tctx, &lsa_handle)) {
|
||||
if (!test_lsa_OpenPolicy2(lp->binding_handle, tctx, &lsa_handle)) {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
@ -4685,7 +4685,7 @@ static bool test_user_ops(struct dcerpc_pipe *p,
|
||||
ret = false;
|
||||
}
|
||||
|
||||
if (!test_lsa_Close(lp, tctx, lsa_handle)) {
|
||||
if (!test_lsa_Close(lp->binding_handle, tctx, lsa_handle)) {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ static bool test_CreateSecret_basic(struct dcerpc_pipe *p,
|
||||
const char *secret1 = "abcdef12345699qwerty";
|
||||
char *secret2;
|
||||
char *secname;
|
||||
struct dcerpc_binding_handle *b = p->binding_handle;
|
||||
|
||||
secname = talloc_asprintf(tctx, "torturesecret-%u", (unsigned int)random());
|
||||
|
||||
@ -62,7 +63,7 @@ static bool test_CreateSecret_basic(struct dcerpc_pipe *p,
|
||||
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
|
||||
r.out.sec_handle = &sec_handle;
|
||||
|
||||
status = dcerpc_lsa_CreateSecret(p, tctx, &r);
|
||||
status = dcerpc_lsa_CreateSecret_r(b, tctx, &r);
|
||||
torture_assert_ntstatus_ok(tctx, status, "CreateSecret failed");
|
||||
|
||||
status = dcerpc_fetch_session_key(p, &session_key);
|
||||
@ -79,7 +80,7 @@ static bool test_CreateSecret_basic(struct dcerpc_pipe *p,
|
||||
|
||||
torture_comment(tctx, "Testing SetSecret\n");
|
||||
|
||||
status = dcerpc_lsa_SetSecret(p, tctx, &r3);
|
||||
status = dcerpc_lsa_SetSecret_r(b, tctx, &r3);
|
||||
torture_assert_ntstatus_ok(tctx, status, "SetSecret failed");
|
||||
|
||||
r3.in.sec_handle = &sec_handle;
|
||||
@ -94,7 +95,7 @@ static bool test_CreateSecret_basic(struct dcerpc_pipe *p,
|
||||
|
||||
torture_comment(tctx, "Testing SetSecret with broken key\n");
|
||||
|
||||
status = dcerpc_lsa_SetSecret(p, tctx, &r3);
|
||||
status = dcerpc_lsa_SetSecret_r(b, tctx, &r3);
|
||||
torture_assert_ntstatus_equal(tctx, status, NT_STATUS_UNKNOWN_REVISION,
|
||||
"SetSecret should have failed UNKNOWN_REVISION");
|
||||
|
||||
@ -113,7 +114,7 @@ static bool test_CreateSecret_basic(struct dcerpc_pipe *p,
|
||||
bufp1.buf = NULL;
|
||||
|
||||
torture_comment(tctx, "Testing QuerySecret\n");
|
||||
status = dcerpc_lsa_QuerySecret(p, tctx, &r4);
|
||||
status = dcerpc_lsa_QuerySecret_r(b, tctx, &r4);
|
||||
torture_assert_ntstatus_ok(tctx, status, "QuerySecret failed");
|
||||
if (r4.out.new_val == NULL || r4.out.new_val->buf == NULL)
|
||||
torture_fail(tctx, "No secret buffer returned");
|
||||
@ -128,7 +129,7 @@ static bool test_CreateSecret_basic(struct dcerpc_pipe *p,
|
||||
|
||||
d.in.handle = &sec_handle;
|
||||
d.out.handle = &sec_handle;
|
||||
status = dcerpc_lsa_DeleteObject(p, tctx, &d);
|
||||
status = dcerpc_lsa_DeleteObject_r(b, tctx, &d);
|
||||
torture_assert_ntstatus_ok(tctx, status, "delete should have returned OKINVALID_HANDLE");
|
||||
return true;
|
||||
}
|
||||
@ -148,6 +149,7 @@ static bool test_secrets(struct torture_context *torture, const void *_data)
|
||||
const struct secret_settings *settings =
|
||||
(const struct secret_settings *)_data;
|
||||
NTSTATUS status;
|
||||
struct dcerpc_binding_handle *b;
|
||||
|
||||
lp_set_cmdline(torture->lp_ctx, "ntlmssp client:keyexchange", settings->keyexchange?"True":"False");
|
||||
lp_set_cmdline(torture->lp_ctx, "ntlmssp_client:ntlm2", settings->ntlm2?"True":"False");
|
||||
@ -171,8 +173,9 @@ static bool test_secrets(struct torture_context *torture, const void *_data)
|
||||
torture->lp_ctx);
|
||||
|
||||
torture_assert_ntstatus_ok(torture, status, "connect");
|
||||
b = p->binding_handle;
|
||||
|
||||
if (!test_lsa_OpenPolicy2(p, torture, &handle)) {
|
||||
if (!test_lsa_OpenPolicy2(b, torture, &handle)) {
|
||||
talloc_free(p);
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user