From 1ef7f18752399e71f6cfd58fa95769fb6600d45b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 6 Dec 2015 23:47:47 +0100 Subject: core.usermanager: Return as soon as possible once admin status is known --- core/usermanager.lua | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/core/usermanager.lua b/core/usermanager.lua index d874447d..0d8d7f91 100644 --- a/core/usermanager.lua +++ b/core/usermanager.lua @@ -111,7 +111,6 @@ local function is_admin(jid, host) if host and not hosts[host] then return false; end if type(jid) ~= "string" then return false; end - local is_admin; jid = jid_bare(jid); host = host or "*"; @@ -122,8 +121,7 @@ local function is_admin(jid, host) if type(host_admins) == "table" then for _,admin in ipairs(host_admins) do if jid_prep(admin) == jid then - is_admin = true; - break; + return true; end end elseif host_admins then @@ -131,12 +129,11 @@ local function is_admin(jid, host) end end - if not is_admin and global_admins then + if global_admins then if type(global_admins) == "table" then for _,admin in ipairs(global_admins) do if jid_prep(admin) == jid then - is_admin = true; - break; + return true; end end elseif global_admins then @@ -145,10 +142,10 @@ local function is_admin(jid, host) end -- Still not an admin, check with auth provider - if not is_admin and host ~= "*" and hosts[host].users and hosts[host].users.is_admin then - is_admin = hosts[host].users.is_admin(jid); + if host ~= "*" and hosts[host].users and hosts[host].users.is_admin then + return hosts[host].users.is_admin(jid); end - return is_admin or false; + return false; end return { -- cgit v1.2.3 From 2458f50dcae3f60055a9f79e8a9c91dd1b28fc46 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 8 Dec 2015 20:12:38 +0100 Subject: portmanager: Lower the priority of module-supplied TLS options --- core/portmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/portmanager.lua b/core/portmanager.lua index 9f95077a..ad1a0be3 100644 --- a/core/portmanager.lua +++ b/core/portmanager.lua @@ -111,10 +111,10 @@ local function activate(service_name) local global_ssl_config = config.get("*", "ssl") or {}; local prefix_ssl_config = config.get("*", config_prefix.."ssl") or global_ssl_config; ssl, err = certmanager.create_context(service_info.name.." port "..port, "server", - service_info.ssl_config or {}, prefix_ssl_config[interface], prefix_ssl_config[port], prefix_ssl_config, + service_info.ssl_config or {}, global_ssl_config[interface], global_ssl_config[port]); if not ssl then -- cgit v1.2.3 From db9b82199fdc9ea3fee6c032c03bebcdd669f4a0 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 8 Dec 2015 20:16:49 +0100 Subject: util.dataforms: Track which fields are included in a form --- util/dataforms.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/dataforms.lua b/util/dataforms.lua index 05846ab3..79b4d1a4 100644 --- a/util/dataforms.lua +++ b/util/dataforms.lua @@ -118,6 +118,7 @@ local field_readers = {}; function form_t.data(layout, stanza) local data = {}; local errors = {}; + local present = {}; for _, field in ipairs(layout) do local tag; @@ -133,6 +134,7 @@ function form_t.data(layout, stanza) errors[field.name] = "Required value missing"; end else + present[field.name] = true; local reader = field_readers[field.type]; if reader then data[field.name], errors[field.name] = reader(tag, field.required); @@ -140,9 +142,9 @@ function form_t.data(layout, stanza) end end if next(errors) then - return data, errors; + return data, errors, present; end - return data; + return data, nil, present; end local function simple_text(field_tag, required) -- cgit v1.2.3 From 64c33caee65e8e585c89a836247ba55b2a63245c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 8 Dec 2015 20:19:30 +0100 Subject: MUC: Process only options that are included in a form (Fixes #521) --- plugins/muc/muc.lib.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 48231c37..20e91192 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -674,7 +674,7 @@ function room_mt:process_form(origin, stanza) if form.attr.type == "cancel" then origin.send(st.reply(stanza)); return; end if form.attr.type ~= "submit" then origin.send(st.error_reply(stanza, "cancel", "bad-request", "Not a submitted form")); return; end - local fields = self:get_form_layout(stanza.attr.from):data(form); + local fields, errors, present = self:get_form_layout(stanza.attr.from):data(form); if fields.FORM_TYPE ~= "http://jabber.org/protocol/muc#roomconfig" then origin.send(st.error_reply(stanza, "cancel", "bad-request", "Form is not of type room configuration")); return; @@ -683,8 +683,8 @@ function room_mt:process_form(origin, stanza) local changed = {}; local function handle_option(name, field, allowed) - local new = fields[field]; - if new == nil then return; end + local new, err, included = fields[field], errors[field], present[field]; + if not included then return; end if allowed and not allowed[new] then return; end if new == self["get_"..name](self) then return; end changed[name] = true; -- cgit v1.2.3 From fe3404124e3dc2ad8284159e72d74842b9f41869 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 9 Dec 2015 16:33:43 +0100 Subject: MUC: Fix previous commit --- plugins/muc/muc.lib.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 20e91192..6f21ec3a 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -683,8 +683,8 @@ function room_mt:process_form(origin, stanza) local changed = {}; local function handle_option(name, field, allowed) - local new, err, included = fields[field], errors[field], present[field]; - if not included then return; end + if not present[field] then return; end + local new = fields[field]; if allowed and not allowed[new] then return; end if new == self["get_"..name](self) then return; end changed[name] = true; -- cgit v1.2.3 From 60ccccb95986f320717601ba0c485832d2e753fd Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 10 Dec 2015 15:16:49 +0100 Subject: mod_compression: Remove FIXMEs, mod_c2s and mod_s2s checks if TLS compression is used and sets a flag since 969e0a054795 --- plugins/mod_compression.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/mod_compression.lua b/plugins/mod_compression.lua index da55e5bb..d49e3880 100644 --- a/plugins/mod_compression.lua +++ b/plugins/mod_compression.lua @@ -27,14 +27,12 @@ end module:hook("stream-features", function(event) local origin, features = event.origin, event.features; if not origin.compressed and origin.type == "c2s" then - -- FIXME only advertise compression support when TLS layer has no compression enabled features:add_child(compression_stream_feature); end end); module:hook("s2s-stream-features", function(event) local origin, features = event.origin, event.features; - -- FIXME only advertise compression support when TLS layer has no compression enabled if not origin.compressed and origin.type == "s2sin" then features:add_child(compression_stream_feature); end -- cgit v1.2.3 From ed3b57fd194ee4eebfccf5f09e3ac55011eda5a1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 10 Dec 2015 13:33:14 +0000 Subject: prosody: Don't silently ignore unknown command-line options --- prosody | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/prosody b/prosody index 47998583..a2cb0e6c 100755 --- a/prosody +++ b/prosody @@ -43,6 +43,12 @@ if CFG_DATADIR then end end +if #arg > 0 and arg[1] ~= "--config" then + print("Unknown command-line option: "..tostring(arg[1])); + print("Perhaps you meant to use prosodyctl instead?"); + return 1; +end + -- Global 'prosody' object local prosody = { events = require "util.events".new(); }; _G.prosody = prosody; -- cgit v1.2.3 From 9409b787dc7d6602836f43eeafee772b79afe6a4 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 10 Dec 2015 17:58:52 +0000 Subject: .luacheckrc: Whitelist import() global function --- .luacheckrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.luacheckrc b/.luacheckrc index bcce1155..590f9c37 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,5 +1,5 @@ cache = true -read_globals = { "prosody", "hosts" } +read_globals = { "prosody", "hosts", "import" } globals = { "_M" } allow_defined_top = true module = true -- cgit v1.2.3 From 7f8d1c0995b51435b4d6a4f5c7a5d5ed7ab5d8e2 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 10 Dec 2015 18:00:08 +0000 Subject: mod_admin_telnet: Add http:list() command to get info about current HTTP endpoints on the server --- plugins/mod_admin_telnet.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index 16bc786d..b77a1f56 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -282,6 +282,8 @@ end -- Session environment -- -- Anything in def_env will be accessible within the session as a global variable +--luacheck: ignore 212/self + def_env.server = {}; function def_env.server:insane_reload() @@ -1093,6 +1095,33 @@ function def_env.dns:cache() return true, "Cache:\n"..tostring(dns.cache()) end +def_env.http = {}; + +function def_env.http:list() + local print = self.session.print; + + for host in pairs(prosody.hosts) do + local http_apps = modulemanager.get_items("http-provider", host); + if #http_apps > 0 then + local http_host = module:context(host):get_option("http_host"); + print("HTTP endpoints on "..host..(http_host and (" (using "..http_host.."):") or ":")); + for _, provider in ipairs(http_apps) do + local url = module:context(host):http_url(provider.name); + print("", url); + end + print(""); + end + end + + local default_host = module:get_option("http_default_host"); + if not default_host then + print("HTTP requests to unknown hosts will return 404 Not Found"); + else + print("HTTP requests to unknown hosts will be handled by "..default_host); + end + return true; +end + ------------- function printbanner(session) -- cgit v1.2.3