]> granicus.if.org Git - ejabberd/commitdiff
* src/extauth.erl: When the extauth call fails or timeouts, deny
authorBadlop <badlop@process-one.net>
Thu, 6 Nov 2008 15:36:49 +0000 (15:36 +0000)
committerBadlop <badlop@process-one.net>
Thu, 6 Nov 2008 15:36:49 +0000 (15:36 +0000)
authorization. Use two timeouts: 60s for script initialization and
10s for regular calls. (thanks to Kevin Crosbie from
Ravenpack) (EJAB-627)

SVN Revision: 1673

ChangeLog
src/extauth.erl

index d43576dcc31e0cc84ec837eea8b1f9f87319103b..6c74ced8320123bb7d81dd6325f5f5917e2b0a9f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * src/ejabberd_c2s.erl: Disable zlib when STARTTLS is required
index c4acb305df6c99ec99451fc595d847ade8e49865..99fc1fae3cb5aef09e2671e50c9074d1b363528a 100644 (file)
@@ -32,7 +32,8 @@
 
 -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) ->
     spawn(?MODULE, init, [Host, ExtPrg]).
@@ -41,7 +42,7 @@ init(Host, ExtPrg) ->
     register(gen_mod:get_module_proc(Host, eauth), self()),
     process_flag(trap_exit,true),
     Port = open_port({spawn, ExtPrg}, [{packet,2}]),
-    loop(Port).
+    loop(Port, ?INIT_TIMEOUT).
 
 stop(Host) ->
     gen_mod:get_module_proc(Host, eauth) ! stop.
@@ -63,21 +64,23 @@ call_port(Server, Msg) ->
            Result
     end.
 
-loop(Port) ->
+loop(Port, Timeout) ->
     receive
        {call, Caller, Msg} ->
            Port ! {self(), {command, encode(Msg)}},
            receive
                {Port, {data, Data}} ->
                     ?DEBUG("extauth call '~p' received data response:~n~p", [Msg, Data]),
-                   Caller ! {eauth, decode(Data)};
-                {Port, Other} ->
-                    ?ERROR_MSG("extauth call '~p' received strange response:~n~p", [Msg, Other])
+                    Caller ! {eauth, decode(Data)};
+               {Port, Other} ->
+                    ?ERROR_MSG("extauth call '~p' received strange response:~n~p", [Msg, Other]),
+                    Caller ! {eauth, false}
             after
-                ?CALL_TIMEOUT ->
-                    ?ERROR_MSG("extauth call '~p' didn't receive response~n", [Msg])
+                Timeout ->
+                    ?ERROR_MSG("extauth call '~p' didn't receive response", [Msg]),
+                    Caller ! {eauth, false}
            end,
-           loop(Port);
+           loop(Port, ?CALL_TIMEOUT);
        stop ->
            Port ! {self(), close},
            receive