From 03eeb56d06aa44827c7881c2c1e6acc46312abdc Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 15 Feb 2017 15:29:37 +0100 Subject: migrator: Unexpand whitespace --- tools/migration/prosody-migrator.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/migration/prosody-migrator.lua b/tools/migration/prosody-migrator.lua index 8560ddb5..85234745 100644 --- a/tools/migration/prosody-migrator.lua +++ b/tools/migration/prosody-migrator.lua @@ -5,11 +5,11 @@ CFG_CONFIGDIR=os.getenv("PROSODY_CFGDIR"); -- Substitute ~ with path to home directory in paths if CFG_CONFIGDIR then - CFG_CONFIGDIR = CFG_CONFIGDIR:gsub("^~", os.getenv("HOME")); + CFG_CONFIGDIR = CFG_CONFIGDIR:gsub("^~", os.getenv("HOME")); end if CFG_SOURCEDIR then - CFG_SOURCEDIR = CFG_SOURCEDIR:gsub("^~", os.getenv("HOME")); + CFG_SOURCEDIR = CFG_SOURCEDIR:gsub("^~", os.getenv("HOME")); end local default_config = (CFG_CONFIGDIR or ".").."/migrator.cfg.lua"; -- cgit v1.2.3 From 374f61a26b937601159ac2422a90ff9ae36139bc Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 15 Feb 2017 15:30:19 +0100 Subject: migrator: Fix argument parsing --- tools/migration/prosody-migrator.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/migration/prosody-migrator.lua b/tools/migration/prosody-migrator.lua index 85234745..7ceff721 100644 --- a/tools/migration/prosody-migrator.lua +++ b/tools/migration/prosody-migrator.lua @@ -16,19 +16,18 @@ local default_config = (CFG_CONFIGDIR or ".").."/migrator.cfg.lua"; -- Command-line parsing local options = {}; -local handled_opts = 0; -for i = 1, #arg do +local i = 1; +while arg[i] do if arg[i]:sub(1,2) == "--" then local opt, val = arg[i]:match("([%w-]+)=?(.*)"); if opt then options[(opt:sub(3):gsub("%-", "_"))] = #val > 0 and val or true; end - handled_opts = i; + table.remove(arg, i); else - break; + i = i + 1; end end -table.remove(arg, handled_opts); if CFG_SOURCEDIR then package.path = CFG_SOURCEDIR.."/?.lua;"..package.path; -- cgit v1.2.3 From 49ae1e60fdc5f1a31b4c1ae5027a3fec76095a90 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 15 Feb 2017 15:30:34 +0100 Subject: migrator: Fix missing word --- tools/migration/prosody-migrator.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/migration/prosody-migrator.lua b/tools/migration/prosody-migrator.lua index 7ceff721..6cff9f67 100644 --- a/tools/migration/prosody-migrator.lua +++ b/tools/migration/prosody-migrator.lua @@ -47,7 +47,7 @@ config = {}; local config_env = setmetatable({}, { __index = function(t, k) return function(tbl) config[k] = tbl; end; end }); local config_chunk, err = envloadfile(config_file, config_env); if not config_chunk then - print("There was an error loading the config file, check the file exists"); + print("There was an error loading the config file, check that the file exists"); print("and that the syntax is correct:"); print("", err); os.exit(1); -- cgit v1.2.3 From d6cc41b9ec7689bd58244744db820f9eb96989be Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 15 Feb 2017 22:59:19 +0100 Subject: mod_saslauth: Cache logger in local for less typing --- plugins/mod_saslauth.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index 9917c303..f7803bc9 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -223,6 +223,7 @@ local bind_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-bind' }; local xmpp_session_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-session' }; module:hook("stream-features", function(event) local origin, features = event.origin, event.features; + local log = origin.log or log; if not origin.username then if secure_auth_only and not origin.secure then return; @@ -251,7 +252,7 @@ module:hook("stream-features", function(event) if mechanisms[1] then features:add_child(mechanisms); else - (origin.log or log)("warn", "No SASL mechanisms to offer"); + log("warn", "No SASL mechanisms to offer"); end else features:tag("bind", bind_attr):tag("required"):up():up(); -- cgit v1.2.3 From bb3cc61b4fb82088dde9d6ae8a492dede5803892 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 15 Feb 2017 23:00:03 +0100 Subject: mod_saslauth: Improve logging as to why when SASL is not offered --- plugins/mod_saslauth.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index f7803bc9..b9ce6d60 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -226,6 +226,7 @@ module:hook("stream-features", function(event) local log = origin.log or log; if not origin.username then if secure_auth_only and not origin.secure then + log("debug", "Not offering authentication on insecure connection"); return; end local sasl_handler = usermanager_get_sasl_handler(module.host, origin) @@ -244,15 +245,22 @@ module:hook("stream-features", function(event) end end local mechanisms = st.stanza("mechanisms", mechanisms_attr); - for mechanism in pairs(sasl_handler:mechanisms()) do - if (not disabled_mechanisms:contains(mechanism)) and (origin.secure or not insecure_mechanisms:contains(mechanism)) then + local sasl_mechanisms = sasl_handler:mechanisms() + for mechanism in pairs(sasl_mechanisms) do + if disabled_mechanisms:contains(mechanism) then + log("debug", "Not offering disabled mechanism %s", mechanism); + elseif not origin.secure and insecure_mechanisms:contains(mechanism) then + log("debug", "Not offering mechanism %s on insecure connection", mechanism); + else mechanisms:tag("mechanism"):text(mechanism):up(); end end if mechanisms[1] then features:add_child(mechanisms); + elseif not next(sasl_mechanisms) then + log("warn", "No available SASL mechanisms, verify that the configured authentication module is working"); else - log("warn", "No SASL mechanisms to offer"); + log("warn", "All available authentication mechanisms are either disabled or not suitable for an insecure connection"); end else features:tag("bind", bind_attr):tag("required"):up():up(); -- cgit v1.2.3 From 7b00dce835bd682365798bc2573985f03ad7315d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 15 Feb 2017 23:03:22 +0100 Subject: mod_tls: Log reasons for not being able to do TLS --- plugins/mod_tls.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/mod_tls.lua b/plugins/mod_tls.lua index 2b265032..3903a760 100644 --- a/plugins/mod_tls.lua +++ b/plugins/mod_tls.lua @@ -63,6 +63,7 @@ end local function can_do_tls(session) if not session.conn.starttls then + session.log("debug", "Underlying connection does not support STARTTLS"); return false; elseif session.ssl_ctx ~= nil then return session.ssl_ctx; @@ -77,6 +78,7 @@ local function can_do_tls(session) session.ssl_ctx = ssl_ctx_s2sout; session.ssl_cfg = ssl_cfg_s2sout; else + session.log("debug", "Unknown session type, don't know which TLS context to use"); return false; end if not session.ssl_ctx then -- cgit v1.2.3 From 7d79421b6e703c62382534db614a8da2a3e91ff3 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 15 Feb 2017 23:04:44 +0100 Subject: mod_saslauth: Ignore shadowing of logger [luacheck] --- plugins/mod_saslauth.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index b9ce6d60..68c4fe64 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -5,7 +5,7 @@ -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. -- - +-- luacheck: ignore 431/log local st = require "util.stanza"; -- cgit v1.2.3