1
votes

I'm trying to run an external authentication script in Ejabberd 19.09.1 running on Ubuntu 18.04.3, but I'm running into problems. After trying and failing I tried to more or less directly copy the examples from the documentation:

I set the ejabberd.yml file to this:

auth_method: [external]
extauth_program: /etc/ejabberd/pyAuth.py
extauth_instances: 3
auth_use_cache: false

And I copied the eample python script:

#!/usr/bin/python

import sys
import struct

def read():
    (pkt_size,) = struct.unpack('>H', sys.stdin.read(2))
    pkt = sys.stdin.read(pkt_size)
    cmd = pkt.split(':')[0]
    if cmd == 'auth':
        u, s, p = pkt.split(':', 3)[1:]
        if u == "wrong":
            write(False)
        else:
            write(True)
    elif cmd == 'isuser':
        u, s = pkt.split(':', 2)[1:]
    elif cmd == 'setpass':
        u, s, p = pkt.split(':', 3)[1:]
        write(True)
    elif cmd == 'tryregister':
        u, s, p = pkt.split(':', 3)[1:]
        write(True)
    elif cmd == 'removeuser':
        u, s = pkt.split(':', 2)[1:]
        write(True)
    elif cmd == 'removeuser3':
        u, s, p = pkt.split(':', 3)[1:]
        write(True)
    else:
        write(False)
    read()

def write(result):
    if result:
        sys.stdout.write('\x00\x02\x00\x01')
    else:
        sys.stdout.write('\x00\x02\x00\x00')
    sys.stdout.flush()

if __name__ == "__main__":
    try:
        read()
    except struct.error:
        pass

This gives me these error messages:

2020-03-06 16:47:24.459 [error] <0.660.0>@extauth:handle_info:152 Failed to start external authentication program '../../../etc/ejabberd/pyAuthTest.py'
2020-03-06 16:47:24.459 [error] <0.656.0> Supervisor 'extauth_pool_xmpp.example.net' had child 'extauth_pool_xmpp.example.net_1' started with extauth:start_link('extauth_pool_xmpp.example.net_1', "../../../etc/ejabberd/pyAuthTest.py") at <0.660.0> exit with reason normal in context child_terminated

I noticed that most of the comments on the ejabberd forum are very old, and I also get this

2020-03-06 16:47:21.909 [warning] <0.107.0>@ejabberd_config_transformer:warn_replaced_option:528 Option 'extauth_instances' is deprecated and was automatically replaced by 'extauth_pool_size'. Please adjust your configuration file accordingly. Hint: run `ejabberdctl dump-config` command to view current configuration as it is seen by ejabberd.

in the ejabberd.log while the documentation says to use extauth_instances, so I'm wondering if maybe some of the documentation could be out of date.

For information, I don't actually know python. I'm trying to run a c# script, partially based on mark.p.jones script here https://www.ejabberd.im/node/1617/index.html, but I'm including this since I get the same error messages from both and the python script is from the official docs.

1
I installed your same version, copied your example script and configured with your options. I get the warning about deprecated option, but everything else works correctly: no error, and I can login correctly... No idea what is wrong, as the error message you get doesn't give hints...Badlop
@Badlop I don't know if you'll find any more information here, but here is the full error log when I try to start with auth_method: [external] link Here's my yaml file: linkWopenras
did you found solution? I have the same issue by the error message is cannot execute: Permission denied. Both ejabberd and the script is in same user permissionskrishnan

1 Answers

0
votes

Now I installed ejabberd 19.09.1 with your full configuration file (except several lines that I had to adapt of course), and the Python script you provided allows me to login. The log file you provided doesn't show any new information, at least for my limited experience with extauth.

Hypothesis: the problem is in your python installation, maybe the script doesn't work well with your Python installation, for whatever reason. For reference, I have Python 2.7.16.

How to check that: instead of using that Python script, try the example Perl extauth script examples/extauth/check_pass_null.pl https://github.com/processone/ejabberd/tree/master/examples/extauth