【发布时间】:2020-06-19 12:42:26
【问题描述】:
我正在尝试在 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论坛上的大部分cmet都非常老了,我也得到了这个
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 脚本来自官方文档。
【问题讨论】:
-
我安装了您的相同版本,复制了您的示例脚本并配置了您的选项。我收到有关已弃用选项的警告,但其他一切正常:没有错误,我可以正确登录...不知道出了什么问题,因为您收到的错误消息没有给出提示...
-
您找到解决方案了吗?我有同样的问题,错误消息是无法执行:权限被拒绝。 ejabberd 和脚本都具有相同的用户权限
标签: python ubuntu ejabberd ejabberd-auth