summaryrefslogtreecommitdiff
path: root/lib/ssh.c
Commit message (Collapse)AuthorAgeFilesLines
* code style: use spaces around plusesDaniel Stenberg2017-09-111-10/+10
|
* code style: use spaces around equals signsDaniel Stenberg2017-09-111-5/+5
|
* ssh: add the ability to enable compression (for SCP/SFTP)Viktor Szakats2017-08-171-0/+7
| | | | | | | | | | | | | | | | | | The required low-level logic was already available as part of `libssh2` (via `LIBSSH2_FLAG_COMPRESS` `libssh2_session_flag()`[1] option.) This patch adds the new `libcurl` option `CURLOPT_SSH_COMPRESSION` (boolean) and the new `curl` command-line option `--compressed-ssh` to request this `libssh2` feature. To have compression enabled, it is required that the SSH server supports a (zlib) compatible compression method and that `libssh2` was built with `zlib` support enabled. [1] https://www.libssh2.org/libssh2_session_flag.html Ref: https://github.com/curl/curl/issues/1732 Closes https://github.com/curl/curl/pull/1735
* strtoofft: reduce integer overflow risks globallyDaniel Stenberg2017-08-141-5/+12
| | | | | | | ... make sure we bail out on overflows. Reported-by: Brian Carpenter Closes #1758
* timeval: struct curltime is a struct timeval replacementDaniel Stenberg2017-07-281-1/+1
| | | | | | | | | ... to make all libcurl internals able to use the same data types for the struct members. The timeval struct differs subtly on several platforms so it makes it cumbersome to use everywhere. Ref: #1652 Closes #1693
* handler: refactor connection checkingMax Dymond2017-06-301-0/+2
| | | | | | Add a new type of callback to Curl_handler which performs checks on the connection. Alter RTSP so that it uses this callback to do its own check on connection health.
* ssh: fix 'left' may be used uninitializedDaniel Stenberg2017-05-251-1/+1
| | | | | | | follow-up to f31760e63b4e Reported-by: Michael Kaufmann Bug: https://github.com/curl/curl/pull/1495#issuecomment-303982793
* ssh: ignore timeouts during disconnectDaniel Stenberg2017-05-201-12/+15
| | | | | | | | | | | | ... as otherwise it risks not cleaning up the libssh2 handle properly which leads to memory leak! Assisted-by: Joel Depooter Closes #1495 Closes #1479 Bug: https://curl.haxx.se/mail/lib-2017-04/0024.html
* multi: use a fixed array of timers instead of mallocDaniel Stenberg2017-05-101-1/+1
| | | | | | | | | | ... since the total amount is low this is faster, easier and reduces memory overhead. Also, Curl_expire_done() can now mark an expire timeout as done so that it never times out. Closes #1472
* ssh: fix compiler warning from e40e9d7f0deDaniel Stenberg2017-05-021-1/+1
|
* buffer: use data->set.buffer_size instead of BUFSIZEDaniel Stenberg2017-05-011-3/+4
| | | | ... to properly use the dynamically set buffer size!
* ssh: fix narrowing conversion warningMarcel Raad2017-03-301-1/+1
| | | | | | | | 'left' is used as time_t but declared as long. MinGW complains: error: conversion to 'long int' from 'time_t {aka long long int}' may alter its value [-Werror=conversion] Changed the declaration to time_t.
* Improve code readbilitySylvestre Ledru2017-03-131-168/+147
| | | | | | ... by removing the else branch after a return, break or continue. Closes #1310
* sftp: improved checks for create dir failuresJean Gressmann2017-02-201-1/+9
| | | | | | | Since negative values are errors and not only -1. This makes SFTP upload with --create-dirs work (again). Closes #1269
* ssh: inhibit coverity warning with (void)Daniel Stenberg2016-12-201-2/+2
| | | | CID 1397391 (#1 of 1): Unchecked return value (CHECKED_RETURN)
* checksrc: warn for assignments within if() expressionsDaniel Stenberg2016-12-141-15/+20
| | | | | ... they're already frowned upon in our source code style guide, this now enforces the rule harder.
* checksrc: stricter no-space-before-paren enforcementDaniel Stenberg2016-12-131-4/+4
| | | | In order to make the code style more uniform everywhere
* proxy: Support HTTPS proxy and SOCKS+HTTP(s)Alex Rousskov2016-11-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * HTTPS proxies: An HTTPS proxy receives all transactions over an SSL/TLS connection. Once a secure connection with the proxy is established, the user agent uses the proxy as usual, including sending CONNECT requests to instruct the proxy to establish a [usually secure] TCP tunnel with an origin server. HTTPS proxies protect nearly all aspects of user-proxy communications as opposed to HTTP proxies that receive all requests (including CONNECT requests) in vulnerable clear text. With HTTPS proxies, it is possible to have two concurrent _nested_ SSL/TLS sessions: the "outer" one between the user agent and the proxy and the "inner" one between the user agent and the origin server (through the proxy). This change adds supports for such nested sessions as well. A secure connection with a proxy requires its own set of the usual SSL options (their actual descriptions differ and need polishing, see TODO): --proxy-cacert FILE CA certificate to verify peer against --proxy-capath DIR CA directory to verify peer against --proxy-cert CERT[:PASSWD] Client certificate file and password --proxy-cert-type TYPE Certificate file type (DER/PEM/ENG) --proxy-ciphers LIST SSL ciphers to use --proxy-crlfile FILE Get a CRL list in PEM format from the file --proxy-insecure Allow connections to proxies with bad certs --proxy-key KEY Private key file name --proxy-key-type TYPE Private key file type (DER/PEM/ENG) --proxy-pass PASS Pass phrase for the private key --proxy-ssl-allow-beast Allow security flaw to improve interop --proxy-sslv2 Use SSLv2 --proxy-sslv3 Use SSLv3 --proxy-tlsv1 Use TLSv1 --proxy-tlsuser USER TLS username --proxy-tlspassword STRING TLS password --proxy-tlsauthtype STRING TLS authentication type (default SRP) All --proxy-foo options are independent from their --foo counterparts, except --proxy-crlfile which defaults to --crlfile and --proxy-capath which defaults to --capath. Curl now also supports %{proxy_ssl_verify_result} --write-out variable, similar to the existing %{ssl_verify_result} variable. Supported backends: OpenSSL, GnuTLS, and NSS. * A SOCKS proxy + HTTP/HTTPS proxy combination: If both --socks* and --proxy options are given, Curl first connects to the SOCKS proxy and then connects (through SOCKS) to the HTTP or HTTPS proxy. TODO: Update documentation for the new APIs and --proxy-* options. Look for "Added in 7.XXX" marks.
* realloc: use Curl_saferealloc to avoid common mistakesDaniel Stenberg2016-11-111-3/+4
| | | | Discussed: https://curl.haxx.se/mail/lib-2016-11/0087.html
* ssh: check md5 fingerprints case insensitively (regression)Daniel Stenberg2016-11-071-1/+1
| | | | | | | Revert the change from ce8d09483eea but use the new function Reported-by: Kamil Dudka Bug: https://github.com/curl/curl/commit/ce8d09483eea2fcb1b50e323e1a8ed1f3613b2e3#commitcomment-19666146
* strcasecompare: all case insensitive string compares ignore locale nowDaniel Stenberg2016-10-311-15/+15
| | | | | We had some confusions on when each function was used. We should not act differently on different locales anyway.
* strcasecompare: is the new name for strequal()Daniel Stenberg2016-10-311-1/+1
| | | | | | | ... to make it less likely that we forget that the function actually does case insentive compares. Also replaced several invokes of the function with a plain strcmp when case sensitivity is not an issue (like comparing with "-").
* SSH: check md5 fingerprint case sensitivelyDaniel Stenberg2016-10-311-1/+1
|
* escape: avoid using curl_easy_unescape() internallyDaniel Stenberg2016-10-311-6/+6
| | | | Since the internal Curl_urldecode() function has a better API.
* select: switch to macros in uppercaseDaniel Stenberg2016-10-181-1/+1
| | | | | | | | | | Curl_select_ready() was the former API that was replaced with Curl_select_check() a while back and the former arg setup was provided with a define (in order to leave existing code unmodified). Now we instead offer SOCKET_READABLE and SOCKET_WRITABLE for the most common shortcuts where only one socket is checked. They're also more visibly macros.
* http2: Remove incorrect commentsJay Satiro2016-08-251-5/+0
| | | | .. also remove same from scp
* multi: make Curl_expire() work with 0 ms timeoutsDaniel Stenberg2016-08-041-1/+1
| | | | | | | | | | Previously, passing a timeout of zero to Curl_expire() was a magic code for clearing all timeouts for the handle. That is now instead made with the new Curl_expire_clear() function and thus a 0 timeout is fine to set and will trigger a timeout ASAP. This will help removing short delays, in particular notable when doing HTTP/2.
* conn: don't free easy handle data in handler->disconnectDaniel Stenberg2016-06-291-4/+0
| | | | | Reported-by: Gou Lingfeng Bug: https://curl.haxx.se/mail/lib-2016-06/0139.html
* SFTP: set a generic error when no SFTP one exists...Daniel Stenberg2016-06-281-2/+7
| | | | | | | | ... as otherwise we could get a 0 which would count as no error and we'd wrongly continue and could end up segfaulting. Bug: https://curl.haxx.se/mail/lib-2016-06/0052.html Reported-by: 暖和的和暖
* typedefs: use the full structs in internal code...Daniel Stenberg2016-06-221-1/+1
| | | | ... and save the typedef'ed names for headers and external APIs.
* internals: rename the SessionHandle struct to Curl_easyDaniel Stenberg2016-06-221-7/+7
|
* ssh: fix version number check typoDaniel Stenberg2016-05-301-1/+1
|
* ssh: fix build for libssh2 before 1.2.6Daniel Stenberg2016-05-291-1/+9
| | | | | | | The statvfs functionality was added to libssh2 in that version, so we switch off that functionality when built with older libraries. Fixes #831
* lib: include curl_printf.h as one of the last headersDaniel Stenberg2016-04-291-1/+2
| | | | | | | | | | | | | | | | | | | | curl_printf.h defines printf to curl_mprintf, etc. This can cause problems with external headers which may use __attribute__((format(printf, ...))) markers etc. To avoid that they cause problems with system includes, we include curl_printf.h after any system headers. That makes the three last headers to always be, and we keep them in this order: curl_printf.h curl_memory.h memdebug.h None of them include system headers, they all do funny #defines. Reported-by: David Benjamin Fixes #743
* code: style updatesDaniel Stenberg2016-04-031-1/+1
|
* multi: turn Curl_done into file local multi_doneDaniel Stenberg2016-03-301-3/+2
| | | | ... as it now is used by multi.c only.
* SSH: new CURLOPT_QUOTE command "statvfs"marquis-de-muesli2016-03-271-0/+57
| | | | | usage: "statvfs path" returns remote file system statistics
* SSH: support CURLINFO_FILETIMEmarquis-de-muesli2016-03-271-3/+34
|
* SCP: use libssh2_scp_recv2 to support > 2GB files on windowsDavid Byron2016-02-141-4/+15
| | | | | | | libssh2_scp_recv2 is introduced in libssh2 1.7.0 - to be released "any day now. Closes #451
* URLs: change all http:// URLs to https://Daniel Stenberg2016-02-031-1/+1
|
* ssh: make CURLOPT_SSH_PUBLIC_KEYFILE treat "" as NULLKamil Dudka2016-01-151-2/+5
| | | | | | | | | | | | The CURLOPT_SSH_PUBLIC_KEYFILE option has been documented to handle empty strings specially since curl-7_25_0-31-g05a443a but the behavior was unintentionally removed in curl-7_38_0-47-gfa7d04f. This commit restores the original behavior and clarifies it in the documentation that NULL and "" have both the same meaning when passed to CURLOPT_SSH_PUBLIC_KEYFILE. Bug: http://curl.haxx.se/mail/lib-2016-01/0072.html
* Revert "cleanup: general removal of TODO (and similar) comments"Daniel Stenberg2015-11-241-3/+11
| | | | | | | This reverts commit 64e959ffe37c436503f9fed1ce2d6ee6ae50bd9a. Feedback-by: Dan Fandrich URL: http://curl.haxx.se/mail/lib-2015-11/0062.html
* cleanup: general removal of TODO (and similar) commentsDaniel Stenberg2015-11-131-11/+3
| | | | | | They tend to never get updated anyway so they're frequently inaccurate and we never go back to revisit them anyway. We document issues to work on properly in KNOWN_BUGS and TODO instead.
* fread_func: move callback pointer from set to state structDaniel Stenberg2015-10-151-2/+2
| | | | | | | | | | | | | | | | ... and assign it from the set.fread_func_set pointer in the Curl_init_CONNECT function. This A) avoids that we have code that assigns fields in the 'set' struct (which we always knew was bad) and more importantly B) it makes it impossibly to accidentally leave the wrong value for when the handle is re-used etc. Introducing a state-init functionality in multi.c, so that we can set a specific function to get called when we enter a state. The Curl_init_CONNECT is thus called when switching to the CONNECT state. Bug: https://github.com/bagder/curl/issues/346 Closes #346
* SFTP: fix range request off-by-one in size checkDaniel Stenberg2015-08-101-1/+1
| | | | | | Reported-by: Tim Stack Closes #359
* SSH: three state machine fixupsDaniel Stenberg2015-08-021-4/+7
| | | | | | | | | | | The SSH state machine didn't clear the 'rc' variable appropriately in a two places which prevented it from looping the way it should. And it lacked an 'else' statement that made it possible to erroneously get stuck in the SSH_AUTH_AGENT state. Reported-by: Tim Stack Closes #357
* read_callback: move to SessionHandle from connectdataDaniel Stenberg2015-05-201-2/+2
| | | | | | | With many easy handles using the same connection for multiplexing, it is important we store and keep the transfer-oriented stuff in the SessionHandle so that callbacks and callback data work fine even when many easy handles share the same physical connection.
* checksrc: use space after commaDaniel Stenberg2015-03-171-1/+1
|
* free: instead of Curl_safefree()Daniel Stenberg2015-03-161-5/+5
| | | | | | | | | | | | Since we just started make use of free(NULL) in order to simplify code, this change takes it a step further and: - converts lots of Curl_safefree() calls to good old free() - makes Curl_safefree() not check the pointer before free() The (new) rule of thumb is: if you really want a function call that frees a pointer and then assigns it to NULL, then use Curl_safefree(). But we will prefer just using free() from now on.
* mprintf.h: remove #ifdef CURLDEBUGDaniel Stenberg2015-03-031-5/+2
| | | | | ... and as a consequence, introduce curl_printf.h with that re-define magic instead and make all libcurl code use that instead.