commit e4eab38: [Minor] Add warning about conflictin local files

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Feb 1 15:14:04 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-02-01 15:09:38 +0000
URL: https://github.com/rspamd/rspamd/commit/e4eab3822fe257ed4a044390a04eaba9a126afcd (HEAD -> master)

[Minor] Add warning about conflictin local files

---
 lualib/lua_cfg_transform.lua | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lualib/lua_cfg_transform.lua b/lualib/lua_cfg_transform.lua
index 717ce5a22..8a61dcd29 100644
--- a/lualib/lua_cfg_transform.lua
+++ b/lualib/lua_cfg_transform.lua
@@ -16,6 +16,7 @@ limitations under the License.
 
 local logger = require "rspamd_logger"
 local lua_util = require "lua_util"
+local rspamd_util = require "rspamd_util"
 
 local function is_implicit(t)
   local mt = getmetatable(t)
@@ -216,6 +217,21 @@ local function merge_groups(groups)
   return ret
 end
 
+-- Checks configuration files for statistics
+local function check_statistics_sanity()
+  local local_conf = rspamd_paths['LOCAL_CONFDIR']
+  local local_stat = string.format('%s/local.d/%s', local_conf,
+      'statistic.conf')
+  local local_bayes = string.format('%s/local.d/%s', local_conf,
+      'classifier-bayes.conf')
+
+  if rspamd_util.file_exists(local_stat) and
+      rspamd_util.file_exists(local_bayes) then
+    logger.warnx(rspamd_config, 'conflicting files %s and %s are found: '..
+        'Rspamd classifier configuration might be broken!', local_stat, local_bayes)
+  end
+end
+
 return function(cfg)
   local ret = false
 
@@ -226,6 +242,8 @@ return function(cfg)
     ret = true
   end
 
+  check_statistics_sanity()
+
   if not cfg.actions then
     logger.errx('no actions defined')
   else


More information about the Commits mailing list