diff options
Diffstat (limited to 'src/rspamadm')
-rw-r--r-- | src/rspamadm/configdump.c | 5 | ||||
-rw-r--r-- | src/rspamadm/confighelp.c | 3 | ||||
-rw-r--r-- | src/rspamadm/configtest.c | 3 | ||||
-rw-r--r-- | src/rspamadm/control.c | 3 | ||||
-rw-r--r-- | src/rspamadm/dkim_keygen.c | 3 | ||||
-rw-r--r-- | src/rspamadm/fuzzy_convert.c | 3 | ||||
-rw-r--r-- | src/rspamadm/fuzzy_merge.c | 3 | ||||
-rw-r--r-- | src/rspamadm/grep.c | 3 | ||||
-rw-r--r-- | src/rspamadm/keypair.c | 3 | ||||
-rw-r--r-- | src/rspamadm/lua_repl.c | 3 | ||||
-rw-r--r-- | src/rspamadm/pw.c | 3 | ||||
-rw-r--r-- | src/rspamadm/rspamadm.c | 15 | ||||
-rw-r--r-- | src/rspamadm/rspamadm.h | 2 | ||||
-rw-r--r-- | src/rspamadm/signtool.c | 3 | ||||
-rw-r--r-- | src/rspamadm/stat_convert.c | 3 |
15 files changed, 44 insertions, 14 deletions
diff --git a/src/rspamadm/configdump.c b/src/rspamadm/configdump.c index 60cd75c36..cf49f4632 100644 --- a/src/rspamadm/configdump.c +++ b/src/rspamadm/configdump.c @@ -39,7 +39,8 @@ struct rspamadm_command configdump_command = { .name = "configdump", .flags = 0, .help = rspamadm_configdump_help, - .run = rspamadm_configdump + .run = rspamadm_configdump, + .lua_subrs = NULL, }; static GOptionEntry entries[] = { @@ -244,7 +245,7 @@ rspamadm_configdump (gint argc, gchar **argv) gint i; context = g_option_context_new ( - "keypair - create encryption keys"); + "configdump - dumps Rspamd configuration"); g_option_context_set_summary (context, "Summary:\n Rspamd administration utility version " RVERSION diff --git a/src/rspamadm/confighelp.c b/src/rspamadm/confighelp.c index 5f8e1cfcc..ac25cd18f 100644 --- a/src/rspamadm/confighelp.c +++ b/src/rspamadm/confighelp.c @@ -38,7 +38,8 @@ struct rspamadm_command confighelp_command = { .name = "confighelp", .flags = 0, .help = rspamadm_confighelp_help, - .run = rspamadm_confighelp + .run = rspamadm_confighelp, + .lua_subrs = NULL, }; static GOptionEntry entries[] = { diff --git a/src/rspamadm/configtest.c b/src/rspamadm/configtest.c index 59f466de2..18104c109 100644 --- a/src/rspamadm/configtest.c +++ b/src/rspamadm/configtest.c @@ -35,7 +35,8 @@ struct rspamadm_command configtest_command = { .name = "configtest", .flags = 0, .help = rspamadm_configtest_help, - .run = rspamadm_configtest + .run = rspamadm_configtest, + .lua_subrs = NULL, }; static GOptionEntry entries[] = { diff --git a/src/rspamadm/control.c b/src/rspamadm/control.c index 62a7e26ae..a65ff554c 100644 --- a/src/rspamadm/control.c +++ b/src/rspamadm/control.c @@ -38,7 +38,8 @@ struct rspamadm_command control_command = { .name = "control", .flags = 0, .help = rspamadm_control_help, - .run = rspamadm_control + .run = rspamadm_control, + .lua_subrs = NULL, }; struct rspamadm_control_cbdata { diff --git a/src/rspamadm/dkim_keygen.c b/src/rspamadm/dkim_keygen.c index 14a2e18f2..b29621978 100644 --- a/src/rspamadm/dkim_keygen.c +++ b/src/rspamadm/dkim_keygen.c @@ -33,7 +33,8 @@ struct rspamadm_command dkim_keygen_command = { .name = "dkim_keygen", .flags = 0, .help = rspamadm_dkim_keygen_help, - .run = rspamadm_dkim_keygen + .run = rspamadm_dkim_keygen, + .lua_subrs = NULL, }; static GOptionEntry entries[] = { diff --git a/src/rspamadm/fuzzy_convert.c b/src/rspamadm/fuzzy_convert.c index a143b89d9..a65f3a397 100644 --- a/src/rspamadm/fuzzy_convert.c +++ b/src/rspamadm/fuzzy_convert.c @@ -31,7 +31,8 @@ struct rspamadm_command fuzzyconvert_command = { .name = "fuzzyconvert", .flags = 0, .help = rspamadm_fuzzyconvert_help, - .run = rspamadm_fuzzyconvert + .run = rspamadm_fuzzyconvert, + .lua_subrs = NULL, }; static GOptionEntry entries[] = { diff --git a/src/rspamadm/fuzzy_merge.c b/src/rspamadm/fuzzy_merge.c index c286bffa9..94631137c 100644 --- a/src/rspamadm/fuzzy_merge.c +++ b/src/rspamadm/fuzzy_merge.c @@ -29,7 +29,8 @@ struct rspamadm_command fuzzy_merge_command = { .name = "fuzzy_merge", .flags = 0, .help = rspamadm_fuzzy_merge_help, - .run = rspamadm_fuzzy_merge + .run = rspamadm_fuzzy_merge, + .lua_subrs = NULL, }; static GOptionEntry entries[] = { diff --git a/src/rspamadm/grep.c b/src/rspamadm/grep.c index 2ce4f2c76..309b1e769 100644 --- a/src/rspamadm/grep.c +++ b/src/rspamadm/grep.c @@ -33,7 +33,8 @@ struct rspamadm_command grep_command = { .name = "grep", .flags = 0, .help = rspamadm_grep_help, - .run = rspamadm_grep + .run = rspamadm_grep, + .lua_subrs = NULL, }; static GOptionEntry entries[] = { diff --git a/src/rspamadm/keypair.c b/src/rspamadm/keypair.c index 4f54d0b55..4214e0052 100644 --- a/src/rspamadm/keypair.c +++ b/src/rspamadm/keypair.c @@ -32,7 +32,8 @@ struct rspamadm_command keypair_command = { .name = "keypair", .flags = 0, .help = rspamadm_keypair_help, - .run = rspamadm_keypair + .run = rspamadm_keypair, + .lua_subrs = NULL, }; static GOptionEntry entries[] = { diff --git a/src/rspamadm/lua_repl.c b/src/rspamadm/lua_repl.c index f959c6bf3..0edfeb05e 100644 --- a/src/rspamadm/lua_repl.c +++ b/src/rspamadm/lua_repl.c @@ -54,7 +54,8 @@ struct rspamadm_command lua_command = { .name = "lua", .flags = 0, .help = rspamadm_lua_help, - .run = rspamadm_lua + .run = rspamadm_lua, + .lua_subrs = NULL, }; /* diff --git a/src/rspamadm/pw.c b/src/rspamadm/pw.c index fb2817c59..4345ff1c5 100644 --- a/src/rspamadm/pw.c +++ b/src/rspamadm/pw.c @@ -35,7 +35,8 @@ struct rspamadm_command pw_command = { .name = "pw", .flags = 0, .help = rspamadm_pw_help, - .run = rspamadm_pw + .run = rspamadm_pw, + .lua_subrs = NULL, }; static GOptionEntry entries[] = { 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); diff --git a/src/rspamadm/rspamadm.h b/src/rspamadm/rspamadm.h index a778457bc..9a209fd91 100644 --- a/src/rspamadm/rspamadm.h +++ b/src/rspamadm/rspamadm.h @@ -25,6 +25,7 @@ GQuark rspamadm_error (void); typedef const gchar* (*rspamadm_help_func) (gboolean full_help); typedef void (*rspamadm_run_func) (gint argc, gchar **argv); +typedef void (*rspamadm_lua_exports_func) (gpointer lua_state); #define RSPAMADM_FLAG_NOHELP (1 << 0) @@ -33,6 +34,7 @@ struct rspamadm_command { guint flags; rspamadm_help_func help; rspamadm_run_func run; + rspamadm_lua_exports_func lua_subrs; }; extern const struct rspamadm_command *commands[]; diff --git a/src/rspamadm/signtool.c b/src/rspamadm/signtool.c index 1acd46745..0ae7e22c5 100644 --- a/src/rspamadm/signtool.c +++ b/src/rspamadm/signtool.c @@ -46,7 +46,8 @@ struct rspamadm_command signtool_command = { .name = "signtool", .flags = 0, .help = rspamadm_signtool_help, - .run = rspamadm_signtool + .run = rspamadm_signtool, + .lua_subrs = NULL, }; static GOptionEntry entries[] = { diff --git a/src/rspamadm/stat_convert.c b/src/rspamadm/stat_convert.c index 98eb33700..cd15fb8a0 100644 --- a/src/rspamadm/stat_convert.c +++ b/src/rspamadm/stat_convert.c @@ -32,7 +32,8 @@ struct rspamadm_command statconvert_command = { .name = "statconvert", .flags = 0, .help = rspamadm_statconvert_help, - .run = rspamadm_statconvert + .run = rspamadm_statconvert, + .lua_subrs = NULL, }; static GOptionEntry entries[] = { |