Skip to content

Refine negotiation sniffer short-circuiting - #175

Merged
oferchen merged 1 commit into
masterfrom
codex/implement-rsync-full-protocol-fidelity
Oct 16, 2025
Merged

oferchen merged 1 commit into
masterfrom
codex/implement-rsync-full-protocol-fidelity

Conversation

@oferchen

@oferchen oferchen commented Oct 16, 2025 •

Copy link
Copy Markdown
Owner

Summary

  • restructure the negotiation sniffer's cached-decision fast path to use a match with a guard, avoiding nested if statements while preserving behavior
  • use Option::filter inside the read loop so the early return stays clear and clippy-clean

Testing

  • cargo test
  • cargo clippy

@oferchen
oferchen merged commit 8824400 into master Oct 16, 2025
@oferchen
oferchen deleted the codex/implement-rsync-full-protocol-fidelity branch October 16, 2025 09:03
oferchen added a commit that referenced this pull request Sep 1, 2026
* fix(engine): answer am_root from the process identity

The local-copy privilege gate resolved `am_root` with
`rustix::process::geteuid()`, while the two other consumers of the same
question in this crate (`may_attempt_node_creation` and the metadata-sync
options) already call `metadata::am_root()`. Route the third through the
same helper so there is one answer.

The two differ in a way that matters. On Linux rustix compiles `geteuid`
to the bare syscall instruction rather than a call to the libc symbol
(`mov w8, #175; svc #0` on aarch64), so `fakeroot`'s LD_PRELOAD
interposition cannot see it and it reports the real unprivileged uid in
exactly the runs - the upstream testsuite's fakeroot legs, and packaging
builds - where upstream believes it is root. Upstream samples the libc
`geteuid()` (`main.c:1764` `our_uid = MY_UID()`, `rsync.h:1455`), which
fakeroot does intercept. It also re-samples it in `become_copy_as_user()`
after the permanent `--copy-as` drop; `metadata::am_root()` honours that
drop through the identity override, a raw syscall does not.

The new test drives the identity in both directions, so it stays
non-vacuous whether or not the test process runs as root.

* fix(engine): retarget the am_root citation at the 3.5.0 pin

`our_uid = MY_UID()` resolves at main.c:313 and main.c:1844 in 3.5.0, not
1764. The process-identity site is the one in main(), corroborated by the
existing `main.c:1843 starttime = time(NULL)` citation one line above it;
313 is become_copy_as_user()'s re-sample after the --copy-as drop.
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