Skip to content

fix(daemon): unbackslash --groupmap=*:GID wildcard in non-protect_args path - #5752

Merged
oferchen merged 1 commit into
masterfrom
fix/uts-8-reopen-groupmap-wild-backslash
Jun 14, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/uts-8-reopen-groupmap-wild-backslash

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Phase 1 of the secluded-args daemon-push wire was --server [--sender] -s ., which diverges from upstream's clientserver.c:395-402 wire layout. Upstream phase 1 never contains a standalone . (do_cmd only appends . to sargs AFTER server_options() returns past the NULL marker at options.c:2745) and never contains a bare -s (the s is embedded inside the compact flag string argstr per options.c:2622-2623).
  • The stray phase-1 . made the daemon's apply_long_form_args first-. dot_position lookup bound the option region BEFORE the merge boundary, so every long-form option emitted in phase 2 - including --groupmap=*:GID - was silently dropped before reaching GroupMapping::parse. The bare -s also shadowed phase 2's real compact flag string in build_server_config's first-short-form-arg picker, breaking compression/recursion negotiation. UTS-8.REOPEN / upstream issue Add daemon hosts allow/deny enforcement for module access #829 / daemon-groupmap-wild: [secluded-args] groupmap upload failed (rc=12) + connection unexpectedly closed (23 bytes received) [sender].
  • Switch phase 1 to --server [--sender] --secluded-args. The long-form alias is in the daemon's has_secluded_args_flag detection set, so phase 2 reading still trips, and upstream daemons accept the alias per options.c:804 so this remains wire-compatible with upstream rsync.

Test plan

  • Pin client-side phase 1 wire layout: build_minimal_daemon_args emits neither a standalone . nor a bare -s for push or pull, and is exactly [--server, [--sender], --secluded-args].
  • Pin daemon-side round trip: with the new phase 1 + a representative phase 2 (real compact flag string + --groupmap=*:4242), merge_secluded_args -> apply_long_form_args reaches GroupMapping::parse with *:4242 intact, and the real compact flag string (-logDtprIze.LsfxCIvu) is the first short-form arg in the merged list.
  • cargo fmt --all clean before push (no formatting drift).
  • CI: fmt + clippy, nextest (stable), Windows, macOS, Linux musl.
  • Upstream testsuite: daemon-groupmap-wild ([secluded-args] groupmap upload) passes.

upstream: clientserver.c:303 - sargs[sargc++] = "." after server_options()
upstream: clientserver.c:395-402 - phase 1 wire writes args until !sargs[i]
upstream: options.c:2622-2623 - argstr[x++] = 's' when protect_args
upstream: options.c:2744-2745 - NULL marker between phase 1 / phase 2 args
upstream: options.c:804 - --secluded-args long-form alias for -s

@github-actions github-actions Bot added the bug Something isn't working label Jun 14, 2026
…s path

Under secluded-args daemon push, the client's phase 1 wire was
`--server [--sender] -s .` - both the trailing `.` and the bare `-s`
diverge from upstream's `clientserver.c:395-402` wire layout. Upstream's
phase 1 never contains a standalone `.` (that token only enters `sargs`
in `do_cmd` at `clientserver.c:303` AFTER `server_options()` inserts the
phase 1 / phase 2 split NULL at `options.c:2745`), and never contains a
bare `-s` (the `s` for `--secluded-args` is embedded in the compact flag
string `argstr` at `options.c:2622-2623`).

The stray phase 1 `.` short-circuited the daemon's `apply_long_form_args`
dot_position lookup (it picks the FIRST standalone `.` as the boundary
between option region and positional file args). Every option after the
phase 1 / phase 2 merge boundary - including `--groupmap=*:GID` - was
silently dropped before reaching `GroupMapping::parse`, so the wildcard
match rule was never installed on the receiver. Upstream regression
#829 / `daemon-groupmap-wild` (`[secluded-args] groupmap upload failed
(rc=12) + connection unexpectedly closed (23 bytes received) [sender]`).

The bare `-s` also shadowed phase 2's real compact flag string in
`build_server_config`'s first-short-form-arg picker, so compression /
recursion / capability negotiation broke before the transfer started.

Emit phase 1 as `--server [--sender] --secluded-args` instead. The
long-form alias is in the daemon's `has_secluded_args_flag` detection
set (`-s` | `--protect-args` | `--secluded-args`), so phase 2 reading
still trips. Upstream daemons accept `--secluded-args` per
`options.c:804` (`{"secluded-args", 's', POPT_ARG_VAL, ...}`), so this
remains wire-compatible with upstream rsync.

Adds character-level coverage on both ends of the wire:
- `crates/core/.../orchestration/tests.rs` pins that
  `build_minimal_daemon_args` emits neither a standalone `.` nor a bare
  `-s` for both push and pull, and that phase 1 is exactly
  `[--server, [--sender], --secluded-args]`.
- `crates/daemon/.../module_access/tests.rs` pins that the merged arg
  list from the new phase 1 + a representative phase 2 round-trips
  `--groupmap=*:4242` through `apply_long_form_args` to
  `GroupMapping::parse`, and that the real compact flag string
  (`-logDtprIze.LsfxCIvu`) is the first short-form arg in the merged
  list - locking against a future regression that would reintroduce the
  bare-`-s` shadow.

upstream: clientserver.c:303 - `sargs[sargc++] = "."` after server_options()
upstream: clientserver.c:395-402 - phase 1 wire writes args until !sargs[i]
upstream: options.c:2622-2623 - `argstr[x++] = 's'` when `protect_args`
upstream: options.c:2744-2745 - NULL marker between phase 1 / phase 2 args
upstream: options.c:804 - `--secluded-args` long-form alias for `-s`
@oferchen
oferchen force-pushed the fix/uts-8-reopen-groupmap-wild-backslash branch from cb3c307 to 0bf2c51 Compare June 14, 2026 03:55
@oferchen
oferchen merged commit c612853 into master Jun 14, 2026
7 of 8 checks passed
@oferchen
oferchen deleted the fix/uts-8-reopen-groupmap-wild-backslash branch June 14, 2026 04:32
oferchen added a commit that referenced this pull request Aug 24, 2026
…s path (#5752)

Under secluded-args daemon push, the client's phase 1 wire was
`--server [--sender] -s .` - both the trailing `.` and the bare `-s`
diverge from upstream's `clientserver.c:395-402` wire layout. Upstream's
phase 1 never contains a standalone `.` (that token only enters `sargs`
in `do_cmd` at `clientserver.c:303` AFTER `server_options()` inserts the
phase 1 / phase 2 split NULL at `options.c:2745`), and never contains a
bare `-s` (the `s` for `--secluded-args` is embedded in the compact flag
string `argstr` at `options.c:2622-2623`).

The stray phase 1 `.` short-circuited the daemon's `apply_long_form_args`
dot_position lookup (it picks the FIRST standalone `.` as the boundary
between option region and positional file args). Every option after the
phase 1 / phase 2 merge boundary - including `--groupmap=*:GID` - was
silently dropped before reaching `GroupMapping::parse`, so the wildcard
match rule was never installed on the receiver. Upstream regression
#829 / `daemon-groupmap-wild` (`[secluded-args] groupmap upload failed
(rc=12) + connection unexpectedly closed (23 bytes received) [sender]`).

The bare `-s` also shadowed phase 2's real compact flag string in
`build_server_config`'s first-short-form-arg picker, so compression /
recursion / capability negotiation broke before the transfer started.

Emit phase 1 as `--server [--sender] --secluded-args` instead. The
long-form alias is in the daemon's `has_secluded_args_flag` detection
set (`-s` | `--protect-args` | `--secluded-args`), so phase 2 reading
still trips. Upstream daemons accept `--secluded-args` per
`options.c:804` (`{"secluded-args", 's', POPT_ARG_VAL, ...}`), so this
remains wire-compatible with upstream rsync.

Adds character-level coverage on both ends of the wire:
- `crates/core/.../orchestration/tests.rs` pins that
  `build_minimal_daemon_args` emits neither a standalone `.` nor a bare
  `-s` for both push and pull, and that phase 1 is exactly
  `[--server, [--sender], --secluded-args]`.
- `crates/daemon/.../module_access/tests.rs` pins that the merged arg
  list from the new phase 1 + a representative phase 2 round-trips
  `--groupmap=*:4242` through `apply_long_form_args` to
  `GroupMapping::parse`, and that the real compact flag string
  (`-logDtprIze.LsfxCIvu`) is the first short-form arg in the merged
  list - locking against a future regression that would reintroduce the
  bare-`-s` shadow.

upstream: clientserver.c:303 - `sargs[sargc++] = "."` after server_options()
upstream: clientserver.c:395-402 - phase 1 wire writes args until !sargs[i]
upstream: options.c:2622-2623 - `argstr[x++] = 's'` when `protect_args`
upstream: options.c:2744-2745 - NULL marker between phase 1 / phase 2 args
upstream: options.c:804 - `--secluded-args` long-form alias for `-s`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant