aboutsummaryrefslogtreecommitdiffstats
path: root/src/rspamadm/rspamadm.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-12-02 13:45:36 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-12-02 13:45:36 +0000
commitf5df796a9f91bdecb3f3e35e67fd0c52adedb685 (patch)
tree75a7c931dedad0b8343938117d74b0faeb00768f /src/rspamadm/rspamadm.c
parent5b1a87305b3c8fde5db68b191f1ac239343d01a4 (diff)
downloadrspamd-f5df796a9f91bdecb3f3e35e67fd0c52adedb685.tar.gz
rspamd-f5df796a9f91bdecb3f3e35e67fd0c52adedb685.zip
[Feature] Allow rspamadm commands to export methods in Lua
Diffstat (limited to 'src/rspamadm/rspamadm.c')
-rw-r--r--src/rspamadm/rspamadm.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/rspamadm/rspamadm.c b/src/rspamadm/rspamadm.c
index f58da84af..67b93149a 100644
--- a/src/rspamadm/rspamadm.c
+++ b/src/rspamadm/rspamadm.c
@@ -193,11 +193,26 @@ rspamadm_execute_lua_ucl_subr (gpointer pL, gint argc, gchar **argv,
gint err_idx, i, ret;
GString *tb;
gchar str[PATH_MAX];
+ const struct rspamadm_command **cmd;
g_assert (script_name != NULL);
g_assert (res != NULL);
g_assert (L != NULL);
+ /* Init internal rspamadm routines */
+ lua_newtable (L);
+ cmd = commands;
+
+ while (*cmd) {
+ if ((*cmd)->lua_subrs != NULL) {
+ (*cmd)->lua_subrs (L);
+ }
+
+ cmd ++;
+ }
+
+ lua_setglobal (L, "rspamadm");
+
rspamd_snprintf (str, sizeof (str), "return require \"%s.%s\"", "rspamadm",
script_name);