Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.7

Request #3519 Net_Sieve w/ externally established sockets
Submitted: 2005-02-18 21:06 UTC
From: liamr at umich dot edu Assigned: amistry
Status: Closed Package: Net_Sieve
PHP Version: 4.4.1 OS: linux 2.4.31
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 26 + 8 = ?

 
 [2005-02-18 21:06 UTC] liamr at umich dot edu
Description: ------------ The bypassAuth boolean was added to Net_Sieve::login to facilitate using Net_Sieve with a sieve socket that had been established externally (using Cyrus's sivtest, for example). There doesn't seem to be a way to set bypassAuth from code invoking Net_Sieve. I've had to set it manually in Net/Sieve.php. Also - if the socket has been established externally, you cannot assume that Net_Sieve::connect is going to retrieve a CAPABILITY statement without specifically requesting one.. if (PEAR::isError($res = $this->_doCmd())) { return $res; } /* if(PEAR::isError($res = $this->_cmdCapability() )) { $msg='Failed to connect, server said: ' . $res->getMessage(); $code=2; return $this->_raiseError($msg,$code); } */ $this->_parseCapability($res); If you're going to try and parse the CAPABILITY statement, you probably should ask for one. I'd uncomment out the _cmdCapability line, and remove the if{} block above it.

Comments

 [2005-12-08 18:18 UTC] liamr at umich dot edu
10mos later and this is still an issue.
 [2006-01-27 19:35 UTC] amistry at php dot net
Can you try the following patch to see if it fixes your problem? http://am-productions.biz/docs/Sieve.patch It also adds STARTTLS support for PHP5 and above.
 [2006-02-03 18:45 UTC] liamr at umich dot edu
I still had to comment out the doCmd() around line 355, but otherwise the patch worked. I'm unsure what this block of code is trying to accomplish. doCmd() doesn't have anything passed to it, the server connection attached to my socket keeps waiting for /something/. Debugging shows an endless string of.. S: S: S: as long as you care to let it go. Anyhoo.. here's my change: --- /tmp/Net_Sieve-1.1.1/Sieve.php 2006-02-03 13:41:55.000000000 -0500 +++ Sieve.php 2006-02-03 13:37:47.000000000 -0500 @@ -355,7 +355,9 @@ } $this->_state = NET_SIEVE_STATE_AUTHORISATION; +/* if (PEAR::isError($res = $this->_doCmd())) { return $res; } +*/ // Explicitly ask for the capabilities in case the connection
 [2006-02-03 21:37 UTC] amistry at php dot net
I've uploaded a new patch in the same location. Try that. The updated contructor is: Net_Sieve($user = null , $pass = null , $host = 'localhost', $port = 2000, $logintype = '', $euser = '', $debug = false, $bypassAuth = false) So you'll want to bypass the authentication step in connect by using something like this: $sieve = Net_Sieve($user,$pass, $host, $port, '','', false, true) If that doesn't work, can you reply with the code that you are using to connect? Thanks,
 [2006-02-06 19:56 UTC] liamr at umich dot edu
It's looking better... I think you're going to want to skip the login() call in _handleConnectAndLogin(), as the point of using the externally established socket is to allow something else (ie the cyrus "sivtest" utility) to establish the connection and handle the authorization. I'm hoping at some point the PECL SASL extension will allow us to stop resorting to sivtest to do GSSAPI authentication to our sieve servers, but in the mean time, I offer this diff: diff -U 2 ~liamr/Public/html/Sieve.php Sieve.php --- /home/liamr/Public/html/Sieve.php 2006-02-06 13:26:43.000000000 -0500 +++ Sieve.php 2006-02-06 14:50:43.000000000 -0500 @@ -219,7 +219,9 @@ return $res; } - if (PEAR::isError($res = $this->login($this->_data['user'], $this->_data['pass'], $this->_data['logintype'] , $this->_data['euser'] , $this->_bypassAuth) ) ) { - return $res; - } + if ($this->_bypassAuth === false){ + if (PEAR::isError($res = $this->login($this->_data['user'], $this->_data['pass'], $this->_data['logintype'] , $this->_data['euser'] , $this->_bypassAuth) ) ) { + return $res; + } + } return true;
 [2006-02-06 20:20 UTC] amistry at php dot net
Thanks. I've updated the patch to included your diff. I'll be updating the package sometime this week and will close this bug once I've uploaded the release.
 [2006-02-14 20:30 UTC] liamr at umich dot edu
Looks like a different version of my last diff made it into the release.. and it doesn't work. We still need to do the this->connect() even if we skip the this->login() portion of handleConnectAndLogin(). --- /usr/lib/php/Net/Sieve.php 2006-02-14 15:25:08.000000000 -0500 +++ Sieve.php 2006-02-14 15:23:41.000000000 -0500 @@ -219,8 +219,8 @@ function _handleConnectAndLogin() { - if($this->_bypassAuth === false) { if (PEAR::isError($res = $this->connect($this->_data['host'] , $this->_data['port'] ))) { return $res; } + if($this->_bypassAuth === false) { if (PEAR::isError($res = $this->login($this->_data['user'], $this->_data['pass'], $this->_data['logintype'] , $this->_data['euser'] , $this->_bypassAuth) ) ) { return $res; Here's the code I'm using: <pre> <?php require( 'Net/Sieve.php' ); $sock = '/tmp/sieve.' . posix_getpid(); $SIVTEST = '/usr/bin/sivtest'; $host = 'sieve.example.com'; if( substr( phpversion(), 0, 1 ) == '5' ) { $domain_socket = 'unix://' . $sock; } else { $domain_socket = $sock; } $ps = shell_exec( "/bin/ps -ef | /bin/grep $SIVTEST | /bin/grep $sock | /bin /grep -v grep" ); if( !preg_match( "|$sock|", $ps ) && file_exists( $sock )) { unlink( $sock ); } if( !file_exists( $sock )) { exec( 'KRB5CCNAME=' . $_SERVER[ 'KRB5CCNAME' ] . " $SIVTEST -m GSSAPI" . ' -u ' . $_SERVER[ 'REMOTE_USER' ] . ' -a ' . $_SERVER[ 'REMOTE_USER' ] . ' -w ' . $_SERVER[ 'REMOTE_USER' ] . ' -p 2000' . " -X $sock " . $host . ' > /dev/null' ); sleep( 1 ); } $sieve = new Net_Sieve( $_SERVER[ 'REMOTE_USER' ], $_SERVER[ 'REMOTE_USER' ], $domain_socket, 0, NULL, NULL, true, true ); if( PEAR::isError( $sieve )) { print_r( $sieve ); } print_r( $sieve->listScripts()); ?>
 [2006-03-22 03:11 UTC] amistry at php dot net (Anish Mistry)
Sorry about that. I've updated the CVS. It should be fixed now. If you could just double-check the version there I'll roll a release once you've confirmed it. Thanks.
 [2006-03-23 17:50 UTC] liamr at umich dot edu
Looks good!
 [2006-05-21 06:36 UTC] amistry at php dot net (Anish Mistry)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/Net_Sieve