]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow to set include trace on config load
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Mar 2019 11:46:33 +0000 (11:46 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Mar 2019 11:46:33 +0000 (11:46 +0000)
src/libserver/cfg_rcl.c
src/libserver/cfg_rcl.h
src/lua/lua_config.c

index 7520b66d86b15fa35035ddfd93bb7119a2b81635..59b1fc932e0595104c8f1de3b2aac46e762b4d0c 100644 (file)
@@ -3541,8 +3541,12 @@ rspamd_config_calculate_cksum (struct rspamd_config *cfg)
 }
 
 gboolean
-rspamd_config_parse_ucl (struct rspamd_config *cfg, const gchar *filename,
-                                       GHashTable *vars, GError **err)
+rspamd_config_parse_ucl (struct rspamd_config *cfg,
+                                                const gchar *filename,
+                                                GHashTable *vars,
+                                                ucl_include_trace_func_t inc_trace,
+                                                void *trace_data,
+                                                GError **err)
 {
        struct stat st;
        gint fd;
@@ -3615,6 +3619,10 @@ rspamd_config_parse_ucl (struct rspamd_config *cfg, const gchar *filename,
        rspamd_ucl_add_conf_macros (parser, cfg);
        ucl_parser_set_filevars (parser, filename, true);
 
+       if (inc_trace) {
+               ucl_parser_set_include_tracer (parser, inc_trace, trace_data);
+       }
+
        if (decrypt_keypair) {
                struct ucl_parser_special_handler *decrypt_handler;
 
@@ -3655,7 +3663,7 @@ rspamd_config_read (struct rspamd_config *cfg, const gchar *filename,
        struct rspamd_rcl_section *top, *logger_section;
        const ucl_object_t *logger_obj;
 
-       if (!rspamd_config_parse_ucl (cfg, filename, vars, &err)) {
+       if (!rspamd_config_parse_ucl (cfg, filename, vars, NULL, NULL, &err)) {
                msg_err_config_forced ("failed to load config: %e", err);
                g_error_free (err);
 
index 830a1bfe3a126512c32dcb8cb8b150497c748cf5..e2477481eaf014ad0a47ed01bb909fa050ac1aeb 100644 (file)
@@ -479,6 +479,8 @@ void rspamd_config_calculate_cksum (struct rspamd_config *cfg);
 gboolean rspamd_config_parse_ucl (struct rspamd_config *cfg,
                                                                  const gchar *filename,
                                                                  GHashTable *vars,
+                                                                 ucl_include_trace_func_t inc_trace,
+                                                                 void *trace_data,
                                                                  GError **err);
 gboolean rspamd_config_read (struct rspamd_config *cfg,
                                                         const gchar *filename,
index 2ea72f075843b6d1bcd0f23f1eeae76a8363d8d3..a9b71baefe2b501532f6a8048c390ed1c47a92ab 100644 (file)
@@ -721,7 +721,7 @@ LUA_FUNCTION_DEF (config, has_torch);
 LUA_FUNCTION_DEF (config, experimental_enabled);
 
 /***
- * @method rspamd_config:load_ucl(filename)
+ * @method rspamd_config:load_ucl(filename[, include_trace])
  * Loads config from the UCL file (but does not perform parsing using rcl)
  * @param {string} filename file to load
  * @return true or false + error message
@@ -3705,7 +3705,7 @@ lua_config_load_ucl (lua_State *L)
 
                lua_pop (L, 1);
 
-               if (!rspamd_config_parse_ucl (cfg, filename, paths, &err)) {
+               if (!rspamd_config_parse_ucl (cfg, filename, paths, NULL, NULL, &err)) {
                        lua_pushboolean (L, false);
                        lua_pushfstring (L, "failed to load config: %s", err->message);
                        g_error_free (err);