Repository navigation
fix(engine): answer am_root from the process identity - #7574
Merged
Merged
Conversation
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.
`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.
oferchen
added a commit
that referenced
this pull request
Sep 2, 2026
`## [Unreleased]` last covered the #7304-#7522 era. Measured against the 60 most recently merged pull requests, 44 were absent; of the most recent 45, 43 were absent. Nothing from #7574 onward was recorded at all. Each entry is derived from what the pull request actually landed - the merge commit and the body - not from its title. Three cases where those differ: * #7616 ships far more than the doc-alias correction its body describes: the `upstream_version` pin moves to 3.5.0 and `--version` starts naming `quic`, `sd-notify`, `vmsplice` and `send_zc`. * #7618 also adds the pull-request rustdoc-link job its body says was filed separately, which is what closes the master-only-gate recurrence. * #7602's squash carries the closed #7597 as its first commit, so the directory-obstacle half is recorded under #7602. #7587 is deliberately not recorded. Its merge commit is empty: the change had already landed as #7563, which the section already names. Entries extend the existing Keep a Changelog groups and the bold sub-groupings. Clusters that are one story carry one entry with several references: the FERROR_XFER routing and its two-phase drain (#7576, #7581), the connection-FSM close edge and the accept loop that outlives a session error (#7579, #7590), the three detaching daemon suites (#7578, #7588, #7592), the io_uring and SEND_ZC work (#7593, #7600, #7610), the citation retargets (#7601, #7603, #7604), and the accept-loop pin flake (#7615, #7620). Only `## [Unreleased]` is touched; every released section, including the 3.4.4 statements that were correct when written, is byte-identical.
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.
Problem
crates/engine/src/local_copy/options/metadata/accessors.rsresolved thelocal-copy
am_rootgate withrustix::process::geteuid().is_root(). Twoother consumers of the same question in the same crate already call
metadata::am_root():crates/engine/src/local_copy/options/path_behavior.rs:450(
may_attempt_node_creation)crates/engine/src/local_copy/metadata_sync.rs:137So the crate had two ways to answer one question, and they do not agree.
Why they do not agree
On Linux, rustix's default backend emits the bare syscall instruction instead
of calling the libc symbol. Compiled for
aarch64-unknown-linux-gnu:fakerootworks byLD_PRELOAD-interposing the libc symbol, so it can seeb geteuidand cannot seesvc #0. Under fakeroot the raw form reports thereal unprivileged uid while upstream rsync - which samples the libc
geteuid()(main.c:1764our_uid = MY_UID(),rsync.h:1455) - believes itis root. That silently flips the
--super, device-creation and fake-superplaceholder gates in exactly the runs meant to validate them: the upstream
testsuite's fakeroot legs and packaging builds.
The same call is also blind to the permanent
--copy-asprivilege drop.Upstream re-samples
our_uid/am_rootinbecome_copy_as_user();metadata::am_root()reproduces that through the identity override installedby
metadata::copy_as::become_copy_as_user, a raw syscall does not.Change
is_effective_root()delegates tometadata::am_root(). The#[cfg(unix)]/#[cfg(not(unix))]pair goes away becausemetadata::am_root()is alreadyfalseon non-POSIX platforms, matching upstream'sam_root = 0there. Nobehaviour change on a plain unprivileged or plain root run; the two now agree
under fakeroot and after
--copy-as.Test
am_root_follows_the_process_identity_not_the_raw_euiddrives the identitysource in both directions, so it is non-vacuous whatever uid the test process
runs at. Reverting the one-line fix to
rustix::process::geteuid().is_root()turns it red and nothing else:
With the fix in place:
324 tests run: 324 passedfortest(local_copy::options) or test(execute_super).cargo fmt --all -- --checkandcargo clippy --workspace --all-targets --all-features --no-deps -- -D warningsare clean.
cargo check -p engine --all-features --testsalso passes forx86_64-pc-windows-gnu.