diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-11-21 16:20:06 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-11-21 16:20:06 +0000 |
commit | 3a790729df214dfb00d0d92f813819b23edb23fb (patch) | |
tree | b96594335c3c96f9652b3db6e6b3ee04c00b46df | |
parent | 663b3baddce648e320657b0443aaf2629e9be98d (diff) | |
download | rspamd-3a790729df214dfb00d0d92f813819b23edb23fb.tar.gz rspamd-3a790729df214dfb00d0d92f813819b23edb23fb.zip |
Allow dump of invalid xml to ucl format.
-rw-r--r-- | src/cfg_utils.c | 29 | ||||
-rw-r--r-- | src/main.c | 2 |
2 files changed, 20 insertions, 11 deletions
diff --git a/src/cfg_utils.c b/src/cfg_utils.c index 80faadbf3..1faaf08a7 100644 --- a/src/cfg_utils.c +++ b/src/cfg_utils.c @@ -774,10 +774,15 @@ read_rspamd_config (struct config_file *cfg, const gchar *filename, const gchar } close (fd); - ext = get_filename_extension (filename); - if (ext != NULL && strcmp (ext, "xml") == 0) { + if (convert_to != NULL) { is_xml = TRUE; } + else { + ext = get_filename_extension (filename); + if (ext != NULL && strcmp (ext, "xml") == 0) { + is_xml = TRUE; + } + } if (is_xml) { /* Prepare xml parser */ @@ -805,14 +810,6 @@ read_rspamd_config (struct config_file *cfg, const gchar *filename, const gchar return FALSE; } - top = rspamd_rcl_config_init (); - err = NULL; - - if (!rspamd_read_rcl_config (top, cfg, cfg->rcl_obj, &err)) { - msg_err ("rcl parse error: %s", err->message); - return FALSE; - } - if (is_xml && convert_to != NULL) { /* Convert XML config to UCL */ rcl = ucl_object_emit (cfg->rcl_obj, UCL_EMIT_CONFIG); @@ -824,11 +821,23 @@ read_rspamd_config (struct config_file *cfg, const gchar *filename, const gchar else if (write (fd, rcl, strlen (rcl)) == -1) { msg_err ("cannot write rcl %s: %s", convert_to, strerror (errno)); } + else { + msg_info ("dumped xml configuration %s to ucl configuration %s", + filename, convert_to); + } close (fd); free (rcl); } } + top = rspamd_rcl_config_init (); + err = NULL; + + if (!rspamd_read_rcl_config (top, cfg, cfg->rcl_obj, &err)) { + msg_err ("rcl parse error: %s", err->message); + return FALSE; + } + return TRUE; } diff --git a/src/main.c b/src/main.c index b96d37309..66eb5b6c7 100644 --- a/src/main.c +++ b/src/main.c @@ -1038,7 +1038,7 @@ main (gint argc, gchar **argv, gchar **env) rspamd_main->cfg->log_level = G_LOG_LEVEL_DEBUG; } else { - rspamd_main->cfg->log_level = G_LOG_LEVEL_CRITICAL; + rspamd_main->cfg->log_level = G_LOG_LEVEL_INFO; } type = g_quark_from_static_string ("main"); |