From: Vsevolod Stakhov Date: Tue, 29 Nov 2016 11:13:04 +0000 (+0000) Subject: [Fix] Fix external dependencies for SA module X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0f60fc73e95c7835e190f769ea02a59a33d61b62;p=thirdparty%2Frspamd.git [Fix] Fix external dependencies for SA module Conflicts: src/plugins/lua/spamassassin.lua --- diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua index cf17aa2476..a88326edb5 100644 --- a/src/plugins/lua/spamassassin.lua +++ b/src/plugins/lua/spamassassin.lua @@ -1463,15 +1463,18 @@ local function post_process() for i,a in ipairs(expr_atoms) do if not atoms[a] then - local rspamd_symbol, replaced_symbol = replace_symbol(a) - rspamd_logger.debugx('atom %1 is a direct foreign dependency, ' .. - 'register dependency for %2 on %3', - a, k, rspamd_symbol) - rspamd_config:register_dependency(k, rspamd_symbol) + local rspamd_symbol = replace_symbol(a) if not external_deps[k] then - external_deps[k] = {rspamd_symbol} - else - table.insert(external_deps[k], rspamd_symbol) + external_deps[k] = {} + end + + if not external_deps[k][rspamd_symbol] then + rspamd_config:register_dependency(k, rspamd_symbol) + external_deps[k][rspamd_symbol] = true + rspamd_logger.debugx(rspamd_config, + 'atom %1 is a direct foreign dependency, ' .. + 'register dependency for %2 on %3', + a, k, rspamd_symbol) end end end @@ -1483,16 +1486,27 @@ local function post_process() rules)) -- ... And then indirect ones ... - each(function(k, r) + local nchanges + repeat + nchanges = 0 + each(function(k, r) if r['expression'] then local expr_atoms = r['expression']:atoms() for i,a in ipairs(expr_atoms) do if type(external_deps[a]) == 'table' then for _,dep in ipairs(external_deps[a]) do - rspamd_logger.debugx('atom %1 holds a foreign dependency, ' .. - 'register dependency for %2 on %3', - a, k, dep); + if not external_deps[k] then + external_deps[k] = {} + end + if not external_deps[k][dep] then rspamd_config:register_dependency(k, dep) + external_deps[k][dep] = true + rspamd_logger.debugx(rspamd_config, + 'atom %1 is a direct foreign dependency, ' .. + 'register dependency for %2 on %3', + a, k, dep) + end + nchanges = nchanges + 1 end else local rspamd_symbol, replaced_symbol = replace_symbol(a) @@ -1509,6 +1523,7 @@ local function post_process() return r['type'] == 'meta' end, rules)) + until nchanges ~= 0 -- Set missing symbols each(function(key, score)