diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-07 13:32:48 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-07 13:32:48 +0100 |
commit | 890e7fe0e079b946c34986f5c65fbd05626486d0 (patch) | |
tree | 20011a3b973ee26e5907fccc9137744fe2f60711 /src/rspamadm | |
parent | f1e53832fb37f2cf059b74139ce5de1dffc82651 (diff) | |
download | rspamd-890e7fe0e079b946c34986f5c65fbd05626486d0.tar.gz rspamd-890e7fe0e079b946c34986f5c65fbd05626486d0.zip |
[Feature] Check for plugin configuration errors on `configtest`
Diffstat (limited to 'src/rspamadm')
-rw-r--r-- | src/rspamadm/configtest.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/rspamadm/configtest.c b/src/rspamadm/configtest.c index bfad1984e..8f1482fc1 100644 --- a/src/rspamadm/configtest.c +++ b/src/rspamadm/configtest.c @@ -1,11 +1,11 @@ -/*- - * Copyright 2016 Vsevolod Stakhov +/* + * Copyright 2023 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -150,6 +150,23 @@ rspamadm_configtest(gint argc, gchar **argv, const struct rspamadm_command *cmd) FALSE)) { ret = FALSE; } + + if (ret) { + if (rspamd_lua_require_function(cfg->lua_state, "lua_cfg_utils", "check_configuration_errors")) { + GError *err = NULL; + + if (!rspamd_lua_universal_pcall(cfg->lua_state, -1, G_STRLOC, 1, "", &err)) { + msg_err_config("call to lua function failed: %s", + lua_tostring(cfg->lua_state, -1)); + lua_pop(cfg->lua_state, 2); + ret = FALSE; + } + else { + ret = lua_toboolean(cfg->lua_state, -1); + lua_pop(cfg->lua_state, 2); + } + } + } } if (strict && ret) { |