diff options
author | Simo Sorce <ssorce@redhat.com> | 2009-04-14 11:20:30 -0400 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2009-04-14 14:18:45 -0400 |
commit | 4ad7fe5e6acc87140fc29b635605af8445d2d32f (patch) | |
tree | e4211d9de6ccb57f95f75cae702d9c69d6178249 /server/monitor/monitor.c | |
parent | ac5a54e24ac79a33ddf8320811d981b950e21e8e (diff) | |
download | sssd-4ad7fe5e6acc87140fc29b635605af8445d2d32f.tar.gz sssd-4ad7fe5e6acc87140fc29b635605af8445d2d32f.tar.bz2 sssd-4ad7fe5e6acc87140fc29b635605af8445d2d32f.zip |
Add common function to retrieve comma sep. lists
Also convert all places where we were using custom code to parse
config arguments.
And fix a copy&paste error in nss_get_config
Diffstat (limited to 'server/monitor/monitor.c')
-rw-r--r-- | server/monitor/monitor.c | 54 |
1 files changed, 4 insertions, 50 deletions
diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c index dd80830b..20734d1f 100644 --- a/server/monitor/monitor.c +++ b/server/monitor/monitor.c @@ -544,11 +544,6 @@ static int service_signal_reload(struct mt_svc *svc) int get_monitor_config(struct mt_ctx *ctx) { int ret; - size_t svc_count = 0; - char *svcs; - char *cur, *p, *t; - char **svc_list = NULL; - char **tmp_list = NULL; ret = confdb_get_int(ctx->cdb, ctx, MONITOR_CONF_ENTRY, "sbusTimeout", @@ -557,61 +552,20 @@ int get_monitor_config(struct mt_ctx *ctx) return ret; } - ret = confdb_get_string(ctx->cdb, ctx, - SERVICE_CONF_ENTRY, "activeServices", - NULL, &svcs); - - if (ret != EOK || svcs == NULL) { + ret = confdb_get_string_as_list(ctx->cdb, ctx, SERVICE_CONF_ENTRY, + "activeServices", &ctx->services); + if (ret != EOK) { DEBUG(0, ("No services configured!\n")); return EINVAL; } - cur = p = talloc_strdup(svcs, svcs); - while (p && *p) { - for (cur = p; (*cur == ' ' || *cur == '\t'); cur++) /* trim */ ; - if (!*cur) break; - - p = strchr(cur, ','); - if (p) { - /* terminate element */ - *p = '\0'; - /* trim spaces */ - for (t = p-1; (*t == ' ' || *t == '\t'); t--) *t = '\0'; - p++; - } - - svc_count++; - tmp_list = talloc_realloc(svcs, svc_list, char *, svc_count); - if (!tmp_list) { - ret = ENOMEM; - goto done; - } - svc_list = tmp_list; - svc_list[svc_count-1] = talloc_strdup(svc_list, cur); - } - - svc_count++; - tmp_list = talloc_realloc(svcs, svc_list, char *, svc_count); - if (!tmp_list) { - ret = ENOMEM; - goto done; - } - svc_list = tmp_list; - svc_list[svc_count-1] = NULL; - - ctx->services = talloc_steal(ctx, svc_list); - ret = confdb_get_domains(ctx->cdb, ctx, &ctx->domains); if (ret != EOK) { DEBUG(2, ("No domains configured. LOCAL should always exist!\n")); return ret; } - ret = EOK; - -done: - talloc_free(svcs); - return ret; + return EOK; } static int get_service_config(struct mt_ctx *ctx, const char *name, |