Changeset

338:6560fd0b77f5

mod_auth_dovecot: One mechanism per MECH command.
author Kim Alvefur <zash@zash.se>
date Sun, 13 Feb 2011 23:29:05 +0100
parents 337:beb5073b866a
children 339:5aa8229e8815
files mod_auth_dovecot/mod_auth_dovecot.lua
diffstat 1 files changed, 6 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mod_auth_dovecot/mod_auth_dovecot.lua	Wed Feb 09 21:08:31 2011 +0500
+++ b/mod_auth_dovecot/mod_auth_dovecot.lua	Sun Feb 13 23:29:05 2011 +0100
@@ -78,19 +78,15 @@
 					return false;
 				end
 			elseif first == "MECH" then
-				-- Mechanisms should include PLAIN
-				local ok = false;
-				for part in parts do
-					if part == "PLAIN" then
-						ok = true;
-					end
-				end
-				if not ok then
-					log("warn", "server doesn't support PLAIN mechanism. It supports '%s'", line);
+				local mech = parts();
+				supported_mechs[mech] = true;
+			elseif first == "DONE" then
+				-- We need PLAIN
+				if not supported_mechs.PLAIN then
+					log("warn", "server doesn't support PLAIN mechanism.");
 					provider:close();
 					return false;
 				end
-			elseif first == "DONE" then
 				done = true;
 			end
 		end