curl-library
Set CURLOPT_FTP_FILEMETHOD to CURLFTPMETHOD_NOCWD does not work when changing dir
Date: Fri, 18 Nov 2011 12:06:34 +0000
Hi,
I'm having a little problem here accessing a ftp that does not allow me to
access the root directory.
For this i use the CURLFTPMETHOD_NOCWD option in order to avoid commands
like this CWD "/", or CURLFTPMETHOD_SINGLECWD in order to access directly
to the ftp path. But it seems that when i try to change from one directory
to another directory in the same ftp server the libcurl sometimes (and this
is odd) it uses the CWD "/" command that is forbidden by the ftp server,
leading to a failed operation that previously worked fine.
Using this two options will not always prevent operations like this CWD
"/"? or this is something that the ftp server does!? or it is a bug of the
libcurl?
For example what i do to simulate the problem is something like this:
get file content from [
ftp://ftp.xpto.com/HGNOTO01/inv01_04/INV01_04-17-11-2011.csv]
list files from dir [ftp://ftp.xpto.com/HGNOTO01/inv01_05/]
and the verbose output is something like this:
* About to connect() to ftp.xpto.com port 21 (#0)
* Trying 95.23.33.17... * connected
* Connected to ftp.xpto.com (95.23.33.17) port 21 (#0)
< 220-FileZilla Server version 0.9.39 beta
< 220-written by Tim Kosse (Tim.Kosse_at_gmx.de)
< 220 Please visit http://sourceforge.net/projects/filezilla/
> USER aaaaa
< 331 Password required for aaaaa
> PASS xxxx
< 230 Logged on
> PWD
< 257 "/" is current directory.
* Entry path is '/'
> PORT 192,168,1,5,184,79
< 200 PORT command successful.
* Connect data stream actively
> TYPE I
< 200 Command okay.
> SIZE HGNOTO01/inv01_04/INV01_04-17-11-2011.csv
< 213 12390
> RETR HGNOTO01/inv01_04/INV01_04-17-11-2011.csv
< 150 File status okay; about to open data connection.
* Connection accepted from server
* Maxdownload = -1
* Getting file with size: 12390
* Remembering we are in dir ""
< 226 Transfer complete, closing data connection.
* Connection #0 to host ftp.xpto.com left intact
* Re-using existing connection! (#0) with host ftp.xpto.com
* Connected to ftp.xpto.com (95.23.33.17) port 21 (#0)
> CWD /
< 550 CWD failed. "/": Permission denied.
* Server denied you to change to the given directory
* Connection #0 to host ftp.xpto.com left intact
The code is normal code, something like this:
curl_easy_setopt(..., CURLOPT_URL, ... );
curl_easy_setopt(..., CURLOPT_USERNAME, ... );
curl_easy_setopt(..., CURLOPT_PASSWORD, ... );
curl_easy_setopt(..., CURLOPT_FTP_FILEMETHOD, ... );
curl_easy_setopt(..., CURLOPT_WRITEFUNCTION, ... );
curl_easy_setopt(..., CURLOPT_WRITEDATA, ... );
curl_easy_perform(...); // first get contents operation
...
curl_easy_setopt(..., CURLOPT_URL, ... );
curl_easy_setopt(..., CURLOPT_USERNAME, ... );
curl_easy_setopt(..., CURLOPT_PASSWORD, ... );
curl_easy_setopt(..., CURLOPT_FTP_FILEMETHOD, ... );
curl_easy_setopt(..., CURLOPT_WRITEFUNCTION, ... );
curl_easy_setopt(..., CURLOPT_WRITEDATA, ... );
curl_easy_setopt(..., CURLOPT_DIRLISTONLY, 1L );
curl_easy_perform(...); // list dir operation
curl_easy_setopt(..., CURLOPT_DIRLISTONLY, 0L );
...
I always set all the options, i think this is not a problem.
Can someone explain me what is wrong here and what are the possible
solutions for this (for now i have to destroy the libcurl enviroment and
start a new one - curl_easy_cleanup - and this works fine, but i loose all
the cached connections that i already have).
Thanks.
-- Nuno Esculcas
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-11-18