dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

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

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