1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-20 14:03:59 +03:00

fixed the AddAliasMem test code

This commit is contained in:
Andrew Tridgell -
parent f740b02ac3
commit abe7ffcece
2 changed files with 44 additions and 13 deletions

View File

@ -138,3 +138,26 @@ size_t ndr_size_security_descriptor(struct security_descriptor *sd)
ret += ndr_size_security_acl(sd->sacl); ret += ndr_size_security_acl(sd->sacl);
return ret; return ret;
} }
/*
add a rid to a domain dom_sid to make a full dom_sid
*/
struct dom_sid *dom_sid_add_rid(TALLOC_CTX *mem_ctx,
const struct dom_sid *domain_sid,
uint32 rid)
{
struct dom_sid *sid;
sid = talloc_p(mem_ctx, struct dom_sid);
if (!sid) return NULL;
*sid = *domain_sid;
sid->sub_auths = talloc_array_p(mem_ctx, uint32, sid->num_auths+1);
if (!sid->sub_auths) {
return NULL;
}
memcpy(sid->sub_auths, domain_sid->sub_auths, sid->num_auths*sizeof(uint32));
sid->sub_auths[sid->num_auths] = rid;
sid->num_auths++;
return sid;
}

View File

@ -315,29 +315,33 @@ static BOOL test_GetMembersInAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
static BOOL test_AddMemberToAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, static BOOL test_AddMemberToAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *alias_handle, struct policy_handle *alias_handle,
struct policy_handle *domain_handle ) struct policy_handle *domain_handle,
const struct dom_sid *domain_sid)
{ {
struct samr_AddAliasMem r; struct samr_AddAliasMem r;
struct samr_DelAliasMem d; struct samr_DelAliasMem d;
NTSTATUS status; NTSTATUS status;
BOOL ret = True; BOOL ret = True;
struct dom_sid *sid;
printf("testing ADD_ALIASMEM\n"); sid = dom_sid_add_rid(mem_ctx, domain_sid, 512);
printf("testing AddAliasMem\n");
r.in.handle = alias_handle; r.in.handle = alias_handle;
r.in.sid = sid;
return True;
status = dcerpc_samr_AddAliasMem(p, mem_ctx, &r); status = dcerpc_samr_AddAliasMem(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
printf("ADD_ALIASMEM failed - %s\n", nt_errstr(status)); printf("AddAliasMem failed - %s\n", nt_errstr(status));
ret = False; ret = False;
} }
d.in.handle = alias_handle; d.in.handle = alias_handle;
d.in.sid = sid;
status = dcerpc_samr_DelAliasMem(p, mem_ctx, &d); status = dcerpc_samr_DelAliasMem(p, mem_ctx, &d);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
printf("DEL_ALIASMEM failed - %s\n", nt_errstr(status)); printf("DelAliasMem failed - %s\n", nt_errstr(status));
ret = False; ret = False;
} }
@ -370,7 +374,8 @@ static BOOL test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
static BOOL test_alias_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, static BOOL test_alias_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *alias_handle, struct policy_handle *alias_handle,
struct policy_handle *domain_handle) struct policy_handle *domain_handle,
const struct dom_sid *domain_sid)
{ {
BOOL ret = True; BOOL ret = True;
@ -386,7 +391,8 @@ static BOOL test_alias_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
ret = False; ret = False;
} }
if (!test_AddMemberToAlias(p, mem_ctx, alias_handle, domain_handle)) { if (!test_AddMemberToAlias(p, mem_ctx, alias_handle,
domain_handle, domain_sid)) {
ret = False; ret = False;
} }
@ -501,7 +507,9 @@ static BOOL test_DeleteAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
} }
static BOOL test_CreateAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, static BOOL test_CreateAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle, struct policy_handle *alias_handle) struct policy_handle *domain_handle,
struct policy_handle *alias_handle,
const struct dom_sid *domain_sid)
{ {
NTSTATUS status; NTSTATUS status;
struct samr_CreateDomAlias r; struct samr_CreateDomAlias r;
@ -537,7 +545,7 @@ static BOOL test_CreateAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return False; return False;
} }
if (!test_alias_ops(p, mem_ctx, alias_handle, domain_handle)) { if (!test_alias_ops(p, mem_ctx, alias_handle, domain_handle, domain_sid)) {
ret = False; ret = False;
} }
@ -1136,7 +1144,7 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
} }
static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, struct dom_sid2 *sid) struct policy_handle *handle, struct dom_sid *sid)
{ {
NTSTATUS status; NTSTATUS status;
struct samr_OpenDomain r; struct samr_OpenDomain r;
@ -1169,7 +1177,7 @@ static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
ret = False; ret = False;
} }
if (!test_CreateAlias(p, mem_ctx, &domain_handle, &alias_handle)) { if (!test_CreateAlias(p, mem_ctx, &domain_handle, &alias_handle, sid)) {
ret = False; ret = False;
} }