cURL / Mailing Lists / curl-library / Single Mail

curl-library

Patch to report the error message returned by libssh2 when using scp

From: Gavrie Philipson <gavrie_at_philipson.co.il>
Date: Wed, 4 Jul 2007 17:09:27 +0300

Hi,

I'm using curl with libssh2 to upload a file to a remote host using
the SCP protocol.
Now, if the remote side returns an error message such as "Permission
denied" or "No such file or directory", it is not reported by curl.
Instead, is returns the message "curl: (2) failed init" since the
error handling code returns CURLE_FAILED_INIT.

The attached patch reports the error message that is returned by
libssh2. It goes together with a patch to libssh2 (that I've posted on
the libssh2 list) that returns remote error messages (which the
current libssh2 doesn't do).

To see its effect, when using curl normally, this is what happens on a
"Permission denied" error:

Without the patch:

curl -T /etc/shadow scp://user:pass_at_hostname/etc/shadow
...
curl: (2) failed init

With the patch:

curl -T /etc/shadow scp://user:pass_at_hostname/etc/shadow
...
curl: (79) scp: /etc/shadow: Permission denied

-- Gavrie

Received on 2007-07-04