aboutsummaryrefslogtreecommitdiffstats
path: root/prosodyctl
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-09-29 13:45:03 +0200
committerKim Alvefur <zash@zash.se>2017-09-29 13:45:03 +0200
commitca622317f100d67023e2088179011eb61a243a2d (patch)
treecd04cb8a03e077a91511ed8d509a4e2e83588628 /prosodyctl
parentdb450adf9e7f6dbb96cddb15a8b929f367435981 (diff)
parent37d1497aedaf666ed0a1c4d5eeb47c54b1efd98c (diff)
downloadprosody-ca622317f100d67023e2088179011eb61a243a2d.tar.gz
prosody-ca622317f100d67023e2088179011eb61a243a2d.zip
Merge 0.10->trunk
Diffstat (limited to 'prosodyctl')
-rwxr-xr-xprosodyctl29
1 files changed, 18 insertions, 11 deletions
diff --git a/prosodyctl b/prosodyctl
index 94d3a4e5..02237082 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -91,13 +91,13 @@ do
print("\n");
print("**************************");
if level == "parser" then
- print("A problem occured while reading the config file "..(CFG_CONFIGDIR or ".").."/prosody.cfg.lua");
+ print("A problem occured while reading the config file "..filename);
local err_line, err_message = tostring(err):match("%[string .-%]:(%d*): (.*)");
print("Error"..(err_line and (" on line "..err_line) or "")..": "..(err_message or tostring(err)));
print("");
elseif level == "file" then
print("Prosody was unable to find the configuration file.");
- print("We looked for: "..(CFG_CONFIGDIR or ".").."/prosody.cfg.lua");
+ print("We looked for: "..filename);
print("A sample config file is included in the Prosody download called prosody.cfg.lua.dist");
print("Copy or rename it to prosody.cfg.lua and edit as necessary.");
end
@@ -162,6 +162,17 @@ if have_pposix and pposix then
if not switched_user then
-- Boo!
print("Warning: Couldn't switch to Prosody user/group '"..tostring(desired_user).."'/'"..tostring(desired_group).."': "..tostring(err));
+ else
+ -- Make sure the Prosody user can read the config
+ local conf, err, errno = io.open(ENV_CONFIG);
+ if conf then
+ conf:close();
+ else
+ print("The config file is not readable by the '"..desired_user.."' user.");
+ print("Prosody will not be able to read it.");
+ print("Error was "..err);
+ os.exit(1);
+ end
end
end
@@ -892,18 +903,14 @@ function cert_commands.import(arg)
owner = config.get("*", "prosody_user") or "prosody";
group = config.get("*", "prosody_group") or owner;
end
+ local cm = require "core.certmanager";
local imported = {};
for _, host in ipairs(hostnames) do
for _, dir in ipairs(arg) do
- if lfs.attributes(dir .. "/" .. host .. "/fullchain.pem")
- and lfs.attributes(dir .. "/" .. host .. "/privkey.pem") then
- copy(dir .. "/" .. host .. "/fullchain.pem", cert_basedir .. "/" .. host .. ".crt", nil, owner, group);
- copy(dir .. "/" .. host .. "/privkey.pem", cert_basedir .. "/" .. host .. ".key", "0377", owner, group);
- table.insert(imported, host);
- elseif lfs.attributes(dir .. "/" .. host .. ".crt")
- and lfs.attributes(dir .. "/" .. host .. ".key") then
- copy(dir .. "/" .. host .. ".crt", cert_basedir .. "/" .. host .. ".crt", nil, owner, group);
- copy(dir .. "/" .. host .. ".key", cert_basedir .. "/" .. host .. ".key", "0377", owner, group);
+ local paths = cm.find_cert(dir, host);
+ if paths then
+ copy(paths.certificate, cert_basedir .. "/" .. host .. ".crt", nil, owner, group);
+ copy(paths.key, cert_basedir .. "/" .. host .. ".key", "0377", owner, group);
table.insert(imported, host);
else
-- TODO Say where we looked