summaryrefslogtreecommitdiffstats
path: root/src/util/usertools.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-05-29 00:56:18 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-06-07 00:14:13 +0200
commit02d1cb8935d5c9b57cd05dfdbfe6ed38e0d61c28 (patch)
tree99eba160bfb608f08dc3f38e3524a3badff3ed67 /src/util/usertools.c
parentc51f7a064b0d7ef86110bdeb6dc09fa6c08be7d3 (diff)
downloadsssd-02d1cb8935d5c9b57cd05dfdbfe6ed38e0d61c28.tar.gz
sssd-02d1cb8935d5c9b57cd05dfdbfe6ed38e0d61c28.tar.xz
sssd-02d1cb8935d5c9b57cd05dfdbfe6ed38e0d61c28.zip
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.
Diffstat (limited to 'src/util/usertools.c')
-rw-r--r--src/util/usertools.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/util/usertools.c b/src/util/usertools.c
index cc8f583b9..dc863ce82 100644
--- a/src/util/usertools.c
+++ b/src/util/usertools.c
@@ -627,3 +627,20 @@ sss_fqdom_len(struct sss_names_ctx *nctx,
len += fq_part_len(nctx, domain, FQ_FMT_FLAT_NAME, domain->flat_name);
return len;
}
+
+char *
+sss_get_domain_name(TALLOC_CTX *mem_ctx,
+ const char *orig_name,
+ struct sss_domain_info *dom)
+{
+ char *user_name;
+
+ if (IS_SUBDOMAIN(dom) && dom->fqnames) {
+ /* 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);
+ }
+
+ return user_name;
+}