Skip to content

Remove redundant must_use annotations on protocol parsers - #33

Merged
oferchen merged 1 commit into
masterfrom
codex/implement-functional-rsync-3.4.1-in-rust
Oct 15, 2025
Merged

oferchen merged 1 commit into
masterfrom
codex/implement-functional-rsync-3.4.1-in-rust

Conversation

@oferchen

@oferchen oferchen commented Oct 15, 2025 •

Copy link
Copy Markdown
Owner

Summary

  • drop redundant #[must_use] annotations from Result-returning legacy negotiation helpers to keep clippy clean
  • remove redundant attribute from protocol version selection helpers that already rely on Result

Testing

  • cargo clippy
  • cargo test

@oferchen
oferchen merged commit 3509e3d into master Oct 15, 2025
@oferchen
oferchen deleted the codex/implement-functional-rsync-3.4.1-in-rust branch October 15, 2025 14:58
oferchen added a commit that referenced this pull request Aug 15, 2026
…#7357)

Upstream has exactly one writer to the log file: `logit()` (log.c:126),
which hands every line to `filtered_fwrite(logfile_fp, buf, len, 0, 1,
trailing)` at log.c:132. Escaping in the sink is what makes it
unbypassable - a producer cannot forget it, because there is no other
way to reach the file.

oc-rsync escaped in the CLI out-format renderer instead. That covered
`--log-file` on the client and nothing else: the daemon writes its log
through an entirely different path, so a peer-supplied operand reached
the log with a raw ESC where rsync 3.5.0 writes `\#33`.

Move the escaper down to `logging_sink::logfile::LogFileWriter`, the one
type both the CLI (summary.rs) and the daemon (daemon.rs, privilege.rs,
hardening.rs, module_access) construct for a log file, and switch the
renderer to the new `EscapeStyle::passthrough`. Applying both would
double-escape: the sink's `\#ddd` guard (log.c:252-254) fires on the
renderer's own output and turns `\#33` into `\#134#033`.

Two consequences fall out of putting it in the sink:

- `EscapeStyle` gains an `escape_controls` switch. Upstream has no such
  switch because every `filtered_fwrite` call site escapes C0 controls;
  oc-rsync needs one because it now has a sink upstream does not - the
  passthrough style, whose whole job is to leave the bytes alone.

- The `Write` adapter now treats a newline as a record terminator only
  when it ends the write. A newline *inside* the message is escaped as
  `\#12`, matching log.c:128-129, which strips exactly one trailing
  newline. This is the injection itself: every line the sink emits gets
  a real timestamp and pid, so a name carrying `\n` would otherwise
  produce a second, entirely authentic-looking record.

Tests: a daemon integration test pins the half a renderer-side escaper
cannot reach (peer-supplied operand in the `client args:` line), with a
printable control operand so the assertions cannot pass vacuously. It
fails with a raw ESC in the log when the sink escaping is reverted. The
existing 3.5.0 oracle test for `--log-file` still passes unchanged,
which is what proves the move did not perturb the client half.
oferchen added a commit that referenced this pull request Aug 24, 2026
…#7357)

Upstream has exactly one writer to the log file: `logit()` (log.c:126),
which hands every line to `filtered_fwrite(logfile_fp, buf, len, 0, 1,
trailing)` at log.c:132. Escaping in the sink is what makes it
unbypassable - a producer cannot forget it, because there is no other
way to reach the file.

oc-rsync escaped in the CLI out-format renderer instead. That covered
`--log-file` on the client and nothing else: the daemon writes its log
through an entirely different path, so a peer-supplied operand reached
the log with a raw ESC where rsync 3.5.0 writes `\#33`.

Move the escaper down to `logging_sink::logfile::LogFileWriter`, the one
type both the CLI (summary.rs) and the daemon (daemon.rs, privilege.rs,
hardening.rs, module_access) construct for a log file, and switch the
renderer to the new `EscapeStyle::passthrough`. Applying both would
double-escape: the sink's `\#ddd` guard (log.c:252-254) fires on the
renderer's own output and turns `\#33` into `\#134#033`.

Two consequences fall out of putting it in the sink:

- `EscapeStyle` gains an `escape_controls` switch. Upstream has no such
  switch because every `filtered_fwrite` call site escapes C0 controls;
  oc-rsync needs one because it now has a sink upstream does not - the
  passthrough style, whose whole job is to leave the bytes alone.

- The `Write` adapter now treats a newline as a record terminator only
  when it ends the write. A newline *inside* the message is escaped as
  `\#12`, matching log.c:128-129, which strips exactly one trailing
  newline. This is the injection itself: every line the sink emits gets
  a real timestamp and pid, so a name carrying `\n` would otherwise
  produce a second, entirely authentic-looking record.

Tests: a daemon integration test pins the half a renderer-side escaper
cannot reach (peer-supplied operand in the `client args:` line), with a
printable control operand so the assertions cannot pass vacuously. It
fails with a raw ESC in the log when the sink escaping is reverted. The
existing 3.5.0 oracle test for `--log-file` still passes unchanged,
which is what proves the move did not perturb the client half.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant