Commit Graph

317 Commits

Author SHA1 Message Date
Dan Fandrich 7fc4e8af0a Changed some arrays of char* to arrays of char[] to reduce data size and
run-time relocations.
2008-10-22 05:46:29 +00:00
Dan Fandrich 7ff38c14a9 Fixed some problems with SFTP range support to fix test cases 634 through 637. 2008-10-21 07:10:25 +00:00
Daniel Stenberg c27d2d4b93 - Ian Lynagh provided a patch that now makes CURLOPT_RANGE work fine for SFTP
downloads!
2008-09-29 13:21:21 +00:00
Yang Tse 4e909ee8b1 ntoa() and inet_ntoa_r() no longer used 2008-09-24 12:22:16 +00:00
Yang Tse a834b98232 fix compiler warning 2008-09-10 13:39:35 +00:00
Yang Tse 59e378f48f remove unnecessary typecasting of malloc() 2008-09-06 05:29:05 +00:00
Yang Tse a622fd90b4 remove unnecessary typecasting of calloc() 2008-09-06 04:47:14 +00:00
Dan Fandrich 0994d7811f Removed some redundant type casts 2008-09-02 18:36:39 +00:00
Yang Tse ad638da2c2 Library internal only C preprocessor macros FORMAT_OFF_T and FORMAT_OFF_TU
remain in use as internal curl_off_t print formatting strings for the internal
*printf functions which still cannot handle print formatting string directives
such as "I64d", "I64u", and others available on MSVC, MinGW, Intel's ICC, and
other DOS/Windows compilers.

This reverts previous commit part which did:

FORMAT_OFF_T  -> CURL_FORMAT_CURL_OFF_T
FORMAT_OFF_TU -> CURL_FORMAT_CURL_OFF_TU
2008-08-16 01:33:59 +00:00
Yang Tse 66fb9ca5f6 For congruency sake with the naming of other CURL_XXXXXX_CURL_OFF_T macros,
the names of the curl_off_t formatting string directives now become
CURL_FORMAT_CURL_OFF_T and CURL_FORMAT_CURL_OFF_TU.

CURL_FMT_OFF_T  -> CURL_FORMAT_CURL_OFF_T
CURL_FMT_OFF_TU -> CURL_FORMAT_CURL_OFF_TU

Remove the use of an internal name for the curl_off_t formatting string directives
and use the common one available from the inside and outside of the library.

FORMAT_OFF_T  -> CURL_FORMAT_CURL_OFF_T
FORMAT_OFF_TU -> CURL_FORMAT_CURL_OFF_TU
2008-08-15 02:58:15 +00:00
Dan Fandrich b000b8a736 Removed unneeded header files 2008-08-12 20:21:40 +00:00
Dan Fandrich 42cabc14d4 Added support for --append on SFTP uploads. Unfortunately, OpenSSH doesn't
support this so it goes untested.
2008-08-01 18:41:14 +00:00
Dan Fandrich b4b6cfdb1c Changed slightly the SFTP quote commands chmod, chown and chgrp to only
set the attribute that has changed instead of all possible ones. Hopefully,
this will solve the "Permission denied" problem that Nagarajan Sreenivasan
reported when setting some modes, but regardless, it saves a protocol
round trip in the chmod case.
2008-07-11 04:38:11 +00:00
Daniel Stenberg 7c648782bc Introcuding a new timestamp for curl_easy_getinfo():
CURLINFO_APPCONNECT_TIME. This is set with the "application layer"
handshake/connection is completed (typically SSL, TLS or SSH). By using this
you can figure out the application layer's own connect time. You can extract
the time stamp using curl's -w option and the new variable named
'time_appconnect'. This feature was sponsored by Lenny Rachitsky at NeuStar.
2008-07-03 06:56:03 +00:00
Yang Tse 4774582dfb Fix problem: 'result' may be used uninitialized.
Issue detected by Guenter Knauf's NetWare autobuild.
2008-05-31 01:37:21 +00:00
Daniel Stenberg b49dcfb52b - Jeff Weber reported memory leaks with aborted SCP and SFTP transfers and
provided excellent repeat recipes. I fixed the cases I managed to reproduce
  but Jeff still got some (SCP) problems even after these fixes:
  http://curl.haxx.se/mail/lib-2008-05/0342.html
2008-05-28 20:31:28 +00:00
Dan Fandrich 100945694a Removed some duplicated #includes 2008-05-21 21:08:31 +00:00
Michal Marek e2b82b4325 - Make Curl_write and it's callees accept a const pointer, in preparation
of tetetest's patch for curl_easy_send()
2008-05-09 11:27:54 +00:00
Daniel Stenberg d051dd8087 Scott Barrett added support for CURLOPT_NOBODY over SFTP 2008-04-03 20:56:59 +00:00
Dan Fandrich e9a460411f Fixed an infinite loop when given an invalid SFTP quote command. 2008-03-18 22:59:04 +00:00
Daniel Stenberg ad4a9955c5 - Brian Ulm figured out that if you did an SFTP upload with
CURLOPT_FTP_CREATE_MISSING_DIRS to create a directory, and then re-used the
  handle and uploaded another file to another directory that needed to be
  created, the second upload would fail. Another case of a state variable that
  wasn't properly reset between requests.
2008-03-13 21:43:30 +00:00
Daniel Stenberg 82e095a275 - Brian Ulm reported a crash when doing a second SFTP transfer on a re-used
easy handle if curl_easy_reset() was used between them. I fixed it and Brian
  verified that it cured his problem.

- Brian Ulm reported that if you first tried to download a non-existing SFTP
  file and then fetched an existing one and re-used the handle, libcurl would
  still report the second one as non-existing as well! I fixed it abd Brian
  verified that it cured his problem.
2008-03-09 11:37:48 +00:00
Daniel Stenberg 0836893335 Mike Protts brought a patch that makes resumed transfers work with SFTP. 2008-03-04 11:53:15 +00:00
Yang Tse 7b5c86033a fix compiler warnings: 'statement is unreachable' 2008-02-19 17:25:19 +00:00
Yang Tse d2125cf501 fix compiler warnings: 'enumerated type mixed with another type' 2008-02-19 15:07:50 +00:00
Yang Tse ab0de23d83 fix compiler warnings:
'enumerated type mixed with another type'

and

  'variable was set but never used'
2008-02-18 13:05:46 +00:00
Yang Tse dc42d6fb8d log SSH public key authentication failure and reason 2008-02-15 17:00:56 +00:00
Yang Tse acd7c94598 when unable to initialize sftp session, also log failure reason 2008-01-22 17:26:42 +00:00
Daniel Stenberg ed6466d176 Calls to Curl_failf() are not supposed to provide a trailing newline as the
function itself adds that. Fixed on 50 or something strings!
2008-01-15 23:19:02 +00:00
Daniel Stenberg 46e6115d72 include the libssh2 return code in the output for these failures to ease
debugging
2007-11-29 11:25:10 +00:00
Daniel Stenberg 13648f8ccd struct HandleData is now called struct SingleRequest, and is only for data that
is inited at the start of the DO action. I removed the Curl_transfer_keeper
struct completely, and I had to move out a few struct members (that had to
be set before DO or used after DONE) to the UrlState struct. The SingleRequest
struct is accessed with SessionHandle->req.

One of the biggest reasons for doing this was the bunch of duplicate struct
members in HandleData and Curl_transfer_keeper since it was really messy to
keep track of two variables with the same name and basically the same purpose!
2007-11-24 23:16:55 +00:00
Daniel Stenberg c508d70258 Fixed a remaining problem with doing SFTP directory listings on a re-used
persistent connection. Mentioned by Immanuel Gregoire on the mailing list.
2007-11-12 23:04:44 +00:00
Daniel Stenberg 3c71a1bab7 oops, fixed build when CURL_LIBSSH2_DEBUG is defined 2007-11-12 09:24:05 +00:00
Yang Tse b99a61c5b0 Fix compiler warning: may be used uninitialized 2007-11-08 16:43:01 +00:00
Daniel Stenberg ba6f20a244 Bug report #1823487 (http://curl.haxx.se/bug/view.cgi?id=1823487) pointed
out that SFTP requests didn't use persistent connections. Neither did SCP
ones.  I gave the SSH code a good beating and now both SCP and SFTP should
use persistent connections fine. I also did a bunch for indent changes as
well as a bug fix for the "keyboard interactive" auth.
2007-11-08 10:22:49 +00:00
Daniel Stenberg cbd1a77ec2 if () => if()
while () => while()
and some other minor re-indentings
2007-11-07 09:21:35 +00:00
Daniel Stenberg b9a7f4e502 Move connection-oriented variables from the SessionHandle struct to the
connectdata struct. This will in theory enable us to do persistent connections
with SCP+SFTP, but currently the state machine always (and wrongly) cleanup
everything in the 'done' action instead of in 'disconnect'. Also did a bunch
of indent fixes, if () => if() and a few other source cleanups like added
comments etc.
2007-11-05 09:30:45 +00:00
Daniel Stenberg 5b358603bd Michal Marek forwarded the bug report
https://bugzilla.novell.com/show_bug.cgi?id=332917 about a HTTP redirect to
FTP that caused memory havoc. His work together with my efforts created two
fixes:

#1 - FTP::file was moved to struct ftp_conn, because is has to be dealt with
     at connection cleanup, at which time the struct HandleData could be
     used by another connection.
     Also, the unused char *urlpath member is removed from struct FTP.

#2 - provide a Curl_reset_reqproto() function that frees
     data->reqdata.proto.* on connection setup if needed (that is if the
     SessionHandle was used by a different connection).
2007-10-22 15:05:35 +00:00
Yang Tse 92433e596b We use this ZERO_NULL to avoid picky compiler warnings,
when assigning a NULL pointer to a function pointer var.
2007-10-17 16:58:32 +00:00
Patrick Monnerat 07b6e7363d Added per-protocol callback static tables, replacing callback ptr storage
in the connectdata structure by a single handler table ptr.
2007-10-12 13:36:37 +00:00
Daniel Stenberg ce81cd21d3 I renamed the CURLE_SSL_PEER_CERTIFICATE error code to
CURLE_PEER_FAILED_VERIFICATION (standard CURL_NO_OLDIES style), and made this
return code get used by the previous SSH MD5 fingerprint check in case it
fails.
2007-10-03 08:07:50 +00:00
Daniel Stenberg 51c6a5d43b Based on a patch brought by Johnny Luong, libcurl now offers
CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 and the curl tool --hostpubmd5. They both make
the SCP or SFTP connection verify the remote host's md5 checksum of the public
key before doing a connect, to reduce the risk of a man-in-the-middle attack.
2007-10-03 08:00:42 +00:00
Daniel Stenberg f58ba5ab1c Immanuel Gregoire fixed a problem with persistent transfers over SFTP - the
previous proto struct was kept.
2007-09-29 21:34:34 +00:00
Daniel Stenberg bb667c8ac6 rename variable to prevent shadow warning 2007-09-28 21:45:05 +00:00
Daniel Stenberg 45fd6685bd Immanuel pointed out that public key SSH auth failed if no public/private
key was specified and there was no HOME environment variable, and then it
didn't continue to try the other auth methods. Now it will instead try to
get the files id_dsa.pub and id_dsa from the current directory if none of
the two conditions were met.
2007-09-18 21:14:28 +00:00
Dan Fandrich f6251734fc Added more accurate error code returns from SFTP operations. Added test
case 615 to test an SFTP upload failure.
2007-08-30 23:03:59 +00:00
Dan Fandrich 9f44a95522 Renamed several libcurl error codes and options to make them more general
and allow reuse by multiple protocols. Several unused error codes were
removed.  In all cases, macros were added to preserve source (and binary)
compatibility with the old names.  These macros are subject to removal at
a future date, but probably not before 2009.  An application can be
tested to see if it is using any obsolete code by compiling it with the
CURL_NO_OLDIES macro defined.

Documented some newer error codes in libcurl-error(3)
2007-08-30 20:34:57 +00:00
James Housley e7a50e37d6 Start adding some expanded error conversion of libssh2 errors. 2007-08-03 13:57:37 +00:00
Daniel Stenberg 252f16db02 remove left-over partly support for libssh2 0.14 2007-08-03 08:25:28 +00:00
Daniel Stenberg 72f5d6ba46 The SSH code now only works with libssh2 0.16 or later. Thus we must not
release the next curl until there is a libssh2 0.16 released.
2007-08-03 08:14:51 +00:00
Daniel Stenberg 50c10aa5bf Patrick Monnerat and I modified libcurl so that now it *copies* all strings
passed to it with curl_easy_setopt()! Previously it has always just refered
to the data, forcing the user to keep the data around until libcurl is done
with it. That is now history and libcurl will instead clone the given
strings and keep private copies.
2007-08-01 21:20:01 +00:00
Dan Fandrich b465750041 Make the pointers of a few static const arrays const, too, for safety. 2007-07-21 02:08:17 +00:00
James Housley 2ab854cafd Fix a loop with PWD 2007-07-20 01:03:49 +00:00
Dan Fandrich 4a2f0fb2be Made some const arrays static to avoid unnecessary stack usage. 2007-07-20 00:41:12 +00:00
James Housley ca1356702a As has been pointed out, err_msg should not be freed here. The actual
issue is in libssh2 and not freeing a dynamic error message during cleanup.
2007-07-18 18:31:34 +00:00
Gunter Knauf fee4f8c86d for now unless we do better fixed LIBSSH2_APINO compares to use long constants. 2007-07-14 15:59:01 +00:00
James Housley 8026d94c07 * Finish moving sftp:// into a state machine so it won't block in multi mode
* Move scp:// into a state machine so it won't block in multi mode
* When available use the full directory entry from the sftp:// server
2007-07-10 22:26:32 +00:00
James Housley 7fd4f82a45 Gavrie Philipson provided a patch that will use a more specific error
message for an scp:// upload failure.  If libssh2 has his matching
patch, then the error message return by the server will be used instead
of a more generic error.
2007-07-05 12:48:34 +00:00
James Housley 29357151af Fix spelling error in error message 2007-07-04 22:54:29 +00:00
James Housley 4cd7f85410 Add two new options for the SFTP/SCP/FILE protocols: CURLOPT_NEW_FILE_PERMS
and CURLOPT_NEW_DIRECTORY_PERMS.  These control the premissions for files
and directories created on the remote server.  CURLOPT_NEW_FILE_PERMS
defaults to 0644 and CURLOPT_NEW_DIRECTORY_PERMS defaults to 0755
2007-06-27 20:15:48 +00:00
Gunter Knauf edd35cab5c removed trailing spaces. 2007-06-27 10:14:00 +00:00
Gunter Knauf a2060effed fixed wrong var name 2007-06-27 10:12:48 +00:00
James Housley 7a360de49d The results for a list only directory should be sent to the callback 2007-06-26 20:23:10 +00:00
James Housley 1be4557694 ftp_list_only mode should list all file types, not just directories. 2007-06-26 19:12:58 +00:00
James Housley 6e7f47da5b If the creation of rsa and rsa_pub fail due to memory, don't try
other authentication methods.  Terminate with a memory error.
2007-06-20 11:30:35 +00:00
James Housley 277bab0c7b Check both variables, not the same one twice. Pointed out by Colin Hogben 2007-06-19 13:23:21 +00:00
Daniel Stenberg 891dffb528 extra precaution to make PATH_MAX always be defined 2007-06-19 11:50:08 +00:00
James Housley f0b361ecc1 Change rsa and rsa_pub from static arrays in ssh_conn to be dynamically
allocated when needed
2007-06-19 11:31:33 +00:00
James Housley df7eed16dd If LIBSSH2DEBUG was defined "i" was undefined 2007-06-18 22:28:40 +00:00
James Housley b61b420cb8 Curl_ssh_connect() was using an uninitialized variable in one location.
Caught by the auto-builds
2007-06-16 16:58:02 +00:00
James Housley db5d4bd811 Remove duplicate code that was left in as part of 1.35. This code
only affected sftp_sendquote() for the "chgrp/chmod/chown" commands.

This also fixed failure of test 614 on a system that previously failed.
2007-06-14 13:22:00 +00:00
James Housley 82d3f97659 BUG FIX: When reading a directory listing that contains symlinks
with the latest libssh2, the listing would be truncated at the symlink.
Fix by looping on LIBSSH2_ERROR_EAGAIN, like the rest of the calls.
2007-06-14 10:36:53 +00:00
James Housley f37dc9168a Restore functionality mistakenly removed in the previous commit 2007-06-13 17:13:44 +00:00
Gisle Vanem 05ba9f9fcd libssh2_session_free() returns void. Fix "#endif". 2007-06-13 14:01:48 +00:00
James Housley 96f4af4db9 Commit Tom Regner's code for SFTP create missing directories. This patch
uses the --ftp-create-dirs flag to control if cURL will try and create
directories that are specified in an upload path, but don't exist.
2007-06-13 12:15:23 +00:00
James Housley 3ec7f8a25a Add a define to protect the state machine from older versions of libssh2,
ie 0.14, that don't know about newer constants used in the state machine.
2007-06-13 11:27:41 +00:00
James Housley ab7e7144ef * Updates for the latest version of libssh2, specifically
libssh2_sftp_shutdown() and libssh2_session_free() can now return
  LIBSSH2_ERROR_EAGAIN.

* Fix the _send() and _recv() return values so non-blocking works
2007-06-12 21:32:45 +00:00
James Housley 6f59e19b91 While connect and transfer works fine in non-blocking mode for the test
suite, transfer fails in the real world.  So after connect set to blocking
as full non-blocking is migrated out.
2007-06-12 16:15:20 +00:00
James Housley 73c13220ee Prevent the state machine from getting stuck in SSH_AUTH_HOST_INIT 2007-06-12 13:47:32 +00:00
James Housley 99e0597c7b Convert Curl_ssh_connect() to run in a state machine for
LIBSSH2_APINO >= 200706012030.  More to come...
2007-06-12 12:31:10 +00:00
Gisle Vanem 03bc2d34da Squelsh some warnings for libssh older than 0.1.5. 2007-06-11 04:07:51 +00:00
James Housley 4f8ebd1673 Curl_scp_done() needs to call libssh2_channel_free() to prevent a
memory leak, and it is the right thing to do.
2007-06-08 16:19:21 +00:00
James Housley cd4e6fbcac Fix to work with the latest CVS version of libssh2
* As of (LIBSSH2_APINO >= 200706012030) there are not *nb() functions
* As of (LIBSSH2_APINO >= 200706012030) most libssh2_*() functions
  can return LIBSSH2_ERROR_EAGAIN to indicate that the call would block.

To make the code work as previously, blocking, all the code has been
updated so that when (LIBSSH2_APINO >= 200706012030) it loops simulating
blocking.  This allows the existing code to function and not hold up
the upcoming release.
2007-06-08 16:02:57 +00:00
Dan Fandrich ea43bb013b Added support for quote commands before a transfer using SFTP and test
case 614.
Allow SFTP quote commands chmod, chown, chgrp to set a value of 0.
2007-05-15 00:28:50 +00:00
Dan Fandrich 41ba7666f0 Kristian Gunstone fixed a problem where overwriting an uploaded file with
sftp didn't truncate it first, which would corrupt the file if the new
file was shorter than the old.
2007-05-09 18:24:27 +00:00
Daniel Stenberg 1b7f00b2a6 CURLE_FTP_COULDNT_STOR_FILE is now known as CURLE_UPLOAD_FAILED. This is
because I just made SCP uploads return this value if the file size of
the upload file isn't given with CURLOPT_INFILESIZE*. Docs updated to
reflect this news, and a define for the old name was added to the public
header file.
2007-05-08 11:34:31 +00:00
Daniel Stenberg c234b9d04b clarify the comment about libssh2_sftp_write's return type 2007-04-18 20:15:22 +00:00
Daniel Stenberg 7a86740afd - James Housley made SFTP uploads use libssh2's non-blocking API (if available) 2007-04-18 20:11:47 +00:00
Daniel Stenberg c518c52aba Nick Zitzmann did ssh.c cleanups 2007-04-08 22:44:21 +00:00
Dan Fandrich e9ffa9a3b8 Fixed a few memory leaks in OOM conditions.
Made libssh2 logging more verbose when debugging is enabled.
2007-04-06 06:32:05 +00:00
Dan Fandrich 7d48d851a2 Fixed a memory leak and improper shutdown on SFTP post-quote command failure. 2007-04-04 00:46:16 +00:00
Daniel Stenberg 20d33ad7e5 Nick Zitzmann made CURLOPT_POSTQUOTE work for SFTP as well. 2007-04-02 21:24:05 +00:00
Dan Fandrich 7763bb9172 Send an EOF message before closing a channel, as recommended by RFC4254.
Enable libssh2 tracing when ssh debugging is turned on.
2007-03-29 19:17:18 +00:00
Dan Fandrich 2bd1d7e996 Fixed a couple of compile problems. 2007-03-24 17:23:01 +00:00
Dan Fandrich 0043e87014 Added --pubkey option to curl and made --key also work for SCP/SFTP,
plus made --pass work on an SSH private key as well.
2007-03-23 17:59:40 +00:00
Dan Fandrich 6bb9bd8b69 Don't shut down sftp in an error if it was never started. 2007-03-23 00:03:34 +00:00
Dan Fandrich 9189ac1141 Fixed some memory leaks in various error paths. 2007-03-15 21:25:56 +00:00
Dan Fandrich 8605321d06 Fixed a memory leak. 2007-03-15 00:04:41 +00:00
Dan Fandrich 9cb69f77f1 Fixed a NULL pointer dereference on sftp initialization failure.
Added some more debug logs.
2007-03-14 02:04:17 +00:00
Gisle Vanem c514a2a89a Removed inclusion of <sys/types.h> and <sys/stat.h> in .c-files
since they're already included through "setup.h".
2007-02-26 04:24:26 +00:00
Daniel Stenberg 04e6568a7e SCP upload done non-blocking 2007-02-07 22:00:33 +00:00
Daniel Stenberg 028a9d6785 read SFTP with the non-blocking API 2007-02-06 15:41:19 +00:00
Daniel Stenberg abe90019d3 prefer using the (upcoming) non-blocking libssh2 API 2007-02-02 15:26:57 +00:00
Daniel Stenberg 8162b32bad silence compiler warnings 2007-01-28 22:36:23 +00:00
Gunter Knauf d31153584e another small fix to directory listing output; disabled CURL_LIBSSH2_DEBUG. 2007-01-28 12:35:39 +00:00
Gunter Knauf a79e5d7925 fix sftp directory listing so that it works without -v and is redirectable with -o/-O. 2007-01-27 12:14:02 +00:00
Gunter Knauf 82491d5c06 tell us what we put out here... 2007-01-27 11:50:42 +00:00
Daniel Stenberg 9e1aef7183 very minor indent change 2007-01-23 22:13:05 +00:00
Daniel Stenberg 385e612fa5 - Armel Asselin improved libcurl to behave a lot better when an easy handle
doing an FTP transfer is removed from a multi handle before completion. The
  fix also fixed the "alive counter" to be correct on "premature removal" for
  all protocols.
2007-01-16 22:22:10 +00:00
Daniel Stenberg cb4a5f5a2b minor indent fix 2006-12-21 15:47:19 +00:00
Daniel Stenberg 9ea3831c08 James Housley fixed SCP downloading by setting the maxdownload. 2006-11-25 09:49:29 +00:00
Daniel Stenberg a634f64400 James Housley did lots of work and introduced SFTP downloads. 2006-11-24 22:14:39 +00:00
Gisle Vanem b8039a821b Call libssh2_session_free() to release memory allocated during
libssh2 startup.
2006-11-15 05:35:35 +00:00
Gisle Vanem 438312f00e Free 'scp->path' in case of libssh2 setup failure. 2006-11-14 20:26:13 +00:00
Yang Tse d1c84705ec remove redundant check for Win32 2006-11-06 18:26:36 +00:00
Gisle Vanem bf57e9bb12 Ifdef around S_IRGRP and S_IROTH (meaningless on Win32). 2006-11-03 15:52:21 +00:00
Daniel Stenberg 2147284cad James Housley brought support for SCP transfers 2006-11-02 21:56:40 +00:00