]> source.dussan.org Git - rspamd.git/commitdiff
Allow dump of invalid xml to ucl format.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 21 Nov 2013 16:20:06 +0000 (16:20 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 21 Nov 2013 16:20:06 +0000 (16:20 +0000)
src/cfg_utils.c
src/main.c

index 80faadbf3a1e0fcd4754e57c3978facc4aefb758..1faaf08a7606d10988e95d211acb77009adc53ef 100644 (file)
@@ -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;
 }
 
index b96d373093aa433640b3a93406879e92b8238095..66eb5b6c79dab812b48138d5fc09444a1f18f0bf 100644 (file)
@@ -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");