瀏覽代碼

[Minor] Some fixes to ids propagation

tags/2.0
Vsevolod Stakhov 4 年之前
父節點
當前提交
d79e398a8b
共有 3 個檔案被更改,包括 46 行新增8 行删除
  1. 21
    5
      src/libserver/rspamd_symcache.c
  2. 23
    1
      src/lua/lua_config.c
  3. 2
    2
      src/plugins/surbl.c

+ 21
- 5
src/libserver/rspamd_symcache.c 查看文件

@@ -542,6 +542,8 @@ rspamd_symcache_propagate_dep (struct rspamd_symcache *cache,
const guint *ids;
guint nids = 0;

msg_debug_cache ("check id propagation for dependency %s from %s",
it->symbol, dit->symbol);
ids = rspamd_symcache_get_allowed_settings_ids (cache, dit->symbol, &nids);

/* TODO: merge? */
@@ -573,12 +575,15 @@ rspamd_symcache_process_dep (struct rspamd_symcache *cache,
struct cache_dependency *rdep;

if (dep->id >= 0) {
msg_debug_cache ("process real dependency %s on %s", it->symbol, dep->sym);
dit = rspamd_symcache_find_filter (cache, dep->sym, true);
}

if (dep->vid >= 0) {
/* Case of the virtual symbol that depends on another (maybe virtual) symbol */
vdit = rspamd_symcache_find_filter (cache, dep->sym, false);
msg_debug_cache ("process virtual dependency %s(%d) on %s(%d)", it->symbol,
dep->vid, vdit->symbol, vdit->id);
}
else {
vdit = dit;
@@ -686,7 +691,8 @@ rspamd_symcache_post_init (struct rspamd_symcache *cache)
else {
msg_debug_cache ("delayed between %s(%d:%d) -> %s", ddep->from,
it->id, vit->id, ddep->to);
rspamd_symcache_add_dependency (cache, it->id, ddep->to, vit->id);
rspamd_symcache_add_dependency (cache, it->id, ddep->to, vit != it ?
vit->id : -1);
}

cur = g_list_next (cur);
@@ -730,6 +736,14 @@ rspamd_symcache_post_init (struct rspamd_symcache *cache)
}
}

/* Special case for virtual symbols */
PTR_ARRAY_FOREACH (cache->virtual, i, it) {

PTR_ARRAY_FOREACH (it->deps, j, dep) {
rspamd_symcache_process_dep (cache, it, dep);
}
}

g_ptr_array_sort_with_data (cache->prefilters_empty, prefilters_cmp, cache);
g_ptr_array_sort_with_data (cache->prefilters, prefilters_cmp, cache);
g_ptr_array_sort_with_data (cache->postfilters, postfilters_cmp, cache);
@@ -2485,7 +2499,7 @@ rspamd_symcache_add_dependency (struct rspamd_symcache *cache,

g_assert (id_from >= 0 && id_from < (gint)cache->items_by_id->len);

source = g_ptr_array_index (cache->items_by_id, id_from);
source = (struct rspamd_symcache_item *)g_ptr_array_index (cache->items_by_id, id_from);
dep = rspamd_mempool_alloc (cache->static_pool, sizeof (*dep));
dep->id = id_from;
dep->sym = rspamd_mempool_strdup (cache->static_pool, to);
@@ -2494,11 +2508,13 @@ rspamd_symcache_add_dependency (struct rspamd_symcache *cache,
dep->vid = -1;
g_ptr_array_add (source->deps, dep);

if (id_from != virtual_id_from) {
if (virtual_id_from >= 0) {
g_assert (virtual_id_from < (gint)cache->virtual->len);
/* We need that for settings id propagation */
vsource = g_ptr_array_index (cache->items_by_id, virtual_id_from);
vsource = (struct rspamd_symcache_item *)
g_ptr_array_index (cache->virtual, virtual_id_from);
dep = rspamd_mempool_alloc (cache->static_pool, sizeof (*dep));
dep->vid = id_from;
dep->vid = virtual_id_from;
dep->id = -1;
dep->sym = rspamd_mempool_strdup (cache->static_pool, to);
/* Will be filled later */

+ 23
- 1
src/lua/lua_config.c 查看文件

@@ -1524,6 +1524,17 @@ rspamd_register_symbol_fromlua (lua_State *L,
ids = rspamd_process_id_list (allowed_ids, &nids);

if (nids > 0) {
GString *dbg = g_string_new ("");

for (guint i = 0; i < nids; i ++) {
rspamd_printf_gstring (dbg, "%ud,", ids[i]);
}

dbg->len --;

msg_debug_config ("allowed ids for %s are: %v", name, dbg);
g_string_free (dbg, TRUE);

rspamd_symcache_set_allowed_settings_ids (cfg->cache, name,
ids, nids);

@@ -1535,6 +1546,17 @@ rspamd_register_symbol_fromlua (lua_State *L,
ids = rspamd_process_id_list (forbidden_ids, &nids);

if (nids > 0) {
GString *dbg = g_string_new ("");

for (guint i = 0; i < nids; i ++) {
rspamd_printf_gstring (dbg, "%ud,", ids[i]);
}

dbg->len --;

msg_debug_config ("forbidden ids for %s are: %v", name, dbg);
g_string_free (dbg, TRUE);

rspamd_symcache_set_forbidden_settings_ids (cfg->cache, name,
ids, nids);

@@ -2207,7 +2229,7 @@ lua_config_register_dependency (lua_State * L)
if (child_id > 0 && parent != NULL) {

rspamd_symcache_add_dependency (cfg->cache, child_id, parent,
child_id);
-1);
}
}
else {

+ 2
- 2
src/plugins/surbl.c 查看文件

@@ -868,7 +868,7 @@ surbl_module_parse_rule (const ucl_object_t* value, struct rspamd_config* cfg)
1,
1);
rspamd_symcache_add_dependency (cfg->cache, cb_id,
SURBL_REDIRECTOR_CALLBACK, cb_id);
SURBL_REDIRECTOR_CALLBACK, -1);
/* Failure symbol */
g_string_append (sym, "_FAIL");
rspamd_symcache_add_symbol (cfg->cache, sym->str,
@@ -1205,7 +1205,7 @@ surbl_module_config (struct rspamd_config *cfg)

if (cur_suffix->options & SURBL_OPTION_CHECKDKIM) {
rspamd_symcache_add_dependency (cfg->cache,
cur_suffix->callback_id, "DKIM_TRACE", cur_suffix->callback_id);
cur_suffix->callback_id, "DKIM_TRACE", -1);
}

cur_opt = g_list_next (cur_opt);

Loading…
取消
儲存