[ejabberd] ejabberd 17.04 external authentication: badarg

Badlop badlop at gmail.com
Wed May 24 13:41:43 MSK 2017


On 23 May 2017 at 10:46, Marvin Gülker <m-guelker at phoenixmail.de> wrote:
>> debug). There, does this work or complains too?
>> extauth:is_user_exists(<<"foo">>,<<"localhost">>).
>
> It complains as well. This is what it gives in live mode:
>
>     (ejabberd at localhost)1> extauth:is_user_exists(<<"foo">>, <<"localhost">>).
>     ** exception error: bad argument
>          in function  extauth:call_port/2 (src/extauth.erl, line 101)
>
> That's interesting, because ejabberd starts the process itself. If it
> can start it, how is it possible that it can't contact it?

Right, that's a good question. If I break the example perl script to
not enter a loop and end immediately, ejabberd complains because it
starts it and the script breaks constantly.

I apply this patch:
diff --git a/src/extauth.erl b/src/extauth.erl
index 9f04a44..5f94c34 100644
--- a/src/extauth.erl
+++ b/src/extauth.erl
@@ -66,9 +66,11 @@ stop(Host) ->
   lists:seq(0, get_instances(Host) - 1)).

 get_process_name(Host, Integer) ->
-    gen_mod:get_module_proc(iolist_to_binary([Host,
+    Name = gen_mod:get_module_proc(iolist_to_binary([Host,
                                               integer_to_list(Integer)]),
-    eauth).
+    eauth),
+    ?INFO_MSG("extauth process name: ~p", [Name]),
+    Name.

 check_password(User, Server, Password) ->
     call_port(Server, [<<"auth">>, User, Server, Password]).


Then at server start I see a line per vhost:
12:28:33.118 [info] extauth process name: eauth_examplecom0
12:28:33.119 [info] extauth process name: eauth_localhost0

When I run the command for some user, the process name is correctly
built, and the process is queried:
12:29:25.007 [debug] Command 'check_account' execution allowed by rule
'console commands' (CallerInfo=#{caller_module => ejabberd_ctl})
12:29:25.007 [debug] Executing command ejabberd_auth:user_exists with
Args=[<<"user1">>,<<"localhost">>]
12:29:25.007 [info] extauth process name: eauth_localhost0
12:29:25.008 [debug] extauth call
'[<<"isuser">>,<<"user1">>,<<"localhost">>]' received data response:
[0,1]

In an erlang shell, I can also confirm the process is registered:
> lists:member(eauth_localhost0, registered()).
true


---
Badlop
ProcessOne


More information about the ejabberd mailing list