Skip to content

fix(sender): skip a directory operand when xfer_dirs is off - #7627

Merged
oferchen merged 2 commits into
masterfrom
fix/xfer-dirs-directory-operand
Sep 2, 2026
Merged

oferchen merged 2 commits into
masterfrom
fix/xfer-dirs-directory-operand

Conversation

@oferchen

@oferchen oferchen commented Sep 2, 2026

Copy link
Copy Markdown
Owner

What upstream does

send_file_list()'s argument loop refuses a directory operand outright unless directories are being transferred:

/* rsync-3.5.0/flist.c:2723-2726 */
if (S_ISDIR(st.st_mode) && !xfer_dirs) {
        rprintf(FINFO, "skipping directory %s\n", fbuf);
        continue;
}

xfer_dirs resolves to -d, or -r (else if (recurse) xfer_dirs = 1), or list_only when neither was given — options.c:2314-2320; --files-from forces it on at options.c:2307-2308. The continue is total: no directory entry, no children, and under --relative none of the operand's implied parents (send_implied_dirs() is at flist.c:2735, after the skip).

The DOTDIR spellings are not exempt. dir/ and dir/. become dir/. with name_type = DOTDIR_NAME (flist.c:2586-2604), but they still link_stat as a directory and meet the same skip. The marker decides "contents of" only once directories are being transferred at all. fbuf at that point is the operand after the dir/fn split, so the name printed is a bare . for a DOTDIR operand, the basename in non-relative mode, and the full (leading-slash-preserving) name under -R.

Measured, oc vs rsync 3.5.0

Remote-shell pull, fixture tree/sub/{top.txt,deep/f2} plus tree/alias -> sub:

operand flags upstream 3.5.0 oc before oc after
sub/ -lptgoD skipping directory ., nothing deep/ + top.txt matches
sub/. -lptgoD skipping directory ., nothing deep/ + top.txt matches
alias/ -lptgoD skipping directory ., nothing deep/ + top.txt matches
sub -lptgoD skipping directory sub, nothing ./sub created matches
sub/ -lptgoD -R skipping directory <abs>, nothing whole implied-parent chain matches
sub/ -lptgoD -d deep/ + top.txt same same
sub/ -lptgoD -r full subtree same same
sub/ -lptgoD --list-only lists same same
sub/ -lptgoD --quiet silent printed the line matches

The same shape reproduces through a real upstream daemon: rsync rsync://host/m/ dest/ prints skipping directory . and delivers nothing, where oc delivered a level of contents.

The local-copy executor already refused these transfers but lost the message for the DOTDIR spelling, because the name upstream prints is the fn half of its split (a bare .) and oc passed None.

The fix

  • crates/transfer/src/generator/file_list/walk.rs — the xfer_dirs gate on a top-level operand, ordered as upstream orders it (the ALL_FILTERS exclusion at flist.c:2719 first, with the DOTDIR exemption). try_walk_source_entry computes xfer_dirs; the --files-from caller passes true, mirroring options.c:2307-2308.
  • crates/transfer/src/generator/protocol_io.rs — a SenderDiagnostic::Info class for upstream FINFO: MSG_INFO on the wire, stdout (not stderr) when the sender is the client, and the --quiet early return placed where log.c:344-346 places it, ahead of the am_server frame send at log.c:357.
  • crates/transfer/src/reader/multiplex.rs — a peer's MSG_INFO/MSG_CLIENT frame is delivered through read_a_msg() -> rwrite(), so it meets the same --quiet arm.
  • crates/engine/src/local_copy/executor/sources/handlers.rs — name the skipped DOTDIR operand ..

Fixtures that encoded the pre-fix shape

Five generator unit tests built a DOTDIR file list with neither -r nor -d and asserted ". plus the directory's children" — the very combination upstream refuses. They now ask for -d, which is the one-level form they were describing. The daemon peer-address ACL cells pull fakehost::m/ with no flags and use "did payload.txt arrive" as their admit/deny signal, so without -r the admitted control could not discriminate; verified against a real 3.5.0 daemon before changing them.

Verification

  • New tests/xfer_dirs_directory_operand.rs: 10 cells over a two-process remote-shell transfer plus the local executor, with -d, -r, --list-only, and the bare-operand controls for non-vacuity.
  • Mutation-proved, one production change at a time:
    • disable the walk gate → 5 of 10 RED
    • revert the local-copy . fallback → 1 RED (the_local_executor_names_a_skipped_dotdir_operand)
    • disable the reader's --quiet arm → 1 RED (quiet_suppresses_the_skip_line)
    • all restored → 10/10 GREEN
  • cargo fmt --all -- --check clean.
  • cargo nextest run --workspace: 32589/32590. The one failure, xtask ... backdated_tree_populates_and_backdates_the_root, is environmental (BSD touch rejects -d @epoch) and fails identically on the pristine base.
  • cargo clippy --workspace --all-targets: 403 diagnostics / 0 errors on this branch, 403 / 0 on the pristine base. Nothing introduced.

Refuted

The filed diagnosis for this row — "the sender drops the DOTDIR marker, so sym-to-dir/ is lstat'd as a symlink instead of followed" — does not reproduce. It was fixed by 0cc1517 (#7510) and is already covered by tests/dotdir_symlink_operand.rs. A 21-cell differential over both the local and remote paths (alias/, alias/., alias, alias//, alias/./, each with and without -R and --copy-dirlinks) shows oc and 3.5.0 agreeing on every symlink-follow case. The divergence reported here is a different rule in the same argument loop.

Two further differences were measured and deliberately left alone as unrelated: oc's sent/received byte counters read 0 on an empty transfer where upstream reports small non-zero values, and sub/.. is refused by both sides with different diagnostic text.

Upstream's argument loop refuses a directory operand outright unless
directories are being transferred:

    /* rsync-3.5.0/flist.c:2723-2726 */
    if (S_ISDIR(st.st_mode) && !xfer_dirs) {
            rprintf(FINFO, "skipping directory %s\n", fbuf);
            continue;
    }

`xfer_dirs` comes from `-d`, or `-r`, or `--list-only` when neither was
given (options.c:2314-2320); `--files-from` forces it on
(options.c:2307-2308). The `continue` is total: no directory entry, no
children, and under `--relative` none of the operand's implied parents.

The DOTDIR spellings are not exempt. `dir/` and `dir/.` are rewritten to
`dir/.` with `name_type = DOTDIR_NAME` (flist.c:2586-2604), but they
still `link_stat` as a directory and meet this same skip. The marker
decides "contents of" only once directories are being transferred.

oc's network sender had no such gate. Measured against rsync 3.5.0 over
a remote-shell pull on one fixture:

    operand              upstream 3.5.0            oc (before)
    sub/  -lptgoD        skipping directory .      deep/ + top.txt
    sub/. -lptgoD        skipping directory .      deep/ + top.txt
    alias/ -lptgoD       skipping directory .      deep/ + top.txt
    sub   -lptgoD        skipping directory sub    ./sub created
    sub/  -lptgoD -R     skipping directory <abs>  whole parent chain

The same shape reproduces through a real upstream daemon:
`rsync rsync://host/m/ dest/` prints `skipping directory .` and delivers
nothing, where oc delivered one level.

The local-copy executor already refused the transfer but lost the
message for the DOTDIR spelling: the name upstream prints there is the
`fn` half of its dir/fn split, a bare `.`, and oc passed `None`.

`--quiet` silences the line on upstream's FINFO arm (log.c:344-346),
which runs before the `am_server` frame send at log.c:357 and is met
again when the peer's frame arrives via `read_a_msg()`. Both ends now
drop it.

Six fixtures asserted the pre-fix shape - five generator unit tests that
built a DOTDIR file list with neither `-r` nor `-d`, and the daemon
peer-address ACL cells whose admit/deny signal is "did payload.txt
arrive". They now ask for the `xfer_dirs` they always meant.
@oferchen
oferchen merged commit ed5a38b into master Sep 2, 2026
71 checks passed
@oferchen
oferchen deleted the fix/xfer-dirs-directory-operand branch September 2, 2026 20:32
oferchen added a commit that referenced this pull request Sep 2, 2026
… merged PRs (#7634)

* docs(rustdoc): reach the public items rustdoc could not see, and gate the class

Two halves of the same question - is what a public item says actually reachable
from `cargo doc`?

Half 1: seven `//` comment blocks documented a `pub` item, so their text never
reached the generated docs. Found positionally, not by content: a `//` run whose
next non-attribute line declares a `pub` item. A census keyed on comment CONTENT
is false-positive dominated; this one is mechanical.

Nine sites matched; two are DELIBERATELY left as `//`, because they document the
`#[cfg_attr]` / `#[allow]` attribute directly beneath them rather than the item -
`local_copy/overrides.rs` and `local_copy/plan/report.rs`. Promoting those would
attach a lint rationale to a public surface as if it described the surface.

Text is preserved verbatim, upstream citations included (`generator.c:2149` on
the obstacle module). The only rewrite is `socket_options/consts.rs`, where one
group note covered two constants: split per item, matching the file's own house
style where every other const already carries `///`.

Half 2: five intra-doc links could not resolve in a DEFAULT build, and the
existing gate is structurally unable to see them.

  crates/fast_io/src/lib.rs, ewma.rs (x4)  -> `adaptive_dispatch`, gated by the
                                              off-by-default
                                              `adaptive-basis-dispatch` feature
  crates/rsync_io/.../sync_bridge.rs       -> `crate::channel_adapter`, gated by
                                              the off-by-default `async-ssh`
                                              feature
  crates/fast_io/src/confinement.rs        -> `PinnedRoot`, a PRIVATE struct

plus one already on the branch in `module_list/types.rs`, where the link was
`Transport::Quic` (the `quic` feature) and its surrounding prose still described
the variant as unbuilt.

Every crate denies `rustdoc::broken_intra_doc_links`, so each of these is a hard
`cargo doc` failure, not a warning. MEASURED on the pristine base:

    cargo doc --no-deps --workspace   ->  7 errors, `fast_io` and `rsync_io`
                                          could not be documented
    cargo doc --no-deps --workspace --all-features  ->  clean

That gap is the whole point. Under `--all-features` the gated items EXIST, so
the link resolves and the gate is green; in a default build the item is not
compiled at all. `ci.yml`'s `rustdoc-links` job runs only `--all-features`,
deliberately mirroring `pages.yml` - which is right for the question Pages asks
and cannot ask this one. So the fix is paired with a SECOND step on default
features, and neither subsumes the other: `crates/fast_io/src/io_uring` is
`cfg(all(target_os = "linux", feature = "io_uring"))` and only the all-features
run compiles it.

The names stay in backticks with the reason stated at each site, rather than
being deleted or the links made conditional - the prose still says what it said,
and the next reader learns why it is not a link.

After: both invocations document all 25 crates cleanly, 0 errors. fmt clean;
clippy on the five touched crates reports no new diagnostics.

* docs(changelog): record the ten pull requests merged since the last sweep

#7624 brought the Unreleased section up to #7620 and then stopped being true:
#7621-#7632 landed after it, of which #7624 is itself that changelog pass and
#7628 was never merged. Ten entries were missing.

Each is placed in the subsection its change belongs to rather than appended in
number order, and #7625 is SPLIT across two, because it is two changes: wiring
`--force` is a receiver fix, and the synthetic-transfer-root guard that wiring
made necessary is a peer-supplied input bound. Filing it once under either
heading would have hidden whichever half the reader was looking for.

  Security / peer-supplied input bounds   #7625 (guard half), #7630
  Fixed / transfer and receiver           #7622, #7625 (--force half), #7627
  Fixed / daemon                          #7629
  Testing and CI                          #7621, #7623, #7632
  Documentation                           #7626, #7631

Wording is taken from each merge commit's own body, not from its title - the
titles compress away the part a reader needs. #7629's title says "keep a dead
name converter apart from an unknown name"; what makes it worth an entry is that
five outcomes collapsed into one `None` and the merge failed OPEN on exactly the
mechanism an operator installs to take ownership decisions away from the peer.
oferchen added a commit that referenced this pull request Sep 3, 2026
…use, and a pre-mangled log operand (#7639)

* fix(docs): stop linking a cfg-gated type from an always-rendered module doc

`rustdoc links (informational)` has been red on master, reporting exactly two
errors, both at crates/fast_io/src/io_uring/mod.rs:117 - the `///` comment on
`pub mod send_zc;`:

  error: unresolved link to `ZeroCopySender`
  error: unresolved link to `ZeroCopySender::send_zc`

Two things combine to produce them, and neither is visible on its own.

`ZeroCopySender` is `#[cfg(feature = "iouring-send-zc")]` at BOTH the struct
(send_zc.rs:320) and the re-export (mod.rs:166), so in a DEFAULT build the type
does not exist and no path can resolve to it. Separately, `pub mod send_zc;`
carries a `///` comment, and rustdoc concatenates that with the module's own
`//!` block and resolves the result in the OUTER module's scope - which is why
the errors are reported against mod.rs:117 rather than against the `//!` lines
in send_zc.rs that actually contain them. crates/logging-sink/src/escape.rs
documents this same concatenation trap in its own header.

Both links become plain code spans. The prose already said the type is exposed
"when the `iouring-send-zc` cargo feature is enabled", so nothing is lost: a
link that cannot resolve in the configuration the doc gate actually builds is
not carrying the reader anywhere.

An `--all-features` doc build cannot see either half of this, which is how the
broken link reached master in the first place - the note now says so at the
site, so the next reader does not "fix" it back into a link.

Verified: `RUSTDOCFLAGS="-D warnings" cargo doc -p fast_io --no-deps` on a
default build is clean. The red baseline is CI's own two errors at this exact
file and line.

* test(daemon): pin the dead-converter cause as STICKY, not as one errno

`a_dead_converter_fails_instead_of_answering_unknown` is the first of the two
tests that turned master red: it appeared at ed5a38b (#7627, an unrelated
sender diff), one commit after the run at 7a82dea that was green, and it
failed on all three nextest retries with

  assertion `left == right` failed: the recorded cause must be reported, not a
  fresh one: name converter: writing the request: Broken pipe (os error 32)
    left: BrokenPipe
   right: UnexpectedEof

The assertion pinned `UnexpectedEof` as the recorded cause. Which cause gets
recorded is a RACE, and both arms are legitimate: the child is `exit 0`, so if
it has already exited and closed the pipe when the first lookup runs, the
request WRITE fails with EPIPE and BrokenPipe becomes the sticky cause; if it
has not yet exited, the write lands and the answer READ hits EOF, recording
UnexpectedEof. Neither outcome is a defect - the host just decides which one
wins.

What the test exists for is the property one line below it in its own comment:
that the death is RECORDED and REPLAYED rather than the stream being spoken to
again. That property is orthogonal to which errno won the race, so the test now
captures whichever cause the first failure recorded and asserts the later
lookup reports THAT, plus a bound that the cause came from the pipe at all
(`UnexpectedEof | BrokenPipe`) rather than some unrelated error.

This deliberately keeps two assertions rather than deleting the errno check:
without the pipe-cause bound, a converter that failed for a completely
different reason would satisfy "sticky" trivially.

daemon --lib name_converter_tests: 16/16.

* fix(daemon): stop pre-mangling peer bytes at the log call sites

`daemon_log_file_escaping` is the second of the two tests that turned master
red. It failed at its own non-vacuity guard, not at an assertion: PR #7633
stopped writing the client's argument vector to the daemon log - correctly,
since upstream never writes it at all - and that vector was the test's only
subject. With nothing peer-supplied left in the log, every later assertion
would have passed vacuously, and the guard said so.

Re-pointing the test at a vector oc does log measured a real divergence.

Upstream escapes in the SINK. `logit()` is the only writer of `logfile_fp` and
hands every line to `filtered_fwrite(logfile_fp, buf, len, 0, 1, trailing)`
(log.c:126-132), so no call site needs to pre-clean its operands and none of
upstream's do: `clientserver.c:787` passes the module name straight into
`rprintf(FLOG, "rsync %s %s from %s@%s (%s)\n", ...)`. oc ports that
`filtered_fwrite` faithfully in `crates/logging-sink/src/escape.rs`.

But seven of oc's daemon log builders wrapped the module name in
`sanitize_module_identifier` first, which replaces every control character with
`?`. Measured on a module named `A<ESC>B`, requested over a raw @rsyncd
handshake, master writes BOTH renderings into the SAME log file:

  rsync allowed access on module A?B from localhost (127.0.0.1)
  module 'A\#033B' from localhost (127.0.0.1): 0 client args

The second line is already correct - `client_args_log_line` does not sanitise,
so the sink escapes reversibly. The first is lossy: `?` cannot be undone, and a
reader cannot tell an escaped byte from a literal question mark. Two builders
naming the same peer string in the same file disagreed about what it says.

The sanitiser call is removed from all seven builders. It is deliberately KEPT
on the wire `@ERROR` reply path, which is a different sink with no escaping
layer of its own; that is a separate decision and is not touched here.

The doc on `log_module_refused_option` claimed the name was "sanitised to strip
control chars" - true when written, false after this change - so it now says the
sink escapes it. Leaving it would have been exactly the drift this repo keeps
getting bitten by.

The test moves onto the module name as its vector and asserts three things: the
escaped form is present, the mangled form is absent, and no raw ESC byte reached
the file. The already-correct client-args line is the in-run control that proves
the sink works and the fixture is live, alongside a plain-named control module.
Its header records what is NOT covered: an unresolvable module name, which
upstream also logs (clientserver.c:1568) but oc cannot, because it opens a log
sink only per resolved module. That is a real separate gap, filed rather than
faked.

RED/GREEN proven by restoring the sanitiser calls: the test fails on the
mangled-form assertion, printing both disagreeing lines.

daemon 1800/1800; daemon + log-file sweep 82/82; fmt clean.
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