Changeset

2402:0f884bb1f08a

util.sasl_cyrus: Automatically initialize Cyrus SASL with the first used service name.
author Tobias Markmann <tm@ayena.de>
date Tue, 29 Dec 2009 01:03:37 +0100
parents 2401:dbfdcb75209a
children 2403:916482cdfb74
files util/sasl_cyrus.lua
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/util/sasl_cyrus.lua	Mon Dec 28 22:08:32 2009 +0100
+++ b/util/sasl_cyrus.lua	Tue Dec 29 01:03:37 2009 +0100
@@ -31,12 +31,22 @@
 
 local method = {};
 method.__index = method;
+local initialized = false;
 
-pcall(cyrussasl.server_init, "prosody")
+local function init(service_name)
+	if not initialized then
+		if pcall(cyrussasl.server_init, service_name) then
+			initialized = true;
+		end
+	end
+end
 
 -- create a new SASL object which can be used to authenticate clients
 function new(realm, service_name)
 	local sasl_i = {};
+	
+	init(service_name);
+	
 	sasl_i.realm = realm;
 	sasl_i.service_name = service_name;
 	sasl_i.cyrus = cyrussasl.server_new(service_name, nil, nil, nil, nil)