aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-07-17 14:45:15 +0200
committerKim Alvefur <zash@zash.se>2023-07-17 14:45:15 +0200
commit43c39930c3988b9a1cf9c249861d6f500c864031 (patch)
treee4cc99f5395699c7632b1108c41c20c92a61cd57
parent3f81654a667e07679b9165453cd2f269a5de7f01 (diff)
downloadprosody-43c39930c3988b9a1cf9c249861d6f500c864031.tar.gz
prosody-43c39930c3988b9a1cf9c249861d6f500c864031.zip
util.prosodyctl.check: Validate format of module list options
Should detect things like misplaced settings inside modules_enabled
-rw-r--r--util/prosodyctl/check.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/util/prosodyctl/check.lua b/util/prosodyctl/check.lua
index 8f43e20e..f010af73 100644
--- a/util/prosodyctl/check.lua
+++ b/util/prosodyctl/check.lua
@@ -496,6 +496,34 @@ local function check(arg)
print();
end
+ local function validate_module_list(host, name, modules)
+ if modules == nil then
+ return -- okay except for global section, checked separately
+ end
+ local t = type(modules)
+ if t ~= "table" then
+ print(" The " .. name .. " in the " .. host .. " section should not be a " .. t .. " but a list of strings, e.g.");
+ print(" " .. name .. " = { \"name_of_module\", \"another_plugin\", }")
+ print()
+ ok = false
+ return
+ end
+ for k, v in pairs(modules) do
+ if type(k) ~= "number" or type(v) ~= "string" then
+ print(" The " .. name .. " in the " .. host .. " section should not be a map of " .. type(k) .. " to " .. type(v)
+ .. " but a list of strings, e.g.");
+ print(" " .. name .. " = { \"name_of_module\", \"another_plugin\", }")
+ ok = false
+ break
+ end
+ end
+ end
+
+ for host, options in enabled_hosts() do
+ validate_module_list(host, "modules_enabled", options.modules_enabled);
+ validate_module_list(host, "modules_disabled", options.modules_disabled);
+ end
+
do -- Check for modules enabled both normally and as components
local modules = global:get_option_set("modules_enabled");
for host, options in enabled_hosts() do