From 02d1cb8935d5c9b57cd05dfdbfe6ed38e0d61c28 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Wed, 29 May 2013 00:56:18 +0200 Subject: New utility function sss_get_domain_name Instead of copying a block of code that checks whether domain is a subdomain and uses only name of FQDN as appropriate, wrap the logic into a function. --- src/db/sysdb_search.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'src/db') diff --git a/src/db/sysdb_search.c b/src/db/sysdb_search.c index 344ff6fae..d70d0cc3e 100644 --- a/src/db/sysdb_search.c +++ b/src/db/sysdb_search.c @@ -55,14 +55,9 @@ int sysdb_getpwnam(TALLOC_CTX *mem_ctx, /* If this is a subomain we need to use fully qualified names for the * search as well by default */ - if (IS_SUBDOMAIN(domain) && domain->fqnames) { - ret = ENOMEM; - src_name = sss_tc_fqname(tmp_ctx, domain->names, domain, name); - } else { - ret = EINVAL; - src_name = name; - } + src_name = sss_get_domain_name(tmp_ctx, name, domain); if (!src_name) { + ret = ENOMEM; goto done; } @@ -242,14 +237,9 @@ int sysdb_getgrnam(TALLOC_CTX *mem_ctx, /* If this is a subomain we need to use fully qualified names for the * search as well by default */ - if (IS_SUBDOMAIN(domain) && domain->fqnames) { - ret = ENOMEM; - src_name = sss_tc_fqname(tmp_ctx, domain->names, domain, name); - } else { - ret = EINVAL; - src_name = name; - } + src_name = sss_get_domain_name(tmp_ctx, name, domain); if (!src_name) { + ret = ENOMEM; goto done; } -- cgit