Blame SOURCES/0040-UTIL-Introduce-subdomain_create_conf_path.patch

bb7cd1
From ddfa743159541de498816764c06bf4b13fb923f7 Mon Sep 17 00:00:00 2001
bb7cd1
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzidek@redhat.com>
bb7cd1
Date: Tue, 28 Mar 2017 18:33:46 +0200
bb7cd1
Subject: [PATCH 40/54] UTIL: Introduce subdomain_create_conf_path()
bb7cd1
MIME-Version: 1.0
bb7cd1
Content-Type: text/plain; charset=UTF-8
bb7cd1
Content-Transfer-Encoding: 8bit
bb7cd1
bb7cd1
This is a utility function that replaces the create_subdom_conf_path().
bb7cd1
Differently than the latter, it only takes one parameter and is going to
bb7cd1
be used in a few different places (thus adding it to util.h).
bb7cd1
bb7cd1
Reviewed-by: Fabiano FidĂȘncio <fidencio@redhat.com>
bb7cd1
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
bb7cd1
Reviewed-by: Lukas Slebodnik <lslebodn@redhat.com>
bb7cd1
---
bb7cd1
 src/providers/ad/ad_common.c              |  7 -------
bb7cd1
 src/providers/ad/ad_common.h              |  4 ----
bb7cd1
 src/providers/ad/ad_subdomains.c          |  4 +---
bb7cd1
 src/providers/ipa/ipa_subdomains_server.c |  4 +---
bb7cd1
 src/util/domain_info_utils.c              | 15 +++++++++++++++
bb7cd1
 src/util/util.h                           |  3 +++
bb7cd1
 6 files changed, 20 insertions(+), 17 deletions(-)
bb7cd1
bb7cd1
diff --git a/src/providers/ad/ad_common.c b/src/providers/ad/ad_common.c
bb7cd1
index ec952d3bb4587516ea26fd27c212d5620e2f3dda..f893b748a2ddcff1eab6e8d919d2aa950b825446 100644
bb7cd1
--- a/src/providers/ad/ad_common.c
bb7cd1
+++ b/src/providers/ad/ad_common.c
bb7cd1
@@ -33,13 +33,6 @@ errno_t ad_set_search_bases(struct sdap_options *id_opts);
bb7cd1
 static errno_t ad_set_sdap_options(struct ad_options *ad_opts,
bb7cd1
                                    struct sdap_options *id_opts);
bb7cd1
 
bb7cd1
-char *create_subdom_conf_path(TALLOC_CTX *mem_ctx,
bb7cd1
-                              const char *conf_path,
bb7cd1
-                              const char *subdom_name)
bb7cd1
-{
bb7cd1
-    return talloc_asprintf(mem_ctx, "%s/%s", conf_path, subdom_name);
bb7cd1
-}
bb7cd1
-
bb7cd1
 static struct sdap_options *
bb7cd1
 ad_create_default_sdap_options(TALLOC_CTX *mem_ctx)
bb7cd1
 {
bb7cd1
diff --git a/src/providers/ad/ad_common.h b/src/providers/ad/ad_common.h
bb7cd1
index e02b932cd2da737254de8417d5c82fcdcf14e8d7..2981550f6c390929501ec8942e861b16ea0a5cb0 100644
bb7cd1
--- a/src/providers/ad/ad_common.h
bb7cd1
+++ b/src/providers/ad/ad_common.h
bb7cd1
@@ -99,10 +99,6 @@ struct ad_options {
bb7cd1
     struct be_nsupdate_ctx *dyndns_ctx;
bb7cd1
 };
bb7cd1
 
bb7cd1
-char *create_subdom_conf_path(TALLOC_CTX *mem_ctx,
bb7cd1
-                              const char *conf_path,
bb7cd1
-                              const char *subdom_name);
bb7cd1
-
bb7cd1
 errno_t
bb7cd1
 ad_get_common_options(TALLOC_CTX *mem_ctx,
bb7cd1
                       struct confdb_ctx *cdb,
bb7cd1
diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c
bb7cd1
index 156ecab4272029d69c8b596eff041498a7524ce4..eecae9c9ca82ad67874c13a3c7b7c617d6232d5c 100644
bb7cd1
--- a/src/providers/ad/ad_subdomains.c
bb7cd1
+++ b/src/providers/ad/ad_subdomains.c
bb7cd1
@@ -171,9 +171,7 @@ ad_subdom_ad_ctx_new(struct be_ctx *be_ctx,
bb7cd1
         return EINVAL;
bb7cd1
     }
bb7cd1
 
bb7cd1
-    subdom_conf_path = create_subdom_conf_path(id_ctx,
bb7cd1
-                                               be_ctx->conf_path,
bb7cd1
-                                               subdom->name);
bb7cd1
+    subdom_conf_path = subdomain_create_conf_path(id_ctx, subdom);
bb7cd1
     if (subdom_conf_path == NULL) {
bb7cd1
         DEBUG(SSSDBG_CRIT_FAILURE, "subdom_conf_path failed\n");
bb7cd1
         return ENOMEM;
bb7cd1
diff --git a/src/providers/ipa/ipa_subdomains_server.c b/src/providers/ipa/ipa_subdomains_server.c
bb7cd1
index ae3baf036e4278fb67d86b42742fb7e80b46724e..e8ee30392d84f84e30bcdaa3d2110ba130b1ad73 100644
bb7cd1
--- a/src/providers/ipa/ipa_subdomains_server.c
bb7cd1
+++ b/src/providers/ipa/ipa_subdomains_server.c
bb7cd1
@@ -176,9 +176,7 @@ static struct ad_options *ipa_ad_options_new(struct be_ctx *be_ctx,
bb7cd1
     forest_realm = subdom->forest_root->realm;
bb7cd1
     forest = subdom->forest_root->forest;
bb7cd1
 
bb7cd1
-    subdom_conf_path = create_subdom_conf_path(id_ctx,
bb7cd1
-                                               be_ctx->conf_path,
bb7cd1
-                                               subdom->name);
bb7cd1
+    subdom_conf_path = subdomain_create_conf_path(id_ctx, subdom);
bb7cd1
     if (subdom_conf_path == NULL) {
bb7cd1
         DEBUG(SSSDBG_CRIT_FAILURE, "subdom_conf_path failed\n");
bb7cd1
         return NULL;
bb7cd1
diff --git a/src/util/domain_info_utils.c b/src/util/domain_info_utils.c
bb7cd1
index 6ef6bcfb8c078a360673b6bdd2364fc2918cb324..a7f118842aa8ba870143b2f2b425a3e3c0ea5a78 100644
bb7cd1
--- a/src/util/domain_info_utils.c
bb7cd1
+++ b/src/util/domain_info_utils.c
bb7cd1
@@ -870,3 +870,18 @@ bool is_email_from_domain(const char *email, struct sss_domain_info *dom)
bb7cd1
 
bb7cd1
     return false;
bb7cd1
 }
bb7cd1
+
bb7cd1
+char *subdomain_create_conf_path(TALLOC_CTX *mem_ctx,
bb7cd1
+                                 struct sss_domain_info *subdomain)
bb7cd1
+{
bb7cd1
+    if (!IS_SUBDOMAIN(subdomain)) {
bb7cd1
+        DEBUG(SSSDBG_OP_FAILURE,
bb7cd1
+              "The domain \"%s\" is not a subdomain.\n",
bb7cd1
+              subdomain->name);
bb7cd1
+        return NULL;
bb7cd1
+    }
bb7cd1
+
bb7cd1
+    return talloc_asprintf(mem_ctx, CONFDB_DOMAIN_PATH_TMPL "/%s",
bb7cd1
+                           subdomain->parent->name,
bb7cd1
+                           subdomain->name);
bb7cd1
+}
bb7cd1
diff --git a/src/util/util.h b/src/util/util.h
bb7cd1
index a2dc89b8ddb999437eda551ac17af28672d8759c..82760940269ad8883e725e3a5cf463486c9cfd36 100644
bb7cd1
--- a/src/util/util.h
bb7cd1
+++ b/src/util/util.h
bb7cd1
@@ -551,6 +551,9 @@ find_domain_by_object_name(struct sss_domain_info *domain,
bb7cd1
 bool subdomain_enumerates(struct sss_domain_info *parent,
bb7cd1
                           const char *sd_name);
bb7cd1
 
bb7cd1
+char *subdomain_create_conf_path(TALLOC_CTX *mem_ctx,
bb7cd1
+                                 struct sss_domain_info *subdomain);
bb7cd1
+
bb7cd1
 errno_t sssd_domain_init(TALLOC_CTX *mem_ctx,
bb7cd1
                          struct confdb_ctx *cdb,
bb7cd1
                          const char *domain_name,
bb7cd1
-- 
bb7cd1
2.9.3
bb7cd1