feat: gate --inplace --partial-dir rejection on CF_INPLACE_PARTIAL_DIR negotiation#4064
Merged
Merged
Conversation
Upstream rsync 3.4.1 negotiates the CF_INPLACE_PARTIAL_DIR capability bit (compat.c:117 `#define CF_INPLACE_PARTIAL_DIR (1<<6)`, enabled at compat.c:777-778 when both peers advertise the 'I' capability char). With that bit set, the receiver enables per-file inplace for basis files retrieved from the partial directory, so the otherwise conflicting --inplace/--append plus --partial-dir combination runs successfully. Add ClientConfigBuilder::validate_with_capabilities alongside the strict validate() default. The capability-aware variant accepts the pair when the negotiated bitfield contains CompatibilityFlags::INPLACE_PARTIAL_DIR; the strict default keeps the upstream parse-time rejection (options.c:2406-2414) for callers that have not yet seen the negotiated bits. Pin the wire encoding for CF_INPLACE_PARTIAL_DIR alone (0x40) and combined with CF_INC_RECURSE (0x41) so future varint refactors cannot silently drift from upstream's write_varint payload. Resolves G2 in docs/audits/compatibility-flags-mutual-exclusion-matrix.md. Refs #2142, #2143, #2144.
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
ClientConfigBuilder::validate_with_capabilities(caps)alongside the strictvalidate()default. WhencapscontainsCompatibilityFlags::INPLACE_PARTIAL_DIR,--inplace/--appendand--partial-dirare accepted; otherwise the upstream parse-time rejection atoptions.c:2406-2414is preserved.CF_INPLACE_PARTIAL_DIR(0x40) and the combinedCF_INC_RECURSE | CF_INPLACE_PARTIAL_DIR(0x41) so the negotiation payload remains byte-identical to upstream'swrite_varint(f_out, compat_flags).docs/audits/compatibility-flags-mutual-exclusion-matrix.mdand update the next-fix section accordingly.Upstream reference:
compat.c:117definesCF_INPLACE_PARTIAL_DIR (1<<6);compat.c:777-778enablesinplace_partial = 1when the bit is negotiated.Refs #2142, #2143, #2144.
Test plan
cargo nextest run -p core --all-features -E 'test(validate_with_capabilities)'cargo nextest run -p protocol --all-features -E 'test(inplace_partial_dir)'