Skip to content

chore: resolve host key verification follow-ups - #260

Merged
inureyes merged 1 commit into
mainfrom
chore/issue-243-host-key-followups
Aug 3, 2026
Merged

chore: resolve host key verification follow-ups#260
inureyes merged 1 commit into
mainfrom
chore/issue-243-host-key-followups

Conversation

@inureyes

@inureyes inureyes commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

Resolve the host-key follow-ups from #243: HOME-sensitive tests now share a lock, known-host matches avoid the write-side lock, fresh known_hosts files no longer start with a blank line, the shared server-check enum mirrors the client enum, and socket-address slices now return one recordable hostname.

What changed

  • Added a HOME-specific lock to EnvGuard plus a read-side lock for the tilde expansion test.
  • Added a double-checked accept-new fast path for definite known-host matches while preserving locked re-checks for unknown hosts and conflicts.
  • Removed the leading blank line that learn_known_hosts_path can add to a pre-created empty file.
  • Added AcceptNewKnownHostsFile and AcceptNewInMemory to the shared ServerCheckMethod mirror with conversions to and from the client enum.
  • Changed ToSocketAddrsWithHostname for &[SocketAddr] to use the first address IP instead of joining all IPs with commas.

Test plan

  • CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo test --lib test_helpers::env_guard::tests
  • CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo test --lib commands::interactive::utils::tests::test_expand_path_with_tilde
  • for i in 1 2 3 4 5 6 7 8 9 10; do CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo test --lib commands::interactive::utils::tests::test_expand_path_with_tilde || exit 1; done
  • CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo test --lib shared::auth_types::tests::test_server_check_method
  • CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo test --lib ssh::tokio_client::to_socket_addrs_with_hostname::tests
  • CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo test --lib ssh::tokio_client::host_verification
  • CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo check --lib --tests
  • CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo clippy --lib --tests -- -D warnings

Note: the issue asked for repeated full cargo test --lib, but this chain unit explicitly forbids broad cargo test --lib; the repeated validation above uses the focused tilde regression instead.

Closes #243

Serialize HOME-sensitive tests with a shared helper lock, remove the known_hosts fast-path serialization for definite matches, and keep fresh known_hosts files from starting with a blank line.

Bring the shared ServerCheckMethod mirror back in sync with the client enum and make socket-address slice hostnames use one recordable address instead of a comma-separated host list.

Validation: CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo test --lib ssh::tokio_client::host_verification; focused HOME tilde test passed 10 consecutive runs; CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo check --lib --tests; CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo clippy --lib --tests -- -D warnings.

Closes #243
@inureyes inureyes added priority:medium Medium priority issue type:test Test related changes type:performance Performance improvements type:chore Maintenance tasks (build, CI, etc) status:review Under review status:done Completed and removed status:review Under review labels Aug 3, 2026
@inureyes
inureyes merged commit 9db9050 into main Aug 3, 2026
3 checks passed
@inureyes
inureyes deleted the chore/issue-243-host-key-followups branch August 3, 2026 10:45
inureyes added a commit that referenced this pull request Aug 3, 2026
## Summary
- Restore `&[SocketAddr]::host_port` to the trait implementation after the PR #260 / PR #258 auto-merge placed it inside the test module.
- Merge the #243 first-address hostname tests and #257 host-port parsing tests into one valid `tests` module so both behavior checks remain compiled.

## Validation
- `cargo fmt --check`
- `CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo test --lib to_socket_addrs_with_hostname`
- `CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo check --lib --tests`
- `CARGO_TARGET_DIR=/home/inureyes/Development/backend.ai/bssh/target cargo clippy --lib --tests -- -D warnings`

Refs #243.
Refs #257.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Medium priority issue status:done Completed type:chore Maintenance tasks (build, CI, etc) type:performance Performance improvements type:test Test related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: follow-ups from host key verification and error chain work

1 participant