66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio Fabiano Fidêncio <fidencio@redhat.com>
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio Copyright (C) 2017 Red Hat
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio This program is free software; you can redistribute it and/or modify
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio it under the terms of the GNU General Public License as published by
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio the Free Software Foundation; either version 3 of the License, or
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio (at your option) any later version.
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio This program is distributed in the hope that it will be useful,
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio but WITHOUT ANY WARRANTY; without even the implied warranty of
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio GNU General Public License for more details.
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio You should have received a copy of the GNU General Public License
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio along with this program. If not, see <http://www.gnu.org/licenses/>.
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio#include "responder/common/cache_req/cache_req_domain.h"
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidênciocache_req_domain_get_domain_by_name(struct cache_req_domain *domains,
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio if (sss_domain_get_state(dom->domain) == DOM_DISABLED) {
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio if (strcasecmp(dom->domain->name, name) == 0 ||
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio strcasecmp(dom->domain->flat_name, name) == 0)) {
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio DEBUG(SSSDBG_OP_FAILURE, "Unknown domains [%s].\n", name);
0f44eefe2ce75a0814c8688495477f6c57f3d39aFabiano Fidênciocache_req_domain_copy_cr_domains(TALLOC_CTX *mem_ctx,
0f44eefe2ce75a0814c8688495477f6c57f3d39aFabiano Fidêncio struct cache_req_domain *cr_domains = NULL;
0f44eefe2ce75a0814c8688495477f6c57f3d39aFabiano Fidêncio cr_domain = talloc_zero(mem_ctx, struct cache_req_domain);
0f44eefe2ce75a0814c8688495477f6c57f3d39aFabiano Fidêncio DLIST_ADD_END(cr_domains, cr_domain, struct cache_req_domain *);
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidênciovoid cache_req_domain_list_zfree(struct cache_req_domain **cr_domains)
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio struct cache_req_domain *p, *q, *r;
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidênciocache_req_domain_use_fqnames(struct sss_domain_info *domain,
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * In order to decide whether fully_qualified_names must be used on the
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * lookups we have to take into consideration:
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * - use_fully_qualified_name value of the head of the domains;
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * (head->fqnames)
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * - the presence of a domains' resolution order list;
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * (non_fqnames_enforced)
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * The relationship between those two can be described by:
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * - head->fqnames:
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * - true: in this case doesn't matter whether it's enforced or not,
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * fully-qualified-names will _always_ be used
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * - false: in this case (which is also the default case), the usage
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * depends on it being enforced;
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * - enforce_non_fqnames:
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * - true: in this case, the usage of fully-qualified-names is not
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * - false: in this case, the usage of fully-qualified-names will be
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio * done accordingly to what's set for the domain itself.
b70ec63cca034ce9c638f2dcefbd4358b654d2e1Lukas Slebodnik return false;
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidênciocache_req_domain_new_list_from_string_list(TALLOC_CTX *mem_ctx,
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio struct cache_req_domain *cr_domains = NULL;
f9bac02756aa05cc9c6ac07ae581dba67240c1a4Fabiano Fidêncio /* Firstly, in case a domains' resolution order is passed ... iterate over
f9bac02756aa05cc9c6ac07ae581dba67240c1a4Fabiano Fidêncio * the list adding its domains to the flatten cache req domains' list */
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio for (i = 0; resolution_order[i] != NULL; i++) {
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio for (dom = domains; dom; dom = get_next_domain(dom, flag)) {
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio cr_domain = talloc_zero(mem_ctx, struct cache_req_domain);
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio cache_req_domain_use_fqnames(dom, enforce_non_fqnames);
86526891366c4bc3e1ee861143b736d2670a6ba8Fabiano Fidêncio /* when using the domain resolution order, using shortnames as
86526891366c4bc3e1ee861143b736d2670a6ba8Fabiano Fidêncio * input is allowed by default. However, we really want to use
86526891366c4bc3e1ee861143b736d2670a6ba8Fabiano Fidêncio * the fully qualified name as output in order to avoid
86526891366c4bc3e1ee861143b736d2670a6ba8Fabiano Fidêncio * conflicts whith users who have the very same name. */
fa2fc8a2908619031292eaf375eb1a510b8b2ebaFabiano Fidêncio sss_domain_info_set_output_fqnames(cr_domain->domain, true);
f9bac02756aa05cc9c6ac07ae581dba67240c1a4Fabiano Fidêncio /* Then iterate through all the other domains (and subdomains) and add them
f9bac02756aa05cc9c6ac07ae581dba67240c1a4Fabiano Fidêncio * to the flatten cache req domains' list */
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio for (dom = domains; dom; dom = get_next_domain(dom, flag)) {
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio if (string_in_list(dom->name, resolution_order, false)) {
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio cr_domain = talloc_zero(mem_ctx, struct cache_req_domain);
dae798231fc2c575f213785768bc24ed765ba243Fabiano Fidêncio cache_req_domain_use_fqnames(dom, enforce_non_fqnames);
86526891366c4bc3e1ee861143b736d2670a6ba8Fabiano Fidêncio /* when using the domain resolution order, using shortnames as input
86526891366c4bc3e1ee861143b736d2670a6ba8Fabiano Fidêncio * is allowed by default. However, we really want to use the fully
86526891366c4bc3e1ee861143b736d2670a6ba8Fabiano Fidêncio * qualified name as output in order to avoid conflicts whith users
86526891366c4bc3e1ee861143b736d2670a6ba8Fabiano Fidêncio * who have the very same name. */
fa2fc8a2908619031292eaf375eb1a510b8b2ebaFabiano Fidêncio sss_domain_info_set_output_fqnames(cr_domain->domain, true);
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio DLIST_ADD_END(cr_domains, cr_domain, struct cache_req_domain *);
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidênciocache_req_domain_new_list_from_domain_resolution_order(
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio if (strcmp(domain_resolution_order, ":") != 0) {
b78febe4c579f86f8007a27599605d1eb9f97a62Fabiano Fidêncio "Domain resolution order list (split by ':'): \"%s\"\n",
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio ret = split_on_separator(tmp_ctx, domain_resolution_order, ':',
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio "split_on_separator() failed [%d]: [%s].\n",
b78febe4c579f86f8007a27599605d1eb9f97a62Fabiano Fidêncio "Domain resolution order list: ':' "
b78febe4c579f86f8007a27599605d1eb9f97a62Fabiano Fidêncio "(do not use any specific order)\n");
b78febe4c579f86f8007a27599605d1eb9f97a62Fabiano Fidêncio "Domain resolution order list: not set\n");
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio cr_domains = cache_req_domain_new_list_from_string_list(mem_ctx, domains,
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio "cache_req_domain_new_list_from_domain_resolution_order() "
66c8e92eb5a4985bb7f64c349a53b08030a000cfFabiano Fidêncio "failed [%d]: [%s].\n",