Skip to content

Commit

Permalink
[Minor] Allow to set include trace on config load
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Mar 8, 2019
1 parent f7f1a79 commit 73cf5c9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/libserver/cfg_rcl.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions src/libserver/cfg_rcl.h
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/lua/lua_config.c
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 73cf5c9

Please sign in to comment.