Repository navigation
Add daemon hosts allow/deny enforcement for module access - #829
Merged
Merged
Conversation
4 tasks
This was referenced Jun 11, 2026
Closed
oferchen
added a commit
that referenced
this pull request
Jun 12, 2026
…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
added a commit
that referenced
this pull request
Jun 12, 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)
3 of 5 tasks
oferchen
added a commit
that referenced
this pull request
Jun 12, 2026
…d-args (#5736) * fix(daemon): merge phase-1 cmdline + phase-2 stdin args under secluded-args Under secluded-args mode upstream rsync splits the daemon argv at the NULL it injects at options.c:2745: phase 1 (cmdline) carries `--server`, `--sender`, the compact flag string (`-slogDtprIzxe.iLsfxCIvu`) and `--iconv=...`; phase 2 (stdin via `send_protected_args`) carries every long-form option (`--list-only`, `--log-format`, `--usermap`, `--groupmap`, ...), the `.` separator and the positional paths. Upstream re-runs `parse_arguments()` against each phase so the popt globals carry the union forward (clientserver.c:1073,1083). The daemon was discarding phase 1 entirely and parsing only phase 2, so the compact flag string, `--sender`, and `--iconv` never reached `ServerConfig`. Compression / recursion / role negotiation diverged before the transfer started, explaining the early connection drop on the `daemon-groupmap-wild` secluded-args case (upstream issue #829): the wildcard groupmap was parsed correctly but the missing `-z` from phase 1 broke the protocol handshake. The fix concatenates the two phases (dropping the synthetic `"rsync"` arg0 upstream rewrites into the NULL slot) and feeds the merged list through the same single-pass option parser. No unbackslash pass is needed on either phase: `safe_arg()` skips the WILD_CHARS escape when `protect_args` is set (options.c:2551), so phase 2 args - including `--groupmap=*:GID` - arrive verbatim. upstream: clientserver.c:1059-1086 two-phase read_args() + parse_arguments() upstream: options.c:2614-2745 server_options() placement of `--server`, `--sender`, argstr and the secluded-args NULL split point upstream: rsync.c:283-320 send_protected_args() NULL/arg0 rewrite * style(daemon): take phase2 by mut value in merge_secluded_args Replace the shadow `let mut phase2 = phase2` with `mut phase2: Vec<String>` in the parameter list to drop a redundant statement.
3 of 5 tasks
oferchen
added a commit
that referenced
this pull request
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
added a commit
that referenced
this pull request
Jun 14, 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`
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)
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…d-args (#5736) * fix(daemon): merge phase-1 cmdline + phase-2 stdin args under secluded-args Under secluded-args mode upstream rsync splits the daemon argv at the NULL it injects at options.c:2745: phase 1 (cmdline) carries `--server`, `--sender`, the compact flag string (`-slogDtprIzxe.iLsfxCIvu`) and `--iconv=...`; phase 2 (stdin via `send_protected_args`) carries every long-form option (`--list-only`, `--log-format`, `--usermap`, `--groupmap`, ...), the `.` separator and the positional paths. Upstream re-runs `parse_arguments()` against each phase so the popt globals carry the union forward (clientserver.c:1073,1083). The daemon was discarding phase 1 entirely and parsing only phase 2, so the compact flag string, `--sender`, and `--iconv` never reached `ServerConfig`. Compression / recursion / role negotiation diverged before the transfer started, explaining the early connection drop on the `daemon-groupmap-wild` secluded-args case (upstream issue #829): the wildcard groupmap was parsed correctly but the missing `-z` from phase 1 broke the protocol handshake. The fix concatenates the two phases (dropping the synthetic `"rsync"` arg0 upstream rewrites into the NULL slot) and feeds the merged list through the same single-pass option parser. No unbackslash pass is needed on either phase: `safe_arg()` skips the WILD_CHARS escape when `protect_args` is set (options.c:2551), so phase 2 args - including `--groupmap=*:GID` - arrive verbatim. upstream: clientserver.c:1059-1086 two-phase read_args() + parse_arguments() upstream: options.c:2614-2745 server_options() placement of `--server`, `--sender`, argstr and the secluded-args NULL split point upstream: rsync.c:283-320 send_protected_args() NULL/arg0 rewrite * style(daemon): take phase2 by mut value in merge_secluded_args Replace the shadow `let mut phase2 = phase2` with `mut phase2: Vec<String>` in the parameter list to drop a redundant statement.
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`
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
hosts allow/hosts denydirectives when responding to legacy clients#listoutput accordinglyTesting