# HG changeset patch # User Matthew Wild # Date 1741268077 0 # Node ID fc97319ef48e485160c30b5151cbe804af59f7ab # Parent 18f560dcc9e324a3feee5916492521d4f32f1649 util.sasl: Preserve 'userdata' field between clones The :clean_clone() method is designed to provide a new cloned SASL handler, to be used when starting a fresh SASL negotiation on an existing connection. The userdata field is currently populated by mod_saslauth with the "read-only" information that the channel binding methods need to do their stuff. When :clean_clone() does not preserve this, it causes tracebacks in the cb profile handlers due to the property being nil. This does mean that SASL handlers should now not be reused (even when cloned) across different connections, if they ever could. diff -r 18f560dcc9e3 -r fc97319ef48e util/sasl.lua --- a/util/sasl.lua Sat Mar 01 16:19:43 2025 +0000 +++ b/util/sasl.lua Thu Mar 06 13:34:37 2025 +0000 @@ -67,7 +67,7 @@ end -- create a new SASL object which can be used to authenticate clients -local function new(realm, profile) +local function new(realm, profile, userdata) local mechanisms = profile.mechanisms; if not mechanisms then mechanisms = {}; @@ -80,7 +80,12 @@ end profile.mechanisms = mechanisms; end - return setmetatable({ profile = profile, realm = realm, mechs = mechanisms }, method); + return setmetatable({ + profile = profile, + realm = realm, + mechs = mechanisms, + userdata = userdata + }, method); end -- add a channel binding handler @@ -94,7 +99,7 @@ -- get a fresh clone with the same realm and profile function method:clean_clone() - return new(self.realm, self.profile) + return new(self.realm, self.profile, self.userdata) end -- get a list of possible SASL mechanisms to use