Skip to content

Expose NegotiationPrologueDetector decision state - #20

Merged
oferchen merged 1 commit into
masterfrom
codex/implement-rsync-3.4.1-protocol-parity
Oct 15, 2025
Merged

oferchen merged 1 commit into
masterfrom
codex/implement-rsync-3.4.1-protocol-parity

Conversation

@oferchen

@oferchen oferchen commented Oct 15, 2025 •

Copy link
Copy Markdown
Owner

Summary

  • add an accessor for NegotiationPrologueDetector so callers can query the decided negotiation style without re-reading
  • extend the unit test suite to cover the new accessor behaviour

Testing

  • cargo test

@oferchen
oferchen merged commit 8e89d96 into master Oct 15, 2025
@oferchen
oferchen deleted the codex/implement-rsync-3.4.1-protocol-parity branch October 15, 2025 12:23
oferchen added a commit that referenced this pull request May 22, 2026
#4716)

Adds four new SEC-1 helpers in `fast_io::dir_sandbox::at_syscalls`:

- `openat(dirfd, name, flags, mode) -> File` raw libc wrapper.
- `openat_via_sandbox_or_fallback(...)` adaptor that takes the sandbox
  fast path on a single-component leaf beneath `dest_dir` and falls back
  to `std::fs::OpenOptions` against `link_path` with best-effort `O_*`
  bit translation otherwise.
- `readlinkat(dirfd, name) -> PathBuf` raw libc wrapper with a growing
  buffer (256B -> PATH_MAX, doubling each round trip).
- `readlinkat_via_sandbox_or_fallback(...)` adaptor mirroring the
  openat shape but falling back to `std::fs::read_link`.

The helpers follow the established SEC-1 pattern: pinning the parent
via the sandbox dirfd closes the TOCTOU window between path walk and
the kernel reaching the inode. The `*_via_sandbox_or_fallback` adaptors
keep behaviour byte-identical for callers that have not yet plumbed a
`DirSandbox`, so individual call sites can be cut over one at a time.

This PR adds the helpers and re-exports them through
`dir_sandbox::mod` and `fast_io::lib`. It deliberately does NOT wire
any caller; per-site wiring lands in follow-up PRs so each cutover gets
its own diff and review.

Extends the existing tests module with 10 new tests covering:
- raw `openat` success and ENOENT,
- `openat_via_sandbox_or_fallback` fast path, multi-component
  fallback, and absent-sandbox fallback,
- raw `readlinkat` success and EINVAL on a non-symlink,
- `readlinkat_via_sandbox_or_fallback` fast path, EINVAL, and
  multi-component fallback.

All helpers are `#[cfg(unix)]` (the `dir_sandbox` module is itself
Unix-only); Windows continues to use path-based stdlib opens per the
SEC-1.l NTFS handle audit.

Closes (post-wire) 16+ GAPs from the SEC-1 path-syscall coverage audit
in PR #4710: #4 (readlinkat) plus the 9 direct openat sites (#9-#17)
and lays foundations for #5, #20 (open + readdir-loop) and #6, #27
(recursive *at peel).

Refs PR #4710.
oferchen added a commit that referenced this pull request May 22, 2026
…C-1.r) (#4723)

* feat(transfer): thread DirSandbox through temp_guard/temp_cleanup (SEC-1.r)

Routes receiver-side temp-file creation and the matching unlink-on-drop
through `openat(dirfd, leaf, ...)` / `unlinkat(dirfd, leaf, 0)` instead
of path-based syscalls so a TOCTOU symlink swap on the temp parent
cannot redirect the create or the cleanup.

- `temp_guard::open_tmpfile_sandboxed` dispatches the create through
  `fast_io::openat_via_sandbox_or_fallback` and seeds the returned
  `TempFileGuard` with a sandbox anchor for the matching Drop unlink.
- `temp_cleanup::cleanup_stale_temp_files_sandboxed` routes the per-
  entry unlink through `unlink_via_sandbox_or_fallback`; the read_dir
  scan stays path-based (audit row #20 carrier-acceptable residual).
- `DiskCommitConfig` gains `dest_dir` + `sandbox` so the disk-commit
  worker thread carries the carrier across the SPSC boundary; both
  pipeline + sync receiver paths plumb the existing
  `PipelineSetup::sandbox` into the new fields.
- `ResponseContext::sandbox` switches to `Option<&Arc<DirSandbox>>` so
  the temp-file Drop anchor can clone a stable handle that outlives the
  borrow; renameat call site updates to `.map(Arc::as_ref)`.

Includes a regression test that races a rename + symlink-swap on the
temp parent between create and Drop and verifies the unlink lands on
the original dirfd (decoy survives, real temp file is removed).

Falls back to the existing `OpenOptions::create_new` /
`std::fs::remove_file` path when the carrier is absent (non-Unix,
--temp-dir routed to a sibling tree, or multi-component temp paths);
ENOENT recovery keeps `create_dir_all` as accepted residual.

* fix(transfer): promote libc dep to cfg(unix) for macOS temp_guard openat flags
oferchen added a commit that referenced this pull request Aug 24, 2026
#4716)

Adds four new SEC-1 helpers in `fast_io::dir_sandbox::at_syscalls`:

- `openat(dirfd, name, flags, mode) -> File` raw libc wrapper.
- `openat_via_sandbox_or_fallback(...)` adaptor that takes the sandbox
  fast path on a single-component leaf beneath `dest_dir` and falls back
  to `std::fs::OpenOptions` against `link_path` with best-effort `O_*`
  bit translation otherwise.
- `readlinkat(dirfd, name) -> PathBuf` raw libc wrapper with a growing
  buffer (256B -> PATH_MAX, doubling each round trip).
- `readlinkat_via_sandbox_or_fallback(...)` adaptor mirroring the
  openat shape but falling back to `std::fs::read_link`.

The helpers follow the established SEC-1 pattern: pinning the parent
via the sandbox dirfd closes the TOCTOU window between path walk and
the kernel reaching the inode. The `*_via_sandbox_or_fallback` adaptors
keep behaviour byte-identical for callers that have not yet plumbed a
`DirSandbox`, so individual call sites can be cut over one at a time.

This PR adds the helpers and re-exports them through
`dir_sandbox::mod` and `fast_io::lib`. It deliberately does NOT wire
any caller; per-site wiring lands in follow-up PRs so each cutover gets
its own diff and review.

Extends the existing tests module with 10 new tests covering:
- raw `openat` success and ENOENT,
- `openat_via_sandbox_or_fallback` fast path, multi-component
  fallback, and absent-sandbox fallback,
- raw `readlinkat` success and EINVAL on a non-symlink,
- `readlinkat_via_sandbox_or_fallback` fast path, EINVAL, and
  multi-component fallback.

All helpers are `#[cfg(unix)]` (the `dir_sandbox` module is itself
Unix-only); Windows continues to use path-based stdlib opens per the
SEC-1.l NTFS handle audit.

Closes (post-wire) 16+ GAPs from the SEC-1 path-syscall coverage audit
in PR #4710: #4 (readlinkat) plus the 9 direct openat sites (#9-#17)
and lays foundations for #5, #20 (open + readdir-loop) and #6, #27
(recursive *at peel).

Refs PR #4710.
oferchen added a commit that referenced this pull request Aug 24, 2026
…C-1.r) (#4723)

* feat(transfer): thread DirSandbox through temp_guard/temp_cleanup (SEC-1.r)

Routes receiver-side temp-file creation and the matching unlink-on-drop
through `openat(dirfd, leaf, ...)` / `unlinkat(dirfd, leaf, 0)` instead
of path-based syscalls so a TOCTOU symlink swap on the temp parent
cannot redirect the create or the cleanup.

- `temp_guard::open_tmpfile_sandboxed` dispatches the create through
  `fast_io::openat_via_sandbox_or_fallback` and seeds the returned
  `TempFileGuard` with a sandbox anchor for the matching Drop unlink.
- `temp_cleanup::cleanup_stale_temp_files_sandboxed` routes the per-
  entry unlink through `unlink_via_sandbox_or_fallback`; the read_dir
  scan stays path-based (audit row #20 carrier-acceptable residual).
- `DiskCommitConfig` gains `dest_dir` + `sandbox` so the disk-commit
  worker thread carries the carrier across the SPSC boundary; both
  pipeline + sync receiver paths plumb the existing
  `PipelineSetup::sandbox` into the new fields.
- `ResponseContext::sandbox` switches to `Option<&Arc<DirSandbox>>` so
  the temp-file Drop anchor can clone a stable handle that outlives the
  borrow; renameat call site updates to `.map(Arc::as_ref)`.

Includes a regression test that races a rename + symlink-swap on the
temp parent between create and Drop and verifies the unlink lands on
the original dirfd (decoy survives, real temp file is removed).

Falls back to the existing `OpenOptions::create_new` /
`std::fs::remove_file` path when the carrier is absent (non-Unix,
--temp-dir routed to a sibling tree, or multi-component temp paths);
ENOENT recovery keeps `create_dir_all` as accepted residual.

* fix(transfer): promote libc dep to cfg(unix) for macOS temp_guard openat flags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant