X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fsasl_cyrus.lua;h=b42bee07e1860f89f95508bd14665a68a0b21cc2;hb=fc12470af517089ec7c10fd191498c7d579c7362;hp=0ed8161ec0a7afb9bf213c33332d1064709212de;hpb=9bf9919993f0fda580aabc8691e45adad7e364d0;p=prosody.git diff --git a/util/sasl_cyrus.lua b/util/sasl_cyrus.lua index 0ed8161e..b42bee07 100644 --- a/util/sasl_cyrus.lua +++ b/util/sasl_cyrus.lua @@ -31,12 +31,25 @@ module "sasl_cyrus" local method = {}; method.__index = method; - -pcall(cyrussasl.server_init, "prosody") +local initialized = false; + +local function init(service_name) + if not initialized then + local st, errmsg = pcall(cyrussasl.server_init, service_name); + if st then + initialized = true; + else + log("error", "Failed to initialize CyrusSASL: %s", errmsg); + 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)