cURL / Mailing Lists / curl-library / Single Mail

curl-library

Handling FTP servers that indicate backslash as CWD

From: John Coffey <johnco3_at_gmail.com>
Date: Wed, 11 Feb 2015 00:38:00 -0500

Does anyone know of a way to avoid the automatic CWD command in libCurl,
 as I am connecting to an FTP server that indicates "\" is current working
directory. I am only uploading files to this server, so I do not need to
know the current working directory.

This is a very old windows based embedded server that I cannot modify.
Normally such a system would result in a "SYST" command being issued (see
snippet of code from libCurl's ftp.c below) under the covers in order to
identify the system. Unfortunately this very old server does not support
that command either. As a toying with making some kind of hack to at least
bypass the problem with dir[0] below but I don't fully know the
ramifications of this. At least the change below allows the default CWD
response from the FTP server to keep libCurl happy. If this problem has
been encountered and worked abound before, it would be great to know

John

          /* If the path name does not look like an absolute path
(i.e.: it does not start with a '/'), we probably need
some server-dependent adjustments. For example, this is
the case when connecting to an OS400 FTP server: this
server supports two name syntaxes, the default one being
incompatible with standard pathes. In addition, this
server switches automatically to the regular path syntax
when one is encountered in a command: this results in
having an entrypath in the wrong syntax when later used in CWD.
       The method used here is to check the server OS: we do it only
          if the path name looks strange to minimize overhead on other
            systems. */

          if(!ftpc->server_os && dir[0] != '/' dir[0] != '\\' ) { //
ADD THE EXTRA TEST FOR BACKSLASH

            result = Curl_pp_sendf(&ftpc->pp, "%s", "SYST");
            if(result) {
              free(dir);
              return result;
            }
            Curl_safefree(ftpc->entrypath);
            ftpc->entrypath = dir; /* remember this */
            infof(data, "Entry path is '%s'\n", ftpc->entrypath);
            /* also save it where getinfo can access it: */
            data->state.most_recent_ftp_entrypath = ftpc->entrypath;
            state(conn, FTP_SYST);
            break;
          }

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-02-11