我正在尝试在 Ubuntu 18.04.3 上运行的 Ejabberd 19.09.1 中运行外部身份验证脚本,但我遇到了问题。在尝试并失败后,我尝试或多或少地直接从文档中复制示例:
我将 ejabberd.yml 文件设置为:
auth_method: [external]
extauth_program: /etc/ejabberd/pyAuth.py
extauth_instances: 3
auth_use_cache: false
我复制了示例 python 脚本:
#!/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
这给了我这些错误消息:
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
我注意到ejabberd论坛上的大多数评论都很老了,我也得到了这个
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.
在 ejabberd.log 中,而文档说要使用 extauth_instances,所以我想知道是否某些文档可能已过时。
有关信息,我实际上并不了解python。我正在尝试运行 ac# 脚本,部分基于此处的 mark.p.jones 脚本https://www.ejabberd.im/node/1617/index.html,但我将其包括在内,因为我得到了同样的错误来自两者的消息和 python 脚本来自官方文档。