cURL cURL > Mailing List > Monthly Index > Single Mail

curl-tracker Archives

[curl:bugs] #1452 sftp upload not creating directories

From: Jeffrey Ding <jeffreyding_at_users.sf.net>
Date: Sat, 15 Nov 2014 04:51:40 +0000

---
** [bugs:#1452] sftp upload not creating directories**
**Status:** open
**Created:** Sat Nov 15, 2014 04:51 AM UTC by Jeffrey Ding
**Last Updated:** Sat Nov 15, 2014 04:51 AM UTC
**Owner:** nobody
curl 7.36.0 (i386-pc-win32) libcurl/7.36.0 OpenSSL/1.0.1g zlib/1.2.8 libssh2/1.4.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate Largefile NTLM SSL SSPI libz
Using curl to upload to an SFTP site fails to create directories, even when using --ftp-create-dirs flag.  I've only seen this error once, and is likely specific to the SFTP site I'm attempting to upload files to.  I also tested with version 7.39.0 with the same results.
I debugged curl/libcurl and determined the LIBSSH2 error code returned from the attempted file creation is LIBSSH2_FX_PERMISSION_DENIED.  This errorcode is not part of the if clause and results in immediate termination of the FTP session instead of proceeding with creating the FTP structure.
Relevent changes to ssh.c which adds the test for LIBSSH2_FX_PERMISSION_DENIED:
~~~~~~
          if(sshc->secondCreateDirs) {
            state(conn, SSH_SFTP_CLOSE);
            sshc->actualcode = err>= LIBSSH2_FX_OK?
              sftp_libssh2_error_to_CURLE(err):CURLE_SSH;
            failf(data, "Creating the dir/file failed: %s",
                  sftp_libssh2_strerror(err));
            break;
          }
          else if(((err == LIBSSH2_FX_NO_SUCH_FILE) ||
                   (err == LIBSSH2_FX_FAILURE) ||
                   (err == LIBSSH2_FX_NO_SUCH_PATH) ||
                   (err == LIBSSH2_FX_PERMISSION_DENIED)) &&
                  (data->set.ftp_create_missing_dirs &&
                   (strlen(sftp_scp->path) > 1))) {
            /* try to create the path remotely */
            sshc->secondCreateDirs = 1;
            state(conn, SSH_SFTP_CREATE_DIRS_INIT);
            break;
          }
~~~~~~
This addition seems like a reasonable workaround and would prevent me from using a custom version of curl in my production environment.
Thanks.
Jeff
---
Sent from sourceforge.net because curl-tracker@cool.haxx.se is subscribed to https://sourceforge.net/p/curl/bugs/
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/curl/admin/bugs/options.  Or, if this is a mailing list, you can unsubscribe from the mailing list.
Received on 2014-11-15

These mail archives are generated by hypermail.