commit 73cf5c9: [Minor] Allow to set include trace on config load

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Mar 8 11:49:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-03-08 11:46:33 +0000
URL: https://github.com/rspamd/rspamd/commit/73cf5c9693e93d5a48e0b1b3321539243bc10f10 (HEAD -> master)

[Minor] Allow to set include trace on config load

---
 src/libserver/cfg_rcl.c | 14 +++++++++++---
 src/libserver/cfg_rcl.h |  2 ++
 src/lua/lua_config.c    |  4 ++--
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 7520b66d8..59b1fc932 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -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);
 
diff --git a/src/libserver/cfg_rcl.h b/src/libserver/cfg_rcl.h
index 830a1bfe3..e2477481e 100644
--- a/src/libserver/cfg_rcl.h
+++ b/src/libserver/cfg_rcl.h
@@ -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,
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 2ea72f075..a9b71baef 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -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);


More information about the Commits mailing list