Repository navigation
fix(server): honour --confine-root instead of taking it for the destination - #7388
Merged
Merged
Conversation
…nation
Reproduced against the upstream 3.5.0 testsuite (rrsync-debug-denied):
oc-rsync error: server error: failed to create destination root
--confine-root=/.../root: No such file or directory (os error 2) rc=12
`--confine-root=DIR` was in neither `is_known_server_long_flag` nor
`is_two_arg_server_long_flag` - the latter only covers the space-separated
`safe_arg("", value)` pairs - so the joined single-slot form was not
recognised as a flag at all. It fell through to the positional list and
became the destination root, breaking the transfer outright. That is the
same allow-list drift the `_ =>` arm's own comment says it exists to
prevent, and the same class as the --bwlimit= / --block-size leaks.
A restricted-directory wrapper appends `--confine-root=<cwd>` to the server
argv whenever its restricted dir is not "/" (upstream support/rrsync
main():637-644), so every such invocation hit this.
Recognising the flag alone would trade a broken transfer for a silently
unconfined one, so the value is also carried to where the root is read.
`GeneratorContext::source_open` already mirrors upstream's
`confinement_root()` (syscall.c:136) for the daemon arm; the non-daemon arm
returned None unconditionally and now returns this root. The daemon arm
still wins outright, matching options.c:2382-2386, which nulls a
peer-supplied `--confine-root` before a daemon can ever read it - honouring
it there could only widen the module.
Pinned by two tests on purpose, because they cover DIFFERENT functions:
`parse_server_args_does_not_leak_confine_root_into_the_destination` is the
operand half that actually broke, and `long_flags_capture_confine_root` is
the value half. Recognising the flag in only one of them leaves either a
positional leak or a dropped confinement root, and neither test alone can
see the other failure.
Scope: this covers the sender's source open, which is what
`source_open()` feeds. The operator-named path families (alt-dest, staging,
merge files) resolve elsewhere and are not confined by this change.
oferchen
added a commit
that referenced
this pull request
Aug 19, 2026
…er (#7391) The manifests were baselined at commit 5d11768 and committed by #7387. #7388 then landed behaviour changes that flip two tests from fail to pass, and nothing regenerated the manifests. `upstream testsuite` and `upstream testsuite (root)` - both required contexts - have been red on master ever since, and every open PR inherits the same two mismatches: rename-fullpath-symlink-race: expected fail, got pass (xpass) rrsync-no-overwrite-delay-updates: expected fail, got pass (xpass) Both files are taken verbatim from the expect-result artifacts emitted by master's own run 32296056003 (commit b87da3d), so all 345 outcome rows stay generated rather than typed. Only the Baseline provenance comment is added by hand, matching the convention the previous baseline used. Besides the two flips the diff carries a header-text change (the emitter now names its own regeneration command) and a reposition of `partial_nowrite`, which is a collation artifact: parse_expect_result builds a {testbase: outcome} dict (runtests.py:332), so line order does not affect the gate.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…er (#7391) The manifests were baselined at commit 5d11768 and committed by #7387. #7388 then landed behaviour changes that flip two tests from fail to pass, and nothing regenerated the manifests. `upstream testsuite` and `upstream testsuite (root)` - both required contexts - have been red on master ever since, and every open PR inherits the same two mismatches: rename-fullpath-symlink-race: expected fail, got pass (xpass) rrsync-no-overwrite-delay-updates: expected fail, got pass (xpass) Both files are taken verbatim from the expect-result artifacts emitted by master's own run 32296056003 (commit 5af2685), so all 345 outcome rows stay generated rather than typed. Only the Baseline provenance comment is added by hand, matching the convention the previous baseline used. Besides the two flips the diff carries a header-text change (the emitter now names its own regeneration command) and a reposition of `partial_nowrite`, which is a collation artifact: parse_expect_result builds a {testbase: outcome} dict (runtests.py:332), so line order does not affect the gate.
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.
rsync 3.5.0 added
--confine-root=DIR(options.c:64-65,:690). oc's--serveroperand parser did not know the option, so an incoming
--confine-root=/some/dirfell through
is_known_server_long_flaginto the positional list and became thedestination path.
MEASURED against the real upstream 3.5.0 testsuite, the server side reported:
The filed claim for this gap said oc "rejects
--confine-rootwith exit 1"; that isnot what happens. It is not silently ignored either. It leaks into the operand list
and breaks the transfer by redirecting the destination. Same class as the earlier
--bwlimit=and--block-sizeoperand leaks.Change
crates/cli/src/frontend/server/flags.rs- capture--confine-root=VALUEintoServerLongFlags, and add it to the server-mode allow-list so it can never reachthe positional list.
crates/cli/src/frontend/server/run.rs- carry the captured value intoConnectionConfig, next tofiles_from_path.crates/transfer/src/config/mod.rs- newConnectionConfig::confine_root.crates/transfer/src/generator/context.rs-source_open()picks the confinementanchor per
syscall.c:136 confinement_root():am_daemon ? module_dir : confine_root. The daemon arm wins unconditionally - itsmodule directory is already the boundary, and
--confine-rootarrives in apeer-supplied argv where honouring it could only widen the module.
options.c:2382-2386nulls the option out for a daemon before it is ever read, somirroring that precedence here is the same rule, not a new one.
Tests
Three tests in
crates/cli/src/frontend/server/tests.rs, deliberately spanning twodifferent functions so a fix to one half cannot make the other pass vacuously:
parse_server_args_does_not_leak_confine_root_into_the_destination- the operandhalf, i.e. the half that actually broke. Fails on the pre-fix parser.
long_flags_capture_confine_root- the value half.long_flags_default_confine_root_is_absent- non-vacuity companion; without it thecapture test would also pass if the field were unconditionally populated.
Verification (Linux aarch64)
cargo nextest run -p cli --all-features -E 'test(confine_root)'- 3 passed.cargo fmt --all -- --check- clean.cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings- clean.