From afd6f6b23c1f1b8906ae4eebe87f110a602c9d76 Mon Sep 17 00:00:00 2001 From: Franck Joncourt Date: Thu, 20 Jun 2013 23:33:04 +0200 Subject: [PATCH] Interim commit to add a VERBOSE variable to fwknopd. --- client/config_init.c | 3 +++ server/cmd_opts.h | 1 + server/config_init.c | 21 ++++++++++++++++++--- server/fwknopd_common.h | 1 + 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/client/config_init.c b/client/config_init.c index 08219f60..d477c04d 100644 --- a/client/config_init.c +++ b/client/config_init.c @@ -1136,6 +1136,9 @@ parse_rc_param(fko_cli_options_t *options, const char *var_name, char * val) else parse_error = -1; } + + if (parse_error == 0) + log_set_verbosity(LOG_DEFAULT_VERBOSITY + options->verbose); } /* RESOLVE_IP_HTTP ? */ else if (var->pos == FWKNOP_CLI_ARG_RESOLVE_IP_HTTP) diff --git a/server/cmd_opts.h b/server/cmd_opts.h index 4b27f795..b5c67100 100644 --- a/server/cmd_opts.h +++ b/server/cmd_opts.h @@ -107,6 +107,7 @@ static char *config_map[NUMBER_OF_CONFIG_ENTRIES] = { #endif "GPG_HOME_DIR", "FIREWALL_EXE", + "VERBOSITY" }; diff --git a/server/config_init.c b/server/config_init.c index 39eb7421..a872f772 100644 --- a/server/config_init.c +++ b/server/config_init.c @@ -706,6 +706,10 @@ config_init(fko_srv_options_t *opts, int argc, char **argv) */ if(got_conf_file > 0) break; + /* Verbosity level */ + case 'v': + opts->verbose++; + break; } } @@ -755,6 +759,20 @@ config_init(fko_srv_options_t *opts, int argc, char **argv) } } + /* Set up the verbosity level according to the value found in the + * config files */ + if (opts->config[CONF_VERBOSITY] != NULL) + { + opts->verbose = strtol_wrapper(opts->config[CONF_VERBOSITY], 0, -1, + NO_EXIT_UPON_ERR, &is_err); + if(is_err != FKO_SUCCESS) + { + log_msg(LOG_ERR, "[*] VERBOSITY value '%s' not in the range (>0)", + opts->config[CONF_VERBOSITY]); + clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE); + } + } + /* Reset the options index so we can run through them again. */ optind = 0; @@ -852,9 +870,6 @@ config_init(fko_srv_options_t *opts, int argc, char **argv) case 'S': opts->status = 1; break; - case 'v': - opts->verbose++; - break; case 'V': fprintf(stdout, "fwknopd server %s\n", MY_VERSION); clean_exit(opts, NO_FW_CLEANUP, EXIT_SUCCESS); diff --git a/server/fwknopd_common.h b/server/fwknopd_common.h index 45c7a902..b2277dc1 100644 --- a/server/fwknopd_common.h +++ b/server/fwknopd_common.h @@ -251,6 +251,7 @@ enum { #endif CONF_GPG_HOME_DIR, CONF_FIREWALL_EXE, + CONF_VERBOSITY, NUMBER_OF_CONFIG_ENTRIES /* Marks the end and number of entries */ };