From 8996fc54fe4596368a1677821b1a390a70c56ab0 Mon Sep 17 00:00:00 2001 From: JJ Liebig Date: Tue, 8 Sep 2026 23:08:42 +0200 Subject: fix: support preinstalled windows remote hosts (#3661) * fix: support windows hosts in saved ssh machines refs #3651 * fix: keep windows ssh bridge writes blocking refs #3651 * fix: close saved windows ssh bootstrap input refs #3651 * refactor: simplify remote bridge helpers refs #3651 * refactor: isolate remote bridge platform behavior refs #3651 * fix: close captured ssh input under windows consoles refs #3651 * test: remove redundant remote command assertions refs #3651 refs #3701 * test: handle framed ssh commands in machine setup refs #3651 --------- Co-authored-by: Ogulcan Celik --- src/platform/unix_common.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/platform/unix_common.rs') diff --git a/src/platform/unix_common.rs b/src/platform/unix_common.rs index 0df215d6..756abc17 100644 --- a/src/platform/unix_common.rs +++ b/src/platform/unix_common.rs @@ -27,6 +27,38 @@ pub(crate) fn wait_client_stream_readable(stream: &crate::ipc::LocalStream) -> s Ok(()) } +pub(crate) fn forward_remote_bridge_stdio(stream: crate::ipc::LocalStream) -> std::io::Result<()> { + use interprocess::TryClone as _; + + let mut stdout = std::io::stdout().lock(); + let mut socket_to_stdout = stream.try_clone()?; + let mut stdin_to_socket = stream; + let _upload = std::thread::spawn(move || { + let mut stdin = std::io::stdin(); + let _ = copy_flush(&mut stdin, &mut stdin_to_socket); + let crate::ipc::LocalStream::UdSocket(stream) = stdin_to_socket; + let _ = stream.inner().shutdown(std::net::Shutdown::Write); + }); + copy_flush(&mut socket_to_stdout, &mut stdout) +} + +fn copy_flush( + reader: &mut R, + writer: &mut W, +) -> std::io::Result<()> { + let mut buffer = [0_u8; 16 * 1024]; + loop { + let read = match reader.read(&mut buffer) { + Ok(0) => return Ok(()), + Ok(read) => read, + Err(err) if err.kind() == std::io::ErrorKind::Interrupted => continue, + Err(err) => return Err(err), + }; + writer.write_all(&buffer[..read])?; + writer.flush()?; + } +} + pub(crate) struct RemoteBridgeWake { reader: std::os::unix::net::UnixStream, writer: std::os::unix::net::UnixStream, -- cgit v1.2.3