aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2025-03-06 13:34:37 +0000
committerMatthew Wild <mwild1@gmail.com>2025-03-06 13:34:37 +0000
commit86341e87d3402cfdd2f3fc9f39bd7d947ac99c17 (patch)
treea59fc611ad32bb69cc519956dd6cc5b05b701088
parent830f3e122c229b936bfd34bcbf22e5ed66544af8 (diff)
downloadprosody-86341e87d3402cfdd2f3fc9f39bd7d947ac99c17.tar.gz
prosody-86341e87d3402cfdd2f3fc9f39bd7d947ac99c17.zip
util.sasl: Preserve 'userdata' field between clonesorigin/13.013.0
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.
-rw-r--r--util/sasl.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/util/sasl.lua b/util/sasl.lua
index c3c22a1c..dc11d426 100644
--- a/util/sasl.lua
+++ b/util/sasl.lua
@@ -67,7 +67,7 @@ local function registerMechanism(name, backends, f, cb_backends)
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 @@ local function new(realm, profile)
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 @@ end
-- 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