Skip to content

feat: gate --inplace --partial-dir rejection on CF_INPLACE_PARTIAL_DIR negotiation#4064

Merged
oferchen merged 1 commit into
masterfrom
feat/inplace-partial-dir-cf-negotiation-2142
May 14, 2026
Merged

feat: gate --inplace --partial-dir rejection on CF_INPLACE_PARTIAL_DIR negotiation#4064
oferchen merged 1 commit into
masterfrom
feat/inplace-partial-dir-cf-negotiation-2142

Conversation

@oferchen
Copy link
Copy Markdown
Owner

Summary

  • Add ClientConfigBuilder::validate_with_capabilities(caps) alongside the strict validate() default. When caps contains CompatibilityFlags::INPLACE_PARTIAL_DIR, --inplace/--append and --partial-dir are accepted; otherwise the upstream parse-time rejection at options.c:2406-2414 is preserved.
  • Pin the on-wire byte sequence for CF_INPLACE_PARTIAL_DIR (0x40) and the combined CF_INC_RECURSE | CF_INPLACE_PARTIAL_DIR (0x41) so the negotiation payload remains byte-identical to upstream's write_varint(f_out, compat_flags).
  • Mark G2 RESOLVED in docs/audits/compatibility-flags-mutual-exclusion-matrix.md and update the next-fix section accordingly.

Upstream reference: compat.c:117 defines CF_INPLACE_PARTIAL_DIR (1<<6); compat.c:777-778 enables inplace_partial = 1 when 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)'
  • Full CI: fmt+clippy, nextest stable, Windows, macOS, Linux musl

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.
@github-actions github-actions Bot added the enhancement New feature or request label May 14, 2026
@oferchen oferchen merged commit d4248bc into master May 14, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant