-void
+gboolean
init_lua_filters (struct config_file *cfg)
{
struct config_file **pcfg;
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 */
*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);
/* Code must be loaded from data */
if (luaL_loadstring (L, tmp->data) != 0) {
msg_info ("cannot load normalizer code %s", tmp->data);
+ return FALSE;
}
}
}
}
/* Assign state */
cfg->lua_state = L;
+
+ return TRUE;
}
/* Callback functions */
int luaopen_classifier (lua_State *L);
int luaopen_statfile (lua_State * L);
void init_lua (struct config_file *cfg);
-void init_lua_filters (struct config_file *cfg);
+gboolean init_lua_filters (struct config_file *cfg);
/* Filters functions */
int lua_call_filter (const char *function, struct worker_task *task);
}
l = g_list_next (l);
}
- init_lua_filters (rspamd->cfg);
+ if (! init_lua_filters (rspamd->cfg)) {
+ res = FALSE;
+ }
if (dump_vars) {
dump_cfg_vars (rspamd->cfg);
}
l = g_list_next (l);
}
- init_lua_filters (rspamd->cfg);
+ if (! init_lua_filters (rspamd->cfg)) {
+ msg_err ("error loading lua plugins");
+ exit (EXIT_FAILURE);
+ }
init_cfg_cache (rspamd->cfg);