Diff

plugins/mod_saslauth.lua @ 6427:7653bbd5247e

mod_saslauth: Fix encoding of missing vs empty SASL reply messages
author Kim Alvefur <zash@zash.se>
date Tue, 23 Sep 2014 19:46:29 +0200
parent 6425:436a670a0189
child 6487:edc63dc72566
line wrap: on
line diff
--- a/plugins/mod_saslauth.lua	Tue Sep 23 19:41:10 2014 +0200
+++ b/plugins/mod_saslauth.lua	Tue Sep 23 19:46:29 2014 +0200
@@ -26,15 +26,15 @@
 
 local function build_reply(status, ret, err_msg)
 	local reply = st.stanza(status, {xmlns = xmlns_sasl});
-	if status == "challenge" then
-		--log("debug", "CHALLENGE: %s", ret or "");
-		reply:text(base64.encode(ret or ""));
-	elseif status == "failure" then
+	if status == "failure" then
 		reply:tag(ret):up();
 		if err_msg then reply:tag("text"):text(err_msg); end
-	elseif status == "success" then
-		--log("debug", "SUCCESS: %s", ret or "");
-		reply:text(base64.encode(ret or ""));
+	elseif status == "challenge" or status == "success" then
+		if ret == "" then
+			reply:text("=")
+		elseif ret then
+			reply:text(base64.encode(ret));
+		end
 	else
 		module:log("error", "Unknown sasl status: %s", status);
 	end