Comparison

plugins/mod_saslauth.lua @ 2928:e6380fcaffda

mod_saslauth: Tidier code for SASL backend selection.
author Waqas Hussain <waqas20@gmail.com>
date Tue, 23 Mar 2010 20:17:46 +0500
parent 2927:c041495f0546
child 3061:c9f9b3964bb9
comparison
equal deleted inserted replaced
2927:c041495f0546 2928:e6380fcaffda
33 local xmlns_sasl ='urn:ietf:params:xml:ns:xmpp-sasl'; 33 local xmlns_sasl ='urn:ietf:params:xml:ns:xmpp-sasl';
34 local xmlns_bind ='urn:ietf:params:xml:ns:xmpp-bind'; 34 local xmlns_bind ='urn:ietf:params:xml:ns:xmpp-bind';
35 local xmlns_stanzas ='urn:ietf:params:xml:ns:xmpp-stanzas'; 35 local xmlns_stanzas ='urn:ietf:params:xml:ns:xmpp-stanzas';
36 36
37 local new_sasl; 37 local new_sasl;
38 if sasl_backend == "cyrus" then 38 if sasl_backend == "builtin" then
39 new_sasl = require "util.sasl".new;
40 elseif sasl_backend == "cyrus" then
39 prosody.unlock_globals(); --FIXME: Figure out why this is needed and 41 prosody.unlock_globals(); --FIXME: Figure out why this is needed and
40 -- why cyrussasl isn't caught by the sandbox 42 -- why cyrussasl isn't caught by the sandbox
41 local ok, cyrus = pcall(require, "util.sasl_cyrus"); 43 local ok, cyrus = pcall(require, "util.sasl_cyrus");
42 prosody.lock_globals(); 44 prosody.lock_globals();
43 if ok then 45 if ok then
47 end 49 end
48 else 50 else
49 module:log("error", "Failed to load Cyrus SASL because: %s", cyrus); 51 module:log("error", "Failed to load Cyrus SASL because: %s", cyrus);
50 error("Failed to load Cyrus SASL"); 52 error("Failed to load Cyrus SASL");
51 end 53 end
52 end 54 else
53 if not new_sasl then 55 module:log("error", "Unknown SASL backend: %s", sasl_backend);
54 if sasl_backend ~= "builtin" then 56 error("Unknown SASL backend");
55 module:log("error", "Unknown SASL backend: %s", sasl_backend);
56 error("Unknown SASL backend");
57 end
58 new_sasl = require "util.sasl".new;
59 end 57 end
60 58
61 local default_authentication_profile = { 59 local default_authentication_profile = {
62 plain = function(username, realm) 60 plain = function(username, realm)
63 local prepped_username = nodeprep(username); 61 local prepped_username = nodeprep(username);