Skip to content

[v0.2] Build for Windows behind the platform seam - #36

Merged
Lingbou merged 1 commit into
mainfrom
feat/windows-platform
Sep 30, 2026
Merged

Lingbou merged 1 commit into
mainfrom
feat/windows-platform

Conversation

@Lingbou

@Lingbou Lingbou commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Parent: #1

Closes #35

Advances #30 — the platform implementation and its build story. Windows CI legs, release artifacts, and the README entry follow in the next PR, so #30 stays open.

What changed

Platform seam (src/platform.rs)

Question Windows answer
Config root %USERPROFILE%\.line, still overridable with LINE_CONFIG_DIR
OpenSSH ssh.exe / ssh-keygen.exe from PATH
System policy %ProgramData%\ssh\ssh_config when present, otherwise NUL — the user's own .ssh\config still cannot redefine a profile
File modes no-op; Windows has no POSIX mode bits and the ADR says so instead of pretending
Child signals no-op; Windows reports exit codes, never signals
Interrupt guard empty guard; console control events are not POSIX signals
Child tree taskkill /PID <pid> /T /F

Runtime (#35)

  • wait_for_terminal_line keeps the Unix poll implementation and gains a Windows arm that asks the console for input events every 250 ms. Both paths check the shutdown flag on the same cadence, and a new portable test pins the shutdown contract.
  • Shutdown registration moves to a per-platform SHUTDOWN_SIGNALS list: SIGTERM, SIGHUP, SIGINT, SIGQUIT on Unix; SIGTERM, SIGINT, SIGBREAK on Windows, which is what console close, Ctrl-C, and Ctrl-Break actually deliver.

Saved passwords

SSH_ASKPASS does not exist in Windows OpenSSH, so connect refuses a password profile with SshError::SavedPasswordsUnsupported before spawning anything, and the platform seam exposes supports_saved_passwords() so the decision is stated once. Windows CI covers the refusal.

File identity

same_file is now path-based. Unix keeps the device/inode comparison; Windows needs the file-handle API, which std has not stabilised (windows_by_handle), so the Windows arm uses the same-file crate — declared as a Windows-only dependency, keeping it out of the Linux and macOS dependency graphs. The mirrors/usage logic was reordered to compare identities before the canonical files are deleted, which the existing key-store test caught.

Test scaffolding

The fake OpenSSH programs are POSIX shell scripts, so the tests that depend on them are now #[cfg(unix)]. Windows still runs the portable half, and the platform-specific tests added here run on both.

Verification

  • cargo check --all-targets --locked for x86_64-pc-windows-msvc, aarch64-pc-windows-msvc, aarch64-apple-darwin, and the host — all clean, including cargo +1.88.0 check --target x86_64-pc-windows-msvc.
  • cargo clippy --all-targets --all-features -- -D warnings for Windows and the host.
  • cargo test --all-targets --locked on Linux: 124 lib tests plus every integration suite.
  • cargo fmt --check.

The real Windows evidence arrives with the CI legs in the follow-up PR; this one proves the code compiles and the portable behaviour still holds.

The seam gains a Windows arm: %USERPROFILE%\.line, ssh.exe discovery,
%ProgramData% system policy with the NUL device, no POSIX mode bits, no
POSIX signals, and taskkill for child trees. Saved passwords are refused
because Windows OpenSSH has no SSH_ASKPASS, and the confirmation wait and
shutdown registration no longer assume POSIX.

Refs #35, #30

Signed-off-by: Xingqiu Xu <hilbertanjou83@gmail.com>
@Lingbou
Lingbou merged commit c299474 into main Sep 30, 2026
13 checks passed
@Lingbou
Lingbou deleted the feat/windows-platform branch September 30, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v0.2] Port the interactive confirmation wait and shutdown signals to Windows

1 participant