25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01:00

* src/extauth.erl: When the extauth call fails or timeouts, deny

authorization. Use two timeouts: 60s for script initialization and
10s for regular calls. (thanks to Kevin Crosbie from
Ravenpack) (EJAB-627)

SVN Revision: 1673
This commit is contained in:
Badlop 2008-11-06 15:36:49 +00:00
parent 8cdebd485a
commit 02d68146bd
2 changed files with 19 additions and 9 deletions

View File

@ -1,3 +1,10 @@
2008-11-06 Badlop <badlop@process-one.net>
* src/extauth.erl: When the extauth call fails or timeouts, deny
authorization. Use two timeouts: 60s for script initialization and
10s for regular calls. (thanks to Kevin Crosbie from
Ravenpack) (EJAB-627)
2008-11-03 Alexey Shchepin <alexey@process-one.net> 2008-11-03 Alexey Shchepin <alexey@process-one.net>
* src/ejabberd_c2s.erl: Disable zlib when STARTTLS is required * src/ejabberd_c2s.erl: Disable zlib when STARTTLS is required

View File

@ -32,7 +32,8 @@
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-define(CALL_TIMEOUT, 30000). % Timeout is in milliseconds: 30 seconds == 30000 -define(INIT_TIMEOUT, 60000). % Timeout is in milliseconds: 60 seconds == 60000
-define(CALL_TIMEOUT, 10000). % Timeout is in milliseconds: 10 seconds == 10000
start(Host, ExtPrg) -> start(Host, ExtPrg) ->
spawn(?MODULE, init, [Host, ExtPrg]). spawn(?MODULE, init, [Host, ExtPrg]).
@ -41,7 +42,7 @@ init(Host, ExtPrg) ->
register(gen_mod:get_module_proc(Host, eauth), self()), register(gen_mod:get_module_proc(Host, eauth), self()),
process_flag(trap_exit,true), process_flag(trap_exit,true),
Port = open_port({spawn, ExtPrg}, [{packet,2}]), Port = open_port({spawn, ExtPrg}, [{packet,2}]),
loop(Port). loop(Port, ?INIT_TIMEOUT).
stop(Host) -> stop(Host) ->
gen_mod:get_module_proc(Host, eauth) ! stop. gen_mod:get_module_proc(Host, eauth) ! stop.
@ -63,7 +64,7 @@ call_port(Server, Msg) ->
Result Result
end. end.
loop(Port) -> loop(Port, Timeout) ->
receive receive
{call, Caller, Msg} -> {call, Caller, Msg} ->
Port ! {self(), {command, encode(Msg)}}, Port ! {self(), {command, encode(Msg)}},
@ -72,12 +73,14 @@ loop(Port) ->
?DEBUG("extauth call '~p' received data response:~n~p", [Msg, Data]), ?DEBUG("extauth call '~p' received data response:~n~p", [Msg, Data]),
Caller ! {eauth, decode(Data)}; Caller ! {eauth, decode(Data)};
{Port, Other} -> {Port, Other} ->
?ERROR_MSG("extauth call '~p' received strange response:~n~p", [Msg, Other]) ?ERROR_MSG("extauth call '~p' received strange response:~n~p", [Msg, Other]),
Caller ! {eauth, false}
after after
?CALL_TIMEOUT -> Timeout ->
?ERROR_MSG("extauth call '~p' didn't receive response~n", [Msg]) ?ERROR_MSG("extauth call '~p' didn't receive response", [Msg]),
Caller ! {eauth, false}
end, end,
loop(Port); loop(Port, ?CALL_TIMEOUT);
stop -> stop ->
Port ! {self(), close}, Port ! {self(), close},
receive receive