Repository navigation
fix: alt-dest --copy-dest symlink resolution via remote shell - #5525
Merged
Merged
Conversation
The receiver's `try_reference_dest` stat'd basis-dir entries with `fs::metadata()` (follows symlinks), then accepted any entry whose followed-stat reported a regular file. Upstream `try_dests_reg` (generator.c:953) uses `link_stat(cmpbuf, &sxp->st, 0)`, which calls `x_lstat()` by default (flist.c:234) and filters with `!S_ISREG`. The follow-through to `x_stat()` only happens when `copy_links` is set. A basis-dir entry that is itself a symlink was therefore silently consumed by `--copy-dest` / `--link-dest` / `--compare-dest` even when upstream would skip it. Under remote-shell transports this caused the receiver to populate the destination locally for a file the sender expected to deliver, diverging from upstream's wire pattern on the `alt-dest.test` lsh.sh sub-tests. Plumb `copy_links` through to `try_reference_dest` and stat the basis-dir entry with `symlink_metadata` when `copy_links` is off, falling back to follow-stat when `-L` is set. Add regression coverage for copy-dest, link-dest, and compare-dest under a symlink basis, plus the copy_links=true follow path and a regular-file baseline.
2 tasks
oferchen
added a commit
that referenced
this pull request
Jun 10, 2026
Group PRs #5510, #5516, #5519, #5520, #5523, #5525-#5544 by shared root cause rather than by Stream bucket. Seven clusters surface; the parser- stores-string and field-vs-method shadowing clusters cover the largest share of the series, and the receiver-driver wiring-parity gap explains the NDX_DEL_STATS goodbye misses in both #5536 and #5542. Includes a defense-in-depth audit mapping each cluster onto the rust-landlock ruleset wired at crates/fast_io/src/landlock.rs. Doc-only; no code paths touched.
oferchen
added a commit
that referenced
this pull request
Jun 10, 2026
Group PRs #5510, #5516, #5519, #5520, #5523, #5525-#5544 by shared root cause rather than by Stream bucket. Seven clusters surface; the parser- stores-string and field-vs-method shadowing clusters cover the largest share of the series, and the receiver-driver wiring-parity gap explains the NDX_DEL_STATS goodbye misses in both #5536 and #5542. Includes a defense-in-depth audit mapping each cluster onto the rust-landlock ruleset wired at crates/fast_io/src/landlock.rs. Doc-only; no code paths touched.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
Group PRs #5510, #5516, #5519, #5520, #5523, #5525-#5544 by shared root cause rather than by Stream bucket. Seven clusters surface; the parser- stores-string and field-vs-method shadowing clusters cover the largest share of the series, and the receiver-driver wiring-parity gap explains the NDX_DEL_STATS goodbye misses in both #5536 and #5542. Includes a defense-in-depth audit mapping each cluster onto the rust-landlock ruleset wired at crates/fast_io/src/landlock.rs. Doc-only; no code paths touched.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
* fix: alt-dest --copy-dest symlink resolution via remote shell The receiver's `try_reference_dest` stat'd basis-dir entries with `fs::metadata()` (follows symlinks), then accepted any entry whose followed-stat reported a regular file. Upstream `try_dests_reg` (generator.c:953) uses `link_stat(cmpbuf, &sxp->st, 0)`, which calls `x_lstat()` by default (flist.c:234) and filters with `!S_ISREG`. The follow-through to `x_stat()` only happens when `copy_links` is set. A basis-dir entry that is itself a symlink was therefore silently consumed by `--copy-dest` / `--link-dest` / `--compare-dest` even when upstream would skip it. Under remote-shell transports this caused the receiver to populate the destination locally for a file the sender expected to deliver, diverging from upstream's wire pattern on the `alt-dest.test` lsh.sh sub-tests. Plumb `copy_links` through to `try_reference_dest` and stat the basis-dir entry with `symlink_metadata` when `copy_links` is off, falling back to follow-stat when `-L` is set. Add regression coverage for copy-dest, link-dest, and compare-dest under a symlink basis, plus the copy_links=true follow path and a regular-file baseline. * style: rustfmt quick_check.rs reference test helper
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
Upstream
try_dests_reg(generator.c:942) probes each basis-dircandidate with
link_stat(cmpbuf, &sxp->st, 0)(generator.c:953),which dispatches to
x_lstat()by default andx_stat()only whencopy_linksis set (flist.c:234). The follow-up!S_ISREGcheckfilters out basis-dir entries that are themselves symlinks.
The receiver's
try_reference_destinstead stat'd basis-dir entrieswith
fs::metadata()(always follows symlinks) and accepted anyentry whose followed-stat reported a regular file. When the
basis-dir entry was a symlink, oc-rsync silently copied or
hard-linked from the symlink's target, while upstream would have
skipped the basis-dir entry and requested a wire transfer instead.
Under remote-shell transports the divergence shows up on the
alt-dest.testlsh.shsub-tests (UTS-2 / #3560).Fix
crates/transfer/src/receiver/quick_check.rs—try_reference_destnow takes a
copy_linksargument. Whencopy_linksis false thebasis-dir entry is stat'd with
fs::symlink_metadata()(lstat),matching upstream's
x_lstat()path. Whencopy_linksis true thecall falls through to
fs::metadata(), matching upstream'sx_stat()follow path. The accept gate is nowfile_type().is_file()on the un-followed metadata, which mirrorsupstream's
S_ISREG(sxp->st.st_mode)check.crates/transfer/src/receiver/transfer/candidates.rs— passself.config.flags.copy_linksthrough totry_reference_dest.Tests
crates/transfer/src/receiver/quick_check.rs::symlink_basis_testscopy_dest_skips_symlink_basis_entry_without_copy_linkslink_dest_skips_symlink_basis_entry_without_copy_linkscompare_dest_skips_symlink_basis_entry_without_copy_linkscopy_dest_follows_symlink_basis_entry_with_copy_linkscopy_dest_matches_regular_basis_entry_without_copy_linksEach test builds a basis-dir whose entry for the source name is a
symlink to a regular file with matching size, then verifies that
try_reference_destreturnsfalse(no local handling) under thedefault
copy_links=false, andtrueonly whencopy_links=true.The regular-file baseline guards against an over-eager fix that
breaks the common case.
Test plan
symlink basis under
copy_links=false.copy_links=truefollow path.