Repository navigation
fix(transfer): parse compact -K to honour --keep-dirlinks on receiver - #5853
Merged
oferchen merged 1 commit intoJun 17, 2026
Merged
Conversation
oferchen
force-pushed
the
fix/uts-symlink-dirlink-basis-multibasis-precedence
branch
3 times, most recently
from
June 17, 2026 09:43
1e3812e to
a27baba
Compare
4 of 6 tasks
oferchen
marked this pull request as ready for review
June 17, 2026 12:38
The server-side compact flag parser silently dropped the 'K' byte the client emits whenever `--keep-dirlinks` is active. With the flag absent from `ParsedServerFlags`, the receiver constructed `MetadataOptions` with `keep_dirlinks: false`, so the dirfd-anchored chmod bypass added in PR #5793 never engaged: every per-file chmod through a destination dir-symlink (`$HOME/dir/file` when `dir -> real-dir`) was refused with ELOOP/ENOTDIR before any delta could land. Every basis-symlink scenario in `testsuite/symlink-dirlink-basis.test` (Issue #715, eight topologies covering basic / nested / --backup / --inplace / top-level / proto-28 / --partial-dir) bottoms out on this same gap. Wire `K` and `k` into the compact flag parser and propagate the parsed `keep_dirlinks` into the receiver's `MetadataOptions` via `with_keep_dirlinks`, matching upstream `generator.c:1344`'s `link_stat(fname, &sx.st, keep_dirlinks && is_dir)`. upstream: options.c:688 / generator.c:1344
oferchen
force-pushed
the
fix/uts-symlink-dirlink-basis-multibasis-precedence
branch
from
June 17, 2026 12:39
3ab5166 to
dd90821
Compare
1 of 3 tasks
oferchen
added a commit
that referenced
this pull request
Jun 17, 2026
Pins the receiver-side wiring that the upstream rsync 3.4.4 testsuite `symlink-dirlink-basis` test exercises against -K/--keep-dirlinks. The chmod dirfd-sandbox bypass (#5793) plus the compact `K` flag parser wire-up (#5853) close the failure; this test file is the regression coverage for both halves together. Each test mirrors one of the eight Test N scenarios in `testsuite/symlink-dirlink-basis.test` (Issue #715): basic, compressed, nested, --backup, --inplace, top-level (negative control), proto28 --partial-dir, and proto28 basic. The negative control catches a parser regression that would silently set keep_dirlinks for the non-symlinked top-level case. Pins both halves of the chain: - ParsedServerFlags::parse recognises the compact `K` byte from the server-side flag string the client emits in every topology. - The parsed flag survives MetadataOptions::with_keep_dirlinks, which is what chmod_path_honoring_keep_dirlinks consults at apply time. Upstream sources of truth: - target/interop/upstream-src/rsync-3.4.4/testsuite/symlink-dirlink-basis.test - target/interop/upstream-src/rsync-3.4.1/options.c:688 (-K mapping) - target/interop/upstream-src/rsync-3.4.1/generator.c:1344 (link_stat(fname, &sx.st, keep_dirlinks && is_dir))
oferchen
added a commit
that referenced
this pull request
Jun 17, 2026
Pins the receiver-side wiring that the upstream rsync 3.4.4 testsuite `symlink-dirlink-basis` test exercises against -K/--keep-dirlinks. The chmod dirfd-sandbox bypass (#5793) plus the compact `K` flag parser wire-up (#5853) close the failure; this test file is the regression coverage for both halves together. Each test mirrors one of the eight Test N scenarios in `testsuite/symlink-dirlink-basis.test` (Issue #715): basic, compressed, nested, --backup, --inplace, top-level (negative control), proto28 --partial-dir, and proto28 basic. The negative control catches a parser regression that would silently set keep_dirlinks for the non-symlinked top-level case. Pins both halves of the chain: - ParsedServerFlags::parse recognises the compact `K` byte from the server-side flag string the client emits in every topology. - The parsed flag survives MetadataOptions::with_keep_dirlinks, which is what chmod_path_honoring_keep_dirlinks consults at apply time. Upstream sources of truth: - target/interop/upstream-src/rsync-3.4.4/testsuite/symlink-dirlink-basis.test - target/interop/upstream-src/rsync-3.4.1/options.c:688 (-K mapping) - target/interop/upstream-src/rsync-3.4.1/generator.c:1344 (link_stat(fname, &sx.st, keep_dirlinks && is_dir))
oferchen
added a commit
that referenced
this pull request
Jun 17, 2026
… (#5871) Pins the receiver-side wiring that the upstream rsync 3.4.4 testsuite `symlink-dirlink-basis` test exercises against -K/--keep-dirlinks. The chmod dirfd-sandbox bypass (#5793) plus the compact `K` flag parser wire-up (#5853) close the failure; this test file is the regression coverage for both halves together. Each test mirrors one of the eight Test N scenarios in `testsuite/symlink-dirlink-basis.test` (Issue #715): basic, compressed, nested, --backup, --inplace, top-level (negative control), proto28 --partial-dir, and proto28 basic. The negative control catches a parser regression that would silently set keep_dirlinks for the non-symlinked top-level case. Pins both halves of the chain: - ParsedServerFlags::parse recognises the compact `K` byte from the server-side flag string the client emits in every topology. - The parsed flag survives MetadataOptions::with_keep_dirlinks, which is what chmod_path_honoring_keep_dirlinks consults at apply time. Upstream sources of truth: - target/interop/upstream-src/rsync-3.4.4/testsuite/symlink-dirlink-basis.test - target/interop/upstream-src/rsync-3.4.1/options.c:688 (-K mapping) - target/interop/upstream-src/rsync-3.4.1/generator.c:1344 (link_stat(fname, &sx.st, keep_dirlinks && is_dir))
1 of 2 tasks
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…#5853) The server-side compact flag parser silently dropped the 'K' byte the client emits whenever `--keep-dirlinks` is active. With the flag absent from `ParsedServerFlags`, the receiver constructed `MetadataOptions` with `keep_dirlinks: false`, so the dirfd-anchored chmod bypass added in PR #5793 never engaged: every per-file chmod through a destination dir-symlink (`$HOME/dir/file` when `dir -> real-dir`) was refused with ELOOP/ENOTDIR before any delta could land. Every basis-symlink scenario in `testsuite/symlink-dirlink-basis.test` (Issue #715, eight topologies covering basic / nested / --backup / --inplace / top-level / proto-28 / --partial-dir) bottoms out on this same gap. Wire `K` and `k` into the compact flag parser and propagate the parsed `keep_dirlinks` into the receiver's `MetadataOptions` via `with_keep_dirlinks`, matching upstream `generator.c:1344`'s `link_stat(fname, &sx.st, keep_dirlinks && is_dir)`. upstream: options.c:688 / generator.c:1344
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
… (#5871) Pins the receiver-side wiring that the upstream rsync 3.4.4 testsuite `symlink-dirlink-basis` test exercises against -K/--keep-dirlinks. The chmod dirfd-sandbox bypass (#5793) plus the compact `K` flag parser wire-up (#5853) close the failure; this test file is the regression coverage for both halves together. Each test mirrors one of the eight Test N scenarios in `testsuite/symlink-dirlink-basis.test` (Issue #715): basic, compressed, nested, --backup, --inplace, top-level (negative control), proto28 --partial-dir, and proto28 basic. The negative control catches a parser regression that would silently set keep_dirlinks for the non-symlinked top-level case. Pins both halves of the chain: - ParsedServerFlags::parse recognises the compact `K` byte from the server-side flag string the client emits in every topology. - The parsed flag survives MetadataOptions::with_keep_dirlinks, which is what chmod_path_honoring_keep_dirlinks consults at apply time. Upstream sources of truth: - target/interop/upstream-src/rsync-3.4.4/testsuite/symlink-dirlink-basis.test - target/interop/upstream-src/rsync-3.4.1/options.c:688 (-K mapping) - target/interop/upstream-src/rsync-3.4.1/generator.c:1344 (link_stat(fname, &sx.st, keep_dirlinks && is_dir))
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.
Summary
The server-side compact flag parser silently dropped the
Kbyte the client emits whenever--keep-dirlinksis active. With the flag absent fromParsedServerFlags, the receiver constructedMetadataOptionswithkeep_dirlinks: false, so the dirfd-anchored chmod bypass added in PR #5793 never engaged: every per-file chmod through a destination dir-symlink ($HOME/dir/filewhendir -> real-dir) was refused withELOOP/ENOTDIRbefore any delta could land. Every basis-symlink scenario intestsuite/symlink-dirlink-basis.test(Issue #715, eight topologies covering basic / nested /--backup/--inplace/ top-level / proto-28 /--partial-dir) bottoms out on this same gap.Root cause
crates/transfer/src/flags.rsmapped every transfer byte exceptKandkto a structured field. The unknown-byte catch-all swallowed both, soflags.keep_dirlinkswas permanentlyfalseno matter what the client sent.Downstream,
crates/transfer/src/receiver/transfer/setup.rsbuiltMetadataOptionsfromself.config.flagswithout callingwith_keep_dirlinks. Even after fixing the parser, the receiver would still take the strict chmod path because the bypass is gated onoptions.keep_dirlinks().Fix
keep_dirlinks: bool(andcopy_dirlinks: boolfor parity with the sender-sidek) toParsedServerFlags.Kandkinparse_transfer_flagwithupstream: options.c:687,688references..with_keep_dirlinks(self.config.flags.keep_dirlinks)into the receiver'sMetadataOptionsconstruction sochmod_path_honoring_keep_dirlinks(crates/metadata/src/apply/permissions.rs:451) routes past the dirfd sandbox when the symlinked parent would otherwise surfaceELOOP/ENOTDIR.The default code path (
--keep-dirlinksoff) is unchanged:secure_chmod_atand the dirfd sandbox keep the SEC-1 / CVE-29518 guard intact for every other transfer.Upstream reference
options.c:688{"keep-dirlinks", 'K', POPT_ARG_NONE, &keep_dirlinks, 0, 0, 0}generator.c:1344link_stat(fname, &sx.st, keep_dirlinks && is_dir)Test plan
parses_keep_dirlinks_flag,keep_dirlinks_not_set_by_default, andparses_copy_dirlinks_flagpin the new bytes in the compact server flag parser.testsuite/symlink-dirlink-basis.testend-to-end (all eight topologies) overlsh.sh. Marked DRAFT pending that signal.keep_dirlinks_bypasses_secure_chmod_sandboxandkeep_dirlinks_bypass_is_cross_platform_safeincrates/metadata/src/apply/tests.rscontinue to assert the bypass landing site is wired correctly.