aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/client/rspamc.c2
-rw-r--r--src/controller.c57
-rw-r--r--src/libmime/filter.c36
-rw-r--r--src/libmime/filter.h5
-rw-r--r--src/libserver/cfg_file.h54
-rw-r--r--src/libserver/cfg_rcl.c198
-rw-r--r--src/libserver/cfg_rcl.h10
-rw-r--r--src/libserver/cfg_utils.c147
-rw-r--r--src/libserver/composites.c5
-rw-r--r--src/libserver/dynamic_cfg.c12
-rw-r--r--src/libserver/protocol.c16
-rw-r--r--src/libserver/re_cache.c2
-rw-r--r--src/libserver/symbols_cache.c79
-rw-r--r--src/libutil/mem_pool.c2
-rw-r--r--src/libutil/util.c6
-rw-r--r--src/lua/lua_cfg_file.c37
-rw-r--r--src/lua/lua_config.c116
-rw-r--r--src/lua/lua_fann.c2
-rw-r--r--src/lua/lua_task.c7
-rw-r--r--src/plugins/dkim_check.c4
-rw-r--r--src/plugins/regexp.c2
21 files changed, 225 insertions, 574 deletions
diff --git a/src/client/rspamc.c b/src/client/rspamc.c
index bf13acc68..b27d0e09e 100644
--- a/src/client/rspamc.c
+++ b/src/client/rspamc.c
@@ -158,7 +158,7 @@ static GOptionEntry entries[] =
};
/* Copy to avoid linking with librspamdserver */
-enum rspamd_metric_action {
+enum rspamd_action_type {
METRIC_ACTION_REJECT = 0,
METRIC_ACTION_SOFT_REJECT,
METRIC_ACTION_REWRITE_SUBJECT,
diff --git a/src/controller.c b/src/controller.c
index f2b25f2f5..8e22850e6 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -774,7 +774,6 @@ rspamd_controller_handle_symbols (struct rspamd_http_connection_entry *conn_ent,
GHashTableIter it, sit;
struct rspamd_symbols_group *gr;
struct rspamd_symbol *sym;
- struct rspamd_metric *metric;
ucl_object_t *obj, *top, *sym_obj, *group_symbols;
gpointer k, v;
@@ -785,9 +784,7 @@ rspamd_controller_handle_symbols (struct rspamd_http_connection_entry *conn_ent,
top = ucl_object_typed_new (UCL_ARRAY);
/* Go through all symbols groups in the default metric */
- metric = g_hash_table_lookup (session->ctx->cfg->metrics, DEFAULT_METRIC);
- g_assert (metric != NULL);
- g_hash_table_iter_init (&it, metric->groups);
+ g_hash_table_iter_init (&it, session->cfg->groups);
while (g_hash_table_iter_next (&it, &k, &v)) {
gr = v;
@@ -856,8 +853,7 @@ rspamd_controller_handle_actions (struct rspamd_http_connection_entry *conn_ent,
struct rspamd_http_message *msg)
{
struct rspamd_controller_session *session = conn_ent->ud;
- struct rspamd_metric *metric;
- struct metric_action *act;
+ struct rspamd_action *act;
gint i;
ucl_object_t *obj, *top;
@@ -868,19 +864,16 @@ rspamd_controller_handle_actions (struct rspamd_http_connection_entry *conn_ent,
top = ucl_object_typed_new (UCL_ARRAY);
/* Get actions for default metric */
- metric = g_hash_table_lookup (session->ctx->cfg->metrics, DEFAULT_METRIC);
- if (metric != NULL) {
- for (i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i++) {
- act = &metric->actions[i];
- if (act->score >= 0) {
- obj = ucl_object_typed_new (UCL_OBJECT);
- ucl_object_insert_key (obj,
+ for (i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i++) {
+ act = &session->cfg->actions[i];
+ if (act->score >= 0) {
+ obj = ucl_object_typed_new (UCL_OBJECT);
+ ucl_object_insert_key (obj,
ucl_object_fromstring (rspamd_action_to_str (
- act->action)), "action", 0, false);
- ucl_object_insert_key (obj, ucl_object_fromdouble (
- act->score), "value", 0, false);
- ucl_array_append (top, obj);
- }
+ act->action)), "action", 0, false);
+ ucl_object_insert_key (obj, ucl_object_fromdouble (
+ act->score), "value", 0, false);
+ ucl_array_append (top, obj);
}
}
@@ -1076,7 +1069,7 @@ rspamd_controller_handle_get_map (struct rspamd_http_connection_entry *conn_ent,
}
static ucl_object_t *
-rspamd_controller_pie_element (enum rspamd_metric_action action,
+rspamd_controller_pie_element (enum rspamd_action_type action,
const char *label, gdouble data)
{
ucl_object_t *res = ucl_object_typed_new (UCL_OBJECT);
@@ -2120,14 +2113,13 @@ rspamd_controller_handle_saveactions (
{
struct rspamd_controller_session *session = conn_ent->ud;
struct ucl_parser *parser;
- struct rspamd_metric *metric;
ucl_object_t *obj;
const ucl_object_t *cur;
struct rspamd_controller_worker_ctx *ctx;
const gchar *error;
gdouble score;
gint i, added = 0;
- enum rspamd_metric_action act;
+ enum rspamd_action_type act;
ucl_object_iter_t it = NULL;
ctx = session->ctx;
@@ -2144,14 +2136,6 @@ rspamd_controller_handle_saveactions (
return 0;
}
- metric = g_hash_table_lookup (ctx->cfg->metrics, DEFAULT_METRIC);
- if (metric == NULL) {
- msg_err_session ("cannot find default metric");
- rspamd_controller_send_error (conn_ent, 500,
- "Default metric is absent");
- return 0;
- }
-
parser = ucl_parser_new (0);
if (!ucl_parser_add_chunk (parser, msg->body_buf.begin, msg->body_buf.len)) {
if ((error = ucl_parser_get_error (parser)) != NULL) {
@@ -2167,8 +2151,6 @@ rspamd_controller_handle_saveactions (
return 0;
}
-
-
obj = ucl_parser_get_object (parser);
ucl_parser_free (parser);
@@ -2198,7 +2180,7 @@ rspamd_controller_handle_saveactions (
break;
}
score = ucl_object_todouble (cur);
- if (metric->actions[act].score != score) {
+ if (session->cfg->actions[act].score != score) {
add_dynamic_action (ctx->cfg, DEFAULT_METRIC, act, score);
added ++;
}
@@ -2241,7 +2223,6 @@ rspamd_controller_handle_savesymbols (
{
struct rspamd_controller_session *session = conn_ent->ud;
struct ucl_parser *parser;
- struct rspamd_metric *metric;
ucl_object_t *obj;
const ucl_object_t *cur, *jname, *jvalue;
ucl_object_iter_t iter = NULL;
@@ -2265,14 +2246,6 @@ rspamd_controller_handle_savesymbols (
return 0;
}
- metric = g_hash_table_lookup (ctx->cfg->metrics, DEFAULT_METRIC);
- if (metric == NULL) {
- msg_err_session ("cannot find default metric");
- rspamd_controller_send_error (conn_ent, 500,
- "Default metric is absent");
- return 0;
- }
-
parser = ucl_parser_new (0);
if (!ucl_parser_add_chunk (parser, msg->body_buf.begin, msg->body_buf.len)) {
if ((error = ucl_parser_get_error (parser)) != NULL) {
@@ -2313,7 +2286,7 @@ rspamd_controller_handle_savesymbols (
jname = ucl_object_lookup (cur, "name");
jvalue = ucl_object_lookup (cur, "value");
val = ucl_object_todouble (jvalue);
- sym = g_hash_table_lookup (metric->symbols, ucl_object_tostring (jname));
+ sym = g_hash_table_lookup (session->cfg->symbols, ucl_object_tostring (jname));
if (sym && fabs (*sym->weight_ptr - val) > 0.01) {
if (!add_dynamic_symbol (ctx->cfg, DEFAULT_METRIC,
diff --git a/src/libmime/filter.c b/src/libmime/filter.c
index 13b48cfda..ecbfd24db 100644
--- a/src/libmime/filter.c
+++ b/src/libmime/filter.c
@@ -29,7 +29,6 @@ struct rspamd_metric_result *
rspamd_create_metric_result (struct rspamd_task *task)
{
struct rspamd_metric_result *metric_res;
- struct rspamd_metric *metric;
guint i;
metric_res = task->result;
@@ -38,14 +37,7 @@ rspamd_create_metric_result (struct rspamd_task *task)
return metric_res;
}
- metric = task->cfg->default_metric;
-
- if (metric == NULL) {
- return NULL;
- }
-
- metric_res =
- rspamd_mempool_alloc (task->task_pool,
+ metric_res = rspamd_mempool_alloc (task->task_pool,
sizeof (struct rspamd_metric_result));
metric_res->symbols = g_hash_table_new (rspamd_str_hash,
rspamd_str_equal);
@@ -56,13 +48,12 @@ rspamd_create_metric_result (struct rspamd_task *task)
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t) g_hash_table_unref,
metric_res->sym_groups);
- metric_res->metric = metric;
metric_res->grow_factor = 0;
metric_res->score = 0;
metric_res->changes = 0;
for (i = 0; i < METRIC_ACTION_MAX; i++) {
- metric_res->actions_limits[i] = metric->actions[i].score;
+ metric_res->actions_limits[i] = task->cfg->actions[i].score;
}
metric_res->action = METRIC_ACTION_MAX;
@@ -94,7 +85,6 @@ rspamd_check_group_score (struct rspamd_task *task,
static struct rspamd_symbol_result *
insert_metric_result (struct rspamd_task *task,
- struct rspamd_metric *metric,
const gchar *symbol,
double flag,
const gchar *opt,
@@ -116,7 +106,7 @@ insert_metric_result (struct rspamd_task *task,
flag = 0.0;
}
- sdef = g_hash_table_lookup (metric->symbols, symbol);
+ sdef = g_hash_table_lookup (task->cfg->symbols, symbol);
if (sdef == NULL) {
w = 0.0;
}
@@ -192,10 +182,10 @@ insert_metric_result (struct rspamd_task *task,
/* Handle grow factor */
if (metric_res->grow_factor && diff > 0) {
diff *= metric_res->grow_factor;
- next_gf *= metric->grow_factor;
+ next_gf *= task->cfg->grow_factor;
}
else if (diff > 0) {
- next_gf = metric->grow_factor;
+ next_gf = task->cfg->grow_factor;
}
diff = rspamd_check_group_score (task, symbol, gr, gr_score, diff);
@@ -223,10 +213,10 @@ insert_metric_result (struct rspamd_task *task,
/* Handle grow factor */
if (metric_res->grow_factor && w > 0) {
w *= metric_res->grow_factor;
- next_gf *= metric->grow_factor;
+ next_gf *= task->cfg->grow_factor;
}
else if (w > 0) {
- next_gf = metric->grow_factor;
+ next_gf = task->cfg->grow_factor;
}
s->name = symbol;
@@ -253,10 +243,9 @@ insert_metric_result (struct rspamd_task *task,
g_hash_table_insert (metric_res->symbols, (gpointer) symbol, s);
}
- msg_debug_task ("symbol %s, score %.2f, metric %s, factor: %f",
+ msg_debug_task ("symbol %s, score %.2f, factor: %f",
symbol,
s->score,
- metric->name,
w);
metric_res->changes ++;
@@ -281,7 +270,6 @@ insert_result_common (struct rspamd_task *task,
/* Insert symbol to default metric */
s = insert_metric_result (task,
- task->cfg->default_metric,
symbol,
flag,
opt,
@@ -359,16 +347,16 @@ rspamd_task_add_result_option (struct rspamd_task *task,
return ret;
}
-enum rspamd_metric_action
+enum rspamd_action_type
rspamd_check_action_metric (struct rspamd_task *task, struct rspamd_metric_result *mres)
{
- struct metric_action *action, *selected_action = NULL;
+ struct rspamd_action *action, *selected_action = NULL;
double max_score = 0, sc;
int i;
if (task->pre_result.action == METRIC_ACTION_MAX) {
for (i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i++) {
- action = &mres->metric->actions[i];
+ action = &task->cfg->actions[i];
sc = mres->actions_limits[i];
if (isnan (sc)) {
@@ -385,7 +373,7 @@ rspamd_check_action_metric (struct rspamd_task *task, struct rspamd_metric_resul
sc = NAN;
for (i = task->pre_result.action; i < METRIC_ACTION_MAX; i ++) {
- selected_action = &mres->metric->actions[i];
+ selected_action = &task->cfg->actions[i];
sc = mres->actions_limits[i];
if (isnan (sc)) {
diff --git a/src/libmime/filter.h b/src/libmime/filter.h
index 139034723..53d47a769 100644
--- a/src/libmime/filter.h
+++ b/src/libmime/filter.h
@@ -35,14 +35,13 @@ struct rspamd_symbol_result {
* Result of metric processing
*/
struct rspamd_metric_result {
- struct rspamd_metric *metric; /**< pointer to metric structure */
double score; /**< total score */
double grow_factor; /**< current grow factor */
GHashTable *symbols; /**< symbols of metric */
GHashTable *sym_groups; /**< groups of symbols */
gdouble actions_limits[METRIC_ACTION_MAX]; /**< set of actions for this metric */
guint changes;
- enum rspamd_metric_action action; /**< the current action */
+ enum rspamd_action_type action; /**< the current action */
};
/**
@@ -103,7 +102,7 @@ double rspamd_factor_consolidation_func (struct rspamd_task *task,
/*
* Get action for specific metric
*/
-enum rspamd_metric_action rspamd_check_action_metric (struct rspamd_task *task,
+enum rspamd_action_type rspamd_check_action_metric (struct rspamd_task *task,
struct rspamd_metric_result *mres);
#endif
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index d91a4f06e..412cd4bb0 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -243,7 +243,7 @@ struct rspamd_log_format {
struct rspamd_log_format *prev, *next;
};
-enum rspamd_metric_action {
+enum rspamd_action_type {
METRIC_ACTION_REJECT = 0,
METRIC_ACTION_SOFT_REJECT,
METRIC_ACTION_REWRITE_SUBJECT,
@@ -253,27 +253,12 @@ enum rspamd_metric_action {
METRIC_ACTION_MAX
};
-struct metric_action {
- enum rspamd_metric_action action;
+struct rspamd_action {
+ enum rspamd_action_type action;
gdouble score;
guint priority;
};
-/**
- * Common definition of metric
- */
-struct rspamd_metric {
- const gchar *name; /**< name of metric */
- gchar *func_name; /**< name of consolidation function */
- gboolean accept_unknown_symbols; /**< if true unknown symbols are registered here */
- gdouble unknown_weight; /**< weight of unknown symbols */
- gdouble grow_factor; /**< grow factor for metric */
- GHashTable *symbols; /**< weights of symbols in metric */
- const gchar *subject; /**< subject rewrite string */
- GHashTable * groups; /**< groups of symbols */
- struct metric_action actions[METRIC_ACTION_MAX]; /**< all actions of the metric */
-};
-
struct rspamd_config_post_load_script {
gint cbref;
struct rspamd_config_post_load_script *prev, *next;
@@ -295,6 +280,14 @@ struct rspamd_config {
gchar *profile_path;
#endif
+ gboolean accept_unknown_symbols; /**< if true unknown symbols are registered here */
+ gdouble unknown_weight; /**< weight of unknown symbols */
+ gdouble grow_factor; /**< grow factor for metric */
+ GHashTable *symbols; /**< weights of symbols in metric */
+ const gchar *subject; /**< subject rewrite string */
+ GHashTable * groups; /**< groups of symbols */
+ struct rspamd_action actions[METRIC_ACTION_MAX]; /**< all actions of the metric */
+
gboolean raw_mode; /**< work in raw mode instead of utf one */
gboolean one_shot_mode; /**< rules add only one symbol */
gboolean check_text_attachements; /**< check text attachements as text */
@@ -359,9 +352,6 @@ struct rspamd_config {
ucl_object_t *rcl_obj; /**< rcl object */
ucl_object_t *config_comments; /**< comments saved from the config */
ucl_object_t *doc_strings; /**< documentation strings for config options */
- GHashTable * metrics; /**< hash of metrics indexed by metric name */
- GList * metrics_list; /**< linked list of metrics */
- GHashTable * metrics_symbols; /**< hash table of metrics indexed by symbol */
GHashTable * c_modules; /**< hash of c modules indexed by module name */
GHashTable * composite_symbols; /**< hash of composite symbols indexed by its name */
GList *classifiers; /**< list of all classifiers defined */
@@ -386,8 +376,6 @@ struct rspamd_config {
struct symbols_cache *cache; /**< symbols cache object */
gchar *cache_filename; /**< filename of cache file */
gdouble cache_reload_time; /**< how often cache reload should be performed */
- struct rspamd_metric *default_metric; /**< default metric */
-
gchar * checksum; /**< real checksum of config file */
gchar * dump_checksum; /**< dump checksum of config file */
gpointer lua_state; /**< pointer to lua state */
@@ -537,14 +525,13 @@ struct rspamd_worker_conf * rspamd_config_new_worker (struct rspamd_config *cfg,
/*
* Return a new metric structure, setting default and non-conflicting attributes
*/
-struct rspamd_metric * rspamd_config_new_metric (struct rspamd_config *cfg,
- struct rspamd_metric *c, const gchar *name);
+void rspamd_config_init_metric (struct rspamd_config *cfg);
/*
* Return new symbols group definition
*/
struct rspamd_symbols_group * rspamd_config_new_group (
- struct rspamd_config *cfg, struct rspamd_metric *metric,
+ struct rspamd_config *cfg,
const gchar *name);
/*
* Return a new statfile structure, setting default and non-conflicting attributes
@@ -554,14 +541,6 @@ struct rspamd_statfile_config * rspamd_config_new_statfile (
struct rspamd_statfile_config *c);
/*
- * Read XML configuration file
- */
-gboolean rspamd_config_read (struct rspamd_config *cfg,
- const gchar *filename, const gchar *convert_to,
- rspamd_rcl_section_fin_t logger_fin, gpointer logger_ud,
- GHashTable *vars);
-
-/*
* Register symbols of classifiers inside metrics
*/
void rspamd_config_insert_classify_symbols (struct rspamd_config *cfg);
@@ -605,7 +584,7 @@ gboolean rspamd_init_filters (struct rspamd_config *cfg, bool reconfig);
* @param nshots means maximum number of hits for a symbol in metric (-1 for unlimited)
* @return TRUE if symbol has been inserted or FALSE if symbol already exists with higher priority
*/
-gboolean rspamd_config_add_metric_symbol (struct rspamd_config *cfg,
+gboolean rspamd_config_add_symbol (struct rspamd_config *cfg,
const gchar *symbol, gdouble score, const gchar *description,
const gchar *group, guint flags,
guint priority,
@@ -621,7 +600,6 @@ gboolean rspamd_config_add_metric_symbol (struct rspamd_config *cfg,
* @return TRUE if symbol has been inserted or FALSE if action already exists with higher priority
*/
gboolean rspamd_config_set_action_score (struct rspamd_config *cfg,
- const gchar *metric,
const gchar *action_name,
gdouble score,
guint priority);
@@ -650,8 +628,8 @@ gboolean rspamd_action_from_str (const gchar *data, gint *result);
/*
* Return textual representation of action enumeration
*/
-const gchar * rspamd_action_to_str (enum rspamd_metric_action action);
-const gchar * rspamd_action_to_str_alt (enum rspamd_metric_action action);
+const gchar * rspamd_action_to_str (enum rspamd_action_type action);
+const gchar * rspamd_action_to_str_alt (enum rspamd_action_type action);
/**
* Parse radix tree or radix map from ucl object
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 0a60d45f1..3aa277e1a 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -290,7 +290,6 @@ rspamd_rcl_options_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
}
struct rspamd_rcl_symbol_data {
- struct rspamd_metric *metric;
struct rspamd_symbols_group *gr;
struct rspamd_config *cfg;
};
@@ -300,37 +299,36 @@ rspamd_rcl_group_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
const gchar *key, gpointer ud,
struct rspamd_rcl_section *section, GError **err)
{
- struct rspamd_rcl_symbol_data *sd = ud;
- struct rspamd_metric *metric;
+ struct rspamd_config *cfg = ud;
struct rspamd_symbols_group *gr;
const ucl_object_t *val, *cur;
struct rspamd_rcl_section *subsection;
+ struct rspamd_rcl_symbol_data sd;
g_assert (key != NULL);
- metric = sd->metric;
-
- gr = g_hash_table_lookup (metric->groups, key);
+ gr = g_hash_table_lookup (cfg->groups, key);
if (gr == NULL) {
- gr = rspamd_config_new_group (sd->cfg, metric, key);
+ gr = rspamd_config_new_group (cfg, key);
}
- if (!rspamd_rcl_section_parse_defaults (sd->cfg, section, pool, obj,
+ if (!rspamd_rcl_section_parse_defaults (cfg, section, pool, obj,
gr, err)) {
return FALSE;
}
- sd->gr = gr;
+ sd.gr = gr;
+ sd.cfg = cfg;
/* Handle symbols */
- val = ucl_object_lookup (obj, "symbol");
+ val = ucl_object_lookup (obj, "symbols");
if (val != NULL && ucl_object_type (val) == UCL_OBJECT) {
- HASH_FIND_STR (section->subsections, "symbol", subsection);
+ HASH_FIND_STR (section->subsections, "symbols", subsection);
g_assert (subsection != NULL);
LL_FOREACH (val, cur) {
- if (!rspamd_rcl_process_section (sd->cfg, subsection, sd, cur,
+ if (!rspamd_rcl_process_section (cfg, subsection, &sd, cur,
pool, err)) {
return FALSE;
}
@@ -404,37 +402,28 @@ rspamd_rcl_symbol_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
}
if (sd->gr) {
- rspamd_config_add_metric_symbol (cfg, key, score,
+ rspamd_config_add_symbol (cfg, key, score,
description, sd->gr->name, flags, priority, nshots);
}
else {
- rspamd_config_add_metric_symbol (cfg, key, score,
+ rspamd_config_add_symbol (cfg, key, score,
description, NULL, flags, priority, nshots);
}
return TRUE;
}
-struct metric_actions_cbdata {
- struct rspamd_config *cfg;
- struct rspamd_metric *metric;
-};
-
static gboolean
rspamd_rcl_actions_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
const gchar *key, gpointer ud,
struct rspamd_rcl_section *section, GError **err)
{
gdouble action_score;
- struct metric_actions_cbdata *cbdata = ud;
+ struct rspamd_config *cfg = ud;
gint action_value;
const ucl_object_t *cur;
ucl_object_iter_t it;
- struct rspamd_metric *metric;
- struct rspamd_config *cfg;
- metric = cbdata->metric;
- cfg = cbdata->cfg;
it = ucl_object_iterate_new (obj);
while ((cur = ucl_object_iterate_safe (it, true)) != NULL) {
@@ -450,8 +439,9 @@ rspamd_rcl_actions_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
return FALSE;
}
else {
- rspamd_config_set_action_score (cfg, metric->name,
- ucl_object_key (cur), action_score,
+ rspamd_config_set_action_score (cfg,
+ ucl_object_key (cur),
+ action_score,
ucl_object_get_priority (cur));
}
}
@@ -462,118 +452,6 @@ rspamd_rcl_actions_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
}
static gboolean
-rspamd_rcl_metric_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
- const gchar *key, gpointer ud,
- struct rspamd_rcl_section *section, GError **err)
-{
- const ucl_object_t *val, *cur, *elt;
- ucl_object_iter_t it;
- struct rspamd_config *cfg = ud;
- struct rspamd_metric *metric;
- struct rspamd_rcl_section *subsection;
- struct rspamd_rcl_symbol_data sd;
- struct rspamd_symbol *sym_def;
- struct metric_actions_cbdata acts_cbdata;
-
- g_assert (key != NULL);
-
- metric = g_hash_table_lookup (cfg->metrics, key);
- if (metric == NULL) {
- metric = rspamd_config_new_metric (cfg, metric, key);
- }
-
- if (!rspamd_rcl_section_parse_defaults (cfg, section, cfg->cfg_pool, obj,
- metric, err)) {
- return FALSE;
- }
-
- if (metric->unknown_weight > 0) {
- metric->accept_unknown_symbols = TRUE;
- }
-
- /* Handle actions */
- val = ucl_object_lookup (obj, "actions");
- if (val != NULL) {
- if (val->type != UCL_OBJECT) {
- g_set_error (err, CFG_RCL_ERROR, EINVAL,
- "actions must be an object");
- return FALSE;
- }
-
- HASH_FIND_STR (section->subsections, "actions", subsection);
- g_assert (subsection != NULL);
- acts_cbdata.cfg = cfg;
- acts_cbdata.metric = metric;
-
- if (!rspamd_rcl_process_section (cfg, subsection, &acts_cbdata, val,
- cfg->cfg_pool, err)) {
- return FALSE;
- }
- }
-
- /* No more legacy mode */
-
- /* Handle grouped symbols */
- val = ucl_object_lookup (obj, "group");
- if (val != NULL && ucl_object_type (val) == UCL_OBJECT) {
- HASH_FIND_STR (section->subsections, "group", subsection);
- g_assert (subsection != NULL);
- sd.gr = NULL;
- sd.cfg = cfg;
- sd.metric = metric;
-
- LL_FOREACH (val, cur) {
- if (!rspamd_rcl_process_section (cfg, subsection, &sd, cur,
- cfg->cfg_pool, err)) {
- return FALSE;
- }
- }
- }
-
- /* Handle symbols */
- val = ucl_object_lookup (obj, "symbol");
- if (val != NULL && ucl_object_type (val) == UCL_OBJECT) {
- HASH_FIND_STR (section->subsections, "symbol", subsection);
- g_assert (subsection != NULL);
- sd.gr = NULL;
- sd.cfg = cfg;
- sd.metric = metric;
-
- LL_FOREACH (val, cur) {
- if (!rspamd_rcl_process_section (cfg, subsection, &sd, cur,
- cfg->cfg_pool, err)) {
- return FALSE;
- }
- }
- }
-
- /* Handle ignored symbols */
- val = ucl_object_lookup (obj, "ignore");
- if (val != NULL && ucl_object_type (val) == UCL_ARRAY) {
- LL_FOREACH (val, cur) {
- it = NULL;
-
- while ((elt = ucl_object_iterate (cur, &it, true)) != NULL) {
- if (ucl_object_type (elt) == UCL_STRING) {
- sym_def = g_hash_table_lookup (metric->symbols,
- ucl_object_tostring (elt));
-
- if (sym_def != NULL) {
- sym_def->flags |= RSPAMD_SYMBOL_FLAG_IGNORE;
- }
- else {
- msg_warn ("cannot find symbol %s to set ignore flag",
- ucl_object_tostring (elt));
- }
- }
- }
- }
- }
-
- return TRUE;
-}
-
-static gboolean
rspamd_rcl_worker_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
const gchar *key, gpointer ud,
struct rspamd_rcl_section *section, GError **err)
@@ -1500,7 +1378,7 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool,
description = composite_expression;
}
- rspamd_config_add_metric_symbol (cfg, composite_name, score,
+ rspamd_config_add_symbol (cfg, composite_name, score,
description, group, FALSE, FALSE,
1);
}
@@ -2307,27 +2185,26 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
"Time before attempting to recover upstream after an error");
/**
- * Metric section
+ * Symbols and actions sections
*/
sub = rspamd_rcl_add_section_doc (&new,
- "metric", "name",
- rspamd_rcl_metric_handler,
+ "actions", NULL,
+ rspamd_rcl_actions_handler,
UCL_OBJECT,
FALSE,
TRUE,
cfg->doc_strings,
- "Metrics configuration");
- sub->default_key = DEFAULT_METRIC;
+ "Actions configuration");
rspamd_rcl_add_default_handler (sub,
"unknown_weight",
rspamd_rcl_parse_struct_double,
- G_STRUCT_OFFSET (struct rspamd_metric, unknown_weight),
+ G_STRUCT_OFFSET (struct rspamd_config, unknown_weight),
0,
"Accept unknown symbols with the specified weight");
rspamd_rcl_add_default_handler (sub,
"grow_factor",
rspamd_rcl_parse_struct_double,
- G_STRUCT_OFFSET (struct rspamd_metric, grow_factor),
+ G_STRUCT_OFFSET (struct rspamd_config, grow_factor),
0,
"Multiply the subsequent symbols by this number "
"(does not affect symbols with score less or "
@@ -2335,34 +2212,23 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
rspamd_rcl_add_default_handler (sub,
"subject",
rspamd_rcl_parse_struct_string,
- G_STRUCT_OFFSET (struct rspamd_metric, subject),
+ G_STRUCT_OFFSET (struct rspamd_config, subject),
0,
"Rewrite subject with this value");
- /* Ungrouped symbols */
- ssub = rspamd_rcl_add_section_doc (&sub->subsections,
- "symbol", "name",
- rspamd_rcl_symbol_handler,
- UCL_OBJECT,
- TRUE,
- TRUE,
- sub->doc_ref,
- "Symbols settings");
-
- /* Actions part */
- ssub = rspamd_rcl_add_section_doc (&sub->subsections,
- "actions", NULL,
- rspamd_rcl_actions_handler,
+ sub = rspamd_rcl_add_section_doc (&new,
+ "groups", "name",
+ rspamd_rcl_group_handler,
UCL_OBJECT,
+ FALSE,
TRUE,
- TRUE,
- sub->doc_ref,
- "Actions settings");
+ cfg->doc_strings,
+ "Symbol groups configuration");
/* Group part */
ssub = rspamd_rcl_add_section_doc (&sub->subsections,
- "group", "name",
- rspamd_rcl_group_handler,
+ "symbols", "name",
+ rspamd_rcl_symbol_handler,
UCL_OBJECT,
TRUE,
TRUE,
diff --git a/src/libserver/cfg_rcl.h b/src/libserver/cfg_rcl.h
index e115fda97..51b348e9c 100644
--- a/src/libserver/cfg_rcl.h
+++ b/src/libserver/cfg_rcl.h
@@ -17,6 +17,7 @@
#define CFG_RCL_H_
#include "config.h"
+#include "cfg_file.h"
#include "ucl.h"
#include "mem_pool.h"
@@ -57,6 +58,7 @@ struct rspamd_rcl_struct_parser {
enum rspamd_rcl_flag flags;
};
+
/**
* Common handler type
* @param cfg configuration
@@ -457,4 +459,12 @@ ucl_object_t *rspamd_rcl_add_doc_by_example (struct rspamd_config *cfg,
gboolean rspamd_rcl_add_lua_plugins_path (struct rspamd_config *cfg,
const gchar *path,
GError **err);
+
+/*
+ * Read configuration file
+ */
+gboolean rspamd_config_read (struct rspamd_config *cfg,
+ const gchar *filename, const gchar *convert_to,
+ rspamd_rcl_section_fin_t logger_fin, gpointer logger_ud,
+ GHashTable *vars);
#endif /* CFG_RCL_H_ */
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 691482773..00c7e0db4 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -122,16 +122,13 @@ rspamd_config_new (void)
/* 20 Kb */
cfg->max_diff = 20480;
- cfg->metrics = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
- rspamd_config_new_metric (cfg, NULL, DEFAULT_METRIC);
+ rspamd_config_init_metric (cfg);
cfg->c_modules = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
cfg->composite_symbols =
g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
cfg->classifiers_symbols = g_hash_table_new (rspamd_str_hash,
rspamd_str_equal);
cfg->cfg_params = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
- cfg->metrics_symbols = g_hash_table_new_full (rspamd_str_hash, rspamd_str_equal,
- NULL, (GDestroyNotify)g_list_free);
cfg->debug_modules = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
cfg->explicit_modules = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
cfg->wrk_parsers = g_hash_table_new (g_int_hash, g_int_equal);
@@ -215,7 +212,6 @@ rspamd_config_free (struct rspamd_config *cfg)
}
g_list_free (cfg->classifiers);
- g_list_free (cfg->metrics_list);
g_list_free (cfg->workers);
rspamd_symbols_cache_destroy (cfg->cache);
#ifdef WITH_HIREDIS
@@ -227,14 +223,11 @@ rspamd_config_free (struct rspamd_config *cfg)
ucl_object_unref (cfg->config_comments);
ucl_object_unref (cfg->doc_strings);
ucl_object_unref (cfg->neighbours);
- g_hash_table_remove_all (cfg->metrics);
- g_hash_table_unref (cfg->metrics);
g_hash_table_unref (cfg->c_modules);
g_hash_table_remove_all (cfg->composite_symbols);
g_hash_table_unref (cfg->composite_symbols);
g_hash_table_remove_all (cfg->cfg_params);
g_hash_table_unref (cfg->cfg_params);
- g_hash_table_destroy (cfg->metrics_symbols);
g_hash_table_unref (cfg->classifiers_symbols);
g_hash_table_unref (cfg->debug_modules);
g_hash_table_unref (cfg->explicit_modules);
@@ -764,25 +757,24 @@ rspamd_config_post_load (struct rspamd_config *cfg,
if (opts & RSPAMD_CONFIG_INIT_VALIDATE) {
/* Check for actions sanity */
int i, prev_act = 0;
- struct rspamd_metric *metric = cfg->default_metric;
gdouble prev_score = NAN;
gboolean seen_controller = FALSE;
GList *cur;
struct rspamd_worker_conf *wcf;
for (i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i ++) {
- if (!isnan (prev_score) && !isnan (metric->actions[i].score)) {
- if (prev_score <= isnan (metric->actions[i].score)) {
+ if (!isnan (prev_score) && !isnan (cfg->actions[i].score)) {
+ if (prev_score <= isnan (cfg->actions[i].score)) {
msg_warn_config ("incorrect metrics scores: action %s"
" has lower score: %.2f than action %s: %.2f",
rspamd_action_to_str (prev_act), prev_score,
- rspamd_action_to_str (i), metric->actions[i].score);
+ rspamd_action_to_str (i), cfg->actions[i].score);
ret = FALSE;
}
}
- if (!isnan (metric->actions[i].score)) {
- prev_score = metric->actions[i].score;
+ if (!isnan (cfg->actions[i].score)) {
+ prev_score = cfg->actions[i].score;
prev_act = i;
}
}
@@ -940,47 +932,32 @@ rspamd_config_new_statfile (struct rspamd_config *cfg,
return c;
}
-struct rspamd_metric *
-rspamd_config_new_metric (struct rspamd_config *cfg, struct rspamd_metric *c,
- const gchar *name)
+void
+rspamd_config_init_metric (struct rspamd_config *cfg)
{
int i;
- if (c == NULL) {
- c = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct rspamd_metric));
- c->grow_factor = 1.0;
- c->symbols = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
- c->groups = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);
-
- for (i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i++) {
- c->actions[i].score = NAN;
- c->actions[i].action = i;
- c->actions[i].priority = 0;
- }
-
- c->subject = SPAM_SUBJECT;
- c->name = rspamd_mempool_strdup (cfg->cfg_pool, name);
- rspamd_mempool_add_destructor (cfg->cfg_pool,
- (rspamd_mempool_destruct_t) g_hash_table_unref,
- c->symbols);
- rspamd_mempool_add_destructor (cfg->cfg_pool,
- (rspamd_mempool_destruct_t) g_hash_table_unref,
- c->groups);
-
- g_hash_table_insert (cfg->metrics, (void *)c->name, c);
- cfg->metrics_list = g_list_prepend (cfg->metrics_list, c);
+ cfg->grow_factor = 1.0;
+ cfg->symbols = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
+ cfg->groups = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);
- if (strcmp (c->name, DEFAULT_METRIC) == 0) {
- cfg->default_metric = c;
- }
+ for (i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i++) {
+ cfg->actions[i].score = NAN;
+ cfg->actions[i].action = i;
+ cfg->actions[i].priority = 0;
}
- return c;
+ cfg->subject = SPAM_SUBJECT;
+ rspamd_mempool_add_destructor (cfg->cfg_pool,
+ (rspamd_mempool_destruct_t) g_hash_table_unref,
+ cfg->symbols);
+ rspamd_mempool_add_destructor (cfg->cfg_pool,
+ (rspamd_mempool_destruct_t) g_hash_table_unref,
+ cfg->groups);
}
struct rspamd_symbols_group *
-rspamd_config_new_group (struct rspamd_config *cfg, struct rspamd_metric *metric,
- const gchar *name)
+rspamd_config_new_group (struct rspamd_config *cfg, const gchar *name)
{
struct rspamd_symbols_group *gr;
@@ -991,7 +968,7 @@ rspamd_config_new_group (struct rspamd_config *cfg, struct rspamd_metric *metric
(rspamd_mempool_destruct_t)g_hash_table_unref, gr->symbols);
gr->name = rspamd_mempool_strdup (cfg->cfg_pool, name);
- g_hash_table_insert (metric->groups, gr->name, gr);
+ g_hash_table_insert (cfg->groups, gr->name, gr);
return gr;
}
@@ -1431,14 +1408,12 @@ rspamd_init_filters (struct rspamd_config *cfg, bool reconfig)
}
static void
-rspamd_config_new_metric_symbol (struct rspamd_config *cfg,
- struct rspamd_metric *metric, const gchar *symbol,
+rspamd_config_new_symbol (struct rspamd_config *cfg, const gchar *symbol,
gdouble score, const gchar *description, const gchar *group,
guint flags, guint priority, gint nshots)
{
struct rspamd_symbols_group *sym_group;
struct rspamd_symbol *sym_def;
- GList *metric_list;
gdouble *score_ptr;
sym_def =
@@ -1457,32 +1432,20 @@ rspamd_config_new_metric_symbol (struct rspamd_config *cfg,
sym_def->description = rspamd_mempool_strdup (cfg->cfg_pool, description);
}
- msg_debug_config ("registered symbol %s with weight %.2f in metric %s and group %s",
- sym_def->name, score, metric->name, group);
+ msg_debug_config ("registered symbol %s with weight %.2f in and group %s",
+ sym_def->name, score, group);
- g_hash_table_insert (metric->symbols, sym_def->name, sym_def);
-
- if ((metric_list =
- g_hash_table_lookup (cfg->metrics_symbols, sym_def->name)) == NULL) {
- metric_list = g_list_prepend (NULL, metric);
- g_hash_table_insert (cfg->metrics_symbols, sym_def->name, metric_list);
- }
- else {
- /* Slow but keep start element of list in safe */
- if (!g_list_find (metric_list, metric)) {
- metric_list = g_list_append (metric_list, metric);
- }
- }
+ g_hash_table_insert (cfg->symbols, sym_def->name, sym_def);
/* Search for symbol group */
if (group == NULL) {
group = "ungrouped";
}
- sym_group = g_hash_table_lookup (metric->groups, group);
+ sym_group = g_hash_table_lookup (cfg->groups, group);
if (sym_group == NULL) {
/* Create new group */
- sym_group = rspamd_config_new_group (cfg, metric, group);
+ sym_group = rspamd_config_new_group (cfg, group);
}
sym_def->gr = sym_group;
@@ -1491,19 +1454,16 @@ rspamd_config_new_metric_symbol (struct rspamd_config *cfg,
gboolean
-rspamd_config_add_metric_symbol (struct rspamd_config *cfg,
+rspamd_config_add_symbol (struct rspamd_config *cfg,
const gchar *symbol,
gdouble score, const gchar *description, const gchar *group,
guint flags, guint priority, gint nshots)
{
struct rspamd_symbol *sym_def;
- struct rspamd_metric *metric;
-
g_assert (cfg != NULL);
g_assert (symbol != NULL);
- metric = cfg->default_metric;
- sym_def = g_hash_table_lookup (metric->symbols, symbol);
+ sym_def = g_hash_table_lookup (cfg->symbols, symbol);
if (sym_def != NULL) {
if (sym_def->priority > priority) {
@@ -1546,7 +1506,7 @@ rspamd_config_add_metric_symbol (struct rspamd_config *cfg,
}
}
- rspamd_config_new_metric_symbol (cfg, metric, symbol, score, description,
+ rspamd_config_new_symbol (cfg, symbol, score, description,
group, flags, priority, nshots);
return TRUE;
@@ -1557,12 +1517,10 @@ rspamd_config_is_module_enabled (struct rspamd_config *cfg,
const gchar *module_name)
{
gboolean is_c = FALSE;
- struct rspamd_metric *metric;
const ucl_object_t *conf, *enabled;
GList *cur;
struct rspamd_symbols_group *gr;
- metric = cfg->default_metric;
if (g_hash_table_lookup (cfg->c_modules, module_name)) {
is_c = TRUE;
@@ -1618,17 +1576,15 @@ rspamd_config_is_module_enabled (struct rspamd_config *cfg,
}
}
- if (metric) {
- /* Now we check symbols group */
- gr = g_hash_table_lookup (metric->groups, module_name);
+ /* Now we check symbols group */
+ gr = g_hash_table_lookup (cfg->groups, module_name);
- if (gr) {
- if (gr->disabled) {
- msg_info_config ("%s module %s is disabled in the configuration as "
- "its group has been disabled",
- is_c ? "internal" : "lua", module_name);
- return FALSE;
- }
+ if (gr) {
+ if (gr->disabled) {
+ msg_info_config ("%s module %s is disabled in the configuration as "
+ "its group has been disabled",
+ is_c ? "internal" : "lua", module_name);
+ return FALSE;
}
}
@@ -1637,29 +1593,16 @@ rspamd_config_is_module_enabled (struct rspamd_config *cfg,
gboolean
rspamd_config_set_action_score (struct rspamd_config *cfg,
- const gchar *metric_name,
const gchar *action_name,
gdouble score,
guint priority)
{
- struct metric_action *act;
- struct rspamd_metric *metric;
+ struct rspamd_action *act;
gint act_num;
g_assert (cfg != NULL);
g_assert (action_name != NULL);
- if (metric_name == NULL) {
- metric_name = DEFAULT_METRIC;
- }
-
- metric = g_hash_table_lookup (cfg->metrics, metric_name);
-
- if (metric == NULL) {
- msg_err_config ("metric %s has not been found", metric_name);
- return FALSE;
- }
-
if (!rspamd_action_from_str (action_name, &act_num)) {
msg_err_config ("invalid action name: %s", action_name);
return FALSE;
@@ -1667,7 +1610,7 @@ rspamd_config_set_action_score (struct rspamd_config *cfg,
g_assert (act_num >= METRIC_ACTION_REJECT && act_num < METRIC_ACTION_MAX);
- act = &metric->actions[act_num];
+ act = &cfg->actions[act_num];
if (isnan (act->score)) {
act->score = score;
@@ -1827,7 +1770,7 @@ rspamd_action_from_str (const gchar *data, gint *result)
}
const gchar *
-rspamd_action_to_str (enum rspamd_metric_action action)
+rspamd_action_to_str (enum rspamd_action_type action)
{
switch (action) {
case METRIC_ACTION_REJECT:
@@ -1850,7 +1793,7 @@ rspamd_action_to_str (enum rspamd_metric_action action)
}
const gchar *
-rspamd_action_to_str_alt (enum rspamd_metric_action action)
+rspamd_action_to_str_alt (enum rspamd_action_type action)
{
switch (action) {
case METRIC_ACTION_REJECT:
diff --git a/src/libserver/composites.c b/src/libserver/composites.c
index 41dd60b0c..cfb8968ff 100644
--- a/src/libserver/composites.c
+++ b/src/libserver/composites.c
@@ -142,7 +142,6 @@ rspamd_composite_expr_process (gpointer input, rspamd_expression_atom_t *atom)
struct rspamd_symbol_result *ms = NULL;
struct rspamd_symbols_group *gr;
struct rspamd_symbol *sdef;
- struct rspamd_metric *metric;
GHashTableIter it;
gpointer k, v;
gint rc = 0;
@@ -160,9 +159,7 @@ rspamd_composite_expr_process (gpointer input, rspamd_expression_atom_t *atom)
}
if (strncmp (sym, "g:", 2) == 0) {
- metric = g_hash_table_lookup (cd->task->cfg->metrics, DEFAULT_METRIC);
- g_assert (metric != NULL);
- gr = g_hash_table_lookup (metric->groups, sym + 2);
+ gr = g_hash_table_lookup (cd->task->cfg->groups, sym + 2);
if (gr != NULL) {
g_hash_table_iter_init (&it, gr->symbols);
diff --git a/src/libserver/dynamic_cfg.c b/src/libserver/dynamic_cfg.c
index d576e055a..3f0d490f4 100644
--- a/src/libserver/dynamic_cfg.c
+++ b/src/libserver/dynamic_cfg.c
@@ -37,7 +37,6 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg)
gint test_act;
const ucl_object_t *cur_elt, *cur_nm, *it_val;
ucl_object_iter_t it = NULL;
- struct rspamd_metric *real_metric;
const gchar *name;
gdouble nscore;
static const guint priority = 3;
@@ -54,12 +53,6 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg)
"loaded json metric object element has no 'metric' attribute");
continue;
}
- real_metric = g_hash_table_lookup (cfg->metrics,
- ucl_object_tostring (cur_nm));
- if (real_metric == NULL) {
- msg_warn ("cannot find metric %s", ucl_object_tostring (cur_nm));
- continue;
- }
cur_nm = ucl_object_lookup (cur_elt, "symbols");
/* Parse symbols */
@@ -79,7 +72,7 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg)
/*
* We use priority = 3 here
*/
- rspamd_config_add_metric_symbol (cfg,
+ rspamd_config_add_symbol (cfg,
ucl_object_tostring (n), nscore, NULL, NULL,
0, priority, cfg->default_max_shots);
}
@@ -114,8 +107,7 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg)
}
nscore = ucl_object_todouble (ucl_object_lookup (it_val,
"value"));
- rspamd_config_set_action_score (cfg, real_metric->name,
- name, nscore, priority);
+ rspamd_config_set_action_score (cfg, name, nscore, priority);
}
else {
msg_info (
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 25fb56a0f..5e5132e1d 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -740,7 +740,7 @@ rspamd_emails_tree_ucl (GHashTable *input, struct rspamd_task *task)
/* Write new subject */
static const gchar *
-make_rewritten_subject (struct rspamd_metric *metric, struct rspamd_task *task)
+make_rewritten_subject (struct rspamd_task *task)
{
GString *subj_buf;
gchar *res;
@@ -750,7 +750,7 @@ make_rewritten_subject (struct rspamd_metric *metric, struct rspamd_task *task)
c = rspamd_mempool_get_variable (task->task_pool, "metric_subject");
if (c == NULL) {
- c = metric->subject;
+ c = task->cfg->subject;
}
if (c == NULL) {
@@ -797,8 +797,7 @@ make_rewritten_subject (struct rspamd_metric *metric, struct rspamd_task *task)
}
static ucl_object_t *
-rspamd_metric_symbol_ucl (struct rspamd_task *task, struct rspamd_metric *m,
- struct rspamd_symbol_result *sym)
+rspamd_metric_symbol_ucl (struct rspamd_task *task, struct rspamd_symbol_result *sym)
{
ucl_object_t *obj = NULL, *ar;
const gchar *description = NULL;
@@ -849,15 +848,12 @@ rspamd_metric_result_ucl (struct rspamd_task *task,
{
GHashTableIter hiter;
struct rspamd_symbol_result *sym;
- struct rspamd_metric *m;
gboolean is_spam;
- enum rspamd_metric_action action = METRIC_ACTION_NOACTION;
+ enum rspamd_action_type action = METRIC_ACTION_NOACTION;
ucl_object_t *obj = NULL, *sobj;
gpointer h, v;
const gchar *subject;
- m = mres->metric;
-
if (mres->action == METRIC_ACTION_MAX) {
mres->action = rspamd_check_action_metric (task, mres);
}
@@ -895,7 +891,7 @@ rspamd_metric_result_ucl (struct rspamd_task *task,
"action", 0, false);
if (action == METRIC_ACTION_REWRITE_SUBJECT) {
- subject = make_rewritten_subject (m, task);
+ subject = make_rewritten_subject (task);
if (subject) {
ucl_object_insert_key (obj, ucl_object_fromstring (subject),
@@ -912,7 +908,7 @@ rspamd_metric_result_ucl (struct rspamd_task *task,
while (g_hash_table_iter_next (&hiter, &h, &v)) {
sym = (struct rspamd_symbol_result *)v;
- sobj = rspamd_metric_symbol_ucl (task, m, sym);
+ sobj = rspamd_metric_symbol_ucl (task, sym);
ucl_object_insert_key (obj, sobj, h, 0, false);
}
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c
index e74de4e73..9aad6b591 100644
--- a/src/libserver/re_cache.c
+++ b/src/libserver/re_cache.c
@@ -1389,7 +1389,7 @@ rspamd_re_cache_compile_hyperscan (struct rspamd_re_cache *cache,
/* Read number of regexps */
g_assert (fd != -1);
lseek (fd, RSPAMD_HS_MAGIC_LEN + sizeof (cache->plt), SEEK_SET);
- read (fd, &n, sizeof (n));
+ g_assert (read (fd, &n, sizeof (n)) == sizeof (n));
close (fd);
if (re_class->type_len > 0) {
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index 4cf1cab5b..9b8fba25b 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -1013,48 +1013,35 @@ static void
rspamd_symbols_cache_validate_cb (gpointer k, gpointer v, gpointer ud)
{
struct cache_item *item = v, *parent;
+ struct rspamd_config *cfg;
struct symbols_cache *cache = (struct symbols_cache *)ud;
- GList *cur;
- struct rspamd_metric *m;
struct rspamd_symbol *s;
gboolean skipped, ghost;
gint p1, p2;
ghost = item->st->weight == 0 ? TRUE : FALSE;
+ cfg = cache->cfg;
/* Check whether this item is skipped */
skipped = !ghost;
- g_assert (cache->cfg != NULL);
+ g_assert (cfg != NULL);
if ((item->type &
(SYMBOL_TYPE_NORMAL|SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_COMPOSITE|SYMBOL_TYPE_CLASSIFIER))
- && g_hash_table_lookup (cache->cfg->metrics_symbols, item->symbol) == NULL) {
- cur = g_list_first (cache->cfg->metrics_list);
- while (cur) {
- m = cur->data;
-
- if (m->accept_unknown_symbols) {
- GList *mlist;
-
- skipped = FALSE;
- item->st->weight = m->unknown_weight;
- s = rspamd_mempool_alloc0 (cache->static_pool,
- sizeof (*s));
- s->name = item->symbol;
- s->weight_ptr = &item->st->weight;
- g_hash_table_insert (m->symbols, item->symbol, s);
- mlist = g_hash_table_lookup (cache->cfg->metrics_symbols,
- item->symbol);
- mlist = g_list_append (mlist, m);
- g_hash_table_insert (cache->cfg->metrics_symbols,
- item->symbol, mlist);
-
- msg_info_cache ("adding unknown symbol %s to metric %s", item->symbol,
- m->name);
- ghost = FALSE;
- }
+ && g_hash_table_lookup (cfg->symbols, item->symbol) == NULL) {
+
+ if (cfg->accept_unknown_symbols) {
- cur = g_list_next (cur);
+ skipped = FALSE;
+ item->st->weight = cfg->unknown_weight;
+ s = rspamd_mempool_alloc0 (cache->static_pool,
+ sizeof (*s));
+ s->name = item->symbol;
+ s->weight_ptr = &item->st->weight;
+ g_hash_table_insert (cfg->symbols, item->symbol, s);
+
+ msg_info_cache ("adding unknown symbol %s", item->symbol);
+ ghost = FALSE;
}
}
else {
@@ -1120,10 +1107,8 @@ rspamd_symbols_cache_validate (struct symbols_cache *cache,
{
struct cache_item *item;
GHashTableIter it;
- GList *cur;
gpointer k, v;
struct rspamd_symbol *sym_def;
- struct rspamd_metric *metric;
gboolean ignore_symbol = FALSE, ret = TRUE;
if (cache == NULL) {
@@ -1132,32 +1117,23 @@ rspamd_symbols_cache_validate (struct symbols_cache *cache,
}
/* Now adjust symbol weights according to default metric */
- if (cfg->default_metric != NULL) {
- g_hash_table_foreach (cfg->default_metric->symbols,
+ g_hash_table_foreach (cfg->symbols,
rspamd_symbols_cache_metric_validate_cb,
cache);
- }
g_hash_table_foreach (cache->items_by_symbol,
rspamd_symbols_cache_validate_cb,
cache);
/* Now check each metric item and find corresponding symbol in a cache */
- g_hash_table_iter_init (&it, cfg->metrics_symbols);
+ g_hash_table_iter_init (&it, cfg->symbols);
while (g_hash_table_iter_next (&it, &k, &v)) {
ignore_symbol = FALSE;
- cur = v;
+ sym_def = v;
- while (cur) {
- metric = cur->data;
- sym_def = g_hash_table_lookup (metric->symbols, k);
-
- if (sym_def && (sym_def->flags & RSPAMD_SYMBOL_FLAG_IGNORE)) {
- ignore_symbol = TRUE;
- break;
- }
-
- cur = g_list_next (cur);
+ if (sym_def && (sym_def->flags & RSPAMD_SYMBOL_FLAG_IGNORE)) {
+ ignore_symbol = TRUE;
+ break;
}
if (!ignore_symbol) {
@@ -1518,7 +1494,6 @@ rspamd_symbols_cache_process_settings (struct rspamd_task *task,
struct symbols_cache *cache)
{
const ucl_object_t *wl, *cur, *disabled, *enabled;
- struct rspamd_metric *def;
struct rspamd_symbols_group *gr;
GHashTableIter gr_it;
ucl_object_iter_t it = NULL;
@@ -1547,15 +1522,14 @@ rspamd_symbols_cache_process_settings (struct rspamd_task *task,
/* Enable groups of symbols */
enabled = ucl_object_lookup (task->settings, "groups_enabled");
- def = g_hash_table_lookup (task->cfg->metrics, DEFAULT_METRIC);
- if (def && enabled) {
+ if (enabled) {
it = NULL;
rspamd_symbols_cache_disable_all_symbols (task, cache);
while ((cur = ucl_iterate_object (enabled, &it, true)) != NULL) {
if (ucl_object_type (cur) == UCL_STRING) {
- gr = g_hash_table_lookup (def->groups,
+ gr = g_hash_table_lookup (task->cfg->groups,
ucl_object_tostring (cur));
if (gr) {
@@ -1582,14 +1556,13 @@ rspamd_symbols_cache_process_settings (struct rspamd_task *task,
/* Disable groups of symbols */
disabled = ucl_object_lookup (task->settings, "groups_disabled");
- def = g_hash_table_lookup (task->cfg->metrics, DEFAULT_METRIC);
- if (def && disabled) {
+ if (disabled) {
it = NULL;
while ((cur = ucl_iterate_object (disabled, &it, true)) != NULL) {
if (ucl_object_type (cur) == UCL_STRING) {
- gr = g_hash_table_lookup (def->groups,
+ gr = g_hash_table_lookup (task->cfg->groups,
ucl_object_tostring (cur));
if (gr) {
diff --git a/src/libutil/mem_pool.c b/src/libutil/mem_pool.c
index c9ca42934..103928323 100644
--- a/src/libutil/mem_pool.c
+++ b/src/libutil/mem_pool.c
@@ -714,7 +714,6 @@ rspamd_mempool_cleanup_tmp (rspamd_mempool_t * pool)
{
struct _pool_chain *cur;
guint i;
- gsize len;
POOL_MTX_LOCK ();
@@ -724,7 +723,6 @@ rspamd_mempool_cleanup_tmp (rspamd_mempool_t * pool)
g_atomic_int_add (&mem_pool_stat->bytes_allocated,
-((gint)cur->len));
g_atomic_int_add (&mem_pool_stat->chunks_allocated, -1);
- len = cur->len + sizeof (struct _pool_chain);
g_free (cur);
}
diff --git a/src/libutil/util.c b/src/libutil/util.c
index fe092ad3c..b16040caf 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -1698,8 +1698,8 @@ restart:
return 0;
}
- (void)write (output, "Enter passphrase: ", sizeof ("Enter passphrase: ") -
- 1);
+ g_assert (write (output, "Enter passphrase: ", sizeof ("Enter passphrase: ") -
+ 1) != -1);
/* Save the current sighandler */
for (i = 0; i < NSIG; i++) {
@@ -1727,7 +1727,7 @@ restart:
}
}
*p = '\0';
- (void)write (output, "\n", 1);
+ g_assert (write (output, "\n", 1) == 1);
/* Restore terminal state */
if (memcmp (&term, &oterm, sizeof (term)) != 0) {
diff --git a/src/lua/lua_cfg_file.c b/src/lua/lua_cfg_file.c
index f564f1e79..daa8223ff 100644
--- a/src/lua/lua_cfg_file.c
+++ b/src/lua/lua_cfg_file.c
@@ -28,31 +28,22 @@
static void
lua_process_metric (lua_State *L, const gchar *name, struct rspamd_config *cfg)
{
- GList *metric_list;
gchar *symbol;
const gchar *desc = NULL;
- struct rspamd_metric *metric;
gdouble *score;
struct rspamd_symbol *s;
- /* Get module opt structure */
- if ((metric = g_hash_table_lookup (cfg->metrics, name)) == NULL) {
- metric = rspamd_config_new_metric (cfg, metric, name);
- }
-
/* Now iterate through module table */
for (lua_pushnil (L); lua_next (L, -2); lua_pop (L, 1)) {
/* key - -2, value - -1 */
- symbol =
- rspamd_mempool_strdup (cfg->cfg_pool, luaL_checkstring (L, -2));
+ symbol = rspamd_mempool_strdup (cfg->cfg_pool, luaL_checkstring (L, -2));
if (symbol != NULL) {
if (lua_istable (L, -1)) {
/* We got a table, so extract individual attributes */
lua_pushstring (L, "weight");
lua_gettable (L, -2);
if (lua_isnumber (L, -1)) {
- score =
- rspamd_mempool_alloc (cfg->cfg_pool, sizeof (double));
+ score = rspamd_mempool_alloc (cfg->cfg_pool, sizeof (double));
*score = lua_tonumber (L, -1);
}
else {
@@ -78,37 +69,23 @@ lua_process_metric (lua_State *L, const gchar *name, struct rspamd_config *cfg)
}
/* Insert symbol */
if ((s =
- g_hash_table_lookup (metric->symbols, symbol)) != NULL) {
+ g_hash_table_lookup (cfg->symbols, symbol)) != NULL) {
msg_info_config("replacing weight for symbol %s: %.2f -> %.2f",
- symbol,
- *s->weight_ptr,
- *score);
+ symbol,
+ *s->weight_ptr,
+ *score);
s->weight_ptr = score;
}
else {
s = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (*s));
s->name = symbol;
s->weight_ptr = score;
- g_hash_table_insert (metric->symbols, symbol, s);
+ g_hash_table_insert (cfg->symbols, symbol, s);
}
if (desc) {
s->description = rspamd_mempool_strdup (cfg->cfg_pool, desc);
}
-
- if ((metric_list =
- g_hash_table_lookup (cfg->metrics_symbols, symbol)) == NULL) {
- metric_list = g_list_prepend (NULL, metric);
- rspamd_mempool_add_destructor (cfg->cfg_pool,
- (rspamd_mempool_destruct_t)g_list_free, metric_list);
- g_hash_table_insert (cfg->metrics_symbols, symbol, metric_list);
- }
- else {
- /* Slow but keep start element of list in safe */
- if (!g_list_find (metric_list, metric)) {
- metric_list = g_list_append (metric_list, metric);
- }
- }
}
}
}
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 6407852b2..c1e31eb44 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -1525,8 +1525,8 @@ lua_config_register_symbol (lua_State * L)
nshots = 1;
}
- rspamd_config_add_metric_symbol (cfg, name,
- score, description, group, flags, (guint)priority, nshots);
+ rspamd_config_add_symbol (cfg, name,
+ score, description, group, flags, (guint) priority, nshots);
}
}
else {
@@ -1754,10 +1754,9 @@ static gint
lua_config_set_metric_symbol (lua_State * L)
{
struct rspamd_config *cfg = lua_check_config (L, 1);
- const gchar *metric_name = DEFAULT_METRIC, *description = NULL,
+ const gchar *description = NULL,
*group = NULL, *name = NULL, *flags_str = NULL;
double weight;
- struct rspamd_metric *metric;
gboolean one_shot = FALSE, one_param = FALSE;
GError *err = NULL;
gdouble priority = 0.0;
@@ -1769,11 +1768,11 @@ lua_config_set_metric_symbol (lua_State * L)
if (lua_type (L, 2) == LUA_TTABLE) {
if (!rspamd_lua_parse_table_arguments (L, 2, &err,
"*name=S;score=N;description=S;"
- "group=S;one_shot=B;one_param=B;metric=S;priority=N;flags=S;"
+ "group=S;one_shot=B;one_param=B;priority=N;flags=S;"
"nshots=I",
&name, &weight, &description,
&group, &one_shot, &one_param,
- &metric_name, &priority, &flags_str, &nshots)) {
+ &priority, &flags_str, &nshots)) {
msg_err_config ("bad arguments: %e", err);
g_error_free (err);
@@ -1788,7 +1787,7 @@ lua_config_set_metric_symbol (lua_State * L)
description = luaL_checkstring (L, 4);
}
if (lua_gettop (L) > 4 && lua_type (L, 5) == LUA_TSTRING) {
- metric_name = luaL_checkstring (L, 5);
+ /* XXX: metrics */
}
if (lua_gettop (L) > 5 && lua_type (L, 6) == LUA_TSTRING) {
group = luaL_checkstring (L, 6);
@@ -1798,15 +1797,10 @@ lua_config_set_metric_symbol (lua_State * L)
}
}
- if (metric_name == NULL) {
- metric_name = DEFAULT_METRIC;
- }
-
if (nshots == 0) {
nshots = cfg->default_max_shots;
}
- metric = g_hash_table_lookup (cfg->metrics, metric_name);
if (one_shot) {
nshots = 1;
}
@@ -1826,13 +1820,8 @@ lua_config_set_metric_symbol (lua_State * L)
}
}
- if (metric == NULL) {
- msg_err_config ("metric named %s is not defined", metric_name);
- }
- else if (name != NULL && weight != 0) {
- rspamd_config_add_metric_symbol (cfg, name,
- weight, description, group, flags, (guint)priority, nshots);
- }
+ rspamd_config_add_symbol (cfg, name,
+ weight, description, group, flags, (guint) priority, nshots);
}
else {
return luaL_error (L, "invalid arguments, rspamd_config expected");
@@ -1845,41 +1834,31 @@ static gint
lua_config_get_metric_symbol (lua_State * L)
{
struct rspamd_config *cfg = lua_check_config (L, 1);
- const gchar *sym_name = luaL_checkstring (L, 2),
- *metric_name = DEFAULT_METRIC;
+ const gchar *sym_name = luaL_checkstring (L, 2);
struct rspamd_symbol *sym_def;
- struct rspamd_metric *metric;
if (cfg && sym_name) {
- metric = g_hash_table_lookup (cfg->metrics, metric_name);
+ sym_def = g_hash_table_lookup (cfg->symbols, sym_name);
- if (metric == NULL) {
- msg_err_config ("metric named %s is not defined", metric_name);
+ if (sym_def == NULL) {
lua_pushnil (L);
}
else {
- sym_def = g_hash_table_lookup (metric->symbols, sym_name);
+ lua_createtable (L, 0, 3);
+ lua_pushstring (L, "score");
+ lua_pushnumber (L, sym_def->score);
+ lua_settable (L, -3);
- if (sym_def == NULL) {
- lua_pushnil (L);
- }
- else {
- lua_createtable (L, 0, 3);
- lua_pushstring (L, "score");
- lua_pushnumber (L, sym_def->score);
+ if (sym_def->description) {
+ lua_pushstring (L, "description");
+ lua_pushstring (L, sym_def->description);
lua_settable (L, -3);
+ }
- if (sym_def->description) {
- lua_pushstring (L, "description");
- lua_pushstring (L, sym_def->description);
- lua_settable (L, -3);
- }
-
- if (sym_def->gr) {
- lua_pushstring (L, "group");
- lua_pushstring (L, sym_def->gr->name);
- lua_settable (L, -3);
- }
+ if (sym_def->gr) {
+ lua_pushstring (L, "group");
+ lua_pushstring (L, sym_def->gr->name);
+ lua_settable (L, -3);
}
}
}
@@ -1894,9 +1873,8 @@ static gint
lua_config_set_metric_action (lua_State * L)
{
struct rspamd_config *cfg = lua_check_config (L, 1);
- const gchar *metric_name = DEFAULT_METRIC, *name = NULL;
+ const gchar *name = NULL;
double weight;
- struct rspamd_metric *metric;
GError *err = NULL;
gdouble priority = 0.0;
@@ -1905,9 +1883,9 @@ lua_config_set_metric_action (lua_State * L)
if (lua_type (L, 2) == LUA_TTABLE) {
if (!rspamd_lua_parse_table_arguments (L, 2, &err,
"*action=S;score=N;"
- "metric=S;priority=N",
+ "priority=N",
&name, &weight,
- &metric_name, &priority)) {
+ &priority)) {
msg_err_config ("bad arguments: %e", err);
g_error_free (err);
@@ -1918,18 +1896,8 @@ lua_config_set_metric_action (lua_State * L)
return luaL_error (L, "invalid arguments, table expected");
}
- if (metric_name == NULL) {
- metric_name = DEFAULT_METRIC;
- }
-
- metric = g_hash_table_lookup (cfg->metrics, metric_name);
-
- if (metric == NULL) {
- msg_err_config ("metric named %s is not defined", metric_name);
- }
- else if (name != NULL && weight != 0) {
- rspamd_config_set_action_score (cfg, metric_name, name,
- weight, (guint)priority);
+ if (name != NULL && weight != 0) {
+ rspamd_config_set_action_score (cfg, name, weight, (guint)priority);
}
}
else {
@@ -1943,31 +1911,21 @@ static gint
lua_config_get_metric_action (lua_State * L)
{
struct rspamd_config *cfg = lua_check_config (L, 1);
- const gchar *metric_name = DEFAULT_METRIC,
- *act_name = luaL_checkstring (L, 2);
- struct rspamd_metric *metric;
+ const gchar *act_name = luaL_checkstring (L, 2);
gint act = 0;
if (cfg && act_name) {
- metric = g_hash_table_lookup (cfg->metrics, metric_name);
-
- if (metric == NULL) {
- msg_err_config ("metric named %s is not defined", metric_name);
- lua_pushnil (L);
- }
- else {
- if (rspamd_action_from_str (act_name, &act)) {
- if (!isnan (metric->actions[act].score)) {
- lua_pushnumber (L, metric->actions[act].score);
- }
- else {
- lua_pushnil (L);
- }
+ if (rspamd_action_from_str (act_name, &act)) {
+ if (!isnan (cfg->actions[act].score)) {
+ lua_pushnumber (L, cfg->actions[act].score);
}
else {
lua_pushnil (L);
}
}
+ else {
+ lua_pushnil (L);
+ }
}
else {
return luaL_error (L, "invalid arguments, rspamd_config expected");
@@ -2147,7 +2105,7 @@ lua_config_newindex (lua_State *L)
* Now check if a symbol has not been registered in any metric and
* insert default value if applicable
*/
- if (g_hash_table_lookup (cfg->metrics_symbols, name) == NULL) {
+ if (g_hash_table_lookup (cfg->symbols, name) == NULL) {
nshots = cfg->default_max_shots;
lua_pushstring (L, "score");
lua_gettable (L, -2);
@@ -2197,7 +2155,7 @@ lua_config_newindex (lua_State *L)
* Do not override the existing symbols (using zero priority),
* since we are defining default values here
*/
- rspamd_config_add_metric_symbol (cfg, name, score,
+ rspamd_config_add_symbol (cfg, name, score,
description, group, flags, 0, nshots);
}
else {
diff --git a/src/lua/lua_fann.c b/src/lua/lua_fann.c
index c7fdc6c70..40353ea40 100644
--- a/src/lua/lua_fann.c
+++ b/src/lua/lua_fann.c
@@ -630,7 +630,7 @@ lua_fann_thread_notify (gint fd, short what, gpointer ud)
lua_fann_push_train_result (cbdata, rep.errcode, rep.mse, rep.errmsg);
}
- write (cbdata->pair[0], "", 1);
+ g_assert (write (cbdata->pair[0], "", 1) == 1);
g_thread_join (cbdata->t);
close (cbdata->pair[0]);
close (cbdata->pair[1]);
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index c4f4de3fe..4172d60b7 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -1323,11 +1323,14 @@ static gint
lua_task_set_pre_result (lua_State * L)
{
struct rspamd_task *task = lua_check_task (L, 1);
+ struct rspamd_config *cfg;
struct rspamd_metric_result *mres;
gchar *action_str;
gint action = METRIC_ACTION_MAX;
if (task != NULL) {
+ cfg = task->cfg;
+
if (lua_type (L, 2) == LUA_TNUMBER) {
action = lua_tointeger (L, 2);
}
@@ -1340,7 +1343,7 @@ lua_task_set_pre_result (lua_State * L)
if (!task->result) {
mres = rspamd_create_metric_result (task);
if (mres != NULL) {
- mres->score = mres->metric->actions[action].score;
+ mres->score = cfg->actions[action].score;
mres->action = action;
}
}
@@ -4058,7 +4061,7 @@ lua_task_get_metric_action (lua_State *L)
{
struct rspamd_task *task = lua_check_task (L, 1);
struct rspamd_metric_result *metric_res;
- enum rspamd_metric_action action;
+ enum rspamd_action_type action;
if (task) {
if ((metric_res = task->result) != NULL) {
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c
index 055498746..39ccf9bc6 100644
--- a/src/plugins/dkim_check.c
+++ b/src/plugins/dkim_check.c
@@ -543,10 +543,10 @@ dkim_module_config (struct rspamd_config *cfg)
"DKIM_SIGN", dkim_module_ctx->symbol_reject);
}
- rspamd_config_add_metric_symbol (cfg,
+ rspamd_config_add_symbol (cfg,
"DKIM_SIGN", 0.0, "DKIM signature fake symbol",
"dkim", RSPAMD_SYMBOL_FLAG_IGNORE, 1, 1);
- rspamd_config_add_metric_symbol (cfg,
+ rspamd_config_add_symbol (cfg,
"DKIM_TRACE", 0.0, "DKIM trace symbol",
"dkim", RSPAMD_SYMBOL_FLAG_IGNORE, 1, 1);
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index bd016ac82..03dd21734 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -303,7 +303,7 @@ regexp_module_config (struct rspamd_config *cfg)
priority = ucl_object_toint (elt);
}
- rspamd_config_add_metric_symbol (cfg, cur_item->symbol,
+ rspamd_config_add_symbol (cfg, cur_item->symbol,
score, description, group, flags, priority, nshots);
}
}