return NT_STATUS_OK;
}
-/* enumerate trusted domains
- * (we need to have the list of trustdoms in the cache when we go offline) -
- * Guenther */
-NTSTATUS wb_cache_trusted_domains(struct winbindd_domain *domain,
- TALLOC_CTX *mem_ctx,
- struct netr_DomainTrustList *trusts)
-{
- NTSTATUS status;
- struct winbind_cache *cache;
- struct winbindd_tdc_domain *dom_list = NULL;
- size_t num_domains = 0;
- bool retval = false;
- size_t i;
- bool old_status;
-
- old_status = domain->online;
- trusts->count = 0;
- trusts->array = NULL;
-
- cache = get_cache(domain);
- if (!cache || !cache->tdb) {
- goto do_query;
- }
-
- if (domain->online) {
- goto do_query;
- }
-
- retval = wcache_tdc_fetch_list(&dom_list, &num_domains);
- if (!retval || !num_domains || !dom_list) {
- TALLOC_FREE(dom_list);
- goto do_query;
- }
-
-do_fetch_cache:
- trusts->array = talloc_zero_array(mem_ctx, struct netr_DomainTrust, num_domains);
- if (!trusts->array) {
- TALLOC_FREE(dom_list);
- return NT_STATUS_NO_MEMORY;
- }
-
- for (i = 0; i < num_domains; i++) {
- struct netr_DomainTrust *trust;
- struct dom_sid *sid;
- struct winbindd_domain *dom;
-
- dom = find_domain_from_name_noinit(dom_list[i].domain_name);
- if (dom && dom->internal) {
- continue;
- }
-
- trust = &trusts->array[trusts->count];
- trust->netbios_name = talloc_strdup(trusts->array, dom_list[i].domain_name);
- trust->dns_name = talloc_strdup(trusts->array, dom_list[i].dns_name);
- sid = talloc(trusts->array, struct dom_sid);
- if (!trust->netbios_name || !trust->dns_name ||
- !sid) {
- TALLOC_FREE(dom_list);
- TALLOC_FREE(trusts->array);
- return NT_STATUS_NO_MEMORY;
- }
-
- trust->trust_flags = dom_list[i].trust_flags;
- trust->trust_attributes = dom_list[i].trust_attribs;
- trust->trust_type = dom_list[i].trust_type;
- sid_copy(sid, &dom_list[i].sid);
- trust->sid = sid;
- trusts->count++;
- }
-
- TALLOC_FREE(dom_list);
- return NT_STATUS_OK;
-
-do_query:
- /* Return status value returned by seq number check */
-
- if (!NT_STATUS_IS_OK(domain->last_status))
- return domain->last_status;
-
- DEBUG(10,("trusted_domains: [Cached] - doing backend query for info for domain %s\n",
- domain->name ));
-
- status = domain->backend->trusted_domains(domain, mem_ctx, trusts);
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT) ||
- NT_STATUS_EQUAL(status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) {
- if (!domain->internal && old_status) {
- set_domain_offline(domain);
- }
- if (!domain->internal &&
- !domain->online &&
- old_status) {
- retval = wcache_tdc_fetch_list(&dom_list, &num_domains);
- if (retval && num_domains && dom_list) {
- TALLOC_FREE(trusts->array);
- trusts->count = 0;
- goto do_fetch_cache;
- }
- }
- }
- /* no trusts gives NT_STATUS_NO_MORE_ENTRIES resetting to NT_STATUS_OK
- * so that the generic centry handling still applies correctly -
- * Guenther*/
-
- if (!NT_STATUS_IS_ERR(status)) {
- status = NT_STATUS_OK;
- }
- return status;
-}
/* get lockout policy */
NTSTATUS wb_cache_lockout_policy(struct winbindd_domain *domain,
.name = "PING",
.struct_cmd = WINBINDD_PING,
.struct_fn = winbindd_dual_ping,
- },{
- .name = "LIST_TRUSTDOM",
- .struct_cmd = WINBINDD_LIST_TRUSTDOM,
- .struct_fn = winbindd_dual_list_trusted_domains,
},{
.name = "INIT_CONNECTION",
.struct_cmd = WINBINDD_INIT_CONNECTION,
return ret;
}
-enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *domain,
- struct winbindd_cli_state *state)
-{
- uint32_t i;
- int extra_data_len = 0;
- char *extra_data;
- NTSTATUS result;
- bool have_own_domain = False;
- struct netr_DomainTrustList trusts;
-
- DBG_NOTICE("[%s %u]: list trusted domains\n",
- state->client_name,
- (unsigned int)state->pid);
-
- result = wb_cache_trusted_domains(domain, state->mem_ctx, &trusts);
-
- if (!NT_STATUS_IS_OK(result)) {
- DEBUG(3, ("winbindd_dual_list_trusted_domains: trusted_domains returned %s\n",
- nt_errstr(result) ));
- return WINBINDD_ERROR;
- }
-
- extra_data = talloc_strdup(state->mem_ctx, "");
-
- for (i=0; i<trusts.count; i++) {
- struct dom_sid_buf buf;
-
- if (trusts.array[i].sid == NULL) {
- continue;
- }
- if (dom_sid_equal(trusts.array[i].sid, &global_sid_NULL)) {
- continue;
- }
-
- extra_data = talloc_asprintf_append_buffer(
- extra_data, "%s\\%s\\%s\\%u\\%u\\%u\n",
- trusts.array[i].netbios_name, trusts.array[i].dns_name,
- dom_sid_str_buf(trusts.array[i].sid, &buf),
- trusts.array[i].trust_flags,
- (uint32_t)trusts.array[i].trust_type,
- trusts.array[i].trust_attributes);
- }
-
- /* add our primary domain */
-
- for (i=0; i<trusts.count; i++) {
- if (strequal(trusts.array[i].netbios_name, domain->name)) {
- have_own_domain = True;
- break;
- }
- }
-
- if (state->request->data.list_all_domains && !have_own_domain) {
- struct dom_sid_buf buf;
- extra_data = talloc_asprintf_append_buffer(
- extra_data, "%s\\%s\\%s\n", domain->name,
- domain->alt_name != NULL ?
- domain->alt_name :
- domain->name,
- dom_sid_str_buf(&domain->sid, &buf));
- }
-
- extra_data_len = strlen(extra_data);
- if (extra_data_len > 0) {
-
- /* Strip the last \n */
- extra_data[extra_data_len-1] = '\0';
-
- state->response->extra_data.data = extra_data;
- state->response->length += extra_data_len;
- }
-
- return WINBINDD_OK;
-}
-
bool winbindd_dc_info(struct winbindd_cli_state *cli)
{
struct winbindd_domain *domain;
/* The following definitions come from winbindd/winbindd_misc.c */
bool winbindd_list_trusted_domains(struct winbindd_cli_state *state);
-enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *domain,
- struct winbindd_cli_state *state);
bool winbindd_dc_info(struct winbindd_cli_state *state);
bool winbindd_ping(struct winbindd_cli_state *state);
bool winbindd_info(struct winbindd_cli_state *state);