Software /
code /
prosody
Comparison
util/sasl_cyrus.lua @ 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 |
parent | 2401:dbfdcb75209a |
child | 2403:916482cdfb74 |
comparison
equal
deleted
inserted
replaced
2401:dbfdcb75209a | 2402:0f884bb1f08a |
---|---|
29 | 29 |
30 module "sasl_cyrus" | 30 module "sasl_cyrus" |
31 | 31 |
32 local method = {}; | 32 local method = {}; |
33 method.__index = method; | 33 method.__index = method; |
34 local initialized = false; | |
34 | 35 |
35 pcall(cyrussasl.server_init, "prosody") | 36 local function init(service_name) |
37 if not initialized then | |
38 if pcall(cyrussasl.server_init, service_name) then | |
39 initialized = true; | |
40 end | |
41 end | |
42 end | |
36 | 43 |
37 -- create a new SASL object which can be used to authenticate clients | 44 -- create a new SASL object which can be used to authenticate clients |
38 function new(realm, service_name) | 45 function new(realm, service_name) |
39 local sasl_i = {}; | 46 local sasl_i = {}; |
47 | |
48 init(service_name); | |
49 | |
40 sasl_i.realm = realm; | 50 sasl_i.realm = realm; |
41 sasl_i.service_name = service_name; | 51 sasl_i.service_name = service_name; |
42 sasl_i.cyrus = cyrussasl.server_new(service_name, nil, nil, nil, nil) | 52 sasl_i.cyrus = cyrussasl.server_new(service_name, nil, nil, nil, nil) |
43 if sasl_i.cyrus == 0 then | 53 if sasl_i.cyrus == 0 then |
44 log("error", "got NULL return value from server_new") | 54 log("error", "got NULL return value from server_new") |