2010-12-27 2 views
0

eautab을 사용하여 extauth를 설정하려고하지만 웹에서 수정 프로그램을 검색 한 후에도 작동하지 않습니다. 내가 CONFIGS를 업데이트 한 후 ejabberd를 다시 시작하면ejabberd php mysql 외부 인증 실패 및 종료

{auth_method, external}. 
{extauth_program, "/etc/ejabberd/extauth.class.php"}. 

, 나는 ejabberd.log의 끝 부분이 참조 : 나는 내 ejabberd.cfg 다음 설정

=ERROR REPORT==== 2010-12-26 15:38:10 === 
C(<0.4476.0>:extauth:110) : normal 

=INFO REPORT==== 2010-12-26 15:38:10 === 
I(<0.4181.0>:ejabberd_app:69) : ejabberd 2.1.x is started in the node 

내 extauth 스크립트는 아무것도 없지만에서 파생 된 check_mysql.php.txt,하지만 지금은 데이터베이스 링크가 없습니다.

<?php 

error_reporting(1); 

class imAuth { 

    function __construct() { 
     $this->log = fopen('/etc/ejabberd/extauth.log', 'a'); 
     $this->openstd(); 
    } 

    function openstd() { 
     $this->stdout = @fopen("php://stdout", "w"); 
     $this->stdin = @fopen("php://stdin", "r"); 
    } 

    function out($data) { 
     @fwrite($this->stdout, $data); 
     $dump = @unpack("nn", $data); 
     $dump = $dump["n"]; 
     $this->logg("OUT: ". $dump); 
    } 

    function closestd() { 
     @fclose($this->stdin); 
     @fclose($this->stdout); 
    } 

    function stop() { 
     $this->logg("Shutting down ..."); 
     @fclose($this->log); 
     $this->closestd(); 
     exit(0); 
    } 

    function logg($data) { 
     fwrite($this->log, $data."\n"); 
    } 

    function splitcomm() { 
     return explode(":", $this->data); 
    } 

    function checkuser() { 
     return true; 
    } 

    function checkpass() { 
     return true; 
    } 

    function command() { 
     $data = $this->splitcomm(); 
     $this->logg("Processing command ".$data[0]); 

     switch($data[0]) { 
      case 'isuser': 
       $log = $data[1]; 
       $ret = $this->checkuser(); 
       break; 
      case 'auth': 
       $log = $data[1].":".$data[2].":".md5($data[3]); 
       $ret = $this->checkpass(); 
       break; 
      case 'setpass': 
       $ret = false; 
       break; 
      default: 
       $this->stop(); 
       break; 
     } 

     $ret = ($ret) ? 1 : 0; 
     if(strlen($data[0]) > 0 && strlen($log) > 0) { 
      $this->logg("Command : ".$data[0].":".$log." ==> ".$ret." "); 
     } 

     return @pack("nn", 2, $return); 
    } 

    function readstdin() { 
     $l = @fgets($this->stdin, 3); 
     $length = @unpack("n", $l); 
     $len = $length["1"]; 

     if($len > 0) { 
      $this->logg("Reading $len bytes ... "); 
      $data = @fgets($this->stdin, $len+1); 
      $this->data = $data; 
      $this->logg("IN: ".$data); 
     } 
    } 

    function play() { 
     do { 
      $this->readstdin(); 
      $length = strlen($this->data); 
      $ret = $this->command(); 
      $this->logg("RE:".$ret); 
      $this->out($ret); 
      $this->data = null; 
     } while(true); 
    } 

} 

$auth = new imAuth(); 
$auth->play(); 

?> 

내 클라이언트가 채팅에 로그인을 시도

, 난 ejabberd.log 안에 다음을 참조하십시오 :

=ERROR REPORT==== 2010-12-26 15:38:31 === 
** State machine <0.4566.0> terminating 
** Last event in was {xmlstreamelement, 
        {xmlelement,"auth", 
         [{"xmlns","urn:ietf:params:xml:ns:xmpp-sasl"}, 
          {"mechanism","PLAIN"}], 
         [{xmlcdata, 
           <<"AGpheGwAbGlmZWlzbGlmZTI1QSFAKCk=">>}]}} 
** When State == wait_for_feature_request 
**  Data == {state,{socket_state,gen_tcp,#Port<0.34718>,<0.4565.0>}, 
        ejabberd_socket,#Ref<0.0.0.104846>,false,"103115738", 
        {sasl_state,"jabber","dev.jaxl.im",[], 
           #Fun<ejabberd_c2s.1.30334249>, 
           #Fun<ejabberd_c2s.2.32721014>, 
           #Fun<ejabberd_c2s.3.7052687>,undefined, 
           undefined}, 
        c2s,c2s_shaper,false,false,false,false, 
        [verify_none], 
        false,undefined,[],"dev.jaxl.im",[],undefined, 
        {pres_t,0}, 
        {pres_f,0}, 
        {pres_a,0}, 
        {pres_i,0}, 
        undefined,undefined,undefined,false, 
        {userlist,none,[],false}, 
        unknown,unknown, 
        {{127,0,0,1},33227}, 
        "en"} 
** Reason for termination = 
** {badarg,[{extauth,call_port,2}, 
     {ejabberd_auth_external,check_password_extauth,3}, 
     {ejabberd_auth,check_password_loop,2}, 
     {cyrsasl_plain,mech_step,2}, 
     {cyrsasl,server_step,2}, 
     {ejabberd_c2s,wait_for_feature_request,2}, 
     {p1_fsm,handle_msg,10}, 
     {proc_lib,init_p_do_apply,3}]} 

나는 명령을 통해 실행하여 내 스크립트를 테스트 한 다음 내가 함께 작동하도록 노력하고 완전한 스크립트입니다 직접 /path/to/php /etc/ejabberd/extauth.class.php 라인 및 STDIN을 통해 매개 변수를 전달하고 예상대로 작동합니다.

또한 extauth.class.php와 extauth.log의 사용 권한을 결과없이 수정하려고했습니다.

경험이있는 사람이이 문제를 해결할 수 있습니까?

답변

1

몇 가지 문제가있었습니다. 사용자 루트에서 내 auth PHP 스크립트를 테스트 한 다음 시도했습니다.

[email protected]:/root~$ su ejabberd                                          [20:55:57] 
sh-3.2$ /var/lib/ejabberd/joomla-auth.php 

Warning: fopen(/var/log/ejabberd/exauth.log): failed to open stream: Permission denied in /var/lib/ejabberd/joomla-auth.php on line 105 

Call Stack: 
    0.0009  125028 1. {main}() /var/lib/ejabberd/joomla-auth.php:0 
    0.0009  127136 2. exAuth->__construct() /var/lib/ejabberd/joomla-auth.php:75 
    0.0010  127780 3. fopen() /var/lib/ejabberd/joomla-auth.php:105 

로그 파일을 작성했습니다. 스와 ejabberd하여 스크립트를 확인하고 스크립트에 대한 올바른 접근을 설정 : 실제로 문제를 디버깅에 도움 않았다

chmod 700 /var/lib/ejabberd/joomla-auth.php 
chown ejabberd:ejabberd /var/lib/ejabberd/joomla-auth.php 
+0

감사 popstas ...이 ... 모두가 지금은 잘 작동합니다 :) –