Repository navigation
fix(metadata): bypass dirfd-sandbox chmod under --keep-dirlinks - #5793
Merged
Merged
Conversation
The path-based permission-apply sites in `apply_permissions_with_chmod` and `apply_permissions_with_chmod_fd` delegate to `fast_io::secure_chmod_at`, which opens the parent via `secure_open_dir` and rejects symlinked parents with ELOOP/ENOTDIR. That TOCTOU guard is the right default but is incompatible with `--keep-dirlinks`, where the user has explicitly opted into following dest-side symlinks-to-dirs. Upstream `generator.c:1344` calls `link_stat(fname, &sx.st, keep_dirlinks && is_dir)` so the symlinked dest dir is resolved at stat time and subsequent chmod operates on the canonical path. Mirror that by gating the sandbox dispatch on `options.keep_dirlinks()`: when set, fall back to `std::fs::set_permissions` (which follows symlinks via the OS path walk) so the chmod lands on the real target. The dirfd guard stays in effect for the default path. Wire the bit from `LocalCopyOptions::keep_dirlinks` through `CopyContext::metadata_options` so the engine local-copy executor passes it down. Fixes the macOS panic in `engine::local_copy::tests::execute_keep_dirlinks_multiple_symlink_subdirs_all_preserved` where the `apply dest_mode` chmod hit ENOTDIR because `dest/alpha` was a symlink to `real_alpha/`. upstream: generator.c:1344 link_stat / rsync.c:set_file_attrs()
2 of 3 tasks
oferchen
added a commit
that referenced
this pull request
Jun 15, 2026
PR #5793 added `chmod_path_honoring_keep_dirlinks` but only routed the chmod-modifier and compute_dest_mode paths through it. The path-based fallbacks in `set_permissions_like`, `apply_permissions_without_chmod` executability branch, and both `apply_permissions_from_entry` branches still called `fast_io::secure_chmod_at` directly, which the dirfd sandbox refuses when the destination's parent is a symlink-to-a-dir. Failing test `apply::tests::keep_dirlinks_bypasses_secure_chmod_sandbox` on every Unix CI cell exercised the `apply_file_metadata_with_options` -> `apply_permissions_without_chmod` -> `set_permissions_like` chain and hit ENOTDIR on `dest/alpha/a.txt` whose parent `alpha` is a symlink. Route all four remaining sites through the helper. Pass `options` into `set_permissions_like` (only 2 callers, both in this file) so the Unix chmod can pick `std::fs::set_permissions` when `keep_dirlinks` is set, mirroring upstream `generator.c:1344 link_stat(fname, &sx.st, keep_dirlinks && is_dir)`.
oferchen
added a commit
that referenced
this pull request
Jun 15, 2026
* fix(cli): drain stdin for both server roles to unblock peer shutdown Under the lsh.sh remote-shell transport (00-hello, alt-dest, files-from, ssh-basic, symlink-dirlink-basis, hardlinks), the previous receiver-only stdin drain caused the server-sender (generator) process to exit before the upstream peer (running as server-receiver child) finished its exit_cleanup() sequence in noop_io_until_death(). The peer was left waiting for FIN on its stdin while we tore down, producing "connection unexpectedly closed" and a 300s timeout in runtests.py. Upstream cleanup.c:254 calls noop_io_until_death() unconditionally for both am_sender and am_receiver server children; mirror that contract by removing the role gate so the generator path also drains stdin to EOF after shutting down its write half. upstream: io.c:943 noop_io_until_death(), cleanup.c:254 _exit_cleanup() * test(cli): drain_stdin_until_eof unit tests for server-sender shutdown Extract the previously-inlined stdin drain loop into a `Read`-generic helper and add nextest coverage for the four shapes that matter on the lsh.sh / SSH transport: - bare EOF (the steady-state case once the peer's exit_cleanup runs) - payload-then-EOF (peer flushes trailing MSG_STATS / NDX_DONE before FIN) - Interrupted + WouldBlock retries (no spurious exit on transient errors) - hard error (drain breaks cleanly instead of spinning) The helper mirrors upstream rsync's noop_io_until_death() (io.c:943) and is now exercised by both the receiver and the generator roles after the goodbye handshake. Tests document the contract so a future revert of the gate would surface immediately. * fix(cli): only report is_local_sender for remote-dest pushes PR #5794 added ClientConfig::is_local_sender() to thread the itemize direction arrow into OutFormatContext. Its docstring claimed the local-copy and empty-args polarity was "harmless because upstream hits the local_server branch which emits >". That assumption holds for upstream's log.c, but oc-rsync's itemize formatter at frontend/out_format/render/itemize.rs only branches on is_sender. With the helper returning true for local copies the formatter started emitting < where upstream emits >, breaking every local-copy itemize test (itemize_combined_with_dry_run_shows_what_would_transfer, itemize_combined_with_verbose_shows_itemized_format, itemize_last_toggle_wins_enabled) across all platforms. Narrow is_local_sender() to return true only when the destination is remote and every source is local - the exact case upstream's log.c renders as <. Local copies, pulls, empty arg lists, and proxy operations all return false so the formatter emits > to match upstream. upstream: log.c:701-704 * fix(metadata): cover remaining chmod sites under --keep-dirlinks bypass PR #5793 added `chmod_path_honoring_keep_dirlinks` but only routed the chmod-modifier and compute_dest_mode paths through it. The path-based fallbacks in `set_permissions_like`, `apply_permissions_without_chmod` executability branch, and both `apply_permissions_from_entry` branches still called `fast_io::secure_chmod_at` directly, which the dirfd sandbox refuses when the destination's parent is a symlink-to-a-dir. Failing test `apply::tests::keep_dirlinks_bypasses_secure_chmod_sandbox` on every Unix CI cell exercised the `apply_file_metadata_with_options` -> `apply_permissions_without_chmod` -> `set_permissions_like` chain and hit ENOTDIR on `dest/alpha/a.txt` whose parent `alpha` is a symlink. Route all four remaining sites through the helper. Pass `options` into `set_permissions_like` (only 2 callers, both in this file) so the Unix chmod can pick `std::fs::set_permissions` when `keep_dirlinks` is set, mirroring upstream `generator.c:1344 link_stat(fname, &sx.st, keep_dirlinks && is_dir)`.
oferchen
added a commit
that referenced
this pull request
Jun 15, 2026
…ss (#5799) * fix(metadata): cover remaining chmod sites under --keep-dirlinks bypass PR #5793 added `chmod_path_honoring_keep_dirlinks` but only routed the chmod-modifier and compute_dest_mode paths through it. The path-based fallbacks in `set_permissions_like`, `apply_permissions_without_chmod` executability branch, and both `apply_permissions_from_entry` branches still called `fast_io::secure_chmod_at` directly, which the dirfd sandbox refuses when the destination's parent is a symlink-to-a-dir. Failing test `apply::tests::keep_dirlinks_bypasses_secure_chmod_sandbox` on every Unix CI cell exercised the `apply_file_metadata_with_options` -> `apply_permissions_without_chmod` -> `set_permissions_like` chain and hit ENOTDIR on `dest/alpha/a.txt` whose parent `alpha` is a symlink. Route all four remaining sites through the helper. Pass `options` into `set_permissions_like` (only 2 callers, both in this file) so the Unix chmod can pick `std::fs::set_permissions` when `keep_dirlinks` is set, mirroring upstream `generator.c:1344 link_stat(fname, &sx.st, keep_dirlinks && is_dir)`. * fix(cli): only report is_local_sender for remote-dest pushes PR #5794 added ClientConfig::is_local_sender() to thread the itemize direction arrow into OutFormatContext. Its docstring claimed the local-copy and empty-args polarity was "harmless because upstream hits the local_server branch which emits >". That assumption holds for upstream's log.c, but oc-rsync's itemize formatter at frontend/out_format/render/itemize.rs only branches on is_sender. With the helper returning true for local copies the formatter started emitting < where upstream emits >, breaking every local-copy itemize test (itemize_combined_with_dry_run_shows_what_would_transfer, itemize_combined_with_verbose_shows_itemized_format, itemize_last_toggle_wins_enabled) across all platforms. Narrow is_local_sender() to return true only when the destination is remote and every source is local - the exact case upstream's log.c renders as <. Local copies, pulls, empty arg lists, and proxy operations all return false so the formatter emits > to match upstream. upstream: log.c:701-704
oferchen
added a commit
that referenced
this pull request
Jun 15, 2026
#5803) Add a cross-platform regression test asserting that apply_file_metadata_with_options succeeds through a symlinked destination directory under --keep-dirlinks on Linux, macOS, and Windows. Pins the guarantee from PR #5793 (macOS chmod bypass) and PRs #5798/#5799 (extension to four more chmod sites), and codifies that Linux (openat2 RESOLVE_BENEATH sandboxes parents only) and Windows (chmod no-op) are clean by construction.
This was referenced Jun 16, 2026
oferchen
added a commit
that referenced
this pull request
Jun 17, 2026
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
Jun 17, 2026
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
Jun 17, 2026
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
Jun 17, 2026
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
Jun 17, 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
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
The path-based permission-apply sites in `apply_permissions_with_chmod` and `apply_permissions_with_chmod_fd` delegate to `fast_io::secure_chmod_at`, which opens the parent via `secure_open_dir` and rejects symlinked parents with ELOOP/ENOTDIR. That TOCTOU guard is the right default but is incompatible with `--keep-dirlinks`, where the user has explicitly opted into following dest-side symlinks-to-dirs. Upstream `generator.c:1344` calls `link_stat(fname, &sx.st, keep_dirlinks && is_dir)` so the symlinked dest dir is resolved at stat time and subsequent chmod operates on the canonical path. Mirror that by gating the sandbox dispatch on `options.keep_dirlinks()`: when set, fall back to `std::fs::set_permissions` (which follows symlinks via the OS path walk) so the chmod lands on the real target. The dirfd guard stays in effect for the default path. Wire the bit from `LocalCopyOptions::keep_dirlinks` through `CopyContext::metadata_options` so the engine local-copy executor passes it down. Fixes the macOS panic in `engine::local_copy::tests::execute_keep_dirlinks_multiple_symlink_subdirs_all_preserved` where the `apply dest_mode` chmod hit ENOTDIR because `dest/alpha` was a symlink to `real_alpha/`. upstream: generator.c:1344 link_stat / rsync.c:set_file_attrs()
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
* fix(cli): drain stdin for both server roles to unblock peer shutdown Under the lsh.sh remote-shell transport (00-hello, alt-dest, files-from, ssh-basic, symlink-dirlink-basis, hardlinks), the previous receiver-only stdin drain caused the server-sender (generator) process to exit before the upstream peer (running as server-receiver child) finished its exit_cleanup() sequence in noop_io_until_death(). The peer was left waiting for FIN on its stdin while we tore down, producing "connection unexpectedly closed" and a 300s timeout in runtests.py. Upstream cleanup.c:254 calls noop_io_until_death() unconditionally for both am_sender and am_receiver server children; mirror that contract by removing the role gate so the generator path also drains stdin to EOF after shutting down its write half. upstream: io.c:943 noop_io_until_death(), cleanup.c:254 _exit_cleanup() * test(cli): drain_stdin_until_eof unit tests for server-sender shutdown Extract the previously-inlined stdin drain loop into a `Read`-generic helper and add nextest coverage for the four shapes that matter on the lsh.sh / SSH transport: - bare EOF (the steady-state case once the peer's exit_cleanup runs) - payload-then-EOF (peer flushes trailing MSG_STATS / NDX_DONE before FIN) - Interrupted + WouldBlock retries (no spurious exit on transient errors) - hard error (drain breaks cleanly instead of spinning) The helper mirrors upstream rsync's noop_io_until_death() (io.c:943) and is now exercised by both the receiver and the generator roles after the goodbye handshake. Tests document the contract so a future revert of the gate would surface immediately. * fix(cli): only report is_local_sender for remote-dest pushes PR #5794 added ClientConfig::is_local_sender() to thread the itemize direction arrow into OutFormatContext. Its docstring claimed the local-copy and empty-args polarity was "harmless because upstream hits the local_server branch which emits >". That assumption holds for upstream's log.c, but oc-rsync's itemize formatter at frontend/out_format/render/itemize.rs only branches on is_sender. With the helper returning true for local copies the formatter started emitting < where upstream emits >, breaking every local-copy itemize test (itemize_combined_with_dry_run_shows_what_would_transfer, itemize_combined_with_verbose_shows_itemized_format, itemize_last_toggle_wins_enabled) across all platforms. Narrow is_local_sender() to return true only when the destination is remote and every source is local - the exact case upstream's log.c renders as <. Local copies, pulls, empty arg lists, and proxy operations all return false so the formatter emits > to match upstream. upstream: log.c:701-704 * fix(metadata): cover remaining chmod sites under --keep-dirlinks bypass PR #5793 added `chmod_path_honoring_keep_dirlinks` but only routed the chmod-modifier and compute_dest_mode paths through it. The path-based fallbacks in `set_permissions_like`, `apply_permissions_without_chmod` executability branch, and both `apply_permissions_from_entry` branches still called `fast_io::secure_chmod_at` directly, which the dirfd sandbox refuses when the destination's parent is a symlink-to-a-dir. Failing test `apply::tests::keep_dirlinks_bypasses_secure_chmod_sandbox` on every Unix CI cell exercised the `apply_file_metadata_with_options` -> `apply_permissions_without_chmod` -> `set_permissions_like` chain and hit ENOTDIR on `dest/alpha/a.txt` whose parent `alpha` is a symlink. Route all four remaining sites through the helper. Pass `options` into `set_permissions_like` (only 2 callers, both in this file) so the Unix chmod can pick `std::fs::set_permissions` when `keep_dirlinks` is set, mirroring upstream `generator.c:1344 link_stat(fname, &sx.st, keep_dirlinks && is_dir)`.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…ss (#5799) * fix(metadata): cover remaining chmod sites under --keep-dirlinks bypass PR #5793 added `chmod_path_honoring_keep_dirlinks` but only routed the chmod-modifier and compute_dest_mode paths through it. The path-based fallbacks in `set_permissions_like`, `apply_permissions_without_chmod` executability branch, and both `apply_permissions_from_entry` branches still called `fast_io::secure_chmod_at` directly, which the dirfd sandbox refuses when the destination's parent is a symlink-to-a-dir. Failing test `apply::tests::keep_dirlinks_bypasses_secure_chmod_sandbox` on every Unix CI cell exercised the `apply_file_metadata_with_options` -> `apply_permissions_without_chmod` -> `set_permissions_like` chain and hit ENOTDIR on `dest/alpha/a.txt` whose parent `alpha` is a symlink. Route all four remaining sites through the helper. Pass `options` into `set_permissions_like` (only 2 callers, both in this file) so the Unix chmod can pick `std::fs::set_permissions` when `keep_dirlinks` is set, mirroring upstream `generator.c:1344 link_stat(fname, &sx.st, keep_dirlinks && is_dir)`. * fix(cli): only report is_local_sender for remote-dest pushes PR #5794 added ClientConfig::is_local_sender() to thread the itemize direction arrow into OutFormatContext. Its docstring claimed the local-copy and empty-args polarity was "harmless because upstream hits the local_server branch which emits >". That assumption holds for upstream's log.c, but oc-rsync's itemize formatter at frontend/out_format/render/itemize.rs only branches on is_sender. With the helper returning true for local copies the formatter started emitting < where upstream emits >, breaking every local-copy itemize test (itemize_combined_with_dry_run_shows_what_would_transfer, itemize_combined_with_verbose_shows_itemized_format, itemize_last_toggle_wins_enabled) across all platforms. Narrow is_local_sender() to return true only when the destination is remote and every source is local - the exact case upstream's log.c renders as <. Local copies, pulls, empty arg lists, and proxy operations all return false so the formatter emits > to match upstream. upstream: log.c:701-704
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
#5803) Add a cross-platform regression test asserting that apply_file_metadata_with_options succeeds through a symlinked destination directory under --keep-dirlinks on Linux, macOS, and Windows. Pins the guarantee from PR #5793 (macOS chmod bypass) and PRs #5798/#5799 (extension to four more chmod sites), and codifies that Linux (openat2 RESOLVE_BENEATH sandboxes parents only) and Windows (chmod no-op) are clean by construction.
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
engine::local_copy::tests::execute_keep_dirlinks_multiple_symlink_subdirs_all_preservedwhereapply dest_modechmod failed withENOTDIRbecause the destination's parent (dest/alpha) was a symlink to a real directory.keep_dirlinkstoMetadataOptionsand wire it fromLocalCopyOptionsthroughCopyContext::metadata_options.apply_permissions_with_chmodandapply_permissions_with_chmod_fd, route the four path-basedsecure_chmod_atsites through a new helper that falls back tostd::fs::set_permissionswhen--keep-dirlinksis active, mirroring upstreamgenerator.c:1344'slink_stat(fname, &sx.st, keep_dirlinks && is_dir).Root cause
fast_io::secure_chmod_atopens the parent viasecure_open_dir, which rejects symlinked parents (ELOOP/ENOTDIR) as a TOCTOU guard against chmod-symlink-race. With--keep-dirlinks, the user has explicitly opted into following dest-side symlinks-to-dirs, so the sandbox refusal is semantically wrong. The bypass is gated onoptions.keep_dirlinks(); the default code path keeps the dirfd-anchored guard intact (SEC-1 / CVE-29518 protection preserved). The fd-basedfchmodsites are unaffected because an already-opened fd cannot be redirected by a parent-symlink swap.Upstream reference
// upstream: generator.c:1344 - link_stat with keep_dirlinks resolves symlinked dirsTest plan
keep_dirlinks_bypasses_secure_chmod_sandboxincrates/metadata/src/apply/tests.rscovers the bypass behavior: withoutkeep_dirlinksthe chmod through a symlinked parent is refused; withkeep_dirlinksit succeeds and lands on the canonical target.keep_dirlinks_defaults_to_false_and_can_be_setcovers the newMetadataOptionsaccessor/setter.apply_permissions_from_entry_refuses_parent_symlink_escapecontinues to assert the SEC-1 guard still rejects symlinked-parent chmod when--keep-dirlinksis NOT active.execute_keep_dirlinks_multiple_symlink_subdirs_all_preserved(previously failing on macOS) should now pass.