summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/providers/ipa/ipa_common.c53
-rw-r--r--src/providers/ldap/ldap_common.c33
-rw-r--r--src/providers/ldap/ldap_common.h5
3 files changed, 72 insertions, 19 deletions
diff --git a/src/providers/ipa/ipa_common.c b/src/providers/ipa/ipa_common.c
index 4fd44836..8307f6ab 100644
--- a/src/providers/ipa/ipa_common.c
+++ b/src/providers/ipa/ipa_common.c
@@ -327,6 +327,41 @@ done:
return ret;
}
+static errno_t ipa_parse_search_base(TALLOC_CTX *mem_ctx,
+ struct dp_option *opts, int class,
+ struct sdap_search_base ***_search_bases)
+{
+ const char *class_name;
+ char *unparsed_base;
+
+ *_search_bases = NULL;
+
+ switch (class) {
+ case IPA_HBAC_SEARCH_BASE:
+ class_name = "IPA_HBAC";
+ break;
+ case IPA_HOST_SEARCH_BASE:
+ class_name = "IPA_HOST";
+ break;
+ case IPA_SELINUX_SEARCH_BASE:
+ class_name = "IPA_SELINUX";
+ break;
+ default:
+ DEBUG(SSSDBG_CONF_SETTINGS,
+ ("Unknown search base type: [%d]\n", class));
+ class_name = "UNKNOWN";
+ /* Non-fatal */
+ break;
+ }
+
+ unparsed_base = dp_opt_get_string(opts, class);
+ if (!unparsed_base || unparsed_base[0] == '\0') return ENOENT;
+
+ return common_parse_search_base(mem_ctx, unparsed_base,
+ class_name, NULL,
+ _search_bases);
+}
+
int ipa_get_id_options(struct ipa_options *ipa_opts,
struct confdb_ctx *cdb,
const char *conf_path,
@@ -584,9 +619,9 @@ int ipa_get_id_options(struct ipa_options *ipa_opts,
dp_opt_get_string(ipa_opts->basic,
IPA_HOST_SEARCH_BASE)));
}
- ret = sdap_parse_search_base(ipa_opts->basic, ipa_opts->basic,
- IPA_HOST_SEARCH_BASE,
- &ipa_opts->host_search_bases);
+ ret = ipa_parse_search_base(ipa_opts->basic, ipa_opts->basic,
+ IPA_HOST_SEARCH_BASE,
+ &ipa_opts->host_search_bases);
if (ret != EOK) goto done;
if (NULL == dp_opt_get_string(ipa_opts->basic,
@@ -607,9 +642,9 @@ int ipa_get_id_options(struct ipa_options *ipa_opts,
dp_opt_get_string(ipa_opts->basic,
IPA_HBAC_SEARCH_BASE)));
}
- ret = sdap_parse_search_base(ipa_opts->basic, ipa_opts->basic,
- IPA_HBAC_SEARCH_BASE,
- &ipa_opts->hbac_search_bases);
+ ret = ipa_parse_search_base(ipa_opts->basic, ipa_opts->basic,
+ IPA_HBAC_SEARCH_BASE,
+ &ipa_opts->hbac_search_bases);
if (ret != EOK) goto done;
if (NULL == dp_opt_get_string(ipa_opts->basic,
@@ -630,9 +665,9 @@ int ipa_get_id_options(struct ipa_options *ipa_opts,
dp_opt_get_string(ipa_opts->basic,
IPA_SELINUX_SEARCH_BASE)));
}
- ret = sdap_parse_search_base(ipa_opts->basic, ipa_opts->basic,
- IPA_SELINUX_SEARCH_BASE,
- &ipa_opts->selinux_search_bases);
+ ret = ipa_parse_search_base(ipa_opts->basic, ipa_opts->basic,
+ IPA_SELINUX_SEARCH_BASE,
+ &ipa_opts->selinux_search_bases);
if (ret != EOK) goto done;
value = dp_opt_get_string(ipa_opts->id->basic, SDAP_DEREF);
diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c
index cec3989d..3b6a1b2b 100644
--- a/src/providers/ldap/ldap_common.c
+++ b/src/providers/ldap/ldap_common.c
@@ -706,19 +706,9 @@ errno_t sdap_parse_search_base(TALLOC_CTX *mem_ctx,
struct dp_option *opts, int class,
struct sdap_search_base ***_search_bases)
{
- errno_t ret;
- struct sdap_search_base **search_bases;
- TALLOC_CTX *tmp_ctx;
- struct ldb_context *ldb;
- struct ldb_dn *ldn;
- struct ldb_parse_tree *tree;
const char *class_name;
char *unparsed_base;
- char **split_bases;
- char *filter;
const char *old_filter = NULL;
- int count;
- int i, c;
*_search_bases = NULL;
@@ -751,11 +741,34 @@ errno_t sdap_parse_search_base(TALLOC_CTX *mem_ctx,
("Unknown search base type: [%d]\n", class));
class_name = "UNKNOWN";
/* Non-fatal */
+ break;
}
unparsed_base = dp_opt_get_string(opts, class);
if (!unparsed_base || unparsed_base[0] == '\0') return ENOENT;
+ return common_parse_search_base(mem_ctx, unparsed_base,
+ class_name, old_filter,
+ _search_bases);
+}
+
+errno_t common_parse_search_base(TALLOC_CTX *mem_ctx,
+ const char *unparsed_base,
+ const char *class_name,
+ const char *old_filter,
+ struct sdap_search_base ***_search_bases)
+{
+ errno_t ret;
+ struct sdap_search_base **search_bases;
+ TALLOC_CTX *tmp_ctx;
+ struct ldb_context *ldb;
+ struct ldb_dn *ldn;
+ struct ldb_parse_tree *tree;
+ char **split_bases;
+ char *filter;
+ int count;
+ int i, c;
+
tmp_ctx = talloc_new(NULL);
if (!tmp_ctx) {
ret = ENOMEM;
diff --git a/src/providers/ldap/ldap_common.h b/src/providers/ldap/ldap_common.h
index c9125763..7c472cf4 100644
--- a/src/providers/ldap/ldap_common.h
+++ b/src/providers/ldap/ldap_common.h
@@ -203,5 +203,10 @@ errno_t msgs2attrs_array(TALLOC_CTX *mem_ctx, size_t count,
errno_t sdap_parse_search_base(TALLOC_CTX *mem_ctx,
struct dp_option *opts, int class,
struct sdap_search_base ***_search_bases);
+errno_t common_parse_search_base(TALLOC_CTX *mem_ctx,
+ const char *unparsed_base,
+ const char *class_name,
+ const char *old_filter,
+ struct sdap_search_base ***_search_bases);
#endif /* _LDAP_COMMON_H_ */