From 09a36be00ddcf1d7bd5b8a368143d5b2e2f4fb68 Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Mon, 13 Oct 2014 15:47:09 +0200 Subject: sss_get_domain_name: check for fq name first Reviewed-by: Jakub Hrozek --- src/util/usertools.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/util/usertools.c b/src/util/usertools.c index 0ee167b8e..809b42d67 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; } -- cgit