【问题标题】:Ejabberd External Authentication : extauth script has exitted abruptly with reason 'normal'Ejabberd 外部身份验证:extauth 脚本突然退出,原因为“正常”
【发布时间】:2013-07-25 12:37:58
【问题描述】:

我正在尝试在我的 Ejabberd 安装中启用外部身份验证。我不断收到以下错误消息。

extauth 脚本突然退出,原因是“正常”

我的 ejabberd 版本是 2.1.13。

尝试了以下配置,

1.{auth_method,外部}。
{extauth_program,"php /tmp/test.php"}。

2.{auth_method,外部}。
{extauth_program,"/tmp/test.php"}。

3 {auth_method,外部}。
%%{extauth_program,"/tmp/test.php"}。

以上所有配置都返回相同的错误。

【问题讨论】:

    标签: xmpp ejabberd quickblox


    【解决方案1】:

    你的 test.php 脚本是什么?你确定它可以工作吗?正如错误所说,它可能只是正常终止。 auth 脚本应该不会终止,只是继续从标准输入运行读取。您可以在此处使用一个示例作为指南 https://github.com/processone/ejabberd/blob/master/examples/extauth/check_pass_null.pl

    【讨论】:

    • 我以 root 用户和 ejabberd 用户的身份从命令行手动执行了脚本,它执行并且似乎没有抛出错误。
    【解决方案2】:

    花了 1 天时间尝试获得工作 ejabberd 授权。
    问题基本上出现在从标准输入读取时阻塞进程。它在请求字符串的末尾一直被阻止,直到客户端由于超时而断开连接。
    这是从描述符中逐个符号读取非块符号的解决方案:

    function non_block_read($fd, &$data) {
        $read = array($fd);
        $write = array();
        $except = array();
        $result = stream_select($read, $write, $except, 0);
        if($result === false) {
                    throw new Exception('stream_select failed');
            }
        if($result === 0) return false;
        $data.= stream_get_line($fd, 1);
        return true;
    }
    

    这里是守护程序代码,也是为了使生命周期读取。

    $fh  = fopen("php://stdin", 'r');
    $fhout  = fopen("php://stdout", 'w');
    $pdo = new PDO('mysql:host='.$host.';dbname='.$db, $user,$pass);
    if(!$fh){
        die("Cannot open STDIN\n");
    }
    $aStr='';
    $collect=false;
    do {
            if (!non_block_read($fh,$aStr)) {
                    if (strlen($aStr) > 0) {
                           $toAuth = substr(trim($aStr),1);
                           checkAuth($toAuth,$pdo,$fhout);
                           $aStr='';
                    }
                    else sleep (1);
            }
    }
    while (true);
    

    一些解释:checkAuth - 任何实现“auth”和“isuser”处理程序的函数。
    sleep(1) - 逃避 CPU 负载的简单方法。
    第一个符号 - 预先设置消息的服务符号,它因客户端而异,所以我只是剪掉它。
    这是回复代码。回复 - 真 |错误的值。

    $message =  @pack("nn", 2, $result);
    fwrite($stdout, $message);
    flush();
    

    享受吧。

    【讨论】:

      猜你喜欢
      • 2015-06-04
      • 1970-01-01
      • 2023-03-22
      • 2015-10-03
      • 1970-01-01
      • 2015-07-29
      • 2016-10-25
      • 2013-12-20
      • 2023-03-19
      相关资源
      最近更新 更多