From efe42811baf2c935208982ae99db246ab43d2f50 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 12 Jan 2016 17:40:57 +0000 Subject: [PATCH] Add globbing support --- src/plugins/lua/spamassassin.lua | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua index 45be259df..89ff0853e 100644 --- a/src/plugins/lua/spamassassin.lua +++ b/src/plugins/lua/spamassassin.lua @@ -1292,23 +1292,31 @@ if type(section) == "table" then else if type(fn) == 'table' then for k, elt in ipairs(fn) do - f = io.open(elt, "r") + local files = util.glob(elt) + + for i,matched in ipairs(files) do + f = io.open(matched, "r") + if f then + process_sa_conf(f) + has_rules = true + else + rspamd_logger.errx(rspamd_config, "cannot open %s", matched) + end + end + end + else + -- assume string + local files = util.glob(fn) + + for i,matched in ipairs(files) do + f = io.open(matched, "r") if f then process_sa_conf(f) has_rules = true else - rspamd_logger.errx(rspamd_config, "cannot open %s", elt) + rspamd_logger.errx(rspamd_config, "cannot open %s", matched) end end - else - -- assume string - f = io.open(fn, "r") - if f then - process_sa_conf(f) - has_rules = true - else - rspamd_logger.errx(rspamd_config, "cannot open %s", fn) - end end end end -- 2.39.5