1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 05:12:40 +03:00

Implement ProxyUseFDpass for ssh

This allows the ProxyUseFDpass ssh config option, to be
used on Linux and Mac OS.  This was requested in
enhancement issue #6093
This commit is contained in:
Sean Estabrooks 2024-09-07 07:12:00 -04:00 committed by Wez Furlong
parent 43d221f52f
commit caf450b873
3 changed files with 22 additions and 4 deletions

10
Cargo.lock generated
View File

@ -3656,6 +3656,15 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "passfd"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b332c50e4d07c0011fff51ea305374408319908908bc1dbed7a0ffaaf63a8151"
dependencies = [
"libc",
]
[[package]]
name = "paste"
version = "1.0.15"
@ -6479,6 +6488,7 @@ dependencies = [
"libssh-rs",
"log",
"once_cell",
"passfd",
"portable-pty",
"predicates",
"regex",

View File

@ -40,6 +40,9 @@ wezterm-uds = { path = "../wezterm-uds" }
# Not used directly, but is used to centralize the openssl vendor feature selection
async_ossl = { path = "../async_ossl" }
[target.'cfg(unix)'.dependencies]
passfd = "0.1.6"
[dev-dependencies]
assert_fs = "1.0.4"
clap = {version="4.0", features=["derive"]}

View File

@ -357,11 +357,16 @@ impl SessionInner {
#[cfg(unix)]
unsafe {
use passfd::FdPassingExt;
use std::os::unix::io::{FromRawFd, IntoRawFd};
return Ok((
Socket::from_raw_fd(a.into_raw_fd()),
Some(KillOnDropChild(child)),
));
let raw = a.into_raw_fd();
let dest = match self.config.get("proxyusefdpass").map(|s| s.as_str()) {
Some("yes") => raw.recv_fd()?,
_ => raw,
};
return Ok((Socket::from_raw_fd(dest), Some(KillOnDropChild(child))));
}
#[cfg(windows)]
unsafe {