python - 无法在 Ejabberd 19.09.1 中启动外部身份验证程序
问题描述
我正在尝试在 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 脚本来自官方文档。
解决方案
现在我用你的完整配置文件安装了 ejabberd 19.09.1(除了我必须适应的几行),你提供的 Python 脚本允许我登录。您提供的日志文件没有显示任何新信息,至少对于我对 extauth 的有限经验而言。
假设:问题出在您的 python 安装中,也许脚本不能很好地与您的 Python 安装配合使用,无论出于何种原因。作为参考,我有 Python 2.7.16。
如何检查:不要使用 Python 脚本,而是尝试示例 Perl extauth 脚本示例/extauth/check_pass_null.pl https://github.com/processone/ejabberd/tree/master/examples/extauth
推荐阅读
- jetty - Jetty 9.4.11 出现在 DropWizard 1.3.5 中存在性能问题
- python - DataFrame 无法迭代:出现以下错误:元组索引必须是整数或切片,而不是 str
- msbuild - 在 Visual Studio 2017 中,有没有办法编译使用外部工具的自定义扩展,同时调试程序?
- oracle - 将employeeno 作为参数传递给程序并修改该员工的薪水?
- python - Spark:如果已经通过 `--py-files` 选项传递,slave 是否应该有源代码?
- python - 从Django中的模型类生成可迭代的选择元组
- c# - HTTP 触发器不返回 Azure Functions v2 中的堆栈跟踪
- c# - C# 如何更新 Azure IoT 中心设备的所需孪生属性
- excel - 我的 excel 文件的正确 if 条件是什么?
- sql - 连接表中的错误:传递给 LEFT 或 SUBSTRING 函数的长度参数无效