Skip to content

fix(server): honour --confine-root instead of taking it for the destination - #7388

Merged
oferchen merged 1 commit into
masterfrom
fix/server-confine-root
Aug 19, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/server-confine-root

Conversation

@oferchen

Copy link
Copy Markdown
Owner

rsync 3.5.0 added --confine-root=DIR (options.c:64-65, :690). oc's --server
operand parser did not know the option, so an incoming --confine-root=/some/dir
fell through is_known_server_long_flag into the positional list and became the
destination path.

MEASURED against the real upstream 3.5.0 testsuite, the server side reported:

rsync: [receiver] link_stat "--confine-root=/tmp/.../to" failed: No such file or directory (2)

The filed claim for this gap said oc "rejects --confine-root with exit 1"; that is
not 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-size operand leaks.

Change

  • crates/cli/src/frontend/server/flags.rs - capture --confine-root=VALUE into
    ServerLongFlags, and add it to the server-mode allow-list so it can never reach
    the positional list.
  • crates/cli/src/frontend/server/run.rs - carry the captured value into
    ConnectionConfig, next to files_from_path.
  • crates/transfer/src/config/mod.rs - new ConnectionConfig::confine_root.
  • crates/transfer/src/generator/context.rs - source_open() picks the confinement
    anchor per syscall.c:136 confinement_root():
    am_daemon ? module_dir : confine_root. The daemon arm wins unconditionally - its
    module directory is already the boundary, and --confine-root arrives in a
    peer-supplied argv where honouring it could only widen the module.
    options.c:2382-2386 nulls the option out for a daemon before it is ever read, so
    mirroring that precedence here is the same rule, not a new one.

Tests

Three tests in crates/cli/src/frontend/server/tests.rs, deliberately spanning two
different 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 operand
    half, 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 the
    capture 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.

…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.
@github-actions github-actions Bot added the bug Something isn't working label Aug 19, 2026
@oferchen
oferchen merged commit b87da3d into master Aug 19, 2026
114 of 122 checks passed
@oferchen
oferchen deleted the fix/server-confine-root branch August 19, 2026 19:59
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
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant