From 09a36be00ddcf1d7bd5b8a368143d5b2e2f4fb68 Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Oct 14 2014 12:28:38 +0000 Subject: sss_get_domain_name: check for fq name first Reviewed-by: Jakub Hrozek --- diff --git a/src/util/usertools.c b/src/util/usertools.c index 0ee167b..809b42d 100644 --- a/src/util/usertools.c +++ b/src/util/usertools.c @@ -637,13 +637,25 @@ sss_get_domain_name(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom) { char *user_name; + char *domain = NULL; + int ret; + + /* check if the name already contains domain part */ + if (dom->names != NULL) { + ret = sss_parse_name(mem_ctx, dom->names, orig_name, &domain, NULL); + if (ret != EOK) { + return NULL; + } + } - if (IS_SUBDOMAIN(dom) && dom->fqnames) { + if (IS_SUBDOMAIN(dom) && dom->fqnames && domain == NULL) { /* we always use the fully qualified name for subdomain users */ user_name = sss_tc_fqname(mem_ctx, dom->names, dom, orig_name); } else { user_name = talloc_strdup(mem_ctx, orig_name); } + talloc_free(domain); + return user_name; }