Repository navigation
fix(daemon): symmetric safe_arg/unbackslash_arg for wildcards (UTS-8.REOPEN) - #5727
Merged
Merged
Conversation
2 tasks
oferchen
added a commit
that referenced
this pull request
Jun 12, 2026
* chore: fix master fmt drift + filter_map_bool_then clippy lint
Master CI broke on rustfmt 1.88 and clippy 1.88:
1. `crates/cli/src/frontend/server/run.rs:244` - `use fast_io::landlock::{...}`
collapses to a single line under rustfmt 1.88 (introduced by PR #5724's
landlock wire-in).
2. `crates/transfer/src/generator/filters.rs:589` - `let split = ...` long-form
collapses to single-line under rustfmt 1.88.
3. `crates/transfer/src/generator/file_list/mod.rs:267` - rewrite
`filter_map(|(b, rel)| (b == &entry.base).then(|| rel.clone()))` as the
equivalent `filter(...).map(...)` pair so clippy 1.88's new
`filter_map_bool_then` lint stays clean. Behaviour-identical.
Unblocks PRs #5725, #5726, #5727 once they rebase onto this.
* fix: drop extraneous deref in filter predicate
In .filter(), the destructured 'b' is already &PathBuf since iter() yields
&(PathBuf, PathBuf) and filter receives &Self::Item. The extra deref made it
PathBuf, causing E0277 'can't compare PathBuf with &PathBuf'.
* chore(cli): inline format args in --partial-dir test (clippy 1.88)
uninlined_format_args lint denies the build under clippy 1.88.
…REOPEN) Lock the round-trip parity between the client-side option-arg escape emitted by `safe_arg_for_daemon` and the daemon-side `unbackslash_arg` un-escape. Mirrors upstream `options.c:2539-2594` (rsync 3.4.4 `safe_arg`) and `io.c:1295-1306` (`unbackslash_arg`). The asymmetric case is `--groupmap=*:GID` (upstream issue #829): a 3.4.3+ non-protect_args client wraps the value with `safe_arg("--groupmap", value)`, which backslash-escapes `*` because it is a member of `WILD_CHARS`. The daemon must reverse the escape before option parsing or `--groupmap=\*:GID` reaches `parse_name_map()` and the wildcard silently mismatches. The existing implementation is already symmetric, but had no character-level coverage of the escape set. Adds: - `crates/core/.../arguments.rs`: pin the byte-for-byte form `safe_arg_for_daemon("--groupmap=*:42") == "--groupmap=\*:42"`, plus a round-trip test that covers every `WILD_CHARS + SHELL_CHARS` escape character (`*?[]!#$&;|<>(){}\"'` \t\\`). - `crates/daemon/.../tests.rs`: ground-truth port of upstream `safe_arg` (option-arg branch) used to assert that `unbackslash_arg(upstream_safe_arg("--groupmap", value)) == value` for the wildcard, every escape character, and the `--usermap`/`--groupmap` wildcard family. The ground-truth `safe_arg` helper in the daemon test module is independent of the oc-rsync `safe_arg_for_daemon` implementation so the contract is locked against upstream wire output rather than against our own escape code. No behaviour change; defense-in-depth coverage that pins the daemon arg backslash contract against URV-2.a regression. Production non-protect_args round-trip remains exercised by the secluded-args-default code path that already covers the wire layer. upstream: options.c:2539-2594 safe_arg() (client-side escape) upstream: io.c:1295-1306 unbackslash_arg() (daemon-side un-escape) upstream: options.c:2912-2916 safe_arg("--usermap"|"--groupmap", value)
oferchen
force-pushed
the
fix/uts8-groupmap-wild-safe-arg
branch
from
June 12, 2026 01:40
212d13d to
00f4d00
Compare
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
* chore: fix master fmt drift + filter_map_bool_then clippy lint
Master CI broke on rustfmt 1.88 and clippy 1.88:
1. `crates/cli/src/frontend/server/run.rs:244` - `use fast_io::landlock::{...}`
collapses to a single line under rustfmt 1.88 (introduced by PR #5724's
landlock wire-in).
2. `crates/transfer/src/generator/filters.rs:589` - `let split = ...` long-form
collapses to single-line under rustfmt 1.88.
3. `crates/transfer/src/generator/file_list/mod.rs:267` - rewrite
`filter_map(|(b, rel)| (b == &entry.base).then(|| rel.clone()))` as the
equivalent `filter(...).map(...)` pair so clippy 1.88's new
`filter_map_bool_then` lint stays clean. Behaviour-identical.
Unblocks PRs #5725, #5726, #5727 once they rebase onto this.
* fix: drop extraneous deref in filter predicate
In .filter(), the destructured 'b' is already &PathBuf since iter() yields
&(PathBuf, PathBuf) and filter receives &Self::Item. The extra deref made it
PathBuf, causing E0277 'can't compare PathBuf with &PathBuf'.
* chore(cli): inline format args in --partial-dir test (clippy 1.88)
uninlined_format_args lint denies the build under clippy 1.88.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…REOPEN) (#5727) Lock the round-trip parity between the client-side option-arg escape emitted by `safe_arg_for_daemon` and the daemon-side `unbackslash_arg` un-escape. Mirrors upstream `options.c:2539-2594` (rsync 3.4.4 `safe_arg`) and `io.c:1295-1306` (`unbackslash_arg`). The asymmetric case is `--groupmap=*:GID` (upstream issue #829): a 3.4.3+ non-protect_args client wraps the value with `safe_arg("--groupmap", value)`, which backslash-escapes `*` because it is a member of `WILD_CHARS`. The daemon must reverse the escape before option parsing or `--groupmap=\*:GID` reaches `parse_name_map()` and the wildcard silently mismatches. The existing implementation is already symmetric, but had no character-level coverage of the escape set. Adds: - `crates/core/.../arguments.rs`: pin the byte-for-byte form `safe_arg_for_daemon("--groupmap=*:42") == "--groupmap=\*:42"`, plus a round-trip test that covers every `WILD_CHARS + SHELL_CHARS` escape character (`*?[]!#$&;|<>(){}\"'` \t\\`). - `crates/daemon/.../tests.rs`: ground-truth port of upstream `safe_arg` (option-arg branch) used to assert that `unbackslash_arg(upstream_safe_arg("--groupmap", value)) == value` for the wildcard, every escape character, and the `--usermap`/`--groupmap` wildcard family. The ground-truth `safe_arg` helper in the daemon test module is independent of the oc-rsync `safe_arg_for_daemon` implementation so the contract is locked against upstream wire output rather than against our own escape code. No behaviour change; defense-in-depth coverage that pins the daemon arg backslash contract against URV-2.a regression. Production non-protect_args round-trip remains exercised by the secluded-args-default code path that already covers the wire layer. upstream: options.c:2539-2594 safe_arg() (client-side escape) upstream: io.c:1295-1306 unbackslash_arg() (daemon-side un-escape) upstream: options.c:2912-2916 safe_arg("--usermap"|"--groupmap", value)
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
Locks the round-trip parity between client-side
safe_arg_for_daemonand daemon-side
unbackslash_argfor the option-arg escape set.Mirrors upstream
options.c:2539-2594(safe_arg, rsync 3.4.4) andio.c:1295-1306(unbackslash_arg).The asymmetric case is upstream issue #829: under non-protect_args
daemon mode a 3.4.3+ client wraps
--groupmap=*:GIDwithsafe_arg("--groupmap", "*:GID")which backslash-escapes*. Thedaemon must reverse the escape before option parsing or
--groupmap=\*:GIDreachesparse_name_map()and the wildcardsilently mismatches.
The existing implementations of
safe_arg_for_daemon(client) andunbackslash_arg(daemon) are symmetric by construction:unbackslash_argcollapses\X -> Xfor anyX(mirroringupstream's
if (*f == '\\' && f[1]) f++;loop). This PR adds thecharacter-level tests that pin the contract so a future drift in
either escape set is caught at unit-test time instead of resurfacing
as
daemon-groupmap-wildinterop failure.Changes
crates/core/.../arguments.rs: byte-for-byte pinsafe_arg_for_daemon("--groupmap=*:42") == "--groupmap=\*:42"plus a full-set round-trip across
WILD_CHARS + SHELL_CHARS(*?[]!#$&;|<>(){}\"'\t\`).crates/daemon/.../tests.rs: ground-truth port of upstreamsafe_arg(option-arg branch) used to assertunbackslash_arg(safe_arg("--groupmap", value)) == valuefor thewildcard, every escape character, and the
--usermap/--groupmapwildcard family.
The ground-truth
safe_arghelper in the daemon test module isindependent of
safe_arg_for_daemonso the contract is lockedagainst upstream wire output rather than against our own escape
code.
Test plan
cargo nextest run -p oc-rsync-daemon -E 'test(unbackslash)'greencargo nextest run -p oc-rsync-core -E 'test(safe_arg)'greencargo nextest run -p oc-rsync-core -E 'test(every_safe_arg_escape_char_round_trips_through_unbackslash)'greendefault-args and secluded-args variants