From 02f19c0c1d7d0d94515e18b53529a0c2db081dce Mon Sep 17 00:00:00 2001 From: Badlop Date: Sat, 31 Jul 2010 01:08:11 +0200 Subject: [PATCH] Only start GSSAPI support when configured, and when esasl is found --- src/cyrsasl.erl | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/cyrsasl.erl b/src/cyrsasl.erl index 5eea407e9..baca05e1d 100644 --- a/src/cyrsasl.erl +++ b/src/cyrsasl.erl @@ -35,6 +35,7 @@ server_step/2]). -include("cyrsasl.hrl"). +-include("ejabberd.hrl"). %% @type saslmechanism() = {sasl_mechanism, Mechanism, Module, Require_Plain} %% Mechanism = string() @@ -73,12 +74,28 @@ start() -> ets:new(sasl_mechanism, [named_table, public, {keypos, #sasl_mechanism.mechanism}]), - cyrsasl_gssapi:start([]), cyrsasl_plain:start([]), cyrsasl_digest:start([]), cyrsasl_anonymous:start([]), + maybe_try_start_gssapi(), ok. +maybe_try_start_gssapi() -> + case os:getenv("KRB5_KTNAME") of + false -> + ok; + _String -> + try_start_gssapi() + end. + +try_start_gssapi() -> + case code:load_file(esasl) of + {module, _Module} -> + cyrsasl_gssapi:start([]); + {error, What} -> + ?ERROR_MSG("Support for GSSAPI not started because esasl.beam was not found: ~p", [What]) + end. + %% @spec (Mechanism, Module, Require_Plain) -> true %% Mechanism = string() %% Module = atom()