# HG changeset patch # User Waqas Hussain # Date 1266184267 -18000 # Node ID 333d7e2033b21e1eaf2faa8e35f009ddbbd11258 # Parent b083a667e3be95ee0d6bc6dc301e786b45f66c6c mod_saslauth: Warn and fallback gracefully when Cyrus SASL is requested, but missing. diff -r b083a667e3be -r 333d7e2033b2 plugins/mod_saslauth.lua --- a/plugins/mod_saslauth.lua Sun Feb 14 20:47:09 2010 +0000 +++ b/plugins/mod_saslauth.lua Mon Feb 15 02:51:07 2010 +0500 @@ -34,13 +34,20 @@ local xmlns_bind ='urn:ietf:params:xml:ns:xmpp-bind'; local xmlns_stanzas ='urn:ietf:params:xml:ns:xmpp-stanzas'; -local new_sasl +local new_sasl; if sasl_backend == "cyrus" then - local cyrus_new = require "util.sasl_cyrus".new; - new_sasl = function(realm) - return cyrus_new(realm, module:get_option("cyrus_service_name") or "xmpp"); + local cyrus, err = pcall(require, "util.sasl_cyrus"); + if cyrus then + local cyrus_new = cyrus.new; + new_sasl = function(realm) + return cyrus_new(realm, module:get_option("cyrus_service_name") or "xmpp"); + end + else + sasl_backend = "builtin"; + module:log("warn", "Failed to load Cyrus SASL, falling back to builtin auth mechanisms"); end -else +end +if not new_sasl then if sasl_backend ~= "builtin" then module:log("warn", "Unknown SASL backend %s", sasl_backend); end; new_sasl = require "util.sasl".new; end