Repository navigation
fix(daemon): strip batch flags + explicit goodbye flush + arg rejection error - #5609
Merged
Merged
Conversation
…on error Three independent defenses for the upstream batch-mode interop pattern where the daemon receives client-only flags it cannot handle, currently leading to a silent connection close at protocol byte ~2241725: - UTS-15.b: strip --write-batch / --only-write-batch / --read-batch in build_full_daemon_args() so they can never reach the daemon argv, even if a future refactor wires remote_options or another forwarded list into the daemon path. Mirrors upstream options.c:server_options() which intentionally omits these client-local flags from server argv. - UTS-15.c: explicit writer.flush() at the end of GeneratorContext::run() after the goodbye handshake. Mirrors upstream main.c:912 client_run() and main.c:968 do_server_sender() io_flush(FULL_FLUSH) before return, so NDX_DONE never races the transport FIN. Errors propagate unless the peer already closed. - UTS-15.g: apply_long_form_args() now returns the first client-only batch flag it encounters; build_server_config() surfaces it via rsync_warning! + @error frame + non-zero exit, mirroring upstream options.c:1444-1449 "(in daemon mode)" rejection path. Rule 12 fail-loud: no more silent connection close on unknown args. Tests cover: argv-sanitiser unit tests on bare/kv/two-arg forms, goodbye-flush wire-bytes assertion via FlushTrackingWriter (NDX_DONE is the last byte before FIN and at least one flush happened), and daemon arg rejection unit tests on each batch family flag plus recognised/positional regression guards.
3 tasks
2 tasks done
This was referenced Jun 11, 2026
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…rg-defense fix(daemon): strip batch flags + explicit goodbye flush + arg rejection error
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
UTS-9.REOPEN reported a silent connection close at byte ~612425 when an oc-rsync client pulled a file from an oc-rsync daemon with -zz (new-style compression). The torn capture had no @error frame: the trailing NDX_DONE raced the transport FIN. The daemon-pull -zz codepath flows through GeneratorContext::run() (crates/transfer/src/generator/transfer/ orchestrator.rs), which terminates after handle_goodbye(). PR #5609 (UTS-15.c) added an explicit writer.flush() at that exit point to fix the upstream batch-mode interop suite; the same flush also closes the UTS-9 lineage because every daemon-sender role flows through the same return path. This change closes the verification gap. The regression test in crates/core/tests/uts_9_daemon_gzip_download_ goodbye.rs spawns an oc-rsync daemon serving a deterministic ~700 KB file (sized to clear the 612425-byte cutoff), pulls it with `oc-rsync -azz`, and asserts: - exit 0 - stderr does not contain "connection unexpectedly closed" - destination matches source byte-for-byte The audit doc at docs/audits/uts-9-daemon-gzip-download-goodbye.md captures the codepath analysis, the cross-check vs UTS-15.c batch-mode, and the upstream io_flush(FULL_FLUSH) references at main.c:983 / 1344. Refs UTS-9.REOPEN, companions PR #5609 (UTS-15.c).
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…ye-flush coverage (UTS-9.REOPEN.1-3) Audit bundle for UTS-9.REOPEN.1 (tcpdump capture command set), UTS-9.REOPEN.2 (daemon-sender post-recv_files phase=3 goodbye path trace), and UTS-9.REOPEN.3 (UTS-15.c goodbye-flush coverage analysis). Findings: - The 612425-byte cutoff is not a protocol constant. It is the byte at which the receiver sees a transport FIN with no orderly NDX_DONE having landed first, given the negotiated multiplex window and the test fixture size. - The daemon-sender goodbye path flows through GeneratorContext::run() -> send_stats -> handle_goodbye and exits through the post-goodbye writer.flush() at orchestrator.rs:142. - That post-goodbye flush is the same defense PR #5609 added for UTS-15.c batch-mode (~2241725-byte cutoff). The two regressions surfaced against different upstream tests but share an identical root cause: GeneratorContext::run() did not enforce upstream's io_flush(FULL_FLUSH) contract before returning. - The UTS-9 lineage is therefore covered by PR #5609 plus the regression test shipped in commit e2adb07 (crates/core/tests/uts_9_daemon_gzip_download_goodbye.rs) and the EDG-GOODBYE contract suite shipped in commit 9d7d061 (crates/protocol/tests/goodbye_contract.rs). Feed-forward: - UTS-9.REOPEN.4: covered by PR #5609 - no additional production-code change needed. - UTS-9.REOPEN.5: shipped regression test covers the -zz round-trip; natural extension is a -z (legacy zlib) cell on the same fixture. The tcpdump command set is documented for the rsync-profile podman container per the standing container-debug guidance. The capture is documented as commands rather than committed as a pcap because the cutoff byte varies by host TCP buffer sizes and the fix already shipped.
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
--write-batch/--only-write-batch/--read-batchfrom the daemon-bound argv built bybuild_full_daemon_args. Mirrors upstreamoptions.c:server_options()which never emits these client-only flags to the server; the strip is defense-in-depth so a future refactor that forwardsremote_optionsor any other user-supplied list into the daemon path cannot silently leak them.writer.flush()at the end ofGeneratorContext::run()after the goodbye handshake. Mirrors upstreammain.c:912 client_run()/main.c:968 do_server_sender()callingio_flush(FULL_FLUSH)immediately before return, so NDX_DONE plus any trailing multiplex frames are durable before the transport FIN.apply_long_form_args()now returns the first client-only batch flag it encounters;build_server_config()surfaces it viarsync_warning!plus an explicit@ERROR: <flag>: unrecognized option (in daemon mode)frame and a non-zero exit, mirroring upstreamoptions.c:1444-1449daemon-mode rejection. Rule 12 fail-loud: silent close on unknown args is no longer possible.docs/audits/uts-15-batch-mode-daemon-arg-defense.mdcapturing the three invariants and upstream references.Symptom these three together fix: the upstream
batch-modeinterop pattern where a client invocation likeoc-rsync --write-batch=PATH ...against an oc-rsync daemon previously drove a silent connection close at protocol byte ~2241725 with no actionable diagnostic.Test plan
cargo nextest run -p core --all-features -E 'test(build_full_args_strips_) + test(strips_bare_write_batch) + test(strips_kv_write_batch) + test(strips_kv_read_batch) + test(strips_only_write_batch) + test(leaves_non_batch_args_alone) + test(does_not_swallow_next_flag_when_two_arg_value_missing) + test(build_full_args_default_path_emits_no_batch_flags) + test(build_full_args_strips_read_batch_flag_and_orphan_value) + test(build_full_args_strips_only_write_batch_flag)'- assert all batch-flag forms (bare, key=value, two-arg) are stripped from the daemon argv and the default builder path emits no batch tokens.cargo nextest run -p transfer --all-features -E 'test(handle_goodbye_proto31_flushes_ndx_done_before_close)'- theFlushTrackingWriterconfirms NDX_DONE is the last byte before close, at least oneflush()occurred, and the final recorded operation is a flush (not a partial write).cargo nextest run -p daemon --all-features -E 'test(apply_long_form_args_reports_write_batch) + test(apply_long_form_args_reports_read_batch) + test(apply_long_form_args_reports_only_write_batch) + test(apply_long_form_args_recognised_args_do_not_report_unknown) + test(apply_long_form_args_positional_paths_are_not_classified)'- assert each batch flag is surfaced as the unknown-arg offender, recognised args (delete/temp-dir/link-dest/compact flag strings) do NOT trip the surface, and positional paths containing a literal--write-batch=...past the.separator are correctly classified as paths rather than options.