cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Graceful switch from PASV to PORT on failure (like 502)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 19 Jul 2007 23:24:28 +0200 (CEST)

On Wed, 18 Jul 2007, Daniel Cater wrote:

> Thanks for the pointers, unfortunately I need some more help.

I can see that! :-)

> Here is the patch I applied (against curl-7.16.5-20070718):
>
> --- curl-7.16.5-20070718\lib\ftp.c 2007-07-18 04:00:02.000000000 +0100
> +++ curl-7.16.5-20070718-2\lib\ftp.c 2007-07-18 12:49:27.519984000 +0100
> @@ -1715,6 +1715,14 @@ static CURLcode ftp_state_pasv_resp(stru
> /* remain in the FTP_PASV state */
> return result;
> }
> + else if(ftpcode == 502) {
> + data->set.ftpport = "-";
> + data->set.ftp_use_port = 1;
> + infof(data, "disabling PASV usage\n");
> + data->reqdata.newurl = data->set.set_url;
> + state(conn, FTP_STOP);
> + return CURLE_OK;
> + }

1) This behavior should be an option, not default behavior

2) You MUST NOT change the options in data->set as that is where the app's
    choices are stored, dynamic changes internally in the lib must be stored
    elsewhere. This of course is needed to that subsequent uses of the easy
    handle all have the same options set as the app has set them to.

3) data->reqdata.newurl must get a pointer to an allocated string, and...

4) ... if you want to clone the current URL, you should get it from
    data->change.url and not from data->set.set_url

Then, you should show us the FTP "trace" without cutting off interesting
information. It seems it sent PORT but the server couldn't connect back to
you?

Are you running against a local server? It seems your client uses a 172.*
address, and of course nothing outside your local network can connect back to
that!

It would be useful if you showed us a comparison with full logs with the
"rever to PORT" option enabled and one log with PORT enabled manually.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2007-07-19