Changeset

7900:41f783d4e127

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Wed, 15 Feb 2017 23:05:03 +0100
parents 7892:f00943bbf84f (current diff) 7899:2b3d0ab67f7d (diff)
children 7909:428d4abee723
files
diffstat 3 files changed, 22 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_saslauth.lua	Tue Feb 14 23:42:11 2017 +0100
+++ b/plugins/mod_saslauth.lua	Wed Feb 15 23:05:03 2017 +0100
@@ -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";
@@ -223,8 +223,10 @@
 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
+			log("debug", "Not offering authentication on insecure connection");
 			return;
 		end
 		local sasl_handler = usermanager_get_sasl_handler(module.host, origin)
@@ -243,15 +245,22 @@
 			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
-			(origin.log or 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();
--- a/plugins/mod_tls.lua	Tue Feb 14 23:42:11 2017 +0100
+++ b/plugins/mod_tls.lua	Wed Feb 15 23:05:03 2017 +0100
@@ -63,6 +63,7 @@
 
 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 @@
 		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
--- a/tools/migration/prosody-migrator.lua	Tue Feb 14 23:42:11 2017 +0100
+++ b/tools/migration/prosody-migrator.lua	Wed Feb 15 23:05:03 2017 +0100
@@ -5,30 +5,29 @@
 
 -- 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";
 
 -- 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;
@@ -48,7 +47,7 @@
 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);