[horde] [PATCH] SSL support in lib/VFS/ftp.php

Etienne Goyer etienne.goyer at linuxquebec.com
Thu Sep 4 09:10:31 PDT 2003


Change made as required.  I am not really happy about the parameter
comment.  You may wish to edit it for something shorter.

Also, should I have posted this patch on the dev mailing list instead ?

On Wed, Sep 03, 2003 at 11:00:44PM +0200, Jan Schneider wrote:
> Zitat von Etienne Goyer <etienne.goyer at linuxquebec.com>:
> 
> > Hi,
> >
> > Here is a trivial patch that add SSL support (aka FTPS) to the VFS ftp
> > driver.  This can be used, for example, with Proftpd + mod_tls.  I will
> > post a patch to the Gollem mailing list that add the required param with
> > explanation in gollem/config/backends.php if this one is accepted.
> >
> > This patch is to be applied to lib/VFS/ftp.php.  To make use of it, pass
> > an 'ssl' parameter along with 'hostspec' and 'port' to the VFS
> > constructor.
> 
> This is a nice addition, but you should also add an entry for that paramater
> in the comment header of the file and check if ftp_ssl_connect exists. This
> method is only availabe if openssl support is in php, you should return a
> PEAR_Error if the method doesn't exist.
> 
> Jan.
> 
> --
> http://www.horde.org - The Horde Project
> http://www.ammma.de - discover your knowledge
> http://www.tip4all.de - Deine private Tippgemeinschaft
> 
> -- 
> Horde mailing list
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: horde-unsubscribe at lists.horde.org

-- 
Etienne Goyer                    Linux Québec Technologies Inc.
http://www.LinuxQuebec.com       etienne.goyer at linuxquebec.com
-------------- next part --------------
--- ftp.php.orig	Thu Sep  4 11:59:35 2003
+++ ftp.php	Thu Sep  4 12:05:05 2003
@@ -9,6 +9,9 @@
  * Optional values for $params:
  *      'port'           The port used to connect to the ftp server if other
  *                       than 21.
+ *      'ssl'            If true, and your PHP had been compiled with SSL 
+ *                       support, TLS transport-level encryption will be 
+ *                       negociated with the server.
  *
  * $Horde: horde/lib/VFS/ftp.php,v 1.52 2003/08/23 20:31:22 jan Exp $
  *
@@ -696,7 +699,15 @@
             }
 
             /* Connect to the ftp server using the supplied parameters. */
-            $this->_stream = @ftp_connect($this->_params['hostspec'], $this->_params['port']);
+            if ($this->_params['ssl']) {
+                if (function_exists('ftp_ssl_connect')) {
+                    $this->_stream = @ftp_ssl_connect($this->_params['hostspec'], $this->_params['port']);
+                } else {
+                    return PEAR::raiseError(_("Unable to connect with SSL."));
+		}
+            } else {
+                $this->_stream = @ftp_connect($this->_params['hostspec'], $this->_params['port']);
+            }
             if (!$this->_stream) {
                 return PEAR::raiseError(_("Connection to FTP server failed."));
             }


More information about the horde mailing list