summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2012-02-22 21:18:48 -0500
committerStephen Gallagher <sgallagh@redhat.com>2012-02-23 09:13:21 -0500
commit087219897d8b8a92d7d33da3fa30883d40ad8cdb (patch)
tree5f003f8861d653ca4aabcba8570196861c31b9c5 /src
parent5319ad03a11fb600bea9a9a51a392eef38e10ac8 (diff)
downloadsssd-087219897d8b8a92d7d33da3fa30883d40ad8cdb.tar.gz
sssd-087219897d8b8a92d7d33da3fa30883d40ad8cdb.tar.xz
sssd-087219897d8b8a92d7d33da3fa30883d40ad8cdb.zip
IPA: Add ipa_parse_search_base()
Previously, we were using sdap_parse_search_base() for setting up the search_base objects for use in IPA. However, this was generating unfriendly log messages about unknown search base types. This patch creates a new common_parse_search_base() routine that can be used with either LDAP or IPA providers. https://fedorahosted.org/sssd/ticket/1151
Diffstat (limited to 'src')
-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 4fd448362..8307f6abf 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 cec3989d0..3b6a1b2ba 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 c91257634..7c472cf44 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_ */