Diff

util/sasl_cyrus.lua @ 3428:8a12ae696687

util.sasl_cyrus: Cleanup.
author Waqas Hussain <waqas20@gmail.com>
date Mon, 02 Aug 2010 18:54:16 +0500
parent 3426:37b9b8e171b9
child 3441:d4f89802cf1e
line wrap: on
line diff
--- a/util/sasl_cyrus.lua	Mon Aug 02 18:47:33 2010 +0500
+++ b/util/sasl_cyrus.lua	Mon Aug 02 18:54:16 2010 +0500
@@ -87,21 +87,17 @@
 
 -- create a new SASL object which can be used to authenticate clients
 function new(realm, service_name, app_name)
-	local sasl_i = {};
 
 	init(app_name or service_name);
 
-	sasl_i.realm = realm;
-	sasl_i.service_name = service_name;
-
 	local st, ret = pcall(cyrussasl.server_new, service_name, nil, realm, nil, nil)
-	if st then
-		sasl_i.cyrus = ret;
-	else
+	if not st then
 		log("error", "Creating SASL server connection failed: %s", ret);
 		return nil;
 	end
 
+	local sasl_i = { realm = realm, service_name = service_name, cyrus = ret };
+
 	if cyrussasl.set_canon_cb then
 		local c14n_cb = function (user)
 			local node = s_match(user, "^([^@]+)");
@@ -112,8 +108,7 @@
 	end
 
 	cyrussasl.setssf(sasl_i.cyrus, 0, 0xffffffff)
-	local s = setmetatable(sasl_i, method);
-	return s;
+	return setmetatable(sasl_i, method);
 end
 
 -- get a fresh clone with the same realm and service name