Repository navigation
fix: apply daemon incoming/outgoing chmod specs at transfer time - #5530
Merged
Merged
Conversation
2 tasks
The daemon parser stored `incoming chmod = SPEC` and `outgoing chmod = SPEC` as raw strings on `ModuleDefinition` but never converted them to mode-bit rewrites at transfer time. Push transfers ignored `incoming chmod`; pull transfers ignored `outgoing chmod`. Parse the strings into `metadata::ChmodModifiers` via the existing client-side chmod parser when building the per-session `ServerConfig`, and plumb the parsed clauses to: - the receiver, via `MetadataOptions::with_chmod` in `setup_transfer`, so the existing `apply_permissions_with_chmod` site rewrites the destination mode at file-finalize time (push direction); and - the sender, via the new `daemon_outgoing_chmod` field consumed in `GeneratorContext::create_entry`, so each `FileEntry` ships with the rewritten mode on the wire (pull direction). Mirrors upstream `clientserver.c:rsync_module()` arming `daemon_chmod_modes` through `parse_chmod(lp_*_chmod(i), ...)` and applying it via `flist.c:make_file()` (sender) and `rsync.c:set_file_attrs()` (receiver). Invalid specs surface as `@ERROR: invalid 'incoming chmod' directive ...` during module setup, matching the upstream behavior of aborting the session on a bad `--chmod` style argument. Non-Unix platforms inherit the existing no-op semantics of `ChmodModifiers::apply` and `apply_permissions_with_chmod`, so the wire-up adds no Windows path that would diverge from upstream. Regression coverage: filesystem-level tests confirm `incoming chmod = F600` rewrites the destination to `0o600` and `outgoing chmod = Fg-r` clears the group-read bit on the wire mode, plus negative cases proving the absence of a directive leaves modes untouched. Builder round-trip and daemon-side chmod-spec parser tests cover the wire-up.
ModuleDefinition exposes incoming_chmod/outgoing_chmod as both Option<String> fields and Option<&str> accessor methods. Through Deref on ModuleRuntime, the field shadows the method in resolution, so module.incoming_chmod() was parsed as "call the field as a function" and rejected on MSRV 1.88. Use the field directly with .as_deref() to match the surrounding pattern (e.g. module.dont_compress.as_deref() above) and feed the existing Option<&str> signature of parse_one_chmod_spec.
oferchen
force-pushed
the
fix/uts-7-daemon-filter-chmod
branch
from
June 10, 2026 10:46
63b0933 to
0096c86
Compare
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
* fix: apply daemon incoming/outgoing chmod specs at transfer time The daemon parser stored `incoming chmod = SPEC` and `outgoing chmod = SPEC` as raw strings on `ModuleDefinition` but never converted them to mode-bit rewrites at transfer time. Push transfers ignored `incoming chmod`; pull transfers ignored `outgoing chmod`. Parse the strings into `metadata::ChmodModifiers` via the existing client-side chmod parser when building the per-session `ServerConfig`, and plumb the parsed clauses to: - the receiver, via `MetadataOptions::with_chmod` in `setup_transfer`, so the existing `apply_permissions_with_chmod` site rewrites the destination mode at file-finalize time (push direction); and - the sender, via the new `daemon_outgoing_chmod` field consumed in `GeneratorContext::create_entry`, so each `FileEntry` ships with the rewritten mode on the wire (pull direction). Mirrors upstream `clientserver.c:rsync_module()` arming `daemon_chmod_modes` through `parse_chmod(lp_*_chmod(i), ...)` and applying it via `flist.c:make_file()` (sender) and `rsync.c:set_file_attrs()` (receiver). Invalid specs surface as `@ERROR: invalid 'incoming chmod' directive ...` during module setup, matching the upstream behavior of aborting the session on a bad `--chmod` style argument. Non-Unix platforms inherit the existing no-op semantics of `ChmodModifiers::apply` and `apply_permissions_with_chmod`, so the wire-up adds no Windows path that would diverge from upstream. Regression coverage: filesystem-level tests confirm `incoming chmod = F600` rewrites the destination to `0o600` and `outgoing chmod = Fg-r` clears the group-read bit on the wire mode, plus negative cases proving the absence of a directive leaves modes untouched. Builder round-trip and daemon-side chmod-spec parser tests cover the wire-up. * fix: correct ModuleRuntime field access for incoming/outgoing chmod ModuleDefinition exposes incoming_chmod/outgoing_chmod as both Option<String> fields and Option<&str> accessor methods. Through Deref on ModuleRuntime, the field shadows the method in resolution, so module.incoming_chmod() was parsed as "call the field as a function" and rejected on MSRV 1.88. Use the field directly with .as_deref() to match the surrounding pattern (e.g. module.dont_compress.as_deref() above) and feed the existing Option<&str> signature of parse_one_chmod_spec. * style: apply rustfmt to daemon chmod receiver tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The daemon parser stored
incoming chmod = SPECandoutgoing chmod = SPECas raw strings onModuleDefinitionbut never converted them into mode-bit rewrites at transfer time. Push transfers silently ignoredincoming chmod, and pull transfers silently ignoredoutgoing chmod, so the upstreamdaemon-filter_test.pyregression for these directives was a no-op.This change parses both directives into
metadata::ChmodModifiersvia the existing client-side--chmodparser at module-use time, then plumbs the parsed clauses throughServerConfigto the canonical mode-finalize sites in each direction:setup_transfernow installsdaemon_incoming_chmodon the per-fileMetadataOptionsviawith_chmod, so the existingapply_permissions_with_chmodsite rewrites the destination mode at file-finalize time. Mirrors upstreamrsync.c:set_file_attrs()consultingdaemon_chmod_modes.GeneratorContext::create_entryrewrites the entry's mode viaChmodModifiers::applyafter every other flist field is populated but before the caller serializes the entry. Mirrors upstreamflist.c:make_file()applyingdaemon_chmod_modesto the wire-emittedfile_struct.Invalid specs surface as
@ERROR: invalid 'incoming chmod' directive ...during module setup, matching the upstream semantics of aborting a session on a malformed chmod argument.The chmod-spec parser (
metadata::ChmodModifiers::parse) was already vetted for the client-side--chmodflag and accepts every form upstream'sparse_chmod()accepts: bare octal (644), prefix-letter (F600), class-action-perms (u+x), and combined (Du+x,Fg-r,Fo-r).Audit findings
crates/daemon/src/daemon/sections/config_parsing/module_directives.rs:195-220storedincoming chmod/outgoing chmodasOption<String>onModuleDefinitionand never converted them to mode bits.crates/metadata/src/chmod/{mod,parse,apply,spec}.rswas the natural reuse target; no new grammar code needed.crates/transfer/src/receiver/transfer/setup.rs:135-154(theMetadataOptionsbuilder) routes intocrates/metadata/src/apply/permissions.rs:142-192(apply_permissions_with_chmod).crates/transfer/src/generator/file_list/entry.rs:53-110(theFileEntryconstruction switch); a singleset_moderewrite after every other field is populated covers all file types uniformly.Wire-up
ServerConfig(crates/transfer/src/config/mod.rs:421-451): two new optionalChmodModifiersfields.ServerConfigBuilder(crates/transfer/src/config/builder.rs:468-505): matchingdaemon_incoming_chmod/daemon_outgoing_chmodsetters.crates/daemon/src/daemon/sections/module_access/client_args.rs:292-314): parse strings on session entry, abort with@ERRORon invalid spec.crates/transfer/src/receiver/transfer/setup.rs:148-154):MetadataOptions::with_chmod.crates/transfer/src/generator/file_list/entry.rs:247-258):set_moderewrite at the end ofcreate_entry.Regression coverage
crates/transfer/src/receiver/transfer/setup.rsdaemon_incoming_chmod_tests: end-to-end filesystem test -incoming chmod = F600rewrites a0o644source into a0o600destination on disk; absence of the directive preserves the source mode verbatim.crates/transfer/src/generator/file_list/entry.rsdaemon_outgoing_chmod_tests: end-to-end wire-emission test -outgoing chmod = Fg-rclears the group-read bit on theFileEntrymode (0o664->0o624); absence of the directive emits the on-disk mode untouched.crates/transfer/src/config/builder_tests.rs: builder round-trip tests for both new fields.crates/daemon/src/daemon/sections/module_access/client_args.rsdaemon_chmod_spec_tests: parser tests for None passthrough, all four upstream spec forms, and error-message provenance.Cross-platform
ChmodModifiers::applyandapply_permissions_with_chmodalready short-circuit to no-op on non-Unix. No additional#[cfg]gates needed; theincoming chmodpath naturally becomes a no-op on Windows, matching upstream's behavior wheredaemon_chmod_modesis filtered through POSIX-only mode bits.Test plan
cargo nextest run -p transfer --all-features -E 'test(daemon_incoming_chmod)'passescargo nextest run -p transfer --all-features -E 'test(daemon_outgoing_chmod)'passescargo nextest run -p transfer --all-features -E 'test(builder)'passes (new builder round-trip tests)cargo nextest run -p daemon --all-features -E 'test(daemon_chmod_spec)'passesdaemon-filter_test.pyincoming chmod/outgoing chmodcases pass against the new daemon binaryUpstream references
options.c::parse_chmod()- canonical chmod-spec parserclientserver.c::rsync_module()- daemon-side arming ofdaemon_chmod_modesviaparse_chmod(lp_xxx_chmod(i), ...)flist.c::make_file()- sender appliesdaemon_chmod_modeswhile building wirefile_structrsync.c::set_file_attrs()- receiver consultsdaemon_chmod_modesat file finalize time