diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/domain_info_utils.c | 33 | ||||
-rw-r--r-- | src/util/usertools.c | 20 | ||||
-rw-r--r-- | src/util/util.h | 6 |
3 files changed, 33 insertions, 26 deletions
diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c index 59d5c534..6db7e157 100644 --- a/src/util/domain_info_utils.c +++ b/src/util/domain_info_utils.c @@ -29,8 +29,8 @@ struct sss_domain_info *get_next_domain(struct sss_domain_info *domain, dom = domain; while (dom) { - if (descend && dom->subdomain_count > 0) { - dom = dom->subdomains[0]; + if (descend && dom->subdomains) { + dom = dom->subdomains; } else if (dom->next) { dom = dom->next; } else if (descend && dom->parent) { @@ -44,6 +44,27 @@ struct sss_domain_info *get_next_domain(struct sss_domain_info *domain, return dom; } +struct sss_domain_info *find_subdomain_by_name(struct sss_domain_info *domain, + const char *name, + bool match_any) +{ + struct sss_domain_info *dom = domain; + + while (dom && dom->disabled) { + dom = get_next_domain(dom, true); + } + while (dom) { + if (strcasecmp(dom->name, name) == 0 || + ((match_any == true) && (dom->flat_name != NULL) && + (strcasecmp(dom->flat_name, name) == 0))) { + return dom; + } + dom = get_next_domain(dom, true); + } + + return NULL; +} + struct sss_domain_info *new_subdomain(TALLOC_CTX *mem_ctx, struct sss_domain_info *parent, const char *name, @@ -136,14 +157,6 @@ fail: return NULL; } -struct sss_domain_info *copy_subdomain(TALLOC_CTX *mem_ctx, - struct sss_domain_info *subdomain) -{ - return new_subdomain(mem_ctx, subdomain->parent, - subdomain->name, subdomain->realm, - subdomain->flat_name, subdomain->domain_id); -} - errno_t sssd_domain_init(TALLOC_CTX *mem_ctx, struct confdb_ctx *cdb, const char *domain_name, diff --git a/src/util/usertools.c b/src/util/usertools.c index 33a2a7bd..587fd9cb 100644 --- a/src/util/usertools.c +++ b/src/util/usertools.c @@ -298,24 +298,16 @@ int sss_parse_name(TALLOC_CTX *memctx, return EOK; } -static struct sss_domain_info * match_any_domain_or_subdomain_name ( - struct sss_domain_info *dom, const char *dmatch) +static struct sss_domain_info * match_any_domain_or_subdomain_name( + struct sss_domain_info *dom, + const char *dmatch) { - uint32_t i; - - if (strcasecmp (dom->name, dmatch) == 0 || - (dom->flat_name != NULL && strcasecmp(dom->flat_name, dmatch) == 0)) + if (strcasecmp(dom->name, dmatch) == 0 || + (dom->flat_name != NULL && strcasecmp(dom->flat_name, dmatch) == 0)) { return dom; - - for (i = 0; i < dom->subdomain_count; i++) { - if (strcasecmp(dom->subdomains[i]->name, dmatch) == 0 || - (dom->subdomains[i]->flat_name != NULL && - strcasecmp(dom->subdomains[i]->flat_name, dmatch) == 0)) { - return dom->subdomains[i]; - } } - return NULL; + return find_subdomain_by_name(dom, dmatch, true); } int sss_parse_name_for_domains(TALLOC_CTX *memctx, diff --git a/src/util/util.h b/src/util/util.h index de212811..7697dbb5 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -568,14 +568,16 @@ void to_sized_string(struct sized_string *out, const char *in); /* form domain_info.c */ struct sss_domain_info *get_next_domain(struct sss_domain_info *domain, bool descend); +struct sss_domain_info *find_subdomain_by_name(struct sss_domain_info *domain, + const char *name, + bool match_any); + struct sss_domain_info *new_subdomain(TALLOC_CTX *mem_ctx, struct sss_domain_info *parent, const char *name, const char *realm, const char *flat_name, const char *id); -struct sss_domain_info *copy_subdomain(TALLOC_CTX *mem_ctx, - struct sss_domain_info *subdomain); errno_t sssd_domain_init(TALLOC_CTX *mem_ctx, struct confdb_ctx *cdb, |