Interim commit to add a VERBOSE variable to fwknopd.
authorFranck Joncourt <franck@debian.org>
Thu, 20 Jun 2013 21:33:04 +0000 (23:33 +0200)
committerMichael Rash <mbr@cipherdyne.org>
Fri, 28 Jun 2013 01:39:38 +0000 (21:39 -0400)
client/config_init.c
server/cmd_opts.h
server/config_init.c
server/fwknopd_common.h

index 616e506..d6ebada 100644 (file)
@@ -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)
index 4b27f79..b5c6710 100644 (file)
@@ -107,6 +107,7 @@ static char *config_map[NUMBER_OF_CONFIG_ENTRIES] = {
 #endif
     "GPG_HOME_DIR",
     "FIREWALL_EXE",
+    "VERBOSITY"
 };
 
 
index 08d3125..eb5f41d 100644 (file)
@@ -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);
index 45c7a90..b2277dc 100644 (file)
@@ -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 */
 };