# HG changeset patch # User Kim Alvefur # Date 1488464252 -3600 # Node ID 6940d6db970be1382e80395f1a5f97d48711abaf # Parent 72b6d5ab4137f87e91c23b639b13351f7c41575f mod_saslauth: Log SASL failure reason diff -r 72b6d5ab4137 -r 6940d6db970b plugins/mod_saslauth.lua --- a/plugins/mod_saslauth.lua Tue Feb 21 18:54:44 2017 +0100 +++ b/plugins/mod_saslauth.lua Thu Mar 02 15:17:32 2017 +0100 @@ -96,8 +96,19 @@ module:hook_stanza(xmlns_sasl, "failure", function (session, stanza) if session.type ~= "s2sout_unauthed" or session.external_auth ~= "attempting" then return; end - module:log("info", "SASL EXTERNAL with %s failed", session.to_host) - -- TODO: Log the failure reason + local text = stanza:get_child_text("text"); + local condition = "unknown-condition"; + for child in stanza:childtags() do + if child.name ~= "text" then + condition = child.name; + break; + end + end + if text and condition then + condition = connection .. ": " .. text; + end + module:log("info", "SASL EXTERNAL with %s failed: %s", session.to_host, condition); + session.external_auth = "failed" end, 500)