Skip to content

fix: apply a local -M to the receiver half only - #8365

Merged
oferchen merged 2 commits into
masterfrom
fix/local-m-receiver-only
Nov 11, 2026
Merged

oferchen merged 2 commits into
masterfrom
fix/local-m-receiver-only

Conversation

@oferchen

Copy link
Copy Markdown
Owner

fix: apply a local -M to the receiver half only

Fixes the required upstream-testsuite regression fake-super-acl-xattr that #8332 brought to master. Tasks 520, 540 and 641.

Problem

On master, a local copy folds its -M values into the client argv, so both halves read one option set. Under -rA -M--fake-super that makes the sender fake-super too. It then reads only the source's (empty) %aacl stash, and dst gets no %aacl/%dacl. The upstream test fails with "--fake-super -A should have stored user.rsync.%aacl on dst/f".

3.5.1 forks the receiver, and only the receiver re-parses the -M values (pipe.c:143-148). The sender reads the real ACL (acls.c:609-631), and the receiver stashes it with set_xattr_acl (acls.c:933-971).

#8332's 540 measurement still holds where both halves run fake-super: -rA --fake-super with no -M. 3.5.1 stores no %aacl/%dacl there, re-measured with a named-user ACL and a default dir ACL. That behaviour is unchanged.

Commits

  1. refactor: split the client run into a repeatable translation pass. Behaviour-neutral: execute() runs translate() with a Pass, and the process setup runs only on the process pass. The order of every early return and side effect is kept. A test checks that a --help early return reads no files and opens no log file.
  2. fix: apply a local -M to the receiver half only. Two option sets, described below.

Mechanism

3.5.1 forks the receiver for a local copy. In pipe.c:109-148 local_child(), the child inherits the client's options and re-runs parse_arguments() over the -M values on top of them. The parent sender keeps the client's own options. So every -M option changes the receiver half only.

oc used to fold -M into the client argv, which gave one option set for both halves. That set was wrong for the sender whenever -M named something the sender reads. Now it keeps two option sets, as upstream does:

  • cli: parse_args keeps the client's own parse as ParsedArgs.local_sender, but only when a fold happened. The folded parse is the receiver's. Each set's filter order is built from the argv it was parsed from.
  • execute() runs the real process setup on the client's own parse, as 3.5.1's main() does, and that parse is also the sender's set. The -M fold, the receiver's set, is translated on an inert pass (commit 1: translate()/Pass). The inert pass sets no globals, opens no log file and reads no password; pipe.c:131-141 clears the child's log file. It replays the --files-from list the process pass read rather than reading it again; pipe.c:133 sets the child's filesfrom_fd = -1. The run takes its output settings from the client parse and its config from the receiver set, with the sender's attached by ClientConfig::with_local_sender().
  • core builds the sender's LocalCopyOptions from it, with its own filter program, and attaches it with LocalCopyOptions::with_local_sender().
  • engine: LocalCopyOptions::sender_half() (CopyContext::sender_options()) returns the sender's set when there is one, and self otherwise. Without -M both halves read one set, and behaviour is unchanged.

Side table: which half reads what

read half upstream oc
-r / -d (walk, xfer_dirs) sender flist.c:2436, :2751, :2992 (no generator.c read) recursive_enabled/dirs_enabled facades
-L / -k / --copy-unsafe-links sender flist.c:417, :485, :492, :514; sender.c copy_*_enabled facades, follow_source_symlinks
--files-from sender flist.c:2787-2809; pipe.c:133 clears it in the child files_from_enabled
filter hide (transfer) sender flist.c:1662, :1731 is_excluded CopyContext.filter_program + dir_merge
filter protect / delete receiver generator.c:285 delete_in_dir, :1750 receiver_filter_program + delete_dir_merge
xattr names the receiver may set receiver xattrs.c rsync_xal_set CopyContext::filter_program() (xattr sync)
source stat under --fake-super sender flist.c:497-516 x_stat/x_lstat; xattrs.c:1372 virtualize sites (11), ensure_fake_super_source_stat, fake_super_source_stat, store_effective_fake_super_if_requested, hard-link holder reorder
source ACL/xattr read under --fake-super sender flist.c:2052-2062 get_acl/get_xattr; acls.c:599-607 source_attrs.rs, batch ACL read, FakeSuperSides.sender
%stat / %aacl store receiver xattrs.c:1304-1356 set_stat_xattr; acls.c:933-971 unchanged (fake_super_enabled)
-R (names) sender flist.c:1077, :1753 sources/orchestration.rs, sources/metadata.rs
-R (dest parents) receiver generator.c, receiver.c context_impl/options/dirs.rs, unchanged
--no-implied-dirs receiver generator.c (dir attrs) unchanged
-x (walk) sender flist.c:1375, :1715, :2574, :2989 planner.rs, sources/orchestration.rs, recursive/mod.rs
-x (delete boundary) receiver generator.c:316, :1915 cleanup.rs, obstacle.rs, unchanged
everything else receiver the forked child unchanged

Cells (MEASURED, same commands against the 3.5.1 tarball build)

command 3.5.1 oc before oc now
-d -M-r d/ only recursed d/ only
-r -M--no-r full tree "skipping directory ." full tree
-r -M-R non-relative names tmp/... relative tree non-relative names
-r --delete -M--exclude=*.tmp x.tmp sent, dest y.tmp kept, z deleted x.tmp hidden as 3.5.1
-r -M--fake-super, source 0644 with %stat 100600 0644, %stat 100644 0,0 0:0 0600, 100600 as 3.5.1
-rA -M--fake-super, named-user ACL %aacl stashed none stashed

Cells that stay identical, checked so the split cannot move them: -M--chmod=o+r (the receiver applies it; 604 on both), -M-p, -M-x, -M--copy-dirlinks, -M--remove-source-files.

Tests:

  • tests/local_remote_option_sides.rs: 5 oc-only cells that assert the measured 3.5.1 results, so they run in CI without the oracle.
  • tests/local_copy_skip_and_fake_super_parity.rs:
    • receiver_only_fake_super_ignores_the_source_stat_record: the %stat cell (task 641), oc-only.
    • receiver_only_fake_super_stashes_the_real_source_acl: the ACL cell, oracle comparison.
  • options/sides.rs unit tests.
  • cli help_returns_before_the_process_pass_reads_its_files: a help early return still reads no files and opens no log file.

Not covered

  • 3.5.1 itself breaks on -M-l (rc 22, recv_file_entry overflow), -M--no-l (hang) and -M-c (rc 2, "File-list index ... not in"). These options change the flist shape, so the two halves stop agreeing on the wire format. There is nothing to mirror, so there are no cells.
  • -rl -M--copy-links: 3.5.1 keeps the link. oc refuses the folded receiver argv with a clap conflict between -l and -L, which 3.5.1 accepts. Filed as task 642 and not folded in, per review.
  • A -M rule that adds a per-dir merge file loads on the receiver chain only. That is correct, but no cell covers it.
  • On the process pass, the cli still sets its globals (SIMD override, logging) before the help check, the same order as before this PR.
  • A -M option that 3.5.1 applies per process but oc applies once per run takes the client's value in oc. Output levels are the main case. In 3.5.1, -M-v makes the forked receiver print created directory t (main.c get_local_name), and -M-vv adds the generator's delta-transmission disabled for local transfer or --whole-file. The client's own output is unchanged. oc prints neither, because its verbosity, itemize, info/debug and out-format are process-global and come from the client parse. These are listed, not approximated.
  • -M--log-file=F: pipe.c:136-140 clears the inherited log file in the receiver, and the -M value parsed after it opens the receiver's own. oc opens F from the receiver set when the client parse names no log file. That keeps remote_option_applies_to_a_local_transfer. When both name a log file, oc writes only the client's, while 3.5.1 writes receiver lines to F as well.
  • -M--copy-links stays a symlink in 3.5.1. oc's receiver-side parse still refuses -l together with -L (task 642), so that cell waits for it.

Upstream testsuite (fake-super-acl-xattr, host, 3.5.1 tarball suite)

  • non-root: PASS fake-super-acl-xattr
  • root: PASS fake-super-acl-xattr

The three legs of fake-super-acl-xattr_test.py:89-111 were also replayed directly, against both 3.5.1 and oc. All three give identical results:

  • -rA -M--fake-super: %aacl on f, %dacl on d.
  • -rA --fake-super -M--fake-super: both kept.
  • re-sync after setfacl -k: %dacl removed.

The other host-only failures in the same runs are not caused by this PR:

  • non-root rrsync-userns-procfs: "cannot locate the rsync executable" for the debug binary path.
  • root operator-path-dir-daemon-leaf and operator-path-partial-dir-exclude-daemon: both compare against a host-only 3.2.7 oracle, and both are daemon --partial-dir cells.

@github-actions github-actions Bot added the bug Something isn't working label Nov 11, 2026
@oferchen
oferchen force-pushed the fix/local-m-receiver-only branch 4 times, most recently from 99b3da4 to 2671d6a Compare November 11, 2026 10:31
execute() now translates the parse through translate(), which runs the
process setup only on the process pass, and hands the result to
run_translated(). Behaviour is unchanged; a later pass can translate a
second option set without touching process globals, as 3.5.1 pipe.c
local_child() re-parses -M for the receiver alone.
A local copy folded its -M values into the client argv, so one option
set served both halves. 3.5.1 forks the receiver, which re-parses the
-M values on top of the inherited options (pipe.c:109-148
local_child()); the sender keeps the client options. oc now keeps both
sets: the client parse runs the process setup and is the sender set,
the -M fold is translated without side effects as the receiver set,
and the engine reads the sender set through sender_half() wherever
the 3.5.1 sender does (walk, links, files-from, filter hiding, and
source stat, ACL and xattr reads under --fake-super).
@oferchen
oferchen force-pushed the fix/local-m-receiver-only branch from 2671d6a to b2c814e Compare November 11, 2026 10:49
@oferchen
oferchen merged commit d99e2bf into master Nov 11, 2026
31 checks passed
@oferchen
oferchen deleted the fix/local-m-receiver-only branch November 11, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant