# HG changeset patch # User Kim Alvefur # Date 1732455779 -3600 # Node ID c7c17fac41b3a285bf069297f7cfbb80191d19bc # Parent 25b091cbb471cfe40d82d5fc7fb8dfc120dc41ab mod_sasl2_fast: Only copy SASL handler internals from util.sasl instance Prevents traceback in case the session sasl handler is missing the profile table, as may be the case with non-core sasl handlers. Thanks taba for reporting diff -r 25b091cbb471 -r c7c17fac41b3 mod_sasl2_fast/mod_sasl2_fast.lua --- a/mod_sasl2_fast/mod_sasl2_fast.lua Fri Nov 22 19:09:10 2024 +0000 +++ b/mod_sasl2_fast/mod_sasl2_fast.lua Sun Nov 24 14:42:59 2024 +0100 @@ -8,6 +8,11 @@ local now = require "util.time".now; local hash = require "util.hashes"; +local sasl_mt = getmetatable(sasl.new("", { mechanisms = {} })); +local function is_util_sasl(sasl_handler) + return getmetatable(sasl_handler) == sasl_mt; +end + module:depends("sasl2"); -- Tokens expire after 21 days by default @@ -113,9 +118,11 @@ local sasl_handler = get_sasl_handler(username); if not sasl_handler then return; end sasl_handler.fast_auth = true; -- For informational purposes - -- Copy channel binding info from primary SASL handler - sasl_handler.profile.cb = session.sasl_handler.profile.cb; - sasl_handler.userdata = session.sasl_handler.userdata; + -- Copy channel binding info from primary SASL handler if it's compatible + if is_util_sasl(session.sasl_handler) then + sasl_handler.profile.cb = session.sasl_handler.profile.cb; + sasl_handler.userdata = session.sasl_handler.userdata; + end -- Store this handler, in case we later want to use it for authenticating session.fast_sasl_handler = sasl_handler; local fast = st.stanza("fast", { xmlns = xmlns_fast });