From 9a05006d1e76c8079d356f8d0b1ceb34a8fc76b6 Mon Sep 17 00:00:00 2001 From: kakwa Date: Thu, 1 Sep 2016 08:25:28 +0200 Subject: [PATCH] fix default log_level, and fix chdir * the chdir was done after the loading of the conf file, reversing it * in case log_level is not set, the application would segfault, now handled properly (default is info) * remove logging to the daemon facility --- src/lib/utils.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/lib/utils.c b/src/lib/utils.c index 7f57118..840fa58 100644 --- a/src/lib/utils.c +++ b/src/lib/utils.c @@ -90,7 +90,7 @@ void skeleton_daemon() { } /* Open the log file */ - openlog("uts-server", LOG_PID, LOG_DAEMON); + //openlog("uts-server", LOG_PID, LOG_DAEMON); } void log_hex(rfc3161_context *ct, int priority, char *id, @@ -218,18 +218,26 @@ static CONF *load_config_file(rfc3161_context *ct, const char *filename) { } int set_params(rfc3161_context *ct, char *conf_file, char *conf_wd) { - int ret = 0; - CONF *conf = load_config_file(ct, conf_file); - ret = 1; + chdir(conf_wd); + int ret = 1; int http_counter = 0; - chdir(conf_wd); + CONF *conf = load_config_file(ct, conf_file); + if(conf == NULL) + goto end; + // first pass to set the loglevel as soon as possible for (int i = 0; i < RFC3161_OPTIONS_LEN; i++) { int type = rfc3161_options[i].type; const char *name = rfc3161_options[i].name; const char *default_value = rfc3161_options[i].default_value; const char *value = NCONF_get_string(conf, MAIN_CONF_SECTION, name); + if (value == NULL) { + uts_logger(ct, LOG_NOTICE, + "configuration param['%s'] not set, using default: '%s'", + name, default_value); + value = default_value; + } switch (type) { case LOGLEVEL_OPTIONS: for (int j = 0;; j++) {