Skip to content

fix: parse daemon module filter directives with the shared parser - #8353

Merged
oferchen merged 12 commits into
masterfrom
fix/argv-filter-shared-parser
Nov 11, 2026
Merged

oferchen merged 12 commits into
masterfrom
fix/argv-filter-shared-parser

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

Collapses the daemon's module filter parser into the one core filter parser, so module directives, client options and server argv options all go through a port of 3.5.1's parse_filter_str (exclude.c:1516-1598) and add_rule (exclude.c:279-314). Stacked on #8343.

  • One parser. crates/core/src/client/filter_args/filter_str.rs carries the rule template and xflags (OLD_PREFIXES, ABS_IF_SLASH, DIR2WILD3). add_rule does the side drop, the slash anchoring (a trailing slash does not count, leading ** stays unanchored) and the /*** suffix on Exclude and Protect rules only. --include, --exclude and --filter use it, and so do the module directives.
  • Module directives (clientserver.c:933-952): filter is word-split with the full grammar; include/exclude are word-split with OLD_PREFIXES; include from/exclude from read with OLD_PREFIXES and FATAL_ERRORS. About 1,700 lines of the daemon's own parser in module_access/helpers.rs are deleted. The old parser ignored ! and anchored /, so a module served files that 3.5.1 hides.
  • A clear empties the whole list. pop_filter_list(listp); listp->head = NULL (exclude.c:1540-1546) drops every rule ahead of the clear, argv rules included. oc used to clear only the file's own rules. This was MEASURED on 3.5.1: with -f '- b' -f '. rules' and ! in rules, both a and b transfer.
  • Refusal (E1). A refused module directive ends the session before @RSYNCD: OK, and the cause goes to the daemon log only, as 3.5.1 does. oc used to send an @ERROR line it made up itself.
  • Merge-file opens are gated by check_filter(&daemon_filter_list) while the list is being built (exclude.c:1639-1664). An absolute name skips module_dirlen by length alone. A name with no slash opens from cwd (parse_merge_name, exclude.c:704-715).
  • Error text.
    • A rule read from a file is reported as <rule from FILE line N>.
    • A word-split file rule is reported as <rule from FILE> (exclude.c:71-136, MEASURED).
    • -from records now carry their line number.
  • Wire fixes.
    • A :p dir-merge rule now sends p on the wire (get_rule_prefix, exclude.c:1872).
    • A :r dir-merge rule keeps its side.
    • The receiver's daemon filter set honours directory_only, anchored and negate.
  • Corrected the pop_filter_list comment in merge.rs, which described the clear wrongly.

Tests

  • New tests/daemon_module_filters.rs: 7 cells against live 3.5.1.
    • negate and abs-path modifiers
    • both-sides versus sender-only rules
    • a trailing slash does not anchor
    • old-prefix word split
    • a clear inside a merge file
    • a self-excluding merge gates its own open
    • a refused directive is logged and sends nothing
  • New cell a_clear_inside_a_file_empties_the_rules_ahead_of_it in crates/cli/tests/upstream_compat_filter_rule_parse.rs.
  • New crates/core/src/client/filter_args/tests/filter_str.rs: the add_rule cells, plus the 17 split cells moved from the daemon.

Dropped or replaced daemon tests

The parser these tests exercised is deleted:

  • strip_matched_keyword_* (7): the helper is gone. The keyword walk is covered by the core split_* cells.
  • build_pattern_rule_{exclude,include,anchored,doublestar_prefix_stays_unanchored,directory_only_exclude_dir2wild3,directory_only_include_preserved}, pattern_{leading_slash_is_anchored,no_slash_is_not_anchored,embedded_slash_is_anchored,deep_path_is_anchored}, directory_exclude_gets_wild3, directory_include_keeps_directory_flag, include_with_embedded_slash_is_anchored (13): duplicates of the core add_rule cells (a_pattern_without_a_slash_is_added_as_written, a_slash_anywhere_in_the_pattern_anchors_it, a_leading_double_star_stays_unanchored, a_trailing_slash_marks_a_directory_rule_and_is_not_counted).
  • an_inexpressible_modifier_drops_the_rule_rather_than_refusing_it: replaced by the_negate_and_xattr_modifiers_are_carried_on_the_rule. The rule is now carried, not dropped.
  • read_patterns_from_file_reads_a_plain_file_unchanged: a duplicate of exclude_from_reads_one_pattern_per_line.
  • The other read_patterns_from_file_* and split_filter_tokens_* tests were renamed to exclude_from_* and moved to core split_*, unchanged.
  • Updated tests:
    • build_daemon_filter_rules_line_final_clear_* now expects an empty list.
    • *_non_merge_cvs_* now expects the -C defaults expanded.
    • Three cli tests were renamed to *_clears_*.

Residuals

  • E2 (task 547). These three rows of the 3.5.1 differential table still disagree: :w .ws on rsh, on daemon -M and on a module directive. All three are the sender-side per-dir merge error report: 3.5.1's client prints the parse error first and exits 1. The 4 Push cells in upstream_compat_filter_rule_parse (c_modifier_inside_a_per_directory_merge_file, merge_file_rules_end_where_upstream_ends_them, naming_both_sides_still_names_a_side, sided_merge_file_refuses_a_sided_rule) fail for the same reason. They also fail on master's binary under OC_RSYNC_UPSTREAM_COMPAT=1 and SKIP in CI. Task 547 fixes them in a PR stacked on this one.
  • The missing filter-file texts failed to read filter file '...' and failed to read filter patterns from standard input are not 3.5.1's. This PR moved them unchanged from cli to core, and they are left for the task 632 and 626 sweep.

Gates

  • cargo fmt --check and check_rustfmt_all.py
  • workspace clippy -D warnings
  • windows-gnu clippy (cli, daemon, transfer, core)
  • no-default clippy (cli, transfer, daemon, core)
  • dead-code census: one stale allowlist row (with_dir_merge_options) removed
  • citation ratchet: OK; cli baseline lowered from 1 to 0
  • targeted nextest: 1839 run, 1835 pass. The 4 failures are the task 547 Push cells listed above.

@github-actions github-actions Bot added the bug Something isn't working label Nov 10, 2026
@oferchen
oferchen force-pushed the fix/argv-filter-shared-parser branch from 94ba255 to 53bb2ed Compare November 10, 2026 20:36
@oferchen
oferchen force-pushed the fix/argv-filter-shared-parser branch from 53bb2ed to 79f40ee Compare November 11, 2026 06:39
@oferchen
oferchen force-pushed the fix/argv-filter-shared-parser branch from 79f40ee to 5516e5e Compare November 11, 2026 08:51
@oferchen
oferchen force-pushed the fix/argv-filter-shared-parser branch from 5516e5e to c61375b Compare November 11, 2026 09:49
@oferchen
oferchen force-pushed the fix/argv-filter-shared-parser branch from c61375b to 4f50916 Compare November 11, 2026 10:31
@oferchen
oferchen force-pushed the fix/argv-filter-shared-parser branch from 4f50916 to 1301bc8 Compare November 11, 2026 10:49
A `!` read from a merge file or an --exclude-from/--include-from file
empties the whole list the file is parsed into, argv rules included,
as 3.5.1 does (exclude.c:1542-1551). oc cleared only the file's own
rules, so an earlier --exclude kept applying.

Every filter string now parses through one parse_filter_str with
upstream's xflags, and add_rule applies XFLG_ABS_IF_SLASH and
XFLG_DIR2WILD3 as rules are added, ready for the daemon's module
directives. A dir-merge `e` modifier adds the basename exclude ahead
of the rule, as parse_filter_str does.
The daemon module filter, include, exclude, include from and exclude from
directives now go through the core parse_filter_str with 3.5.1 xflags
(clientserver.c:933-952), and the daemon helpers parser is deleted. A
refused directive ends the session before @rsyncd: OK with the cause in
the daemon log only, and -from records are reported by file and line.
@oferchen
oferchen force-pushed the fix/argv-filter-shared-parser branch from 1301bc8 to cefca29 Compare November 11, 2026 10:59
@oferchen
oferchen merged commit 00c474b into master Nov 11, 2026
31 checks passed
@oferchen
oferchen deleted the fix/argv-filter-shared-parser branch November 11, 2026 15:22
oferchen added a commit that referenced this pull request Nov 18, 2026
#8434)

Two documentation changes for the 0.6.5 release.

**Changelog.** Every PR merged since v0.6.4 was checked against
`[Unreleased]`.
- Seven lines cited five PRs that were closed without merging; they now
cite the PRs that carried the work (#8295, #8304, #8314, #8353, #8383).
- Three lines added by #8363 were no longer in the file and are
restored.
- Eighteen merged PRs with user-visible changes had no entry and now
have one.
- One entry moved from Added to Fixed.

**Differences from rsync 3.5.2.** New
`docs/differences-from-rsync-3.5.2.md`, linked from the README and the
environment reference. It lists behaviour kept on purpose, upstream
fixes adopted early (none yet, three pending), oc-rsync extensions
(options, transports, daemon parameters, debug words, sandboxing,
environment variables, the opt-in consecutive-match extension) and links
to the platform documents. Every row is backed by code or a test.

No code changes.

Closes #8564
Closes #8565
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