Repository navigation
fix(remote): avoid holding write handle on SSH evidence log on Windows - #200
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Windows SSH remote connections failing immediately at
stage=connectwith:Root Cause
Introduced in
289af38(#189):Evidence::new()pre-created%TEMP%\lithe-evidence-<suffix>\ssh.logwithOpenOptions::new().read(true).write(true).create_new(true)and kept that writableFilehandle open while spawningssh.exe -E <path>.On Windows,
Win32-OpenSSH'slog_redirect_stderr_toopens the-Elogfile withoutFILE_SHARE_WRITE. Because the parent process still held a writable handle onssh.log, Windows rejectedssh.exewithERROR_SHARING_VIOLATION(Win32 error32), which MSVC CRT reports viastrerror(32)asEPIPE(Broken pipe), causingssh.exeto exit immediately with status 1.Changes
rust/crates/workspace/src/ssh_evidence.rs:ssh.logwith owner-only permissions (create_new(true)) and immediately drop the write handle sossh.exeis the sole writer.ssh.logread-only on demand inread_boundedforidentity()anddiagnostics()(on Windows, Rust defaultsOpenOptions::new().read(true)toFILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE).evidence_reads_diagnostics_and_identity_written_by_another_handle.rust/crates/workspace/src/sessions.rs:EvidenceintoConnectionTransport::Processand drop it inConnection::end_transport()aftertree.terminate(EXIT_GRACE), so Windows can cleanly deletelithe-evidence-*afterssh.exeexits rather than failing cleanup whilessh.exeholdsssh.logopen.rust/crates/git-host/src/authentication/windows.rs:O:{sid}D:P(A;OICI;GA;;;{sid})forprivate_directoryso files created inside the private directory (includingssh.log) inherit the owner-only protected DACL.rust/crates/platform-tests/tests/platform/permissions.rs:private_directory_evidence_log_allows_read_only_sharing_with_single_writersimulating a writer openingssh.logwithFILE_SHARE_READonly (noFILE_SHARE_WRITE) while the host reads concurrently.Verification
cargo fmt --manifest-path rust/Cargo.toml --check— passednode scripts/rust-core/verify-platform-tests.mjs— passed (every test of 53 crates runs on a host CI tests it on)scripts/rust-core/verify-rust-core-comments.sh git-host workspace platform-tests— passedcargo test --manifest-path rust/Cargo.toml -p lithe-workspace -p lithe-git-host -p lithe-platform-tests— 136 passed, 0 failed (macOS)LIBSQLITE3_SYS_USE_PKG_CONFIG=1 cargo clippy --manifest-path rust/Cargo.toml -p lithe-workspace -p lithe-git-host -p lithe-platform-tests --all-targets --target x86_64-pc-windows-msvc -- -D warnings— passedlithe-platform-testson Windows) — no Windows VM on this macOS host; will run in Windows CI once marked ready.