Changeset

2396:39b2523bcf44

first working version with Cyrus SASL support.
author jorj@jorj.org
date Wed, 23 Dec 2009 16:46:49 -0500
parents 2395:7d7618c21321
children 2397:da8d6ab0c8b4
files util/sasl_cyrus.lua
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/util/sasl_cyrus.lua	Wed Dec 23 16:45:03 2009 -0500
+++ b/util/sasl_cyrus.lua	Wed Dec 23 16:46:49 2009 -0500
@@ -25,6 +25,7 @@
 
 local print = print
 local pcall = pcall
+local s_match, s_gmatch = string.match, string.gmatch
 
 module "sasl_cyrus"
 
@@ -38,7 +39,7 @@
 	local sasl_i = {};
 	sasl_i.realm = realm;
 	sasl_i.service_name = service_name;
-	sasl_i.cyrus = cyrussasl.server_new(service_name, realm, realm, nil, nil)
+	sasl_i.cyrus = cyrussasl.server_new(service_name, nil, nil, nil, nil)
 	if sasl_i.cyrus == 0 then
 		log("error", "got NULL return value from server_new")
 		return nil;
@@ -62,7 +63,7 @@
 -- get a list of possible SASL mechanims to use
 function method:mechanisms()
 	local mechanisms = {}
-	local cyrus_mechs = cyrussasl.listmech(self.cyrus)
+	local cyrus_mechs = cyrussasl.listmech(self.cyrus, nil, "", " ", "")
 	for w in s_gmatch(cyrus_mechs, "%a+") do
 		mechanisms[w] = true;
 	end
@@ -73,17 +74,18 @@
 -- select a mechanism to use
 function method:select(mechanism)
 	self.mechanism = mechanism;
-	return not self.mechanisms[mechanisms];
+	return self.mechanisms[mechanism];
 end
 
 -- feed new messages to process into the library
 function method:process(message)
 	local err;
 	local data;
+
 	if self.mechanism then
-		err, data = cyrussasl.server_start(self.cyrus, self.mechanism, message)
+		err, data = cyrussasl.server_start(self.cyrus, self.mechanism, message or "")
 	else
-		err, data = cyrussasl.server_step(self.cyrus, message)
+		err, data = cyrussasl.server_step(self.cyrus, message or "")
 	end
 
 	self.username = cyrussasl.get_username(self.cyrus)