aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-09-19 17:51:20 +0200
committerKim Alvefur <zash@zash.se>2015-09-19 17:51:20 +0200
commit9b97c52790a17ea25e0e7ab96fe62280e4dbfea8 (patch)
tree47cf9d27ab4a9fef0167cf77f3674b183d9837fc
parent26c4421db4127e1b62fbe90f027803bfc855f387 (diff)
parentf2c69ab1c34060bafbf172915bc8c160bb086af2 (diff)
downloadprosody-9b97c52790a17ea25e0e7ab96fe62280e4dbfea8.tar.gz
prosody-9b97c52790a17ea25e0e7ab96fe62280e4dbfea8.zip
Merge 0.10->trunk
-rw-r--r--plugins/mod_admin_telnet.lua10
-rwxr-xr-xprosodyctl24
2 files changed, 23 insertions, 11 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua
index 7523ec52..16b16e88 100644
--- a/plugins/mod_admin_telnet.lua
+++ b/plugins/mod_admin_telnet.lua
@@ -830,19 +830,19 @@ function def_env.s2s:close(from, to)
(session.close or s2smanager.destroy_session)(session);
count = count + 1 ;
end
- end
+ end
return true, "Closed "..count.." s2s session"..((count == 1 and "") or "s");
end
function def_env.s2s:closeall(host)
- local count = 0;
+ local count = 0;
local s2s_sessions = module:shared"/*/s2s/sessions";
for _,session in pairs(s2s_sessions) do
if not host or session.from_host == host or session.to_host == host then
session:close();
- count = count + 1;
- end
- end
+ count = count + 1;
+ end
+ end
if count == 0 then return false, "No sessions to close.";
else return true, "Closed "..count.." s2s session"..((count == 1 and "") or "s"); end
end
diff --git a/prosodyctl b/prosodyctl
index 0a4491bf..b23d395d 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -675,14 +675,26 @@ local lfs;
local cert_commands = {};
-local function ask_overwrite(filename)
- return lfs.attributes(filename) and not show_yesno("Overwrite "..filename .. "?");
+-- If a file already exists, ask if the user wants to use it or replace it
+-- Backups the old file if replaced
+local function use_existing(filename)
+ local attrs = lfs.attributes(filename);
+ if attrs then
+ if show_yesno(filename .. " exists, do you want to replace it? [y/n]") then
+ local backup = filename..".bkp~"..os.date("%FT%T", attrs.change);
+ os.rename(filename, backup);
+ show_message(filename.." backed up to "..backup);
+ else
+ -- Use the existing file
+ return true;
+ end
+ end
end
function cert_commands.config(arg)
if #arg >= 1 and arg[1] ~= "--help" then
local conf_filename = (CFG_DATADIR or "./certs") .. "/" .. arg[1] .. ".cnf";
- if ask_overwrite(conf_filename) then
+ if use_existing(conf_filename) then
return nil, conf_filename;
end
local conf = openssl.config.new();
@@ -730,7 +742,7 @@ end
function cert_commands.key(arg)
if #arg >= 1 and arg[1] ~= "--help" then
local key_filename = (CFG_DATADIR or "./certs") .. "/" .. arg[1] .. ".key";
- if ask_overwrite(key_filename) then
+ if use_existing(key_filename) then
return nil, key_filename;
end
os.remove(key_filename); -- This file, if it exists is unlikely to have write permissions
@@ -752,7 +764,7 @@ end
function cert_commands.request(arg)
if #arg >= 1 and arg[1] ~= "--help" then
local req_filename = (CFG_DATADIR or "./certs") .. "/" .. arg[1] .. ".req";
- if ask_overwrite(req_filename) then
+ if use_existing(req_filename) then
return nil, req_filename;
end
local _, key_filename = cert_commands.key({arg[1]});
@@ -770,7 +782,7 @@ end
function cert_commands.generate(arg)
if #arg >= 1 and arg[1] ~= "--help" then
local cert_filename = (CFG_DATADIR or "./certs") .. "/" .. arg[1] .. ".crt";
- if ask_overwrite(cert_filename) then
+ if use_existing(cert_filename) then
return nil, cert_filename;
end
local _, key_filename = cert_commands.key({arg[1]});