# HG changeset patch # User Matthew Wild # Date 1228677530 0 # Node ID 2255a2e84ddc973e903186deede44fc76be1aa06 # Parent 30655c5cc531d75fa93b1195a5b9e202c534983d# Parent 2538912d94bad7ff566f4376582cec00df83db89 Automated merge with http://waqas.ath.cx:8000/ diff -r 2538912d94ba -r 2255a2e84ddc plugins/mod_saslauth.lua --- a/plugins/mod_saslauth.lua Sun Dec 07 19:12:50 2008 +0000 +++ b/plugins/mod_saslauth.lua Sun Dec 07 19:18:50 2008 +0000 @@ -66,15 +66,14 @@ end end -local function password_callback(node, host, mechanism, raw_host) - log("host", host); - log("raw_host", raw_host); - local password = (datamanager.load(node, raw_host, "accounts") or {}).password; -- FIXME handle hashed passwords +local function password_callback(node, host, mechanism, decoder) + local password = (datamanager.load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords local func = function(x) return x; end; if password then if mechanism == "PLAIN" then return func, password; elseif mechanism == "DIGEST-MD5" then + if decoder then node, host, password = decoder(node), decoder(host), decoder(password); end return func, md5(node..":"..host..":"..password); end end diff -r 2538912d94ba -r 2255a2e84ddc util/sasl.lua --- a/util/sasl.lua Sun Dec 07 19:12:50 2008 +0000 +++ b/util/sasl.lua Sun Dec 07 19:18:50 2008 +0000 @@ -177,11 +177,10 @@ if not response["qop"] then response["qop"] = "auth" end if response["realm"] == nil then response["realm"] = "" end - local raw_realm = response["realm"]; + local decoder; if response["charset"] == nil then - response["username"] = latin1toutf8(response["username"]) - response["realm"] = utf8tolatin1ifpossible(response["realm"]) + decoder = utf8tolatin1ifpossible; elseif response["charset"] ~= "utf-8" then return "failure", "incorrect-encoding", "The client's response uses "..response["charset"].." for encoding with isn't supported by sasl.lua. Supported encodings are latin or utf-8." end @@ -197,7 +196,7 @@ --TODO maybe realm support self.username = response["username"] - local password_encoding, Y = self.password_handler(response["username"], response["realm"], "DIGEST-MD5", raw_realm) + local password_encoding, Y = self.password_handler(response["username"], response["realm"], "DIGEST-MD5", decoder) if Y == nil then return "failure", "not-authorized" elseif Y == false then return "failure", "account-disabled" end