Comparison

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
comparison
equal deleted inserted replaced
6426:e5945fb5b71f 6427:7653bbd5247e
24 local xmlns_sasl ='urn:ietf:params:xml:ns:xmpp-sasl'; 24 local xmlns_sasl ='urn:ietf:params:xml:ns:xmpp-sasl';
25 local xmlns_bind ='urn:ietf:params:xml:ns:xmpp-bind'; 25 local xmlns_bind ='urn:ietf:params:xml:ns:xmpp-bind';
26 26
27 local function build_reply(status, ret, err_msg) 27 local function build_reply(status, ret, err_msg)
28 local reply = st.stanza(status, {xmlns = xmlns_sasl}); 28 local reply = st.stanza(status, {xmlns = xmlns_sasl});
29 if status == "challenge" then 29 if status == "failure" then
30 --log("debug", "CHALLENGE: %s", ret or "");
31 reply:text(base64.encode(ret or ""));
32 elseif status == "failure" then
33 reply:tag(ret):up(); 30 reply:tag(ret):up();
34 if err_msg then reply:tag("text"):text(err_msg); end 31 if err_msg then reply:tag("text"):text(err_msg); end
35 elseif status == "success" then 32 elseif status == "challenge" or status == "success" then
36 --log("debug", "SUCCESS: %s", ret or ""); 33 if ret == "" then
37 reply:text(base64.encode(ret or "")); 34 reply:text("=")
35 elseif ret then
36 reply:text(base64.encode(ret));
37 end
38 else 38 else
39 module:log("error", "Unknown sasl status: %s", status); 39 module:log("error", "Unknown sasl status: %s", status);
40 end 40 end
41 return reply; 41 return reply;
42 end 42 end