From b70edb66cfffd37c64d5c36c3e9b50571a70807e Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 18 Sep 2017 17:06:35 +0200 Subject: prosodyctl: Use all enabled hosts if no hostnames passed to cert import --- prosodyctl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/prosodyctl b/prosodyctl index ce81877d..353253ec 100755 --- a/prosodyctl +++ b/prosodyctl @@ -870,8 +870,15 @@ function cert_commands.import(arg) while arg[1] and prosody.hosts[ arg[1] ] do table.insert(hostnames, table.remove(arg, 1)); end + if hostnames[1] == nil then + for host in pairs(prosody.hosts) do + if host ~= "*" and config.get(host, "enabled") ~= false then + table.insert(hostnames, host); + end + end + end if not arg[1] or arg[1] == "--help" then -- Probably forgot the path - show_usage("cert import HOSTNAME [HOSTNAME+] /path/to/certs [/other/paths/]+", + show_usage("cert import [HOSTNAME+] /path/to/certs [/other/paths/]+", "Copies certificates to "..cert_basedir); return 1; end -- cgit v1.2.3 From e7f9f1976be8eeb8b287c42182c3fb499252fff7 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 18 Sep 2017 17:08:31 +0200 Subject: prosodyctl: Only demand a hostname argument to cert commands other than import --- prosodyctl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/prosodyctl b/prosodyctl index 353253ec..74bb2ad8 100755 --- a/prosodyctl +++ b/prosodyctl @@ -939,13 +939,15 @@ function commands.cert(arg) end local subcmd = table.remove(arg, 1); if type(cert_commands[subcmd]) == "function" then - if not arg[1] then - show_message"You need to supply at least one hostname" - arg = { "--help" }; - end - if arg[1] ~= "--help" and not hosts[arg[1]] then - show_message(error_messages["no-such-host"]); - return 1; + if subcmd ~= "import" then -- hostnames are optional for import + if not arg[1] then + show_message"You need to supply at least one hostname" + arg = { "--help" }; + end + if arg[1] ~= "--help" and not hosts[arg[1]] then + show_message(error_messages["no-such-host"]); + return 1; + end end return cert_commands[subcmd](arg); elseif subcmd == "check" then -- cgit v1.2.3 From d578e7d08f61171dfe97635ddcc4a119663313b9 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 18 Sep 2017 18:28:29 +0200 Subject: prosodyctl: cert import: Use env variable set by certbot if invoked as post-renew hook --- prosodyctl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/prosodyctl b/prosodyctl index 74bb2ad8..cdcd25d9 100755 --- a/prosodyctl +++ b/prosodyctl @@ -871,10 +871,17 @@ function cert_commands.import(arg) table.insert(hostnames, table.remove(arg, 1)); end if hostnames[1] == nil then - for host in pairs(prosody.hosts) do - if host ~= "*" and config.get(host, "enabled") ~= false then + local domains = os.getenv"RENEWED_DOMAINS"; -- Set if invoked via certbot + if domains then + for host in domains:gmatch("%S+") do table.insert(hostnames, host); end + else + for host in pairs(prosody.hosts) do + if host ~= "*" and config.get(host, "enabled") ~= false then + table.insert(hostnames, host); + end + end end end if not arg[1] or arg[1] == "--help" then -- Probably forgot the path -- cgit v1.2.3 From 32a12191888eb70359daf93289e0ec335aada6fd Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 18 Sep 2017 18:35:01 +0200 Subject: mod_mam: Log a message when not archiving because it only had ignored tags --- plugins/mod_mam/mod_mam.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index 298c770c..6134fc66 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -294,6 +294,7 @@ local function message_handler(event, c2s) end end); if #clone_for_storage.tags == 0 then + log("debug", "Not archiving stanza: %s (empty when stripped)", stanza:top_tag()); return; end else -- cgit v1.2.3 From d16959ce161a09eaf3bd16e621fa63cfc0a70a50 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 20 Sep 2017 14:42:21 +0100 Subject: hostmanager: Add support for 'disco_hidden' option to hide hosts from disco#items (thanks Ge0rG) --- core/hostmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/hostmanager.lua b/core/hostmanager.lua index 53c1cd4e..643724c2 100644 --- a/core/hostmanager.lua +++ b/core/hostmanager.lua @@ -100,7 +100,7 @@ function activate(host, host_config) host_session.type = "component"; end hosts[host] = host_session; - if not host:match("[@/]") then + if not host_config.disco_hidden and not host:match("[@/]") then disco_items:set(host:match("%.(.*)") or "*", host, host_config.name or true); end for option_name in pairs(host_config) do -- cgit v1.2.3 From 1574b7a818dfd40ba2fd5cb3ebf8687ba5a37a4d Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 19 Sep 2017 23:38:08 +0200 Subject: mod_mam: Also return the preferences on set Fixes #995. --- plugins/mod_mam/mod_mam.lua | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index 6134fc66..7499c9ea 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -67,20 +67,18 @@ end module:hook("iq/self/"..xmlns_mam..":prefs", function(event) local origin, stanza = event.origin, event.stanza; local user = origin.username; - if stanza.attr.type == "get" then - local prefs = prefs_to_stanza(get_prefs(user)); - local reply = st.reply(stanza):add_child(prefs); - origin.send(reply); - else -- type == "set" + if stanza.attr.type == "set" then local new_prefs = stanza:get_child("prefs", xmlns_mam); local prefs = prefs_from_stanza(new_prefs); local ok, err = set_prefs(user, prefs); if not ok then origin.send(st.error_reply(stanza, "cancel", "internal-server-error", "Error storing preferences: "..tostring(err))); - else - origin.send(st.reply(stanza)); + return true; end end + local prefs = prefs_to_stanza(get_prefs(user)); + local reply = st.reply(stanza):add_child(prefs); + origin.send(reply); return true; end); -- cgit v1.2.3