cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: ftp_perform problem

From: Dave Halbakken <YetAnotherDev_at_netscape.net>
Date: Thu, 06 Mar 2003 18:22:33 -0800

Hi,

Just figured out way to make this work. Probably libcurl is doing the
right thing, but I'm not sure.

If I use '/' as the path for the URL passed to the CUSTOMREQUEST in my
step 4, below, the problem goes away. So the URL

"ftp://myftpserver/

makes the CUSTOMREQUEST work as I expect.

If this is the expected behavior for libcurl, then my apologies for
bothering the group.

Dave Halbakken

YetAnotherDev_at_netscape.net wrote:
> Hi,
>
> I'm using curl-7.10.4-pre3 with VC6 compiler on Win2K. I'm having
> trouble executing a LIST command as a CUSTOMREQUEST.
>
> Here's what is happening:
>
> 1. Establish a connection to a server with a url that looks like:
>
> "user:password_at_myftpserver/"
>
> Here are the server responses:
>
> "220 myftpserver FTP server (Version wu-2.6.1-18) ready."
> "331 Password required for user."
> "230 User user logged in."
> "257 "/home/mygroup/user_home" is current directory."
>
> Note that the ftp server drops you into a directory other than '/', but
> libcurl seems to record that information internally.
>
> 2. Execute a CWD commmand as a POSTQUOTE with a path that looks like:
>
> "../otherdir/"
>
> Here's the response from the server:
>
> "250 CWD command successful."
>
> 3. Execute a PWD command as another POSTQUOTE. The server responds:
>
> "257 "/home/mygroup/otherdir" is current directory.
>
> 4. Execute a CUSTOMREQUEST with the string:
>
> "LIST /home/mygroup/otherdir/"
>
> and the URL
>
> "ftp://myftpserver/home/mygroup/otherdir/"
>
> Here are the server responses:
>
> "250 CWD command successful."
> "550 home/mygroup/otherdir: No such file or directory."
>
> Tracing into ftp.c function ftp_perform() I found this code:
>
>
> /* This is a re-used connection. Since we change directory to where the
> transfer is taking place, we must now get back to the original dir
> where we ended up after login: */
> if (conn->bits.reuse && ftp->entrypath) {
> if ((result = ftp_cwd(conn, ftp->entrypath)) != CURLE_OK)
> return result;
> }
>
> /* change directory first! */
> if(ftp->dir && ftp->dir[0]) {
> if ((result = ftp_cwd(conn, ftp->dir)) != CURLE_OK)
> return result;
> }
>
>
> The first ftp_cwd() succeeds and the working directory changes to
>
> /home/mygroup/user_home
>
> but the second ftp_cwd() fails. Libcurl appears to drop the first '/'
> character of the path passed to ftp_cwd(), so the path seems to be
> interpreted as being relative to ftp->entrypath instead of relative to '/'.
>
> Is this a known bug, or is there a way to tell libcurl to retain the
> first '/' in the path for the second ftp_cwd?
>
> Dave Halbakken
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Etnus, makers of TotalView, The
> debugger for complex code. Debugging C/C++ programs can leave you
> feeling lost and disoriented. TotalView can help you find your way.
> Available on major UNIX and Linux platforms. Try it free. www.etnus.com
>

-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger
for complex code. Debugging C/C++ programs can leave you feeling lost and
disoriented. TotalView can help you find your way. Available on major UNIX
and Linux platforms. Try it free. www.etnus.com
Received on 2003-03-07