cURL / Mailing Lists / curl-library / Single Mail

curl-library

ftp with EPSV behind a buggy firewall (patch)

From: Michal Marek <mmarek_at_suse.cz>
Date: Tue, 24 Jan 2006 10:42:31 +0100

Hi,

curl uses EPSV by default and fallbacks to PASV if the server doesn't
support it. However, if there is some firewall in the way which doesn't
support EPSV, then curl gives up after the data connection is refused
(because the firewall didn't let it through). The attached patch makes
curl try PASV in that case as well. See also a bugreport from a SUSE
Linux user about this:
https://bugzilla.novell.com/show_bug.cgi?id=136794#c5 (comments #5 and
below).

Curl with this patch fails test238, because it manages to retrieve the
file instead of giving up as it is supposed -- I think this is no
regression.

have a nice day
Michal Marek
SUSE CR

--- lib/ftp.c
+++ lib/ftp.c
@@ -1652,6 +1652,17 @@
                             &connected);
 
   Curl_resolv_unlock(data, addr); /* we're done using this address */
+ if (result && ftp->count1 == 0 && ftpcode == 229) {
+ infof(data, "got positive EPSV response, but can't connect\n");
+ /* disable it for next transfer */
+ conn->bits.ftp_use_epsv = FALSE;
+ infof(data, "disabling EPSV usage\n");
+
+ NBFTPSENDF(conn, "PASV", NULL);
+ ftp->count1++;
+ /* remain in the FTP_PASV state */
+ return result;
+ }
 
   if(result)
     return result;
Received on 2006-01-24