Repository navigation
fix(daemon): merge phase-1 cmdline + phase-2 stdin args under secluded-args - #5736
Merged
Merged
Conversation
…d-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
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
…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.
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
--server,--sender, the compact flag string (-slogDtprIzxe.iLsfxCIvu) and--iconv=...; phase 2 (stdin viasend_protected_args) carries every long-form option (--list-only,--log-format,--usermap,--groupmap, ...), the.separator and the positional paths.--sender, and--iconvnever reachedServerConfig. Compression / recursion / role negotiation diverged before the transfer started, explaining the early connection drop on thedaemon-groupmap-wildsecluded-args case (upstream issue Add daemon hosts allow/deny enforcement for module access #829): the wildcard groupmap was actually parsed correctly by fix(daemon): parse --usermap/--groupmap from daemon client args #5717, but the missing-zfrom phase 1 broke the protocol handshake."rsync"arg0 upstream rewrites into the NULL slot) and feeds the merged list through the same single-pass option parser.Why this fixes
daemon-groupmap-wild[secluded-args]Upstream sender connects with
-s(secluded-args). Wire trace at the cutoff:@RSYNCD: 32.0 sha512 sha256 sha1 md5 md4\n(greeting).@RSYNCD: 32.0\n, module name, then phase 1 args (--server\0--sender\0-slogDtprIze.LsfxCIvu\0\0).@RSYNCD: OK\n.rsync\0--log-format=%i\0--groupmap=*:1000\0.\0upload/\0\0).-zfrom phase 1 is gone;ServerConfig.flags.compress = false.setup_protocol(). Sender uses zlib; receiver expects raw. After@RSYNCD: OK\nis read the sender'sstats.total_readis around 23 bytes (legacy greeting + OK frame), then the receiver mis-decodes the post-OK compat-flags varint and EOFs the socket. Sender surfacesconnection unexpectedly closed (23 bytes received so far) [sender]anderror in rsync protocol data stream (code 12).Merging the two phases restores the compact flag string into
ServerConfigso-z,-l,-r, ...,--senderall reachparse_arguments-equivalent state. The wildcard--groupmap=*:GIDalready round-trips through #5717's typed mapping parser.What this preserves
unbackslash_argon the non-protect_args path - theelsebranch is untouched.client_args.rs, not the refused-option handler.validate_client_paths_in_modulepath traversal checks - the merged argv still flows through the same path-component splitter; the fix only widens the options that reach the parser, never widens what counts as a positional path.Upstream references
clientserver.c:1059-1086- two-phaseread_args()+parse_arguments()options.c:2614-2745-server_options()placement of--server,--sender,argstrand the secluded-args NULL split pointoptions.c:2551-safe_arg()if (!protect_args ...)guard that emits*verbatim under secluded-argsrsync.c:283-320-send_protected_args()NULL/arg0 rewriteTest plan
merge_secluded_args_prepends_phase1_and_skips_rsync_arg0- locks the canonical phase 1 + phase 2 layout.merge_secluded_args_passes_phase2_through_when_no_synthetic_arg0- guards the no-rsync-arg0 fallback.merge_secluded_args_preserves_groupmap_wildcard_through_apply_long_form- end-to-end: parse--groupmap=*:1234through the merged argv, assertServerConfig.group_mapping.spec() == "*:1234".daemon-groupmap-wildupstream-testsuite must transition from[secluded-args] groupmap upload failed (rc=12)to PASS.unescape_phase1_option_args_*andread_client_arguments_with_secluded_flagtests must keep passing (no regression on the non-secluded path).