]> source.dussan.org Git - rspamd.git/commitdiff
Add strict mode for configtest.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 25 Sep 2015 12:26:13 +0000 (13:26 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 25 Sep 2015 12:26:13 +0000 (13:26 +0100)
src/libutil/logger.c
src/rspamadm/configtest.c
src/rspamadm/rspamadm.c

index 82fbf64ab263233080d0a7a9f9631387ae12e71c..3367829a6ef57bc4086a1b7f6e1d19fded0fcceb 100644 (file)
@@ -965,3 +965,13 @@ rspamd_log_nodebug (rspamd_logger_t *rspamd_log)
 {
        rspamd_log->is_debug = FALSE;
 }
+
+const guint64 *
+rspamd_log_counters (rspamd_logger_t *logger)
+{
+       if (logger) {
+               return logger->log_cnt;
+       }
+
+       return NULL;
+}
index 1e70f1cc01d750997857a5e19824781f1d6e0444..1de6949759a3d970568b227620082be94efa136c 100644 (file)
@@ -30,6 +30,7 @@
 
 static gboolean quiet = FALSE;
 static gchar *config = NULL;
+static gboolean strict = FALSE;
 extern struct rspamd_main *rspamd_main;
 /* Defined in modules.c */
 extern module_t *modules[];
@@ -50,6 +51,8 @@ static GOptionEntry entries[] = {
                                "Supress output", NULL},
                {"config", 'c', 0, G_OPTION_ARG_STRING, &config,
                                "Config file to test",     NULL},
+               {"strict", 's', 0, G_OPTION_ARG_NONE, &strict,
+                               "Stop on any error in config", NULL},
                {NULL,  0,   0, G_OPTION_ARG_NONE, NULL, NULL, NULL}
 };
 
@@ -104,6 +107,7 @@ rspamadm_configtest (gint argc, gchar **argv)
        struct rspamd_config *cfg = rspamd_main->cfg;
        gboolean ret = FALSE;
        worker_t **pworker;
+       const guint64 *log_cnt;
 
        context = g_option_context_new (
                        "keypair - create encryption keys");
@@ -167,6 +171,17 @@ rspamadm_configtest (gint argc, gchar **argv)
                }
        }
 
+       if (strict && ret) {
+               log_cnt = rspamd_log_counters (rspamd_main->logger);
+
+               if (log_cnt && log_cnt[0] > 0) {
+                       if (!quiet) {
+                               rspamd_printf ("%L errors found\n", log_cnt[0]);
+                       }
+                       ret = FALSE;
+               }
+       }
+
        if (!quiet) {
                rspamd_printf ("syntax %s\n", ret ? "OK" : "BAD");
        }
index 3698366ae9a47c18dc618cefa5c17b32db0f04f2..be35a8be2c98eaa25e6a98b1f601a7aec8c3198c 100644 (file)
@@ -53,7 +53,7 @@ static GOptionEntry entries[] = {
                        "Enable verbose logging", NULL},
        {"list-commands", 'l', 0, G_OPTION_ARG_NONE, &list_commands,
                        "List available commands", NULL},
-       {"var", 0, 0, G_OPTION_ARG_CALLBACK, rspamadm_parse_ucl_var,
+       {"var", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer)rspamadm_parse_ucl_var,
                        "Redefine UCL variable", NULL},
        {"help", 'h', 0, G_OPTION_ARG_NONE, &show_help,
                        "Show help", NULL},