Skip to content

fix: report a failed source unlink at FERROR_XFER - #7576

Merged
oferchen merged 1 commit into
masterfrom
fix/sender-remove-source-ferror-xfer
Sep 1, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/sender-remove-source-ferror-xfer

Conversation

@oferchen

@oferchen oferchen commented Sep 1, 2026

Copy link
Copy Markdown
Owner

What upstream actually does

Verified against rsync-3.5.0 (the version the citation gate pins, tools/ci/citation_drift_audit.py:40 VER = "3.5.0").

successful_send() sets no io_error bit at all. Every failing arm ends at
FERROR_XFER:

upstream arm
sender.c:421-425,455-459 secure-open-parent refusal
sender.c:429-430,455-459 re-stat failure
sender.c:442-451 changed-file guard (rprintf(FERROR_XFER, ...) at 447)
sender.c:453-459 the unlink itself (rsyserr(FERROR_XFER, ...) at 459)

It is the log code, not a bit, that carries the exit status:

  • log.c:337-338 - case FERROR_XFER: got_xfer_error = 1;
  • log.c:357-367 - if (am_server ...) send_msg(msg, ...) forwards the same
    text as MSG_ERROR_XFER; the client's io.c:1830 re-enters rwrite(), which
    sets got_xfer_error on the client too
  • cleanup.c:210-218 - if (exit_code == 0) { ... if (io_error & IOERR_GENERAL || got_xfer_error) exit_code = RERR_PARTIAL; } (23), and main.c:1683
    if (got_xfer_error) _exit(RERR_PARTIAL);

Precedence: only when exit_code == 0; within that, RERR_PARTIAL is assigned
last, so it wins over RERR_VANISHED (24) and RERR_DEL_LIMIT (25).

The bug

oc's network sender wrote the failure with eprintln! and handed back only
IOERR_GENERAL. Measured, --remove-source-files with an unlinkable source
(parent chmod 555, EACCES - not the seccomp EPERM path, the daemon log
confirms seccomp BPF unavailable in this build):

topology before
local copy 23
push over -e wrapper (client is sender) 23
pull over -e wrapper (server child's exit status reaches the client) 23
daemon pull 0, and the client sees no message at all

The diagnostic went to the daemon log and nowhere else. A destructive-intent
option reported success while having silently not removed anything.

What this PR changes

remove_confirmed_source no longer prints; it returns a SourceRemovalOutcome
carrying the bits and upstream's FERROR_XFER text. The caller routes that
text through emit_sender_diagnostic, the shared drain record_open_failure
and record_read_errors already use - the single place got_xfer_error is set
and the MSG_ERROR_XFER frame is framed. No sixth special case.

Because the text now travels to the peer it names the file-list entry, not the
reconstructed server path, matching f_name(file, fname) after
change_pathname() (sender.c:412-414). A daemon module has no absolute-path
prefix to leak; the message is now sender failed to remove sub/f.txt: Permission denied (13).

Scope: this is the routing half

On a daemon pull the client still exits 0 after this PR. The drain
(for wire_ndx in reader.take_success_indices()) runs after
handle_goodbye_with_finalizer, so the frame is written when the client has
already stopped reading. Measured by moving the drain ahead of the goodbye as a
throwaway probe: the client then prints the diagnostic and exits 23. The routing
is correct; the write window is not.

Moving the drain is not a free change - the drain sits after the goodbye
precisely because MSG_SUCCESS frames keep arriving through the handshake, so
an earlier drain would silently stop removing sources confirmed during it. That
trade-off (observability of failures vs. completeness of removals) is a separate,
still-open question and is deliberately not settled here.

Tests

  • remove_source_files_failure_yields_ferror_xfer_text (new) - a real EACCES
    unlink failure must hand back upstream's FERROR_XFER text, must name the
    file-list entry, and must not contain the sender's path prefix. The doc
    comment states why an io_error bit is not a substitute.
  • The four sender_remove_confinement_tests now also assert the diagnostic is
    handed back (or, for the benign ENOENT arm, that it is not).

Non-vacuity, proved by restoring the pre-fix routing (eprintln! +
error_xfer: None) while keeping the type:

FAIL transfer generator::tests::remove_source_files_failure_yields_ferror_xfer_text
  a failed unlink must hand back upstream's FERROR_XFER text; without it the
  caller has nothing to set got_xfer_error with, and a pulling client exits 0
  (sender.c:455-459, log.c:337-338)

FAIL transfer generator::transfer::transfer_loop::sender_remove_confinement_tests::
       a_parent_symlink_out_of_the_root_cannot_steer_the_removal
  the refusal must carry upstream's failed_op text so the caller can emit it at
  FERROR_XFER (sender.c:421-425,455-459)

Summary 10/11 tests run: 8 passed, 2 failed

Restored: 11 tests run: 11 passed.

Gates: cargo fmt --all -- --check clean; cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings clean; cargo nextest run -p transfer --all-features 2776 passed; the root-level
daemon_sender_removes_sources_for_both_spellings passes; the three topologies
that already exited 23 still do.

Upstream's `successful_send()` sets no `io_error` bit at all. Every failing
arm - the refused parent, the re-stat, the changed-file guard, the unlink -
ends at `rsyserr(FERROR_XFER, ...)` / `rprintf(FERROR_XFER, ...)`
(sender.c:442-451,455-459), and it is that LOG CODE, not a bit, that decides
the exit status: `rwrite()` sets `got_xfer_error = 1` on FERROR_XFER
(log.c:337-338) and, on a server, forwards the same text to the client as
MSG_ERROR_XFER (log.c:357-367), which sets `got_xfer_error` over there too.
`exit_cleanup()` then lifts a zero exit to RERR_PARTIAL (23) at both ends.

The network sender wrote the failure to its own stderr and handed back only
IOERR_GENERAL. A daemon sender therefore reported a failed `--remove-source-files`
unlink to the daemon log and nowhere else: the pulling client saw neither the
message nor an error, for a destructive-intent option that had silently not
done its job.

Route the four failure arms through the shared `emit_sender_diagnostic` drain
that `record_open_failure` and `record_read_errors` already use, which is the
single place `got_xfer_error` is set and the MSG_ERROR_XFER frame is framed.
`remove_confirmed_source` now returns the diagnostic alongside the bits instead
of printing it, so the caller - not the filesystem helper - decides where it
goes.

Because the text now travels to the peer, it names the file-list entry rather
than the reconstructed server path, matching upstream's `f_name(file, fname)`
after `change_pathname()` (sender.c:412-414); a daemon module no longer has an
absolute-path prefix to leak.

This is the routing half. On a daemon pull the client still exits 0, because
the drain runs after the goodbye exchange and the frame is written when the
client has stopped reading. Closing that gap means deciding when the sender
drains its confirmations relative to the goodbye - moving it earlier would drop
confirmations that arrive during the handshake - which is a separate,
still-open question.
@github-actions github-actions Bot added the bug Something isn't working label Sep 1, 2026
@oferchen
oferchen merged commit c19f0ba into master Sep 1, 2026
70 checks passed
@oferchen
oferchen deleted the fix/sender-remove-source-ferror-xfer branch September 1, 2026 08:44
oferchen added a commit that referenced this pull request Sep 2, 2026
`## [Unreleased]` last covered the #7304-#7522 era. Measured against the 60
most recently merged pull requests, 44 were absent; of the most recent 45,
43 were absent. Nothing from #7574 onward was recorded at all.

Each entry is derived from what the pull request actually landed - the merge
commit and the body - not from its title. Three cases where those differ:

  * #7616 ships far more than the doc-alias correction its body describes:
    the `upstream_version` pin moves to 3.5.0 and `--version` starts naming
    `quic`, `sd-notify`, `vmsplice` and `send_zc`.
  * #7618 also adds the pull-request rustdoc-link job its body says was
    filed separately, which is what closes the master-only-gate recurrence.
  * #7602's squash carries the closed #7597 as its first commit, so the
    directory-obstacle half is recorded under #7602.

#7587 is deliberately not recorded. Its merge commit is empty: the change
had already landed as #7563, which the section already names.

Entries extend the existing Keep a Changelog groups and the bold
sub-groupings. Clusters that are one story carry one entry with several
references: the FERROR_XFER routing and its two-phase drain (#7576, #7581),
the connection-FSM close edge and the accept loop that outlives a session
error (#7579, #7590), the three detaching daemon suites (#7578, #7588,
#7592), the io_uring and SEND_ZC work (#7593, #7600, #7610), the citation
retargets (#7601, #7603, #7604), and the accept-loop pin flake (#7615,
#7620).

Only `## [Unreleased]` is touched; every released section, including the
3.4.4 statements that were correct when written, is byte-identical.
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