FreeBSD Bugzilla – Attachment 61323 Details for
Bug 91899
Add STARTTLS support to Net_Sieve
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
pear-Net_Sieve-STARTTLS.patch
pear-Net_Sieve-STARTTLS.patch (text/plain), 4.83 KB, created by
amistry
on 2006-01-17 04:20:03 UTC
(
hide
)
Description:
pear-Net_Sieve-STARTTLS.patch
Filename:
MIME Type:
Creator:
amistry
Created:
2006-01-17 04:20:03 UTC
Size:
4.83 KB
patch
obsolete
>diff -ruN pear-Net_Sieve.orig/Makefile pear-Net_Sieve/Makefile >--- pear-Net_Sieve.orig/Makefile Mon Jan 16 23:04:35 2006 >+++ pear-Net_Sieve/Makefile Mon Jan 16 23:09:09 2006 >@@ -7,6 +7,7 @@ > > PORTNAME= Net_Sieve > PORTVERSION= 1.1.1 >+PORTREVISION= 1 > CATEGORIES= net www pear > > MAINTAINER= martin@matuska.org >diff -ruN pear-Net_Sieve.orig/files/patch-Sieve.php pear-Net_Sieve/files/patch-Sieve.php >--- pear-Net_Sieve.orig/files/patch-Sieve.php Wed Dec 31 19:00:00 1969 >+++ pear-Net_Sieve/files/patch-Sieve.php Wed Jan 4 14:39:08 2006 >@@ -0,0 +1,123 @@ >+--- Sieve.php.orig Sat Dec 17 17:48:27 2005 >++++ Sieve.php Wed Jan 4 14:37:54 2006 >+@@ -331,7 +331,7 @@ >+ * @param string $port Port of server >+ * @return mixed True on success, PEAR_Error otherwise >+ */ >+- function connect($host, $port) >++ function connect($host, $port, $options = null) >+ { >+ if (NET_SIEVE_STATE_DISCONNECTED != $this->_state) { >+ $msg='Not currently in DISCONNECTED state'; >+@@ -339,16 +339,16 @@ >+ return $this->_raiseError($msg,$code); >+ } >+ >+- if (PEAR::isError($res = $this->_sock->connect($host, $port, null, 5))) { >++ if (PEAR::isError($res = $this->_sock->connect($host, $port, null, 5, $options))) { >+ return $res; >+ } >+ >+- >+ $this->_state = NET_SIEVE_STATE_AUTHORISATION; >+ if (PEAR::isError($res = $this->_doCmd())) { >+ return $res; >+ } >+- /* >++ >++ /* >+ if(PEAR::isError($res = $this->_cmdCapability() )) { >+ $msg='Failed to connect, server said: ' . $res->getMessage(); >+ $code=2; >+@@ -358,6 +358,15 @@ >+ // Get logon greeting/capability and parse >+ $this->_parseCapability($res); >+ >++ // check if we can enable TLS via STARTTLS >++ if($this->_capability['starttls'] == true && function_exists('stream_socket_enable_crypto') == true) >++ {// begin enable TLS >++ if (PEAR::isError($res = $this->_startTLS())) { >++ return $res; >++ } >++ }// end enable TLS >++ >++ >+ return true; >+ } >+ >+@@ -806,7 +815,7 @@ >+ $data = preg_split('/\r?\n/', $data, -1, PREG_SPLIT_NO_EMPTY); >+ >+ for ($i = 0; $i < count($data); $i++) { >+- if (preg_match('/^"([a-z]+)" ("(.*)")?$/i', $data[$i], $matches)) { >++ if (preg_match('/^"([a-z]+)"( "(.*)")?$/i', $data[$i], $matches)) { >+ switch (strtolower($matches[1])) { >+ case 'implementation': >+ $this->_capability['implementation'] = $matches[3]; >+@@ -822,6 +831,7 @@ >+ >+ case 'starttls': >+ $this->_capability['starttls'] = true; >++ break; >+ } >+ } >+ } >+@@ -946,8 +956,10 @@ >+ if (preg_match('/^bye \(referral "(sieve:\/\/)?([^"]+)/i', $line, $matches)) { >+ // Check for referral, then follow it. Otherwise, carp an error. >+ //$this->_data['host'] = $matches[1]; >+- $this->_data['host'] = $matches[2]; >+- if (PEAR::isError($error = $this->_handleConnectAndLogin() ) ){ >++ //$this->_data['host'] = $matches[2]; >++ //replace the old host with the referral host preserving any protocol prefix >++ $this->_data['host'] = preg_replace('/\w+(?!(\w|\:\/\/)).*/',$matches[2],$this->_data['host']); >++ if (PEAR::isError($error = $this->_handleConnectAndLogin() ) ){ >+ $msg="Can't follow referral to " . $this->_data['host'] . ", The error was= " . $error->getMessage() ; >+ $code=5; >+ return $this->_raiseError($msg,$code); >+@@ -1133,7 +1145,7 @@ >+ >+ >+ /** >+- * Return true if tyhe server has that extension >++ * Return true if the server has that extension >+ * >+ * @access public >+ * @param string the extension to compare >+@@ -1157,9 +1169,32 @@ >+ return false; >+ } >+ >++ /** >++ * Return true if the TLS negotiation was successful >++ * >++ * @access public >++ * @return mixed true on success, PEAR_Error on failure >++ */ >++ function _startTLS() >++ { >++ if (PEAR::isError($res = $this->_doCmd("STARTTLS"))) { >++ return $res; >++ } >++ >++ if(stream_socket_enable_crypto($this->_sock->fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT) == false) { >++ $msg='Failed to establish TLS connection'; >++ $code=2; >++ return $this->_raiseError($msg,$code); >++ } >+ >+- >+- >++ // RFC says we need to query the server capabilities again >++ if(PEAR::isError($res = $this->_cmdCapability() )) { >++ $msg='Failed to connect, server said: ' . $res->getMessage(); >++ $code=2; >++ return $this->_raiseError($msg,$code); >++ } >++ return true; >++ } >+ >+ } >+-?> >+\ No newline at end of file >++?>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 91899
: 61323