>From e772c931afb8559631608e37341c8caa9887964b Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Wed, 16 Apr 2014 14:52:01 +0200 Subject: [PATCH 2/2] Minor fixes for sss_parse_name_for_domains - use brackets after an if - use the right variable name (candidate_domain instead of candidate_name). - fix a typo in a debug message - only print a debug message about using a default domain when using a default domain - add a comment explaning when is a codepath executed --- src/util/usertools.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/util/usertools.c b/src/util/usertools.c index 51927393db02449c883042bad77a6aa839591708..ea2123061d36bada99bfca71b18b11efd2e343e0 100644 --- a/src/util/usertools.c +++ b/src/util/usertools.c @@ -393,8 +393,9 @@ int sss_parse_name_for_domains(TALLOC_CTX *memctx, int ret; tmp_ctx = talloc_new(NULL); - if (tmp_ctx == NULL) + if (tmp_ctx == NULL) { return ENOMEM; + } rname = NULL; rdomain = NULL; @@ -433,7 +434,7 @@ int sss_parse_name_for_domains(TALLOC_CTX *memctx, } rname = nmatch; break; - } else if (candidate_name == NULL) { + } else if (candidate_domain == NULL) { candidate_domain = dmatch; } } @@ -465,18 +466,22 @@ int sss_parse_name_for_domains(TALLOC_CTX *memctx, } if (match == NULL) { DEBUG(SSSDBG_FUNC_DATA, "default domain [%s] is currently " \ - "not know, trying to look it up.\n", - rdomain); + "not known, trying to look it up.\n", + rdomain); *domain = talloc_steal(memctx, rdomain); ret = EAGAIN; goto done; } + DEBUG(SSSDBG_FUNC_DATA, "using default domain [%s]\n", rdomain); } - DEBUG(SSSDBG_FUNC_DATA, "using default domain [%s]\n", rdomain); - rname = candidate_name; } else if (candidate_domain) { + /* This branch is taken when the input matches the configured + * regular expression, but the domain is now known. Normally, this + * is the case with a FQDN of a user from subdomain that was not + * yet discovered + */ *domain = talloc_steal(memctx, candidate_domain); ret = EAGAIN; goto done; -- 1.9.0