Repository navigation
Add fallible message buffer extension helper - #715
Merged
Merged
Conversation
4 tasks
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
The receiver-side `ensure_dest_root_exists()` pre-flight used `symlink_metadata()` (lstat) and rejected any symlinked destination with `InvalidInput`. Upstream `main.c:745-754` calls `do_stat()` (follows symlinks), accepts the dest when `S_ISDIR(st.st_mode)` is true, then enters the resolved directory via `change_dir()`. The upstream `symlink-dirlink-basis` interop test (issue #715) drives this path with `$HOME/dir -> $HOME/real-dir` and `-K`. Switch the helper to `metadata()` so a symlink-to-existing-directory dest is accepted, and surface a dangling-symlink dest as `NotFound` via an `lstat` follow-up (instead of letting `create_dir_all` materialize the directory at the link target). Canonicalize the symlinked dest in `setup_transfer` so the downstream `DirSandbox` opens the resolved target dirfd once; per-entry `*at` syscalls then anchor at the canonical path. Skip the canonicalize step for daemon connections so the strict `open_sandbox_for_dest_strict` path keeps refusing symlinked dests (chdir-symlink-race defense). Security model: per-entry writes are sandboxed by the SEC-1 `*at` chain (`openat2(RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS)` on Linux 5.6+, `openat(O_NOFOLLOW | O_DIRECTORY)` elsewhere). Accepting a symlinked dest at the pre-flight does not weaken that containment because the canonical resolved path becomes the sandbox root. Tests: - Update `uts_2_dest_root_mkdir.rs` to assert the new accept-on- symlink-to-dir behavior and the dangling-symlink `NotFound` surface; remove the four pre-PR refusal tests they superseded. - Add a chained-dangling-symlink regression and an explicit rejected-non-directory test.
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
The receiver-side `ensure_dest_root_exists()` pre-flight used `symlink_metadata()` (lstat) and rejected any symlinked destination with `InvalidInput`. Upstream `main.c:745-754` calls `do_stat()` (follows symlinks), accepts the dest when `S_ISDIR(st.st_mode)` is true, then enters the resolved directory via `change_dir()`. The upstream `symlink-dirlink-basis` interop test (issue #715) drives this path with `$HOME/dir -> $HOME/real-dir` and `-K`. Switch the helper to `metadata()` so a symlink-to-existing-directory dest is accepted, and surface a dangling-symlink dest as `NotFound` via an `lstat` follow-up (instead of letting `create_dir_all` materialize the directory at the link target). Canonicalize the symlinked dest in `setup_transfer` so the downstream `DirSandbox` opens the resolved target dirfd once; per-entry `*at` syscalls then anchor at the canonical path. Skip the canonicalize step for daemon connections so the strict `open_sandbox_for_dest_strict` path keeps refusing symlinked dests (chdir-symlink-race defense). Security model: per-entry writes are sandboxed by the SEC-1 `*at` chain (`openat2(RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS)` on Linux 5.6+, `openat(O_NOFOLLOW | O_DIRECTORY)` elsewhere). Accepting a symlinked dest at the pre-flight does not weaken that containment because the canonical resolved path becomes the sandbox root. Tests: - Update `uts_2_dest_root_mkdir.rs` to assert the new accept-on- symlink-to-dir behavior and the dangling-symlink `NotFound` surface; remove the four pre-PR refusal tests they superseded. - Add a chained-dangling-symlink regression and an explicit rejected-non-directory test.
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
The receiver-side `ensure_dest_root_exists()` pre-flight used `symlink_metadata()` (lstat) and rejected any symlinked destination with `InvalidInput`. Upstream `main.c:745-754` calls `do_stat()` (follows symlinks), accepts the dest when `S_ISDIR(st.st_mode)` is true, then enters the resolved directory via `change_dir()`. The upstream `symlink-dirlink-basis` interop test (issue #715) drives this path with `$HOME/dir -> $HOME/real-dir` and `-K`. Switch the helper to `metadata()` so a symlink-to-existing-directory dest is accepted, and surface a dangling-symlink dest as `NotFound` via an `lstat` follow-up (instead of letting `create_dir_all` materialize the directory at the link target). Canonicalize the symlinked dest in `setup_transfer` so the downstream `DirSandbox` opens the resolved target dirfd once; per-entry `*at` syscalls then anchor at the canonical path. Skip the canonicalize step for daemon connections so the strict `open_sandbox_for_dest_strict` path keeps refusing symlinked dests (chdir-symlink-race defense). Security model: per-entry writes are sandboxed by the SEC-1 `*at` chain (`openat2(RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS)` on Linux 5.6+, `openat(O_NOFOLLOW | O_DIRECTORY)` elsewhere). Accepting a symlinked dest at the pre-flight does not weaken that containment because the canonical resolved path becomes the sandbox root. Tests: - Update `uts_2_dest_root_mkdir.rs` to assert the new accept-on- symlink-to-dir behavior and the dangling-symlink `NotFound` surface; remove the four pre-PR refusal tests they superseded. - Add a chained-dangling-symlink regression and an explicit rejected-non-directory test.
oferchen
added a commit
that referenced
this pull request
Jun 11, 2026
) * fix(receiver): follow symlink at dest_root to match upstream The receiver-side `ensure_dest_root_exists()` pre-flight used `symlink_metadata()` (lstat) and rejected any symlinked destination with `InvalidInput`. Upstream `main.c:745-754` calls `do_stat()` (follows symlinks), accepts the dest when `S_ISDIR(st.st_mode)` is true, then enters the resolved directory via `change_dir()`. The upstream `symlink-dirlink-basis` interop test (issue #715) drives this path with `$HOME/dir -> $HOME/real-dir` and `-K`. Switch the helper to `metadata()` so a symlink-to-existing-directory dest is accepted, and surface a dangling-symlink dest as `NotFound` via an `lstat` follow-up (instead of letting `create_dir_all` materialize the directory at the link target). Canonicalize the symlinked dest in `setup_transfer` so the downstream `DirSandbox` opens the resolved target dirfd once; per-entry `*at` syscalls then anchor at the canonical path. Skip the canonicalize step for daemon connections so the strict `open_sandbox_for_dest_strict` path keeps refusing symlinked dests (chdir-symlink-race defense). Security model: per-entry writes are sandboxed by the SEC-1 `*at` chain (`openat2(RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS)` on Linux 5.6+, `openat(O_NOFOLLOW | O_DIRECTORY)` elsewhere). Accepting a symlinked dest at the pre-flight does not weaken that containment because the canonical resolved path becomes the sandbox root. Tests: - Update `uts_2_dest_root_mkdir.rs` to assert the new accept-on- symlink-to-dir behavior and the dangling-symlink `NotFound` surface; remove the four pre-PR refusal tests they superseded. - Add a chained-dangling-symlink regression and an explicit rejected-non-directory test. * style: apply cargo fmt to receiver dest_root + test wrappings
1 of 4 tasks
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
4 tasks
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))
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
) * fix(receiver): follow symlink at dest_root to match upstream The receiver-side `ensure_dest_root_exists()` pre-flight used `symlink_metadata()` (lstat) and rejected any symlinked destination with `InvalidInput`. Upstream `main.c:745-754` calls `do_stat()` (follows symlinks), accepts the dest when `S_ISDIR(st.st_mode)` is true, then enters the resolved directory via `change_dir()`. The upstream `symlink-dirlink-basis` interop test (issue #715) drives this path with `$HOME/dir -> $HOME/real-dir` and `-K`. Switch the helper to `metadata()` so a symlink-to-existing-directory dest is accepted, and surface a dangling-symlink dest as `NotFound` via an `lstat` follow-up (instead of letting `create_dir_all` materialize the directory at the link target). Canonicalize the symlinked dest in `setup_transfer` so the downstream `DirSandbox` opens the resolved target dirfd once; per-entry `*at` syscalls then anchor at the canonical path. Skip the canonicalize step for daemon connections so the strict `open_sandbox_for_dest_strict` path keeps refusing symlinked dests (chdir-symlink-race defense). Security model: per-entry writes are sandboxed by the SEC-1 `*at` chain (`openat2(RESOLVE_BENEATH | RESOLVE_NO_SYMLINKS)` on Linux 5.6+, `openat(O_NOFOLLOW | O_DIRECTORY)` elsewhere). Accepting a symlinked dest at the pre-flight does not weaken that containment because the canonical resolved path becomes the sandbox root. Tests: - Update `uts_2_dest_root_mkdir.rs` to assert the new accept-on- symlink-to-dir behavior and the dangling-symlink `NotFound` surface; remove the four pre-PR refusal tests they superseded. - Add a chained-dangling-symlink regression and an explicit rejected-non-directory test. * style: apply cargo fmt to receiver dest_root + test wrappings
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
MessageSegments::try_extend_vecso callers can handle allocation failures without mapping them intoio::Errorextend_vecand expand the test suite to cover both success and empty casesTesting