summaryrefslogtreecommitdiffstats
path: root/server/providers
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2009-12-09 04:00:09 +0100
committerStephen Gallagher <sgallagh@redhat.com>2009-12-10 17:20:20 -0500
commite8498810dc7eb20ea4a652b75e2da194b604f740 (patch)
tree7b8c6736c9f57252f9b0da23d1784d893dd79783 /server/providers
parent51a52431ed52e0312c680e52371882088482071f (diff)
downloadsssd-e8498810dc7eb20ea4a652b75e2da194b604f740.tar.gz
sssd-e8498810dc7eb20ea4a652b75e2da194b604f740.tar.xz
sssd-e8498810dc7eb20ea4a652b75e2da194b604f740.zip
Consolidate code for splitting strings by separator
There were two functions for parsing strings by a separator. This patch consolidates on the one previously used in confdb. This also allows stripping the tokens of whitespace. Fixes: #319
Diffstat (limited to 'server/providers')
-rw-r--r--server/providers/ipa/ipa_common.c5
-rw-r--r--server/providers/krb5/krb5_common.c8
-rw-r--r--server/providers/ldap/ldap_common.c5
3 files changed, 7 insertions, 11 deletions
diff --git a/server/providers/ipa/ipa_common.c b/server/providers/ipa/ipa_common.c
index 0b0eb4897..5ef19da76 100644
--- a/server/providers/ipa/ipa_common.c
+++ b/server/providers/ipa/ipa_common.c
@@ -508,7 +508,6 @@ int ipa_service_init(TALLOC_CTX *memctx, struct be_ctx *ctx,
struct ipa_service *service;
char **list = NULL;
char *realm;
- int count = 0;
int ret;
int i;
@@ -562,14 +561,14 @@ int ipa_service_init(TALLOC_CTX *memctx, struct be_ctx *ctx,
service->krb5_service->realm = realm;
/* split server parm into a list */
- ret = sss_split_list(tmp_ctx, servers, ", ", &list, &count);
+ ret = split_on_separator(tmp_ctx, servers, ',', true, &list, NULL);
if (ret != EOK) {
DEBUG(1, ("Failed to parse server list!\n"));
goto done;
}
/* now for each one add a new server to the failover service */
- for (i = 0; i < count; i++) {
+ for (i = 0; list[i]; i++) {
talloc_steal(service, list[i]);
diff --git a/server/providers/krb5/krb5_common.c b/server/providers/krb5/krb5_common.c
index 6817d6509..b1cf42014 100644
--- a/server/providers/krb5/krb5_common.c
+++ b/server/providers/krb5/krb5_common.c
@@ -49,7 +49,6 @@ errno_t check_and_export_options(struct dp_option *opts,
const char *dummy;
struct stat stat_buf;
char **list;
- int count;
realm = dp_opt_get_cstring(opts, KRB5_REALM);
if (realm == NULL) {
@@ -71,7 +70,7 @@ errno_t check_and_export_options(struct dp_option *opts,
if (dummy == NULL) {
DEBUG(1, ("No KDC expicitly configured, using defaults"));
} else {
- ret = sss_split_list(opts, dummy, ", ", &list, &count);
+ ret = split_on_separator(opts, dummy, ',', true, &list, NULL);
if (ret != EOK) {
DEBUG(1, ("Failed to parse server list!\n"));
return ret;
@@ -287,7 +286,6 @@ int krb5_service_init(TALLOC_CTX *memctx, struct be_ctx *ctx,
TALLOC_CTX *tmp_ctx;
struct krb5_service *service;
char **list = NULL;
- int count = 0;
int ret;
int i;
@@ -320,13 +318,13 @@ int krb5_service_init(TALLOC_CTX *memctx, struct be_ctx *ctx,
goto done;
}
- ret = sss_split_list(tmp_ctx, servers, ", ", &list, &count);
+ ret = split_on_separator(tmp_ctx, servers, ',', true, &list, NULL);
if (ret != EOK) {
DEBUG(1, ("Failed to parse server list!\n"));
goto done;
}
- for (i = 0; i < count; i++) {
+ for (i = 0; list[i]; i++) {
talloc_steal(service, list[i]);
diff --git a/server/providers/ldap/ldap_common.c b/server/providers/ldap/ldap_common.c
index e4f3f6bbf..74b478ccd 100644
--- a/server/providers/ldap/ldap_common.c
+++ b/server/providers/ldap/ldap_common.c
@@ -503,7 +503,6 @@ int sdap_service_init(TALLOC_CTX *memctx, struct be_ctx *ctx,
struct sdap_service *service;
LDAPURLDesc *lud;
char **list = NULL;
- int count = 0;
int ret;
int i;
@@ -531,14 +530,14 @@ int sdap_service_init(TALLOC_CTX *memctx, struct be_ctx *ctx,
}
/* split server parm into a list */
- ret = sss_split_list(tmp_ctx, urls, ", ", &list, &count);
+ ret = split_on_separator(tmp_ctx, urls, ',', true, &list, NULL);
if (ret != EOK) {
DEBUG(1, ("Failed to parse server list!\n"));
goto done;
}
/* now for each URI add a new server to the failover service */
- for (i = 0; i < count; i++) {
+ for (i = 0; list[i]; i++) {
ret = ldap_url_parse(list[i], &lud);
if (ret != LDAP_SUCCESS) {
DEBUG(0, ("Failed to parse ldap URI (%s)!\n", list[i]));