From 065771c9859df9c4137daa5187be3aa5633b3cd5 Mon Sep 17 00:00:00 2001 From: Jan Zeleny Date: Fri, 15 Jun 2012 14:19:34 -0400 Subject: Fix re_expression matching with subdomains This patch fixes an issue which resulted in a need to initialize responder with data from local domain, otherwise it would not correctly detect requests for subdomains. Similar situation can occur if new subdomain is added at runtime. The solution is to ask for a list of subdomains in case there is a candidate domain identified in the process of matching re_expressions with given name. --- src/util/usertools.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src/util') diff --git a/src/util/usertools.c b/src/util/usertools.c index 3b23b6a7..36641d49 100644 --- a/src/util/usertools.c +++ b/src/util/usertools.c @@ -230,9 +230,9 @@ int sss_parse_name_for_domains(TALLOC_CTX *memctx, struct sss_domain_info *dom, *match; char *rdomain, *rname; char *dmatch, *nmatch; - char *only_name = NULL; - bool only_name_seen = false; - bool only_name_mismatch = false; + char *candidate_name = NULL; + char *candidate_domain = NULL; + bool name_mismatch = false; TALLOC_CTX *tmp_ctx; int code; @@ -252,13 +252,11 @@ int sss_parse_name_for_domains(TALLOC_CTX *memctx, * name. */ if (dmatch == NULL) { - if (!only_name_seen) { - only_name = nmatch; - } else if (nmatch == NULL || only_name == NULL || - strcasecmp(only_name, nmatch) != 0) { - only_name_mismatch = true; + if (candidate_name == NULL) { + candidate_name = nmatch; + } else if (strcasecmp(candidate_name, nmatch) != 0) { + name_mismatch = true; } - only_name_seen = true; /* * If a domain was returned, then it must match the name of the @@ -274,6 +272,8 @@ int sss_parse_name_for_domains(TALLOC_CTX *memctx, rdomain = dmatch; rname = nmatch; break; + } else if (candidate_name == NULL) { + candidate_domain = dmatch; } } @@ -284,12 +284,16 @@ int sss_parse_name_for_domains(TALLOC_CTX *memctx, } } - if (rdomain == NULL && rname == NULL && - only_name_seen && !only_name_mismatch && only_name != NULL) { - DEBUG(SSSDBG_FUNC_DATA, - ("name '%s' matched without domain, user is %s\n", orig, nmatch)); - rdomain = NULL; - rname = only_name; + if (rdomain == NULL && rname == NULL) { + if (candidate_name && !name_mismatch) { + DEBUG(SSSDBG_FUNC_DATA, + ("name '%s' matched without domain, user is %s\n", orig, nmatch)); + rdomain = NULL; + rname = candidate_name; + } else if (candidate_domain) { + *domain = talloc_steal(memctx, candidate_domain); + return EAGAIN; + } } if (rdomain == NULL && rname == NULL) { -- cgit