summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2011-07-03 10:13:51 +0200
committerLinus Nordberg <linus@nordu.net>2011-07-03 10:13:51 +0200
commit074f7dfe1934273a2336414c135b2494fda08af3 (patch)
treeadf125a61eab22b6d2e31f720a8a33d284b8fabc /lib
parent1e71b7c57ede27a9cecb0d78d23fb4e48a85479c (diff)
Handle configuration errors better.
Diffstat (limited to 'lib')
-rw-r--r--lib/conf.c6
-rw-r--r--lib/radsec.c5
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/conf.c b/lib/conf.c
index 06ae3aa..e3d5522 100644
--- a/lib/conf.c
+++ b/lib/conf.c
@@ -40,8 +40,6 @@
int
rs_context_read_config(struct rs_context *ctx, const char *config_file)
{
- /* FIXME: Missing some error handling! */
-
cfg_t *cfg, *cfg_realm, *cfg_server;
int i, j;
const char *s;
@@ -74,6 +72,8 @@ rs_context_read_config(struct rs_context *ctx, const char *config_file)
};
cfg = cfg_init (opts, CFGF_NONE);
+ if (cfg == NULL)
+ return rs_err_ctx_push (ctx, RSE_CONFIG, "unable to initialize libconfuse");
if (cfg_parse (cfg, config_file) == CFG_PARSE_ERROR)
return rs_err_ctx_push (ctx, RSE_CONFIG, "%s: invalid configuration file",
config_file);
@@ -139,6 +139,8 @@ rs_context_read_config(struct rs_context *ctx, const char *config_file)
p->realm = r;
cfg_server = cfg_getnsec (cfg_realm, "server", j);
+ /* FIXME: Handle resolve errors, possibly by postponing name
+ resolution. */
rs_resolv (&p->addr, r->type, cfg_getstr (cfg_server, "hostname"),
cfg_getstr (cfg_server, "service"));
p->secret = cfg_getstr (cfg_server, "secret");
diff --git a/lib/radsec.c b/lib/radsec.c
index 6104e46..d4c0a09 100644
--- a/lib/radsec.c
+++ b/lib/radsec.c
@@ -64,7 +64,7 @@ rs_context_init_freeradius_dict (struct rs_context *ctx, const char *dict)
char *fn = NULL;
if (dict == NULL)
- if (ctx->config != NULL)
+ if (ctx->config != NULL && ctx->config->dictionary)
dict = ctx->config->dictionary;
if (dict == NULL)
@@ -83,7 +83,8 @@ rs_context_init_freeradius_dict (struct rs_context *ctx, const char *dict)
if (dict_init (dirname (dir), basename (fn)) < 0)
{
- r = rs_err_ctx_push_fl (ctx, RSE_FR, __FILE__, __LINE__, "dict_init");
+ r = rs_err_ctx_push_fl (ctx, RSE_FR, __FILE__, __LINE__,
+ "failing dict_init(\"%s\")", dict);
goto out;
}