summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2014-10-13 15:47:09 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-10-14 14:28:38 +0200
commit09a36be00ddcf1d7bd5b8a368143d5b2e2f4fb68 (patch)
tree84bccecf25105026ff1bb640e1677c7ec52d52ac
parent76ba5d2b8d95ec444c124dd9a44275ce685fb648 (diff)
downloadsssd-09a36be00ddcf1d7bd5b8a368143d5b2e2f4fb68.tar.gz
sssd-09a36be00ddcf1d7bd5b8a368143d5b2e2f4fb68.tar.xz
sssd-09a36be00ddcf1d7bd5b8a368143d5b2e2f4fb68.zip
sss_get_domain_name: check for fq name first
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
-rw-r--r--src/util/usertools.c14
1 files changed, 13 insertions, 1 deletions
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;
}