aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2009-12-29 01:03:37 +0100
committerTobias Markmann <tm@ayena.de>2009-12-29 01:03:37 +0100
commitd121f0332f23966cbfc701518d6ea8b6a0e09206 (patch)
tree228c906dea278dc6517ab5551e9c389677aa866f
parent9936532e18d408038aeb31cf7def7ccb6ee36694 (diff)
downloadprosody-d121f0332f23966cbfc701518d6ea8b6a0e09206.tar.gz
prosody-d121f0332f23966cbfc701518d6ea8b6a0e09206.zip
util.sasl_cyrus: Automatically initialize Cyrus SASL with the first used service name.
-rw-r--r--util/sasl_cyrus.lua12
1 files changed, 11 insertions, 1 deletions
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)