diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-08-04 17:13:18 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-08-04 17:13:18 +0400 |
commit | f46e13b47c010f16075350e17ca0dbfea46e6e05 (patch) | |
tree | eb674e5ca79be353afea4d65a20e3ac7d03af98a /src/lua/lua_common.c | |
parent | 4680a3fb136ade8bb3a38f0a7837fa0cfe5466c3 (diff) | |
download | rspamd-f46e13b47c010f16075350e17ca0dbfea46e6e05.tar.gz rspamd-f46e13b47c010f16075350e17ca0dbfea46e6e05.zip |
* Consider lua plugins errors as fatal configuration errors
Diffstat (limited to 'src/lua/lua_common.c')
-rw-r--r-- | src/lua/lua_common.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index b0ca3a32b..a880f50e3 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -236,7 +236,7 @@ init_lua (struct config_file *cfg) -void +gboolean init_lua_filters (struct config_file *cfg) { struct config_file **pcfg; @@ -252,7 +252,7 @@ init_lua_filters (struct config_file *cfg) if (luaL_loadfile (L, module->path) != 0) { msg_info ("load of %s failed: %s", module->path, lua_tostring (L, -1)); cur = g_list_next (cur); - continue; + return FALSE; } /* Initialize config structure */ @@ -261,9 +261,17 @@ init_lua_filters (struct config_file *cfg) *pcfg = cfg; lua_setglobal (L, "rspamd_config"); - /* do the call (1 arguments, 1 result) */ + /* do the call (0 arguments, N result) */ if (lua_pcall (L, 0, LUA_MULTRET, 0) != 0) { msg_info ("init of %s failed: %s", module->path, lua_tostring (L, -1)); + return FALSE; + } + if (lua_gettop (L) != 0) { + if (lua_tonumber (L, -1) == -1) { + msg_info ("%s returned -1 that indicates configuration error", module->path); + return FALSE; + } + lua_pop (L, lua_gettop (L)); } } cur = g_list_next (cur); @@ -279,6 +287,7 @@ init_lua_filters (struct config_file *cfg) /* Code must be loaded from data */ if (luaL_loadstring (L, tmp->data) != 0) { msg_info ("cannot load normalizer code %s", tmp->data); + return FALSE; } } } @@ -287,6 +296,8 @@ init_lua_filters (struct config_file *cfg) } /* Assign state */ cfg->lua_state = L; + + return TRUE; } /* Callback functions */ |