summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2013-09-12 12:55:44 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-09-17 16:02:20 +0200
commit0b81cc5d41ec6a1c58e610f402fd93a1fbda4aff (patch)
tree0421dd9259b1f6167a2b000425bcb13ade104aa2
parente1f68731525116ce686ffcdc07ad3a14e4fb1cd7 (diff)
downloadsssd-0b81cc5d41ec6a1c58e610f402fd93a1fbda4aff.tar.gz
sssd-0b81cc5d41ec6a1c58e610f402fd93a1fbda4aff.tar.xz
sssd-0b81cc5d41ec6a1c58e610f402fd93a1fbda4aff.zip
util: add find_subdomain_by_object_name()
This function will parse object name into name and domain name part and return appropriate sss domain. Resolves: https://fedorahosted.org/sssd/ticket/2034
-rw-r--r--src/util/domain_info_utils.c35
-rw-r--r--src/util/util.h4
2 files changed, 39 insertions, 0 deletions
diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c
index f9d9057a8..7b1eb1a39 100644
--- a/src/util/domain_info_utils.c
+++ b/src/util/domain_info_utils.c
@@ -128,6 +128,41 @@ struct sss_domain_info *find_subdomain_by_sid(struct sss_domain_info *domain,
return NULL;
}
+struct sss_domain_info *
+find_subdomain_by_object_name(struct sss_domain_info *domain,
+ const char *object_name)
+{
+ TALLOC_CTX *tmp_ctx;
+ struct sss_domain_info *dom = NULL;
+ char *domainname = NULL;
+ char *name = NULL;
+ errno_t ret;
+
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("talloc_new() failed\n"));
+ return NULL;
+ }
+
+ ret = sss_parse_name(tmp_ctx, domain->names, object_name,
+ &domainname, &name);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("Unable to parse name '%s' [%d]: %s\n",
+ object_name, ret, sss_strerror(ret)));
+ goto done;
+ }
+
+ if (domainname == NULL) {
+ dom = domain;
+ } else {
+ dom = find_subdomain_by_name(domain, domainname, true);
+ }
+
+done:
+ talloc_free(tmp_ctx);
+ return dom;
+}
+
struct sss_domain_info *new_subdomain(TALLOC_CTX *mem_ctx,
struct sss_domain_info *parent,
const char *name,
diff --git a/src/util/util.h b/src/util/util.h
index 3a1da2dcf..18ec4176b 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -548,6 +548,10 @@ struct sss_domain_info *find_subdomain_by_name(struct sss_domain_info *domain,
bool match_any);
struct sss_domain_info *find_subdomain_by_sid(struct sss_domain_info *domain,
const char *sid);
+struct sss_domain_info *
+find_subdomain_by_object_name(struct sss_domain_info *domain,
+ const char *object_name);
+
bool subdomain_enumerates(struct sss_domain_info *parent,
const char *sd_name);