diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/libsmb/trusts_util.c | 28 | ||||
-rw-r--r-- | source3/rpcclient/cmd_lsarpc.c | 23 | ||||
-rw-r--r-- | source3/utils/net_rpc.c | 49 | ||||
-rw-r--r-- | source3/winbindd/winbindd_rpc.c | 18 |
4 files changed, 75 insertions, 43 deletions
diff --git a/source3/libsmb/trusts_util.c b/source3/libsmb/trusts_util.c index 1ca7d56a83..11f691bee6 100644 --- a/source3/libsmb/trusts_util.c +++ b/source3/libsmb/trusts_util.c @@ -152,6 +152,8 @@ bool enumerate_domain_trusts( TALLOC_CTX *mem_ctx, const char *domain, struct cli_state *cli = NULL; struct rpc_pipe_client *lsa_pipe; bool retry; + struct lsa_DomainList dom_list; + int i; *domain_names = NULL; *num_domains = 0; @@ -188,11 +190,33 @@ bool enumerate_domain_trusts( TALLOC_CTX *mem_ctx, const char *domain, /* Lookup list of trusted domains */ - result = rpccli_lsa_enum_trust_dom(lsa_pipe, mem_ctx, &pol, &enum_ctx, - num_domains, domain_names, sids); + result = rpccli_lsa_EnumTrustDom(lsa_pipe, mem_ctx, + &pol, + &enum_ctx, + &dom_list, + (uint32_t)-1); if ( !NT_STATUS_IS_OK(result) ) goto done; + *num_domains = dom_list.count; + + *domain_names = TALLOC_ZERO_ARRAY(mem_ctx, char *, *num_domains); + if (!*domain_names) { + result = NT_STATUS_NO_MEMORY; + goto done; + } + + *sids = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID, *num_domains); + if (!*sids) { + result = NT_STATUS_NO_MEMORY; + goto done; + } + + for (i=0; i< *num_domains; i++) { + (*domain_names)[i] = CONST_DISCARD(char *, dom_list.domains[i].name.string); + (*sids)[i] = *dom_list.domains[i].sid; + } + done: /* cleanup */ if (cli) { diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 4751adfa52..c014dba676 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -377,13 +377,12 @@ static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli, { POLICY_HND pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - DOM_SID *domain_sids; - char **domain_names; + struct lsa_DomainList domain_list; /* defaults, but may be changed using params */ uint32 enum_ctx = 0; - uint32 num_domains = 0; int i; + uint32_t max_size = (uint32_t)-1; if (argc > 2) { printf("Usage: %s [enum context (0)]\n", argv[0]); @@ -407,9 +406,11 @@ static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli, /* Lookup list of trusted domains */ - result = rpccli_lsa_enum_trust_dom(cli, mem_ctx, &pol, &enum_ctx, - &num_domains, - &domain_names, &domain_sids); + result = rpccli_lsa_EnumTrustDom(cli, mem_ctx, + &pol, + &enum_ctx, + &domain_list, + max_size); if (!NT_STATUS_IS_OK(result) && !NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) && !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) @@ -417,12 +418,14 @@ static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli, /* Print results: list of names and sids returned in this * response. */ - for (i = 0; i < num_domains; i++) { + for (i = 0; i < domain_list.count; i++) { fstring sid_str; - sid_to_fstring(sid_str, &domain_sids[i]); - printf("%s %s\n", domain_names[i] ? domain_names[i] : - "*unknown*", sid_str); + sid_to_fstring(sid_str, domain_list.domains[i].sid); + printf("%s %s\n", + domain_list.domains[i].name.string ? + domain_list.domains[i].name.string : "*unknown*", + sid_str); } } diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 4967eb4cff..3767138601 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -6184,10 +6184,9 @@ static int rpc_trustdom_vampire(int argc, const char **argv) union lsa_PolicyInformation *info = NULL; /* trusted domains listing variables */ - unsigned int num_domains, enum_ctx = 0; + unsigned int enum_ctx = 0; int i; - DOM_SID *domain_sids; - char **trusted_dom_names; + struct lsa_DomainList dom_list; fstring pdc_name; /* @@ -6262,10 +6261,11 @@ static int rpc_trustdom_vampire(int argc, const char **argv) d_printf("Vampire trusted domains:\n\n"); do { - nt_status = rpccli_lsa_enum_trust_dom(pipe_hnd, mem_ctx, &connect_hnd, &enum_ctx, - &num_domains, - &trusted_dom_names, &domain_sids); - + nt_status = rpccli_lsa_EnumTrustDom(pipe_hnd, mem_ctx, + &connect_hnd, + &enum_ctx, + &dom_list, + (uint32_t)-1); if (NT_STATUS_IS_ERR(nt_status)) { DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n", nt_errstr(nt_status))); @@ -6273,13 +6273,15 @@ static int rpc_trustdom_vampire(int argc, const char **argv) talloc_destroy(mem_ctx); return -1; }; - - for (i = 0; i < num_domains; i++) { - print_trusted_domain(&(domain_sids[i]), trusted_dom_names[i]); + for (i = 0; i < dom_list.count; i++) { + + print_trusted_domain(dom_list.domains[i].sid, + dom_list.domains[i].name.string); nt_status = vampire_trusted_domain(pipe_hnd, mem_ctx, &connect_hnd, - domain_sids[i], trusted_dom_names[i]); + *dom_list.domains[i].sid, + dom_list.domains[i].name.string); if (!NT_STATUS_IS_OK(nt_status)) { cli_shutdown(cli); talloc_destroy(mem_ctx); @@ -6291,7 +6293,7 @@ static int rpc_trustdom_vampire(int argc, const char **argv) * in case of no trusted domains say something rather * than just display blank line */ - if (!num_domains) d_printf("none\n"); + if (!dom_list.count) d_printf("none\n"); } while (NT_STATUS_EQUAL(nt_status, STATUS_MORE_ENTRIES)); @@ -6329,8 +6331,7 @@ static int rpc_trustdom_list(int argc, const char **argv) /* trusted domains listing variables */ unsigned int num_domains, enum_ctx = 0; int i, pad_len, col_len = 20; - DOM_SID *domain_sids; - char **trusted_dom_names; + struct lsa_DomainList dom_list; fstring pdc_name; /* trusting domains listing variables */ @@ -6409,10 +6410,11 @@ static int rpc_trustdom_list(int argc, const char **argv) d_printf("Trusted domains list:\n\n"); do { - nt_status = rpccli_lsa_enum_trust_dom(pipe_hnd, mem_ctx, &connect_hnd, &enum_ctx, - &num_domains, - &trusted_dom_names, &domain_sids); - + nt_status = rpccli_lsa_EnumTrustDom(pipe_hnd, mem_ctx, + &connect_hnd, + &enum_ctx, + &dom_list, + (uint32_t)-1); if (NT_STATUS_IS_ERR(nt_status)) { DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n", nt_errstr(nt_status))); @@ -6420,16 +6422,17 @@ static int rpc_trustdom_list(int argc, const char **argv) talloc_destroy(mem_ctx); return -1; }; - - for (i = 0; i < num_domains; i++) { - print_trusted_domain(&(domain_sids[i]), trusted_dom_names[i]); + + for (i = 0; i < dom_list.count; i++) { + print_trusted_domain(dom_list.domains[i].sid, + dom_list.domains[i].name.string); }; - + /* * in case of no trusted domains say something rather * than just display blank line */ - if (!num_domains) d_printf("none\n"); + if (!dom_list.count) d_printf("none\n"); } while (NT_STATUS_EQUAL(nt_status, STATUS_MORE_ENTRIES)); diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c index 2703f2f64a..326ff61122 100644 --- a/source3/winbindd/winbindd_rpc.c +++ b/source3/winbindd/winbindd_rpc.c @@ -1008,22 +1008,24 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain, result = STATUS_MORE_ENTRIES; while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) { - uint32 start_idx, num; + uint32 start_idx; char **tmp_names; DOM_SID *tmp_sids; int i; + struct lsa_DomainList dom_list; - result = rpccli_lsa_enum_trust_dom(cli, mem_ctx, - &lsa_policy, &enum_ctx, - &num, &tmp_names, - &tmp_sids); + result = rpccli_lsa_EnumTrustDom(cli, mem_ctx, + &lsa_policy, + &enum_ctx, + &dom_list, + (uint32_t)-1); if (!NT_STATUS_IS_OK(result) && !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) break; start_idx = *num_domains; - *num_domains += num; + *num_domains += dom_list.count; *names = TALLOC_REALLOC_ARRAY(mem_ctx, *names, char *, *num_domains); *dom_sids = TALLOC_REALLOC_ARRAY(mem_ctx, *dom_sids, @@ -1035,8 +1037,8 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain, return NT_STATUS_NO_MEMORY; for (i=0; i<num; i++) { - (*names)[start_idx+i] = tmp_names[i]; - (*dom_sids)[start_idx+i] = tmp_sids[i]; + (*names)[start_idx+i] = dom_list.domains[i].name.string; + (*dom_sids)[start_idx+i] = dom_list.domains[i].sid; (*alt_names)[start_idx+i] = talloc_strdup(mem_ctx, ""); } } |