我现在很困惑。我正尝试让 ejabberd 根据我的 Web 应用程序现有的 MySQL 用户表对用户进行身份验证。
环境信息
- Ubuntu 8.04 服务器
- Ejabberd 2.0.1-2 (使用 hardy-backports)
- PHP 5.2.4
- MySQL 5.0.51a-3
在ejabberd.cfg
:
我已注释掉以下默认auth_method
行:
%%{auth_method, internal}.
取消注释并编辑以下几行:
{auth_method, external}.
{extauth_program, "/var/myapplication/xmpp_auth.php"}.
PHP 脚本
PHP 脚本基于此示例脚本来自 ejabberd 的文档页面。
我的checkuser()
和checkpass()
函数本身运行完美。我已经分别测试了它们php -l
。xmpp_auth.php 中没有显示语法错误。
但是,当auth_method
设置为internal
时,我可以以使用 ejabberdctl 创建的用户身份登录,但当我切换到外部方法时,什么都不起作用。
日志
以下是我尝试在删除身份信息的情况下登录时对应的日志条目。 CLIENT_IP_REMOVED
是我的客户端 IP,SERVER_IP_REMOVED
是我的服务器的 IP,myapplication.com
是我的服务器的域名。
/var/ejabberd/ejabberd.log
:
=INFO REPORT==== 2009-10-28 16:01:46 ===
I(<0.244.0>:ejabberd_listener:112) : (#Port<0.446>) Accepted connection {{CLIENT_IP_REMOVED},65263} -> {{SERVER_IP_REMOVED},5222}
=ERROR REPORT==== 2009-10-28 16:01:48 ===
** State machine <0.447.0> terminating
** Last event in was {xmlstreamelement,
{xmlelement,
"auth",
[{"xmlns","urn:ietf:params:xml:ns:xmpp-sasl"},
{"mechanism","PLAIN"},
{"xmlns:ga",
"http://www.google.com/talk/protocol/auth"},
{"ga:client-uses-full-bind-result","true"}],
[{xmlcdata,<<"AHNlbnNsZXkAam9iNDI0">>}]}}
** When State == wait_for_feature_request
** Data == {state,{socket_state,tls,
{tlssock,#Port<0.446>,#Port<0.448>},
<0.446.0>},
ejabberd_socket,
#Ref<0.0.0.9159>,
"53195611",
{sasl_state,"jabber",
"myapplication.com",
[],
#Fun<ejabberd_c2s.1.74696376>,
#Fun<ejabberd_c2s.2.131707924>,
undefined,
undefined},
c2s,
c2s_shaper,
false,
true,
false,
true,
[{certfile,"/etc/ejabberd/ejabberd.pem"}],
false,
undefined,
[],
"myapplication.com",
[],
undefined,
{0,nil},
{0,nil},
{0,nil},
{0,nil},
{dict,0,
16,
16,
8,
80,
48,
{[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]},
{{[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]}}},
undefined,
undefined,
undefined,
false,
{userlist,none,[]},
unknown,
unknown,
{{CLIENT_IP_REMOVED},65263},
[]}
** Reason for termination =
** {badarg,[{extauth,call_port,2},
{ejabberd_auth,'-check_password_with_authmodule/3-fun-0-',4},
{lists,dropwhile,2},
{ejabberd_auth,check_password_with_authmodule,3},
{cyrsasl_plain,mech_step,2},
{cyrsasl,server_step,2},
{ejabberd_c2s,wait_for_feature_request,2},
{gen_fsm,handle_msg,7}]}
/var/log/ejabberd/sasl.log
:
=CRASH REPORT==== 28-Oct-2009::16:14:50 ===
crasher:
pid: <0.457.0>
registered_name: []
error_info: {badarg,
[{extauth,call_port,2},
{ejabberd_auth,
'-check_password_with_authmodule/3-fun-0-',
4},
{lists,dropwhile,2},
{ejabberd_auth,check_password_with_authmodule,3},
{cyrsasl_plain,mech_step,2},
{cyrsasl,server_step,2},
{ejabberd_c2s,wait_for_feature_request,2},
{gen_fsm,handle_msg,7}]}
initial_call: {gen,
init_it,
[gen_fsm,
<0.235.0>,
<0.235.0>,
ejabberd_c2s,
[{ejabberd_socket,
{socket_state,gen_tcp,#Port<0.458>,<0.456.0>}},
[{access,c2s},
{shaper,c2s_shaper},
{max_stanza_size,65536},
starttls,
{certfile,"/etc/ejabberd/ejabberd.pem"}]],
[]]}
ancestors: [ejabberd_c2s_sup,ejabberd_sup,<0.36.0>]
messages: []
links: [<0.235.0>,#Port<0.460>]
dictionary: []
trap_exit: false
status: running
heap_size: 2584
stack_size: 21
reductions: 3425
neighbours:
=SUPERVISOR REPORT==== 28-Oct-2009::16:14:50 ===
Supervisor: {local,ejabberd_c2s_sup}
Context: child_terminated
Reason: {badarg,
[{extauth,call_port,2},
{ejabberd_auth,
'-check_password_with_authmodule/3-fun-0-',
4},
{lists,dropwhile,2},
{ejabberd_auth,check_password_with_authmodule,3},
{cyrsasl_plain,mech_step,2},
{cyrsasl,server_step,2},
{ejabberd_c2s,wait_for_feature_request,2},
{gen_fsm,handle_msg,7}]}
Offender: [{pid,<0.457.0>},
{name,undefined},
{mfa,
{ejabberd_c2s,
start_link,
[{ejabberd_socket,
{socket_state,gen_tcp,#Port<0.458>,<0.456.0>}},
[{access,c2s},
{shaper,c2s_shaper},
{max_stanza_size,65536},
starttls,
{certfile,"/etc/ejabberd/ejabberd.pem"}]]}},
{restart_type,temporary},
{shutdown,brutal_kill},
{child_type,worker}]
我不知道发生了什么。请帮忙。=)
答案1
脚本出了点问题,如果您使用的是 Ubuntu,我建议您登录 ejabberd 帐户并尝试运行该脚本。我遇到过类似的问题,当脚本尝试打开日志文件时,由于权限问题,它拒绝进行身份验证。