Score:0

Ejabberd mod_ecaptcha crash

ar flag

I'm trying to install new mod_ecaptcha mod in ejabberd-contrib. But ejabberd crashed after enabling it. My initial data: ejabberd 23.01 erlang 25.2.3

  1. I have enabled ejabberd-contrib by ejabberdctl modules_update_specs

  2. Installed and recompiled mod_ecaptcha

    ejabberdctl module_install mod_ecaptcha make -C .ejabberd-modules/sources/ejabberd-contrib/mod_ecaptcha/deps/ecaptcha/c_src ejabberdctl module_upgrade mod_ecaptcha It's compiled without errors.

  3. Installed erlang-dev apt install erlang-dev because without it it wasn't compiled

  4. I'm using basic config

captcha_cmd: mod_ecaptcha
captcha_url: http://myjabber:5280/captcha
listen:
  -
    port: 5280
    module: ejabberd_http
    request_handlers:
      /captcha: ejabberd_captcha
modules:
  mod_ecaptcha: {}

In final I started my ejabberd and receive errors in error.log and ejabberd service crashes.

2023-06-19 19:59:11.892726+03:00 [error] <0.757.0>@proc_lib:crash_report/4:539 CRASH REPORT: crasher: initial call: ejabberd_captcha:init/1 pid: <0.757.0> registered_name: [] exception error: undefined function ecaptcha_nif:rand_size/0 in function ecaptcha:pixels/2 (/var/lib/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/mod_ecaptcha/deps/ecaptcha/src/ecaptcha.erl, line 63) in call from ecaptcha:img/3 (/var/lib/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/mod_ecaptcha/deps/ecaptcha/src/ecaptcha.erl, line 107) in call from mod_ecaptcha:create_image/1 (/var/lib/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/mod_ecaptcha/src/mod_ecaptcha.erl, line 78) in call from ejabberd_captcha:check_captcha_setup/0 (ejabberd_captcha.erl, line 573) in call from ejabberd_captcha:init/1 (ejabberd_captcha.erl, line 294) in call from gen_server:init_it/2 (gen_server.erl, line 851) in call from gen_server:init_it/6 (gen_server.erl, line 814) ancestors: [ejabberd_sup,<0.123.0>] message_queue_len: 0 messages: [] links: [<0.412.0>] dictionary: [{rand_seed,{#{bits => 58,jump => #Fun<rand.3.34006561>, next => #Fun<rand.0.34006561>,type => exsss, uniform => #Fun<rand.1.34006561>, uniform_n => #Fun<rand.2.34006561>}, [114826259057369191|191927986778231166]}}] trap_exit: false status: running heap_size: 376 stack_size: 28 reductions: 393 neighbours: 2023-06-19 19:59:11.925067+03:00 [critical] <0.123.0>@ejabberd_app:start/2:68 Failed to start ejabberd application: {error, {shutdown, {failed_to_start_child, ejabberd_captcha, {undef, [{ecaptcha_nif,rand_size,[],[]}, {ecaptcha,pixels,2, [{file, "/var/lib/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/mod_ecaptcha/deps/ecaptcha/src/ecaptcha.erl"}, {line,63}]}, {ecaptcha,img,3, [{file, "/var/lib/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/mod_ecaptcha/deps/ecaptcha/src/ecaptcha.erl"}, {line,107}]}, {mod_ecaptcha,create_image,1, [{file, "/var/lib/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/mod_ecaptcha/src/mod_ecaptcha.erl"}, {line,78}]}, {ejabberd_captcha, check_captcha_setup,0, [{file,"ejabberd_captcha.erl"}, {line,573}]}, {ejabberd_captcha,init,1, [{file,"ejabberd_captcha.erl"}, {line,294}]}, {gen_server,init_it,2, [{file,"gen_server.erl"}, {line,851}]}, {gen_server,init_it,6, [{file,"gen_server.erl"}, {line,814}]}]}}}}

Full logs:

Error.log https://pastebin.com/yQKefm4N

Ejabberd.log https://pastebin.com/uENVE5fC

Can you help me please?

Score:0
ru flag

undefined function ecaptcha_nif:rand_size/0

It seems some file was not compiled, maybe ecaptcha_nif.beam or ecaptcha.so Or they weren't installed, or they cannot be loaded.

There is a commit that improves this in ejabberd 23.04: https://github.com/processone/ejabberd/commit/c5c7e7fc4db97022986d1595b73781571a3d59f2

First of all, check that all the source code files were compiled and installed:

$ find .ejabberd-modules/mod_ecaptcha/
.ejabberd-modules/mod_ecaptcha/
.ejabberd-modules/mod_ecaptcha/COMMIT.json
.ejabberd-modules/mod_ecaptcha/conf
.ejabberd-modules/mod_ecaptcha/conf/mod_ecaptcha.yml
.ejabberd-modules/mod_ecaptcha/ebin
.ejabberd-modules/mod_ecaptcha/ebin/ecaptcha_gif_lzw.beam
.ejabberd-modules/mod_ecaptcha/ebin/ecaptcha.beam
.ejabberd-modules/mod_ecaptcha/ebin/mod_ecaptcha.beam
.ejabberd-modules/mod_ecaptcha/ebin/ecaptcha_color.beam
.ejabberd-modules/mod_ecaptcha/ebin/ecaptcha_nif.beam
.ejabberd-modules/mod_ecaptcha/ebin/ecaptcha_gif.beam
.ejabberd-modules/mod_ecaptcha/ebin/ecaptcha_png.beam
.ejabberd-modules/mod_ecaptcha/mod_ecaptcha.spec
.ejabberd-modules/mod_ecaptcha/priv
.ejabberd-modules/mod_ecaptcha/priv/ecaptcha.so

Are all the files there? Specially ecaptcha_nif.beam and ecaptcha.so

If some file is missing, maybe you need to install the gcc compiler, or some other package to let ecaptcha.so get compiled.

If all the files are there, maybe ejabberd 23.01 is not able to load them.

The obvious solution would be to update update ejabberd to 23.04.

If you cannot update ejabberd 23.01 to 23.04 right now, another solution is that you copy ecaptcha.so to a place where ejabberd 23.01 can find it. For example, search for a file called xmpp_uri.so, and copy ecaptcha.so in the same directory.

saxad avatar
ar flag
Thank you for reply, much appreciated! gcc compiler is installed: ` gcc --version` `gcc (Debian 12.2.0-14) 12.2.0` All files in their places (according to your list). My `xmpp_uri.so` is here: `/usr/lib/erlang/lib/p1_xmpp-1.6.1/priv/lib/xmpp_uri.so` Should I just copy `ecaptcha.so` to this directory? Or I must additionally edit some path somewhere?
saxad avatar
ar flag
By the way. ecaptcha.so has such rights. Is this okay? `/.ejabberd-modules/sources/ejabberd-contrib/mod_ecaptcha/deps/ecaptcha/priv/ecaptcha.so` `-rwxr-xr-x 1 ejabberd ejabberd`
saxad avatar
ar flag
I copied file ecaptcha.so into dir with xmpp_uri.so. Same result. Not starting... :( Ejabberd crashed. By the way. I tried to do all this on Debian 11 few month ago and everything works fine. Now I'm on Debian 12. And service isn't starting
Badlop avatar
ru flag
Are you running ejabberd inside a container, or installed from debian package, or from some processone installer?
saxad avatar
ar flag
I've installed from Debian package. Ejabberd first was installed (and than updated) with apt tool, when Debian updated from 11 to 12.
saxad avatar
ar flag
Badlop, I'm sorry to bother you. Maybe you have found bugs or my mistaked above? Still can't enable this mod.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.