summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-12-16 21:51:04 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-12-16 21:51:04 +0100
commitf7cdd48892dafe00b8956cd2b087814d0257bdb4 (patch)
treeb7e0d7174f5772f3d5acad78a6e0e5f080ff4171
parent794958aa7834c6703e369d15b99fe0b38a8edb05 (diff)
downloadfastd-f7cdd48892dafe00b8956cd2b087814d0257bdb4.tar
fastd-f7cdd48892dafe00b8956cd2b087814d0257bdb4.zip
config: don't check configuration before logging has been set up
-rw-r--r--src/config.c7
-rw-r--r--src/config.h1
-rw-r--r--src/fastd.c3
3 files changed, 6 insertions, 5 deletions
diff --git a/src/config.c b/src/config.c
index 6b91383..9e04299 100644
--- a/src/config.c
+++ b/src/config.c
@@ -529,12 +529,9 @@ void fastd_configure(fastd_context_t *ctx, fastd_config_t *conf, int argc, char
if (!conf->log_stderr_level && !conf->log_syslog_level && !conf->log_files)
conf->log_stderr_level = FASTD_DEFAULT_LOG_LEVEL;
+}
- ctx->conf = conf;
-
- if (conf->generate_key || conf->show_key)
- return;
-
+void fastd_config_check(fastd_context_t *ctx, fastd_config_t *conf) {
if (conf->ifname) {
if (strchr(conf->ifname, '/'))
exit_error(ctx, "config error: invalid interface name");
diff --git a/src/config.h b/src/config.h
index d12e5ef..9484598 100644
--- a/src/config.h
+++ b/src/config.h
@@ -40,6 +40,7 @@ void fastd_config_peer_group_push(fastd_context_t *ctx, fastd_config_t *conf, co
void fastd_config_peer_group_pop(fastd_context_t *ctx, fastd_config_t *conf);
void fastd_config_release(fastd_context_t *ctx, fastd_config_t *conf);
void fastd_configure(fastd_context_t *ctx, fastd_config_t *conf, int argc, char *const argv[]);
+void fastd_config_check(fastd_context_t *ctx, fastd_config_t *conf);
void fastd_config_load_peer_dirs(fastd_context_t *ctx, fastd_config_t *conf);
void fastd_config_handle_options(fastd_context_t *ctx, fastd_config_t *conf, int argc, char *const argv[]);
diff --git a/src/fastd.c b/src/fastd.c
index d6bfa2f..e456f14 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -879,6 +879,7 @@ int main(int argc, char *argv[]) {
fastd_config_t conf;
fastd_configure(&ctx, &conf, argc, argv);
+ ctx.conf = &conf;
if (conf.generate_key) {
conf.protocol->generate_key(&ctx);
@@ -899,6 +900,8 @@ int main(int argc, char *argv[]) {
init_log(&ctx);
+ fastd_config_check(&ctx, &conf);
+
update_time(&ctx);
conf.long_ago = ctx.now;