diff options
author | Michal Židek <mzidek@redhat.com> | 2017-03-28 18:33:46 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2017-03-29 14:00:17 +0200 |
commit | e0e038218580166648ac24f23180f0f4c2769d99 (patch) | |
tree | 7baed3cb25e46e007810dce2cedfa011500879e3 | |
parent | f75ba99fc8dd64e45af2f642d9fb7660860fd28f (diff) | |
download | sssd-e0e038218580166648ac24f23180f0f4c2769d99.tar.gz sssd-e0e038218580166648ac24f23180f0f4c2769d99.tar.xz sssd-e0e038218580166648ac24f23180f0f4c2769d99.zip |
UTIL: Introduce subdomain_create_conf_path()
This is a utility function that replaces the create_subdom_conf_path().
Differently than the latter, it only takes one parameter and is going to
be used in a few different places (thus adding it to util.h).
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Reviewed-by: Lukas Slebodnik <lslebodn@redhat.com>
-rw-r--r-- | src/providers/ad/ad_common.c | 7 | ||||
-rw-r--r-- | src/providers/ad/ad_common.h | 4 | ||||
-rw-r--r-- | src/providers/ad/ad_subdomains.c | 4 | ||||
-rw-r--r-- | src/providers/ipa/ipa_subdomains_server.c | 4 | ||||
-rw-r--r-- | src/util/domain_info_utils.c | 15 | ||||
-rw-r--r-- | src/util/util.h | 3 |
6 files changed, 20 insertions, 17 deletions
diff --git a/src/providers/ad/ad_common.c b/src/providers/ad/ad_common.c index ec952d3bb..f893b748a 100644 --- a/src/providers/ad/ad_common.c +++ b/src/providers/ad/ad_common.c @@ -33,13 +33,6 @@ errno_t ad_set_search_bases(struct sdap_options *id_opts); static errno_t ad_set_sdap_options(struct ad_options *ad_opts, struct sdap_options *id_opts); -char *create_subdom_conf_path(TALLOC_CTX *mem_ctx, - const char *conf_path, - const char *subdom_name) -{ - return talloc_asprintf(mem_ctx, "%s/%s", conf_path, subdom_name); -} - static struct sdap_options * ad_create_default_sdap_options(TALLOC_CTX *mem_ctx) { diff --git a/src/providers/ad/ad_common.h b/src/providers/ad/ad_common.h index e02b932cd..2981550f6 100644 --- a/src/providers/ad/ad_common.h +++ b/src/providers/ad/ad_common.h @@ -99,10 +99,6 @@ struct ad_options { struct be_nsupdate_ctx *dyndns_ctx; }; -char *create_subdom_conf_path(TALLOC_CTX *mem_ctx, - const char *conf_path, - const char *subdom_name); - errno_t ad_get_common_options(TALLOC_CTX *mem_ctx, struct confdb_ctx *cdb, diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c index 156ecab42..eecae9c9c 100644 --- a/src/providers/ad/ad_subdomains.c +++ b/src/providers/ad/ad_subdomains.c @@ -171,9 +171,7 @@ ad_subdom_ad_ctx_new(struct be_ctx *be_ctx, return EINVAL; } - subdom_conf_path = create_subdom_conf_path(id_ctx, - be_ctx->conf_path, - subdom->name); + subdom_conf_path = subdomain_create_conf_path(id_ctx, subdom); if (subdom_conf_path == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, "subdom_conf_path failed\n"); return ENOMEM; diff --git a/src/providers/ipa/ipa_subdomains_server.c b/src/providers/ipa/ipa_subdomains_server.c index ae3baf036..e8ee30392 100644 --- a/src/providers/ipa/ipa_subdomains_server.c +++ b/src/providers/ipa/ipa_subdomains_server.c @@ -176,9 +176,7 @@ static struct ad_options *ipa_ad_options_new(struct be_ctx *be_ctx, forest_realm = subdom->forest_root->realm; forest = subdom->forest_root->forest; - subdom_conf_path = create_subdom_conf_path(id_ctx, - be_ctx->conf_path, - subdom->name); + subdom_conf_path = subdomain_create_conf_path(id_ctx, subdom); if (subdom_conf_path == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, "subdom_conf_path failed\n"); return NULL; diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c index 6ef6bcfb8..a7f118842 100644 --- a/src/util/domain_info_utils.c +++ b/src/util/domain_info_utils.c @@ -870,3 +870,18 @@ bool is_email_from_domain(const char *email, struct sss_domain_info *dom) return false; } + +char *subdomain_create_conf_path(TALLOC_CTX *mem_ctx, + struct sss_domain_info *subdomain) +{ + if (!IS_SUBDOMAIN(subdomain)) { + DEBUG(SSSDBG_OP_FAILURE, + "The domain \"%s\" is not a subdomain.\n", + subdomain->name); + return NULL; + } + + return talloc_asprintf(mem_ctx, CONFDB_DOMAIN_PATH_TMPL "/%s", + subdomain->parent->name, + subdomain->name); +} diff --git a/src/util/util.h b/src/util/util.h index a2dc89b8d..827609402 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -551,6 +551,9 @@ find_domain_by_object_name(struct sss_domain_info *domain, bool subdomain_enumerates(struct sss_domain_info *parent, const char *sd_name); +char *subdomain_create_conf_path(TALLOC_CTX *mem_ctx, + struct sss_domain_info *subdomain); + errno_t sssd_domain_init(TALLOC_CTX *mem_ctx, struct confdb_ctx *cdb, const char *domain_name, |