diff options
Diffstat (limited to 'source4/torture/rpc/lsa.c')
-rw-r--r-- | source4/torture/rpc/lsa.c | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/source4/torture/rpc/lsa.c b/source4/torture/rpc/lsa.c index a542cad636..5cf56acd30 100644 --- a/source4/torture/rpc/lsa.c +++ b/source4/torture/rpc/lsa.c @@ -22,7 +22,7 @@ #include "includes.h" /* - this really shouldn't be here .... + these really shouldn't be here .... */ static char *lsa_sid_string_talloc(TALLOC_CTX *mem_ctx, struct dom_sid *sid) { @@ -53,6 +53,31 @@ static char *lsa_sid_string_talloc(TALLOC_CTX *mem_ctx, struct dom_sid *sid) return ret; } +static int dom_sid_compare(struct dom_sid *sid1, struct dom_sid *sid2) +{ + int i; + + if (sid1 == sid2) return 0; + if (!sid1) return -1; + if (!sid2) return 1; + + /* Compare most likely different rids, first: i.e start at end */ + if (sid1->num_auths != sid2->num_auths) + return sid1->num_auths - sid2->num_auths; + + for (i = sid1->num_auths-1; i >= 0; --i) + if (sid1->sub_auths[i] != sid2->sub_auths[i]) + return sid1->sub_auths[i] - sid2->sub_auths[i]; + + if (sid1->sid_rev_num != sid2->sid_rev_num) + return sid1->sid_rev_num - sid2->sid_rev_num; + + for (i = 0; i < 6; i++) + if (sid1->id_auth[i] != sid2->id_auth[i]) + return sid1->id_auth[i] - sid2->id_auth[i]; + + return 0; +} static BOOL test_OpenPolicy(struct dcerpc_pipe *p) { @@ -124,24 +149,41 @@ static BOOL test_EnumSids(struct dcerpc_pipe *p, struct policy_handle *handle) { NTSTATUS status; - struct dom_sid **sids; - uint32 num_entries = 100; + struct lsa_SidArray sids1, sids2; + uint32 resume_handle; int i; printf("\ntesting EnumSids\n"); - status = dcerpc_lsa_EnumSids(p, mem_ctx, handle, 0, &num_entries, &sids); + resume_handle = 0; + status = dcerpc_lsa_EnumSids(p, mem_ctx, handle, &resume_handle, 100, &sids1); if (!NT_STATUS_IS_OK(status)) { printf("EnumSids failed - %s\n", nt_errstr(status)); return False; } - printf("Got %d sids\n", num_entries); + printf("Got %d sids resume_handle=%u\n", sids1.num_sids, resume_handle); - for (i=0;i<num_entries;i++) { - printf("%s\n", lsa_sid_string_talloc(mem_ctx, sids[i])); + for (i=0;i<sids1.num_sids;i++) { + printf("%s\n", lsa_sid_string_talloc(mem_ctx, sids1.sids[i].sid)); + } + + if (sids1.num_sids < 3) { + return True; } + printf("trying partial listing (asking for 1 at 2)\n"); + resume_handle = 2; + status = dcerpc_lsa_EnumSids(p, mem_ctx, handle, &resume_handle, 1, &sids2); + if (!NT_STATUS_IS_OK(status)) { + printf("EnumSids failed - %s\n", nt_errstr(status)); + return False; + } + + if (sids2.num_sids != 1) { + printf("Returned wrong number of entries (%d)\n", sids2.num_sids); + return False; + } return True; } |