aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-06-24 15:37:18 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-06-24 15:37:18 +0100
commit99692da96eeb415bed39fa3116df582a7b9e2e27 (patch)
tree080dd759524ef4d0573fe2607ec090f762f0794d /src/lua
parentf017ace89a8f499d7ce206e9d93636420915f6ae (diff)
downloadrspamd-99692da96eeb415bed39fa3116df582a7b9e2e27.tar.gz
rspamd-99692da96eeb415bed39fa3116df582a7b9e2e27.zip
[Minor] Print module digest and path when loading modules
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_common.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index 689dcd1c4..68373c0a9 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -1062,10 +1062,36 @@ rspamd_init_lua_filters (struct rspamd_config *cfg, gboolean force_load)
lua_pushcfunction (L, &rspamd_lua_traceback);
err_idx = lua_gettop (L);
- if (luaL_loadfile (L, module->path) != 0) {
+ gsize fsize;
+ guint8 *data = rspamd_file_xmap (module->path,
+ PROT_READ, &fsize, TRUE);
+ guchar digest[rspamd_cryptobox_HASHBYTES];
+
+ if (data == NULL) {
+ msg_err_config ("cannot mmap %s failed: %s", module->path,
+ strerror (errno));
+
+ lua_settop (L, err_idx - 1); /* Error function */
+
+ rspamd_plugins_table_push_elt (L, "disabled_failed",
+ module->name);
+
+ cur = g_list_next (cur);
+ continue;
+ }
+
+ module->digest = rspamd_mempool_alloc (cfg->cfg_pool,
+ rspamd_cryptobox_HASHBYTES * 2 + 1);
+ rspamd_cryptobox_hash (digest, data, fsize, NULL, 0);
+ rspamd_encode_hex_buf (digest, sizeof (digest),
+ module->digest, rspamd_cryptobox_HASHBYTES * 2 + 1);
+ module->digest[rspamd_cryptobox_HASHBYTES * 2] = '\0';
+
+
+ if (luaL_loadbuffer (L, data, fsize, module->path) != 0) {
msg_err_config ("load of %s failed: %s", module->path,
lua_tostring (L, -1));
- lua_pop (L, 1); /* Error function */
+ lua_settop (L, err_idx - 1); /* Error function */
rspamd_plugins_table_push_elt (L, "disabled_failed",
module->name);
@@ -1094,7 +1120,10 @@ rspamd_init_lua_filters (struct rspamd_config *cfg, gboolean force_load)
}
if (!force_load) {
- msg_info_config ("init lua module %s", module->name);
+ msg_info_config ("init lua module %s from %s; digest: %*s",
+ module->name,
+ module->path,
+ 10, module->digest);
}
lua_pop (L, 1); /* Error function */