- Notifications
You must be signed in to change notification settings - Fork2.5k
Add OpenSSH support#6617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Add OpenSSH support#6617
Uh oh!
There was an error while loading.Please reload this page.
Conversation
bergkvist commentedAug 3, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I'm getting a segfault trying to use it:
I forked/modified the following repos (Cargo.toml/submodule links only) to use this patch: I'm getting the segfault on both macOS and Linux |
Neat, thanks for trying this out. Can you get a core or stack trace? |
bergkvist commentedAug 3, 2023
Valgrind:
|
bergkvist commentedAug 4, 2023
Commenting out the
|
Oops, that's definitely a mistake. It looks like I haven't built that branchwithout any SSH support in a while. Thanks for catching that. You'll need to configure libgit2 with |
bergkvist commentedAug 9, 2023
I had to do this to get it working:bergkvist/git2-rs@9a4d232 (git2-rs doesn't use cmake) I would love for this to get merged into libgit2. |
It'll happen - I think that I just want to give plenty of time for feedback. Doing an |
We may want to support SSH but with a different provider that is notlibssh2. Add GIT_SSH to indicate that we have some inbuilt SSH supportand GIT_SSH_LIBSSH2 to indicate that support is via libssh2. This issimilar to how we support GIT_HTTPS and GIT_OPENSSL, for example.
We can now use the `git_process` class to invoke OpenSSH and use it asan SSH transport. This may be preferred over libssh2 for a variety ofcallers.
We can't reliably detect SIGPIPE on close because of platformdifferences. Track `pid` and send `SIGTERM` to a function and ensurethat we can detect it.
There are no custom callbacks for OpenSSH; don't test them.
Now that we (may) exec a child process to do ssh, we don't want valgrindreporting on that. Suppress children in valgrind runs.
A transport may want to validate that it's in a sane state; whenflushing on close, don't assume that we're doing an upload-pack; sendthe correct direction.
Instead of "early EOF", provide information on _when_ we're seeing theEOF for debugging.
Suppress SIGPIPEs during writes to our piped process. On single-threadedapplications, this is as simple as ignoring the signal. But since thisis process-wide, on multi-threaded applications, we need to use somecumbersome `pthread_sigmask` manipulation.Thanks tohttps://www.doof.me.uk/2020/09/23/sigpipe-and-how-to-ignore-it/andhttp://www.microhowto.info:80/howto/ignore_sigpipe_without_affecting_other_threads_in_a_process.html
Provide a mechanism for callers to read from stderr.
Provide more user-friendly error messages in smart protocol negotiationfailures.
Don't capture stderr, optimize for the CLI case.
Provide both cmdline-style handling (passing it to the shell on POSIX,or directly to CreateProcess on win32) and execv style (passing itdirectly to execv on POSIX, and mangling it into a single command-lineon win32).
Callers can specify the ssh command to invoke using `core.sshcommand` orthe `GIT_SSH` environment variable. This is useful for specifyingalternate configuration, and is particularly useful for our testingenvironment.
This helped when troubleshooting issues running the `ci/test.sh` scriptlocally.
Handle custom paths for OpenSSH.
Seelibgit2/libgit2#6617. This ensures that weget support for ~/.ssh/config, known_hosts etc.
This commit changes the original `ssh` feature into two new ones:`ssh-libssh2` and `ssh-openssh`. By default, the `ssh-libssh2` featureis enabled for backwards compatibility.To use OpenSSH instead, the following listing in `Cargo.toml` can beused: git2-rs = { version = "...", default-features = false, features = ["https", "ssh-openssh"] }Note thatlibgit2/libgit2#6617 has not actuallybeen released in an official libgit2 version, so the prior commit pulledin the latest commit from `main`.
This commit changes the original `ssh` feature into two new ones:`ssh-libssh2` and `ssh-openssh`. By default, the `ssh-libssh2` featureis enabled for backwards compatibility.To use OpenSSH instead, the following listing in `Cargo.toml` can beused: git2-rs = { version = "...", default-features = false, features = ["https", "ssh-openssh"] }Note thatlibgit2/libgit2#6617 has not actuallybeen released in an official libgit2 version, so the prior commit pulledin the latest commit from `main`.Closesrust-lang#1028.
bnjmnt4n commentedMar 1, 2024
Hey, whilst looking through this PR, I realized that there are some instances where |
This commit changes the original `ssh` feature into two new ones:`ssh-libssh2` and `ssh-openssh`. By default, the `ssh-libssh2` featureis enabled for backwards compatibility.To use OpenSSH instead, the following listing in `Cargo.toml` can beused: git2-rs = { version = "...", default-features = false, features = ["https", "ssh-openssh"] }Note thatlibgit2/libgit2#6617 has not actuallybeen released in an official libgit2 version, so the prior commit pulledin the latest commit from `main`.Closesrust-lang#1028.
This commit changes the original `ssh` feature into two new ones:`ssh-libssh2` and `ssh-openssh`. By default, the `ssh-libssh2` featureis enabled for backwards compatibility.To use OpenSSH instead, the following listing in `Cargo.toml` can beused: git2-rs = { version = "...", default-features = false, features = ["https", "ssh-openssh"] }Note thatlibgit2/libgit2#6617 has not actuallybeen released in an official libgit2 version, so the prior commit pulledin the latest commit from `main`.Closesrust-lang#1028.
Provide a smart transport that executes
ssh ...
- this adds a mechanism for executing processes from libgit2, and uses it to invokessh
and deal with the output.