diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-11-29 11:13:04 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-11-29 11:13:23 +0000 |
commit | 003ed74af2622bf14b5cffb7bcacf614487f6c33 (patch) | |
tree | 41b5cc9181ac00fbc62fb98dd71d50ab78640db7 /src/plugins/lua/spamassassin.lua | |
parent | 05f74ba93861dcfe4cddd56573bd8de3dd65b327 (diff) | |
download | rspamd-003ed74af2622bf14b5cffb7bcacf614487f6c33.tar.gz rspamd-003ed74af2622bf14b5cffb7bcacf614487f6c33.zip |
[Fix] Fix external dependencies for SA module
Diffstat (limited to 'src/plugins/lua/spamassassin.lua')
-rw-r--r-- | src/plugins/lua/spamassassin.lua | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua index 5d5961642..ffbb41c6b 100644 --- a/src/plugins/lua/spamassassin.lua +++ b/src/plugins/lua/spamassassin.lua @@ -1493,14 +1493,17 @@ local function post_process() for _,a in ipairs(expr_atoms) do if not atoms[a] then local rspamd_symbol = replace_symbol(a) - rspamd_logger.debugm(N, rspamd_config, 'atom %1 is a direct foreign dependency, ' .. - 'register dependency for %2 on %3', - a, k, rspamd_symbol) - rspamd_config:register_dependency(k, rspamd_symbol) 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.debugm(N, rspamd_config, + 'atom %1 is a direct foreign dependency, ' .. + 'register dependency for %2 on %3', + a, k, rspamd_symbol) end end end @@ -1512,16 +1515,27 @@ local function post_process() rules)) -- ... And then indirect ones ... - fun.each(function(k, r) + local nchanges + repeat + nchanges = 0 + fun.each(function(k, r) if r['expression'] then local expr_atoms = r['expression']:atoms() for _,a in ipairs(expr_atoms) do if type(external_deps[a]) == 'table' then for _,dep in ipairs(external_deps[a]) do - rspamd_logger.debugm(N, rspamd_config, '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.debugm(N, 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) @@ -1538,6 +1552,7 @@ local function post_process() return r['type'] == 'meta' end, rules)) + until nchanges ~= 0 -- Set missing symbols fun.each(function(key, score) |