summaryrefslogtreecommitdiff
path: root/src/transports/ssh.c
Commit message (Collapse)AuthorAgeFilesLines
* str: introduce `git_str` for internal, `git_buf` is externalethomson/gitstrEdward Thomson2021-10-171-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | libgit2 has two distinct requirements that were previously solved by `git_buf`. We require: 1. A general purpose string class that provides a number of utility APIs for manipulating data (eg, concatenating, truncating, etc). 2. A structure that we can use to return strings to callers that they can take ownership of. By using a single class (`git_buf`) for both of these purposes, we have confused the API to the point that refactorings are difficult and reasoning about correctness is also difficult. Move the utility class `git_buf` to be called `git_str`: this represents its general purpose, as an internal string buffer class. The name also is an homage to Junio Hamano ("gitstr"). The public API remains `git_buf`, and has a much smaller footprint. It is generally only used as an "out" param with strict requirements that follow the documentation. (Exceptions exist for some legacy APIs to avoid breaking callers unnecessarily.) Utility functions exist to convert a user-specified `git_buf` to a `git_str` so that we can call internal functions, then converting it back again.
* Fix coding style for pointerpunkymaniac2021-09-091-4/+4
| | | | Make some syntax change to follow coding style.
* Merge branch 'main' into http-use-eauthEdward Thomson2021-08-291-13/+47
|\
| * Wrap newer hostkeys in #ifdefsMiguel Arroz2020-12-211-0/+6
| | | | | | | | This allows the library to be built using a pre-1.9.0 version of libssh2.
| * Add support for additional hostkey types.Miguel Arroz2020-12-211-0/+12
| | | | | | | | Specifically: ECDSA_256, ECDSA_384, ECDSA_521 and ED25519.
| * Also add the raw hostkey to `git_cert_hostkey`lhchavez2020-11-271-0/+19
| | | | | | | | | | `git_cert_x509` has the raw encoded certificate. Let's do the same for the SSH certificate for symmetry.
| * transports: use GIT_ASSERTEdward Thomson2020-11-271-10/+8
| |
| * runtime: move init/shutdown into the "runtime"Edward Thomson2020-10-111-3/+2
| | | | | | | | | | Provide a mechanism for system components to register for initialization and shutdown of the libgit2 runtime.
* | transports: use GIT_EAUTH for authentication failuresJosh Bleecher Snyder2020-02-071-4/+4
|/ | | | | | | | | When the failure is clearly an auth failure (as opposed to possibly an auth failure), use the error code GIT_EAUTH instead of GIT_ERROR. While we're here, fix a typo and improve an error message. Fixes #5389.
* credential: change git_cred to git_credentialethomson/credtypeEdward Thomson2020-01-261-28/+28
| | | | | | | | | | | | | | | | We avoid abbreviations where possible; rename git_cred to git_credential. In addition, we have standardized on a trailing `_t` for enum types, instead of using "type" in the name. So `git_credtype_t` has become `git_credential_t` and its members have become `GIT_CREDENTIAL` instead of `GIT_CREDTYPE`. Finally, the source and header files have been renamed to `credential` instead of `cred`. Keep previous name and values as deprecated, and include the new header files from the previous ones.
* Merge pull request #5305 from kas-luthor/bugfix/multiple-authPatrick Steinhardt2020-01-101-0/+8
|\ | | | | Adds support for multiple SSH auth mechanisms being used sequentially
| * Fixes code stylingkas2019-12-131-5/+3
| |
| * Adds support for multiple SSH auth mechanisms being used sequentiallykas2019-11-161-0/+10
| |
* | ssh: include sha256 host key hash when supportedAnders Borum2019-11-201-0/+8
|/
* cred: separate public interface from low-level detailsEtienne Samson2019-09-131-2/+4
|
* net: rename gitno_connection_data to git_net_urlEdward Thomson2019-06-101-28/+28
| | | | | | | | | | "Connection data" is an imprecise and largely incorrect name; these structures are actually parsed URLs. Provide a parser that takes a URL string and produces a URL structure (if it is valid). Separate the HTTP redirect handling logic from URL parsing, keeping a `gitno_connection_data_handle_redirect` whose only job is redirect handling logic and does not parse URLs itself.
* transports: make use of the `GIT_CONTAINER_OF` macroEtienne Samson2019-04-161-7/+7
|
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-28/+28
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* transport: allow cred/cert callbacks to return GIT_PASSTHROUGHethomson/defer_cert_cred_cbEdward Thomson2018-11-211-4/+5
| | | | | | | | | | | | Allow credential and certificate checking callbacks to return GIT_PASSTHROUGH, indicating that they do not want to act. Introduce this to support in both the http and ssh callbacks. Additionally, enable the same mechanism for certificate validation. This is most useful to disambiguate any meaning in the publicly exposed credential and certificate functions (`git_transport_smart_credentials` and `git_transport_smart_certificate_check`) but it may be more generally useful for callers to be able to defer back to libgit2.
* Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-101-1/+1
|
* transports: ssh: replace deprecated function `libssh2_session_startup`Patrick Steinhardt2018-03-271-1/+1
| | | | | | | | | The function `libssh2_session_startup` has been deprecated since libssh2 version 1.2.8 in favor of `libssh2_session_handshake` introduced in the same version. libssh2 1.2.8 was released in April 2011, so it is already seven years old. It is available in Debian Wheezy, Ubuntu Trusty and CentOS 7.4, so the most important and conservative distros already have it available. As such, it seems safe to just use the new function.
* transports: ssh: disconnect session before freeing itPatrick Steinhardt2018-03-271-0/+1
| | | | | | | | | | | | | | | | | | | | | The function `ssh_stream_free` takes over the responsibility of closing channels and streams just before freeing their memory, but it does not do so for the session. In fact, we never disconnect the session ourselves at all, as libssh2 will not do so itself upon freeing the structure. Quoting the documentation of `libssh2_session_free`: > Frees all resources associated with a session instance. Typically > called after libssh2_session_disconnect_ex, The missing disconnect probably stems from a misunderstanding what it actually does. As we are already closing the TCP socket ourselves, the assumption was that no additional disconnect is required. But calling `libssh2_session_disconnect` will notify the server that we are cleanly closing the connection, such that the server can free his own resources. Add a call to `libssh2_session_disconnect` to fix that issue. [1]: https://www.libssh2.org/libssh2_session_free.html
* ssh urls: use `git_buf_decode_percent`Edward Thomson2018-03-191-8/+6
| | | | | Use `git_buf_decode_percent` so that we can avoid allocating a temporary buffer.
* Unescape repo before constructing ssh requestSteven King Jr2018-03-191-1/+5
|
* Merge pull request #4283 from tiennou/generic-tlsPatrick Steinhardt2017-11-091-1/+1
|\ | | | | CMake: make HTTPS support more generic
| * stream: Gather streams to src/streamsEtienne Samson2017-10-231-1/+1
| |
* | transports: ssh: ask for credentials again when passphrase is wrongCurtis Vogt2017-10-201-2/+4
|/ | | | | When trying to decode the private key it looks like LibSSH2 returns a LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED when the passphrase is incorrect.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* transports: ssh: clean up after libssh2 on exitPatrick Steinhardt2017-05-021-0/+9
| | | | | | | After calling `libssh2_init`, we need to clean up after the library by executing `libssh2_exit` as soon as we exit. Register a shutdown handler to do so which simply calls `libssh2_exit`. This fixes several memory leaks.
* transports: ssh: report failure initializing libssh2Patrick Steinhardt2017-05-021-1/+4
| | | | | | We unconditionally return success when initializing libssh2, regardless of whether `libgssh2_init` signals success or an error. Fix this by checking its return code.
* giterr_set: consistent error messagesEdward Thomson2016-12-291-9/+9
| | | | | | | | Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
* Merge pull request #3555 from cbargren/ssh-git-protocolsEdward Thomson2016-03-081-17/+32
|\ | | | | Support for ssh+git and git+ssh protocols
| * Removing #define for SSH_PREFIX_COUNT and using ARRAY_SIZE insteadChris Bargren2015-12-281-6/+5
| | | | | | Also moving var declarations to top of blocks to support bad old compilers
| * Handle git+ssh:// and ssh+git:// protocols supportChris Bargren2015-12-221-17/+33
| |
* | ssh: initialize libssh2cmn/init-libssh2Carlos Martín Nieto2016-03-031-0/+16
| | | | | | | | | | | | | | We should have been doing this, but it initializes itself upon first use, which works as long as nobody's doing concurrent network operations. Initialize it on our init to make sure it's not getting initialized concurrently.
* | ssh_stream_read(): fix possible *bytes_read < 0 branchMichał Górny2015-12-261-3/+8
|/ | | | | | Fix the possibility of returning successfully from ssh_stream_read() with *bytes_read < 0. This would occur if stdout channel read resulted in 0, and stderr channel read failed afterwards.
* added a single line of additional error reporting from libssh2 when failing ↵Max Leske2015-08-141-1/+3
| | | | to retrieve the list of authentication methods
* Handle ssh:// and git:// urls containing a '~' character.Simon2015-08-031-0/+2
| | | | | For such a path '/~/...' the leading '/' is stripped so the server will get a path starting with '~' and correctly handle it.
* git_cert: child types use proper base typeEdward Thomson2015-07-101-2/+2
|
* ssh: move NULL check to the free functionCarlos Martín Nieto2015-06-091-5/+5
| | | | | | | | Let `ssh_stream_free()` take a NULL stream, as free functions should, and remove the check from the connection setup. The connection setup would not need the check anyhow, as we always have a stream by the time we reach this code.
* Change error when running out of ssh agent keysMarius Ungureanu2015-06-021-1/+7
|
* cred: Check for null values when getting key from memoryMichał Górny2015-05-271-1/+4
| | | | | | The public key field is optional and as such can take NULL. Account for that and do not call strlen() on NULL values. Also assert() for non-NULL values of username & private key.
* Add support to read ssh keys from memory.David Calavera2015-05-271-0/+19
|
* errors: add GIT_EEOF to indicate early EOFcmn/server-errorsCarlos Martín Nieto2015-05-201-2/+6
| | | | | | This can be used by tools to show mesages about failing to communicate with the server. The error message in this case will often contain the server's error message, as far as it managed to send anything.
* ssh: read from stderr if stdout is emptyCarlos Martín Nieto2015-05-201-1/+8
| | | | | | | | When we fail to read from stdout, it's typically because the URL was wrong and the server process has sent some output over its stderr output. Read that output and set the error message to whatever we read from it.
* Add a custom param to git_smart_subtransport_definitionLeo Yang2015-03-181-1/+5
| | | | | The smart transport has already take the payload param. For the sub transport a payload param is useful for the implementer.
* ssh: use socket_stream to perform the connectionCarlos Martín Nieto2014-12-101-8/+12
| | | | | | | | Having an ssh stream would require extra work for stream capabilities we don't need anywhere else (oob auth and command execution) so for now let's move away from the gitno connection to use socket_stream. We can introduce an ssh stream interface if and as we need it.
* Cleanup memory leak in ssh transportEdward Thomson2014-10-261-34/+28
|
* Clean up various compiler warningsEdward Thomson2014-10-261-2/+5
|
* Provide host name to certificate_check_cbSven Strickroth2014-09-221-1/+1
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>