From b4160af73646f48073778b610938c9f67a5f6e39 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 21 Jun 2010 11:13:50 +0200 Subject: s3-winbind: Use rpc_trusted_domains in samr. --- source3/winbindd/winbindd_samr.c | 81 ++++++++++------------------------------ 1 file changed, 20 insertions(+), 61 deletions(-) diff --git a/source3/winbindd/winbindd_samr.c b/source3/winbindd/winbindd_samr.c index 12298e1829..35d4c00181 100644 --- a/source3/winbindd/winbindd_samr.c +++ b/source3/winbindd/winbindd_samr.c @@ -325,18 +325,21 @@ done: /* get a list of trusted domains - builtin domain */ static NTSTATUS sam_trusted_domains(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, - struct netr_DomainTrustList *trusts) + struct netr_DomainTrustList *ptrust_list) { struct rpc_pipe_client *lsa_pipe; - struct netr_DomainTrust *array = NULL; struct policy_handle lsa_policy; - uint32_t enum_ctx = 0; - uint32_t count = 0; + struct netr_DomainTrust *trusts = NULL; + uint32_t num_trusts = 0; TALLOC_CTX *tmp_ctx; NTSTATUS status; DEBUG(3,("samr: trusted domains\n")); + if (ptrust_list) { + ZERO_STRUCTP(ptrust_list); + } + tmp_ctx = talloc_stackframe(); if (tmp_ctx == NULL) { return NT_STATUS_NO_MEMORY; @@ -344,68 +347,24 @@ static NTSTATUS sam_trusted_domains(struct winbindd_domain *domain, status = open_internal_lsa_conn(tmp_ctx, &lsa_pipe, &lsa_policy); if (!NT_STATUS_IS_OK(status)) { - goto error; + goto done; } - do { - struct lsa_DomainList dom_list; - uint32_t start_idx; - uint32_t i; - - /* - * We don't run into deadlocks here, cause winbind_off() is - * called in the main function. - */ - status = rpccli_lsa_EnumTrustDom(lsa_pipe, - tmp_ctx, - &lsa_policy, - &enum_ctx, - &dom_list, - (uint32_t) -1); - if (!NT_STATUS_IS_OK(status)) { - if (!NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { - goto error; - } - } - - start_idx = trusts->count; - count += dom_list.count; - - array = talloc_realloc(tmp_ctx, - array, - struct netr_DomainTrust, - count); - if (array == NULL) { - status = NT_STATUS_NO_MEMORY; - goto error; - } - - for (i = 0; i < dom_list.count; i++) { - struct netr_DomainTrust *trust = &array[i]; - struct dom_sid *sid; - - ZERO_STRUCTP(trust); - - trust->netbios_name = talloc_move(array, - &dom_list.domains[i].name.string); - trust->dns_name = NULL; - - sid = talloc(array, struct dom_sid); - if (sid == NULL) { - status = NT_STATUS_NO_MEMORY; - goto error; - } - sid_copy(sid, dom_list.domains[i].sid); - trust->sid = sid; - } - } while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)); + status = rpc_trusted_domains(tmp_ctx, + lsa_pipe, + &lsa_policy, + &num_trusts, + &trusts); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } - if (trusts) { - trusts->count = count; - trusts->array = talloc_move(mem_ctx, &array); + if (ptrust_list) { + ptrust_list->count = num_trusts; + ptrust_list->array = talloc_move(mem_ctx, &trusts); } -error: +done: TALLOC_FREE(tmp_ctx); return status; } -- cgit