summaryrefslogtreecommitdiff
path: root/src/transports/ssh.c
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* ssh: expose both hashesCarlos Martín Nieto2014-09-161-9/+9
| | | | | The user may have the data hashed as MD5 or SHA-1, so we should provide both types for consumption.
* ssh: provide our own types for host key lengthsCarlos Martín Nieto2014-09-161-9/+7
| | | | | Instead of using the libssh2 defines, provide our own, which eases usage as we do not need to check whether libgit2 was built with libssh2 or not.
* net: use only structs to pass information about certCarlos Martín Nieto2014-09-161-1/+3
| | | | | | Instead of spreading the data in function arguments, some of which aren't used for ssh and having a struct only for ssh, use a struct for both, using a common parent to pass to the callback.
* Merge remote-tracking branch 'upstream/master' into cmn/host-cert-infoCarlos Martín Nieto2014-09-161-1/+7
|\
| * ssh: store error message immediately after a failed agent callcmn/ssh-errorsCarlos Martín Nieto2014-09-041-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When the call to the agent fails, we must retrieve the error message just after the function call, as other calls may overwrite it. As the agent authentication is the only one which has a teardown and there does not seem to be a way to get the error message from a stored error number, this tries to introduce some small changes to store the error from the agent. Clearing the error at the beginning of the loop lets us know whether the agent has already set the libgit2 error message and we should skip it, or if we should set it.
* | Bring certificate check back to the normal return codeCarlos Martín Nieto2014-09-161-11/+8
| | | | | | | | | | Returning 0 lets the certificate check succeed. An error code is bubbled up to the user.
* | ssh: do ssh cert info before asking for credentialsCarlos Martín Nieto2014-09-161-47/+44
| | | | | | | | | | We know the host's key as soon as we connect, so we should perform the check as soon as we can, before we bother with the user's credentials.
* | transport: always call the certificate check callbackCarlos Martín Nieto2014-09-161-1/+2
| | | | | | | | | | | | | | We should let the user decide whether to cancel the connection or not regardless of whether our checks have decided that the certificate is fine. We provide our own assessment to the callback to let the user fall back to our checks if they so desire.
* | http: send the DER-encoded cert to the callbackCarlos Martín Nieto2014-09-161-20/+23
| | | | | | | | | | | | Instead of the parsed data, we can ask OpenSSL to give us the DER-encoded version of the certificate, which the user can then parse and validate.
* | Provide a callback for certificate validationCarlos Martín Nieto2014-09-161-0/+34
|/ | | | | | | | | If the certificate validation fails (or always in the case of ssh), let the user decide whether to allow the connection. The data structure passed to the user is the native certificate information from the underlying implementation, namely OpenSSL or WinHTTP.
* Merge remote-tracking branch 'upstream/master' into cmn/ssh-retryCarlos Martín Nieto2014-08-271-5/+70
|\
| * ssh: Fix unused warningVicent Marti2014-07-161-0/+1
| |
| * ssh: provide a factory function for setting ssh pathscmn/ssh-factory-for-pathsCarlos Martín Nieto2014-07-071-2/+52
| | | | | | | | | | | | | | | | | | git allows you to set which paths to use for the git server programs when connecting over ssh; and we want to provide something similar. We do this by providing a factory function which can be set as the remote's transport callback which will set the given paths upon creation.
| * Include libssh2.h before git2.h (transport.h)Jacques Germishuys2014-07-031-2/+4
| |
| * ssh: libssh2_channel_write() behaves like send()cmn/ssh-send-everythingCarlos Martín Nieto2014-07-021-1/+12
| | | | | | | | | | | | | | | | | | | | When the stream writing function was written, it assume that libssh2_channel_write() would always write all of the data to the wire. This is only true for the first 32k of data, which it tries to fit into one ssh packet. Since it can perform short writes, call it in a loop like we do for send(), advancing the buffer offset.
* | ssh: make sure to ask for a username and use the same oneCarlos Martín Nieto2014-06-261-34/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to know which authentication methods are supported/allowed by the ssh server, we need to send a NONE auth request, which needs a username associated with it. Most ssh server implementations do not allow switching the username between authentication attempts, which means we cannot use a dummy username and then switch. There are two ways around this. The first is to use a different connection, which an earlier commit implements, but this increases how long it takes to get set up, and without knowing the right username, we cannot guarantee that the list we get in response is the right one. The second is what's implemented here: if there is no username specified in the url, ask for it first. We can then ask for the list of auth methods and use the user's credentials in the same connection.
* | ssh: request credentials again on authentication failureCarlos Martín Nieto2014-06-261-26/+60
| | | | | | | | | | Instead of completely giving up on the first failure, ask for credentials as long as we fail to authenticate.
* | ssh: propagate the error code from the auth callbackCarlos Martín Nieto2014-06-171-13/+12
| | | | | | | | We need to be able to get a GIT_EUSER back through the outermost call.
* | ssh: detect authentication methodsCarlos Martín Nieto2014-06-171-6/+77
|/ | | | | | | | Before calling the credentials callback, ask the sever which authentication methods it supports and report that to the user, instead of simply reporting everything that the transport supports. In case of an error, we do fall back to listing all of them.
* transports: allow the creds callback to say it doesn't existCarlos Martín Nieto2014-04-221-12/+20
| | | | | | | | Allow the credentials callback to return GIT_PASSTHROUGH to make the transports code behave as though none was set. This should make it easier for bindings to behave closer to the C code when there is no credentials callback set at their level.
* Make git_cred_ssh_custom_new() naming more consistentJacques Germishuys2014-04-181-1/+1
|
* Introduce git_cred_ssh_interactive_new()Jacques Germishuys2014-04-181-0/+22
| | | | This allows for keyboard-interactive based SSH authentication
* cred: tighten username rulesCarlos Martín Nieto2014-04-181-11/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | The ssh-specific credentials allow the username to be missing. The idea being that the ssh transport will then use the username provided in the url, if it's available. There are two main issues with this. The credential callback already knows what username was provided by the url and needs to figure out whether it wants to ask the user for it or it can reuse it, so passing NULL as the username means the credential callback is suspicious. The username provided in the url is not in fact used by the transport. The only time it even considers it is for the user/pass credential, which asserts the existence of a username in its constructor. For the ssh-specific ones, it passes in the username stored in the credential, which is NULL. The libssh2 macro we use runs strlen() against this value (which is no different from what we would be doing ourselves), so we then crash. As the documentation doesn't suggest to leave out the username, assert the need for a username in the code, which removes this buggy behavior and removes implicit state. git_cred_has_username() becomes a blacklist of credential types that do not have a username. The only one at the moment is the 'default' one, which is meant to call up some Microsoft magic.
* - BUGFIX #2133 (@fourplusone) in smart_protocol.cMiha2014-02-251-1/+2
| | | | | | - added MSVC cmake definitions to disable warnings - general.c is rewritten so it is ansi-c compatible and compiles ok on microsoft windows - some MSVC reported warning fixes
* ssh: add support for ssh-agent authenticationAlessandro Ghedini2013-11-201-2/+52
|
* Fix ssh.c compileBen Straub2013-11-041-2/+3
|
* Use http_parser_parse_url to parse urlsBen Straub2013-11-041-1/+0
|
* Prevent another segfault from bad URLBen Straub2013-10-311-5/+6
|
* Rename the ssh credentialsCarlos Martín Nieto2013-10-231-6/+6
| | | | | | The names from libssh2 are somewhat obtuse for us. We can simplify the usual key/passphrase credential's name, as well as make clearer what the custom signature function is.
* Allowed credential types should be a bitfieldEdward Thomson2013-10-211-1/+2
|
* Whitespace.Etienne Samson2013-09-161-1/+1
|
* Add a wrapper to provide the libssh2 error messageEtienne Samson2013-09-161-13/+21
|
* Test for repo before removing leading colonIsaac Kearse2013-09-101-1/+1
|
* Trim leading colon from ssh repository pathIsaac Kearse2013-09-081-0/+1
|
* Commit 7affc2f7 removed var initializationRussell Belfer2013-08-141-0/+1
| | | | | | That commit accidentally removed the initialization of the "start" variable giving undefined results for the host extraction from the url input.
* Include username in each credential typeCarlos Martín Nieto2013-08-121-10/+12
| | | | | | | | Key-based authentication also needs an username, so include it in each one. Also stop assuming a default username of "git" in the ssh transport which has no business making such a decision.
* Bring SSH error reporting up to base standardsRussell Belfer2013-07-101-79/+72
| | | | | | | The SSH error checking and reporting could still be further improved by using the libssh2 native methods to get error info, but at least this ensures that all error codes are checked and translated into libgit2 error messages.
* Merge branch 'ssh-cred-fix' of tiennou/libgit2Russell Belfer2013-07-101-25/+35
|\ | | | | | | | | Conflicts: src/transports/ssh.c
| * Tab indent.Etienne Samson2013-07-101-90/+92
| |
| * Add some missing error messages.Etienne Samson2013-07-101-9/+16
| |
| * Fix a probable leak.Etienne Samson2013-07-031-1/+1
| |
| * Fix a crash if git_remote_set_cred_acquire_cb wasn't called before connecting.Etienne Samson2013-07-031-2/+4
| | | | | | | | Fixes #1700.
* | Make SSH APIs present even without SSH supportRussell Belfer2013-07-091-86/+95
|/ | | | | | The SSH APIs will just return an error code and state that the library was built without SSH support if they are called in that case.