aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-10-05 21:13:23 +0200
committerKim Alvefur <zash@zash.se>2020-10-05 21:13:23 +0200
commit3c0445e1b22bd0b6ab0fa160f2ad3250da48014c (patch)
tree70e942c1404b037d337db494636727cc3946fb80 /util
parent0113f59de04e2ac926e392e6295936e854534883 (diff)
downloadprosody-3c0445e1b22bd0b6ab0fa160f2ad3250da48014c.tar.gz
prosody-3c0445e1b22bd0b6ab0fa160f2ad3250da48014c.zip
util.prosodyctl: Construct luarocks command line with templates
More flexible and safer wrt escaping
Diffstat (limited to 'util')
-rw-r--r--util/prosodyctl.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/util/prosodyctl.lua b/util/prosodyctl.lua
index cb86a5a1..6378856a 100644
--- a/util/prosodyctl.lua
+++ b/util/prosodyctl.lua
@@ -12,6 +12,7 @@ local encodings = require "util.encodings";
local stringprep = encodings.stringprep;
local storagemanager = require "core.storagemanager";
local usermanager = require "core.usermanager";
+local interpolation = require "util.interpolation";
local signal = require "util.signal";
local set = require "util.set";
local lfs = require "lfs";
@@ -224,6 +225,8 @@ local function get_path_custom_plugins(plugin_paths)
end
end
+local render_cli = interpolation.new("%b{}", function (s) return "'"..s:gsub("'","'\\''").."'" end)
+
local function call_luarocks(mod, operation)
local dir = get_path_custom_plugins(prosody.paths.plugins);
if operation == "install" then
@@ -232,9 +235,11 @@ local function call_luarocks(mod, operation)
show_message("Removing %s from %s", mod, dir);
end
if operation == "list" then
- os.execute("luarocks list --tree='"..dir.."'")
+ os.execute(render_cli("luarocks list --tree={dir}", {dir = dir}));
else
- os.execute("luarocks --tree='"..dir.."' --server='http://localhost/' "..operation.." "..mod);
+ os.execute(render_cli("luarocks {op} --tree={dir} {server&--server={server}} {mod}", {
+ dir = dir; op = operation; mod = mod; server = "http://localhost/";
+ }));
end
if operation == "install" then
show_module_configuration_help(mod);