From d121f0332f23966cbfc701518d6ea8b6a0e09206 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Tue, 29 Dec 2009 01:03:37 +0100 Subject: util.sasl_cyrus: Automatically initialize Cyrus SASL with the first used service name. --- util/sasl_cyrus.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'util/sasl_cyrus.lua') diff --git a/util/sasl_cyrus.lua b/util/sasl_cyrus.lua index 0ed8161e..fd192233 100644 --- a/util/sasl_cyrus.lua +++ b/util/sasl_cyrus.lua @@ -31,12 +31,22 @@ module "sasl_cyrus" 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) -- cgit v1.2.3