aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-01-19 10:26:43 +0100
committerKim Alvefur <zash@zash.se>2022-01-19 10:26:43 +0100
commit2a1f14fc26ce3ad4e5acc29bd2a5a2aeb6b0e7b0 (patch)
tree3209bac8af32c55f0ab275dbde508f6aa7008ef9
parent456d91e7d76f89bd9019d8fd2976ec174d2fedd7 (diff)
downloadprosody-2a1f14fc26ce3ad4e5acc29bd2a5a2aeb6b0e7b0.tar.gz
prosody-2a1f14fc26ce3ad4e5acc29bd2a5a2aeb6b0e7b0.zip
util.prosodyctl.cert: Pass variables via formatting instead of concatenation
Prevents potential weirdness in case there's any %s or such in a host, file or directory name, since show_warning() is printf().
-rw-r--r--util/prosodyctl/cert.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/util/prosodyctl/cert.lua b/util/prosodyctl/cert.lua
index 4779fdc4..42f529ca 100644
--- a/util/prosodyctl/cert.lua
+++ b/util/prosodyctl/cert.lua
@@ -80,7 +80,7 @@ function cert_commands.config(arg)
local conf_file, err = io.open(conf_filename, "w");
if not conf_file then
pctl.show_warning("Could not open OpenSSL config file for writing");
- pctl.show_warning(err);
+ pctl.show_warning("%s", err);
os.exit(1);
end
conf_file:write(conf:serialize());
@@ -233,7 +233,7 @@ function cert_commands.import(arg)
imported[paths.certificate] = true;
else
-- TODO Say where we looked
- pctl.show_warning("No certificate for host "..host.." found :(");
+ pctl.show_warning("No certificate for host %s found :(", host);
end
-- TODO Additional checks
-- Certificate names matches the hostname
@@ -257,18 +257,18 @@ local function cert(arg)
lfs = require "lfs";
local cert_dir_attrs = lfs.attributes(cert_basedir);
if not cert_dir_attrs then
- pctl.show_warning("The directory "..cert_basedir.." does not exist");
+ pctl.show_warning("The directory %s does not exist", cert_basedir);
return 1; -- TODO Should we create it?
end
local uid = pposix.getuid();
if uid ~= 0 and uid ~= cert_dir_attrs.uid then
- pctl.show_warning("The directory "..cert_basedir.." is not owned by the current user, won't be able to write files to it");
+ pctl.show_warning("The directory %s is not owned by the current user, won't be able to write files to it", cert_basedir);
return 1;
elseif not cert_dir_attrs.permissions then -- COMPAT with LuaFilesystem < 1.6.2 (hey CentOS!)
pctl.show_message("Unable to check permissions on %s (LuaFilesystem 1.6.2+ required)", cert_basedir);
pctl.show_message("Please confirm that Prosody (and only Prosody) can write to this directory)");
elseif cert_dir_attrs.permissions:match("^%.w..%-..%-.$") then
- pctl.show_warning("The directory "..cert_basedir.." not only writable by its owner");
+ pctl.show_warning("The directory %s not only writable by its owner", cert_basedir);
return 1;
end
local subcmd = table.remove(arg, 1);