Extauth ошибка чтения

Hi @badlop, thank you for your reply.

Ejabberd does not complain during server start. Here is the log when I start ejabberd and try to login:

2017-06-23 11:00:02.336 [info] <0.7.0> Application lager started on node ejabberd@localhost
2017-06-23 11:00:02.462 [info] <0.7.0> Application crypto started on node ejabberd@localhost
2017-06-23 11:00:02.531 [info] <0.7.0> Application sasl started on node ejabberd@localhost
2017-06-23 11:00:02.574 [info] <0.7.0> Application asn1 started on node ejabberd@localhost
2017-06-23 11:00:02.575 [info] <0.7.0> Application public_key started on node ejabberd@localhost
2017-06-23 11:00:02.634 [info] <0.7.0> Application ssl started on node ejabberd@localhost
2017-06-23 11:00:02.754 [info] <0.7.0> Application fast_yaml started on node ejabberd@localhost
2017-06-23 11:00:02.855 [info] <0.7.0> Application fast_tls started on node ejabberd@localhost
2017-06-23 11:00:02.938 [info] <0.7.0> Application fast_xml started on node ejabberd@localhost
2017-06-23 11:00:02.986 [info] <0.7.0> Application stringprep started on node ejabberd@localhost
2017-06-23 11:00:03.046 [info] <0.7.0> Application cache_tab started on node ejabberd@localhost
2017-06-23 11:00:03.201 [info] <0.7.0> Application elixir started on node ejabberd@localhost
2017-06-23 11:00:04.056 [info] <0.7.0> Application mnesia started on node ejabberd@localhost
2017-06-23 11:00:11.205 [info] <0.7.0> Application inets started on node ejabberd@localhost
2017-06-23 11:00:18.150 [info] <0.38.0>@cyrsasl_digest:start:60 FQDN used to check DIGEST-MD5 SASL authentication: <<"ip-172-31-28-142.eu-west-1.compute.internal">>
2017-06-23 11:00:18.302 [warning] <0.38.0>@gen_mod:sort_modules:108 module 'mod_mam' is recommended for module 'mod_muc' but is not found in the config
2017-06-23 11:00:18.629 [info] <0.458.0>@ejabberd_listener:listen_tcp:189 Reusing listening port for {5222,{0,0,0,0},tcp}
2017-06-23 11:00:18.630 [info] <0.459.0>@ejabberd_listener:listen_tcp:189 Reusing listening port for {5269,{0,0,0,0},tcp}
2017-06-23 11:00:18.630 [info] <0.461.0>@ejabberd_listener:listen_tcp:189 Reusing listening port for {7101,{0,0,0,0},tcp}
2017-06-23 11:00:18.630 [info] <0.38.0>@ejabberd_app:start:81 ejabberd 16.09 is started in the node ejabberd@localhost
2017-06-23 11:00:18.630 [info] <0.7.0> Application ejabberd started on node ejabberd@localhost
2017-06-23 11:00:30.958 [info] <0.461.0>@ejabberd_listener:accept:333 (#Port<0.26773>) Accepted connection 213.30.18.1:49443 -> 172.31.28.142:7101
2017-06-23 11:00:30.958 [info] <0.465.0>@ejabberd_http:init:163 started: {gen_tcp,#Port<0.26773>}
2017-06-23 11:00:33.486 [error] <0.465.0> CRASH REPORT Process <0.465.0> with 0 neighbours crashed with reason: bad argument in extauth:call_port/2 line 101

The crash log returns this:
2017-06-23 11:01:09 =CRASH REPORT==== crasher: initial call: ejabberd_http:init/2 pid: <0.469.0> registered_name: [] exception error: bad argument: [{extauth,call_port,2,[{file,"src/extauth.erl"},{line,101}]},{ejabberd_auth_external,check_password_extauth,4,[{file,"src/ejabberd_auth_external.erl"},{line,189}]},{ejabberd_auth,check_password_loop,2,[{file,"src/ejabberd_auth.erl"},{line,160}]},{ejabberd_auth,check_password,4,[{file,"src/ejabberd_auth.erl"},{line,108}]},{ejabberd_web_admin,get_auth_account,5,[{file,"src/ejabberd_web_admin.erl"},{line,274}]},{ejabberd_web_admin,process,2,[{file,"src/ejabberd_web_admin.erl"},{line,197}]},{ejabberd_http,process,5,[{file,"src/ejabberd_http.erl"},{line,368}]},{ejabberd_http,process_request,1,[{file,"src/ejabberd_http.erl"},{line,456}]}] ancestors: [<0.461.0>,ejabberd_listeners,ejabberd_sup,<0.38.0>] messages: [] links: [#Port<0.26777>] dictionary: [{random_seed,{14177,17751,25897}}] trap_exit: false status: running heap_size: 1598 stack_size: 27 reductions: 1508 neighbours:

It does not seem to have anything suspicious, other than the crash…Do you have any idea of what is going on?
Thanks

Пытаюсь прикрутить к CommuniGate’у внешнюю аутентификацию в ActiveDirectory через скрипт, написанный ребятами с unixgeek.nm.ru (см. хауту@http://unixgeek.nm.ru/adsetup.html), сделал всё в полном соответствии с описанием, приведённым в хаутушке, в итоге получил буквально следующее:

16:26:27.600 1 EXTAUTH akkerman@cgp.tra-la-la.ru creation failed. Error Code=external helper is not running
16:26:27.626 1 ROUTER SYSTEM: ‘akkerman@cgp.tra-la-la.ru’ rejected. Error Code=internal system error

В чём может быть проблема? :(

Я пытаюсь включить внешнюю аутентификацию в своей установке Ejabberd. Я продолжаю получать следующее сообщение об ошибке.

Скрипт extauth внезапно завершил работу по причине «нормальный»

Моя версия ejabberd 2.1.13.

Пробовал со следующими конфигурациями,

1.{метод_аутентификации, внешний}.
{extauth_program,»php/tmp/test.php»}.

2.{метод_аутентификации, внешний}.
{extauth_program,»/tmp/test.php»}.

3 {метод_аутентификации, внешний}.
%%{extauth_program,»/tmp/test.php»}.

Все приведенные выше конфигурации возвращают одну и ту же ошибку.

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 STDINn");
}
$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) — простой способ избежать нагрузки на процессор.
Первый символ — служебный символ, который предшествует сообщению и отличается от клиента к клиенту, поэтому я просто вырезал его.
Вот код ответа. Ответ — верно | ложные значения.

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

Наслаждаться.


0

ETech
15 Авг 2014 в 16:56

I’m trying to see if a problem I’m having with shared resource groups and extauth with 2.1.x is fixed in master, but I’m having a hard time getting even the example extauth in the Developers Guide to work with master. The extauth script appears to be getting 0 bytes from ejabberd. This is with current master, erlang R16B01, and Python 2.6.6 on CentOS 6.4.

Here is my extauth script (auth4.py):

#!/usr/bin/python

import sys
import logging
from struct import *

sys.stderr = open('/var/log/ejabberd/extauth_err4.log', 'w')
logging.basicConfig(level=logging.INFO,
                    format='%(asctime)s %(levelname)s %(message)s',
                    filename='/var/log/ejabberd/extauth4.log',
                    filemode='a')

logging.info('extauth script started, waiting for ejabberd requests')

def from_ejabberd():
    input_length = sys.stdin.read(2)
    logging.info("Bytes read: " + str(len(input_length)))
    logging.info("Input Length: " + str(input_length))
    (size,) = unpack('>h', input_length)
    return sys.stdin.read(size).split(':')

def to_ejabberd(bool):
    answer = 0
    if bool:
        answer = 1
    token = pack('>hh', 2, answer)
    sys.stdout.write(token)
    sys.stdout.flush()

def auth(username, server, password):
    return True

def isuser(username, server):
    return True

def setpass(username, server, password):
    return True

while True:
    data = from_ejabberd()
    success = False
    if data[0] == "auth":
        success = auth(data[1], data[2], data[3])
    elif data[0] == "isuser":
        success = isuser(data[1], data[2])
    elif data[0] == "setpass":
        success = setpass(data[1], data[2], data[3])
    to_ejabberd(success)

And this is what I get in extauth4.log:

2013-06-25 13:42:12,974 INFO extauth script started, waiting for ejabberd requests
2013-06-25 13:42:12,977 INFO extauth script started, waiting for ejabberd requests
2013-06-25 13:42:15,205 INFO Bytes read: 0
2013-06-25 13:42:15,205 INFO Input Length: 
2013-06-25 13:42:54,190 INFO Bytes read: 0
2013-06-25 13:42:54,190 INFO Input Length: 

And this is what I get in extauth_err4.log:

Traceback (most recent call last):
  File "/etc/ejabberd/auth4.py", line 40, in <module>
    data = from_ejabberd()
  File "/etc/ejabberd/auth4.py", line 19, in from_ejabberd
    (size,) = unpack('>h', input_length)
struct.error: unpack requires a string argument of length 2

And finally, the two lines in my ejabberd.cfg for extauth:

{auth_method, external}.
{extauth_program, "/etc/ejabberd/auth4.py"}.

I have seen ejabberd apparently launch two instances of auth4.py at the same time, and occasionally I get two running instances of auth4.py, but not always. I am launching it with the ejabberd.init example in master. Is anyone seeing extauth work with recent master? Am I doing something wrong?

Провел 1 день, пытаясь получить разрешение на работу ejabberd.
Проблема обычно возникает при блокировке процесса при чтении из stdin. Он блокируется в конце строки запроса, пока клиент не отключится из-за таймаута.
Вот решение для неблокированного символа путем считывания символа из дескриптора:

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 STDINn");
}
$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) — простой способ избежать загрузки процессора.
Первый символ — служебный символ, который добавляет сообщение, и он отличается от клиента клиенту, поэтому я просто разрезал его.
Вот код ответа. Ответить — true | ложные значения.

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

Наслаждаться.

Понравилась статья? Поделить с друзьями:
  • Ext3 проверить на ошибки
  • Expression result pointer nullptr ошибка
  • Expression expected ошибка vba
  • Express отправить ошибку
  • Express gate ошибка 8c000002