cache_req_domain.c revision dae798231fc2c575f213785768bc24ed765ba243
377dd19a90436b8f96902af741a3ea130bc3fe75Timo Sirainen Fabiano FidĂȘncio <fidencio@redhat.com>
377dd19a90436b8f96902af741a3ea130bc3fe75Timo Sirainen Copyright (C) 2017 Red Hat
377dd19a90436b8f96902af741a3ea130bc3fe75Timo Sirainen This program is free software; you can redistribute it and/or modify
377dd19a90436b8f96902af741a3ea130bc3fe75Timo Sirainen it under the terms of the GNU General Public License as published by
377dd19a90436b8f96902af741a3ea130bc3fe75Timo Sirainen the Free Software Foundation; either version 3 of the License, or
5f5713d6468dca1acf3d350dd8a33057331f78c5Timo Sirainen (at your option) any later version.
5f5713d6468dca1acf3d350dd8a33057331f78c5Timo Sirainen This program is distributed in the hope that it will be useful,
5f5713d6468dca1acf3d350dd8a33057331f78c5Timo Sirainen but WITHOUT ANY WARRANTY; without even the implied warranty of
377dd19a90436b8f96902af741a3ea130bc3fe75Timo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
377dd19a90436b8f96902af741a3ea130bc3fe75Timo Sirainen GNU General Public License for more details.
377dd19a90436b8f96902af741a3ea130bc3fe75Timo Sirainen You should have received a copy of the GNU General Public License
377dd19a90436b8f96902af741a3ea130bc3fe75Timo Sirainen along with this program. If not, see <http://www.gnu.org/licenses/>.
377dd19a90436b8f96902af741a3ea130bc3fe75Timo Sirainen#include "responder/common/cache_req/cache_req_domain.h"
377dd19a90436b8f96902af741a3ea130bc3fe75Timo Sirainencache_req_domain_get_domain_by_name(struct cache_req_domain *domains,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen if (sss_domain_get_state(dom->domain) == DOM_DISABLED) {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen if (strcasecmp(dom->domain->name, name) == 0 ||
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen strcasecmp(dom->domain->flat_name, name) == 0)) {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEBUG(SSSDBG_OP_FAILURE, "Unknown domains [%s].\n", name);
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenvoid cache_req_domain_list_zfree(struct cache_req_domain **cr_domains)
5a530f778cc3eae05e70d13b8e5d7d501e7ba0b3Timo Sirainen struct cache_req_domain *p, *q, *r;
5f5713d6468dca1acf3d350dd8a33057331f78c5Timo Sirainencache_req_domain_use_fqnames(struct sss_domain_info *domain,
4bc4042782c465636eff2c713bc85f5a1d773d91Timo Sirainen * In order to decide whether fully_qualified_names must be used on the
4bc4042782c465636eff2c713bc85f5a1d773d91Timo Sirainen * lookups we have to take into consideration:
8c2b4a45f17a5cb13bb01058ca37798cf48d91baTimo Sirainen * - use_fully_qualified_name value of the head of the domains;
d8a93844f0b25be82da9c0ab79c321c110f5fb5fTimo Sirainen * (head->fqnames)
9a656df90290a5fef45b3a1191ae75864f17602dTimo Sirainen * - the presence of a domains' resolution order list;
dff32d11a411a24f3b76003c1ae22c5a960f180eTimo Sirainen * (non_fqnames_enforced)
468c28dfb03613ab8d487b5aebc985a969193aceTimo Sirainen * The relationship between those two can be described by:
dfbd56c81cb8fb7fe70393c4682cc99e68fe06b6Timo Sirainen * - head->fqnames:
dfbd56c81cb8fb7fe70393c4682cc99e68fe06b6Timo Sirainen * - true: in this case doesn't matter whether it's enforced or not,
dfbd56c81cb8fb7fe70393c4682cc99e68fe06b6Timo Sirainen * fully-qualified-names will _always_ be used
dfbd56c81cb8fb7fe70393c4682cc99e68fe06b6Timo Sirainen * - false: in this case (which is also the default case), the usage
9054b5f92a7e5666c6beaa04916699a1408bf021Timo Sirainen * depends on it being enforced;
5f5713d6468dca1acf3d350dd8a33057331f78c5Timo Sirainen * - enforce_non_fqnames:
5f5713d6468dca1acf3d350dd8a33057331f78c5Timo Sirainen * - true: in this case, the usage of fully-qualified-names is not
5f5713d6468dca1acf3d350dd8a33057331f78c5Timo Sirainen * - false: in this case, the usage of fully-qualified-names will be
377dd19a90436b8f96902af741a3ea130bc3fe75Timo Sirainen * done accordingly to what's set for the domain itself.
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainen return false;
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainencache_req_domain_new_list_from_string_list(TALLOC_CTX *mem_ctx,
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen for (i = 0; resolution_order[i] != NULL; i++) {
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen for (dom = domains; dom; dom = get_next_domain(dom, flag)) {
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen cr_domain = talloc_zero(mem_ctx, struct cache_req_domain);
312213260e384239ac93c77951c2f1f5f3d3611eTimo Sirainen cache_req_domain_use_fqnames(dom, enforce_non_fqnames);
eb209d12e3b1cfed564c35cf19fdb1bf7fcc6811Timo Sirainen for (dom = domains; dom; dom = get_next_domain(dom, flag)) {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen if (string_in_list(dom->name, resolution_order, false)) {
98d5941dc28754f32432edc38578b946ba71dd0bTimo Sirainen cr_domain = talloc_zero(mem_ctx, struct cache_req_domain);
34115224152b94328ffe3ec4ff4f30927c8f9aa1Timo Sirainen cache_req_domain_use_fqnames(dom, enforce_non_fqnames);
98d5941dc28754f32432edc38578b946ba71dd0bTimo Sirainen DLIST_ADD_END(cr_domains, cr_domain, struct cache_req_domain *);
8a513c80e95a51c29f5af5c702fbf71ecbad41f4Timo Sirainencache_req_domain_new_list_from_domain_resolution_order(
5f5713d6468dca1acf3d350dd8a33057331f78c5Timo Sirainen if (strcmp(domain_resolution_order, ":") != 0) {
1ef9754a5169dc886d15089e59b45a7017d647d7Timo Sirainen ret = split_on_separator(tmp_ctx, domain_resolution_order, ':',
1ef9754a5169dc886d15089e59b45a7017d647d7Timo Sirainen "split_on_separator() failed [%d]: [%s].\n",
1ef9754a5169dc886d15089e59b45a7017d647d7Timo Sirainen cr_domains = cache_req_domain_new_list_from_string_list(mem_ctx, domains,
1ef9754a5169dc886d15089e59b45a7017d647d7Timo Sirainen "cache_req_domain_new_list_from_domain_resolution_order() "
1ef9754a5169dc886d15089e59b45a7017d647d7Timo Sirainen "failed [%d]: [%s].\n",