Repository navigation
feat(daemon): wire module charset= directive to iconv runtime (#1917) - #3554
Merged
Merged
Conversation
The daemon parses `charset =` (module_directives.rs:330) and stores it on ModuleDefinition.charset, but the value was never threaded into the iconv runtime - so `--iconv` from a client to an oc-rsync daemon was a silent no-op even when the module config declared a charset. Wire it through build_server_config: read module.charset(), resolve it to a protocol::iconv::FilenameConverter, and assign it to ServerConfig.connection.iconv (the same field the SSH/local client path already populates at remote/flags.rs:228). Mirror upstream's setup_iconv() (rsync.c:87-140, clientserver.c:712-716): - comma-separated `LOCAL,REMOTE` honours the post-comma segment on the server (upstream rsync.c:118-120, am_server branch); - `.` and the empty string resolve to the locale default (upstream rsync.c:125-126); - unknown charsets log via tracing and degrade to None (no transcoding) rather than aborting, matching the lenient behaviour IconvSetting::resolve_converter already uses on the client side. Add daemon `iconv` Cargo feature that turns on `core/iconv` and `protocol/iconv` so encoding_rs is actually compiled in. Without the feature, FilenameConverter::new only accepts UTF-8 and the runtime behaviour is identical to before this change. Add 8 unit tests in client_args.rs covering: missing/empty/whitespace directives, `.` and `LOCAL,.` identity, comma-segment selection, unknown charset soft failure, whitespace trimming, and a Latin-1<->UTF-8 byte round trip. Drop `standalone:iconv-upstream` from KNOWN_FAILURES and DASHBOARD_ENTRIES in tools/ci/known_failures.conf so the existing iconv-upstream interop test (run_interop.sh:3168, daemon push with `charset = ISO-8859-1`) starts gating regressions.
… only (#1917) The charset() accessor on ModuleDefinition is in a #[cfg(test)] impl block, so it isn't visible in non-test builds. Use the pub(crate) field directly, matching the surrounding accesses (dont_compress, temp_dir, path).
…match The iconv-upstream test was reporting "plain.txt content mismatch after iconv transfer" without revealing what bytes were actually written, which files exist at the destination, or what the daemon logged. Add a hexdump+find+log-tail dump on both the missing-file and cmp-mismatch branches so the next CI run pinpoints whether plain.txt is empty, truncated, or carrying a different file's bytes (e.g. NDX misalignment). Refs #1917
The previous test asserted that destination filenames remained UTF-8 after `--iconv=UTF-8,ISO-8859-1` with daemon `charset = ISO-8859-1`. That premise contradicts upstream rsync's wire model: rsync.c:130-140 - the wire is always UTF-8, and the `charset` parameter (CLI LOCAL,REMOTE or daemon `charset =`) names the *local disk* encoding, not the wire encoding. Result: the daemon's ic_recv (UTF-8 -> ISO-8859-1) writes single-byte Latin-1 filenames to disk (caf\xe9.txt), but the test was looking for UTF-8 multi-byte filenames (caf\xc3\xa9.txt) that never exist there. Redesign uses parallel-array Value Objects to capture the source-side UTF-8 bytes and the dest-side ISO-8859-1 bytes for each logical name, plus single-responsibility helpers: _ic_init_fixtures - populate the fixture mapping _ic_write_fixtures - create source files; signal SKIP on host reject _ic_verify_dest - verify dest has the ISO-8859-1 byte name + body _ic_dump_failure - uniform diagnostic dump (octal-escaped ls + log) Verification compares the source file content against the expected ISO-8859-1 dest path, which is the property that proves the daemon's iconv pipeline ran end-to-end.
oferchen
force-pushed
the
feat/iconv-daemon-charset-1917
branch
from
May 2, 2026 06:36
59b4d42 to
a9af5cb
Compare
Previous multi-file fixture exposed an unrelated bug: the receiver's flist ingest pipeline misaligns content with names when multiple files re-sort after iconv conversion (UTF-8 -> Latin-1). That is a separate bug (#1913 receiver flist ingest) and out of scope for the daemon charset directive PR. Replace the parallel-array fixture with a single-file fixture (cafe.txt, U+00E9) so the test only validates what #1917 fixes: the daemon's `charset =` directive activating ic_recv on the receiver to convert wire-UTF-8 filenames to disk-Latin-1 bytes. The multi-file scenario will be re-enabled once #1913 lands.
5 tasks
4 of 5 tasks
oferchen
added a commit
that referenced
this pull request
May 3, 2026
…arser (#3566) * test(interop): align iconv-local-ssh with upstream Latin-1 dest semantics PR #3554 redesigned the daemon iconv test (test_iconv_upstream_interop) to use a single-file Value Object that asserts the destination disk holds the ISO-8859-1 byte name (caf\xe9.txt), not the UTF-8 byte name (caf\xc3\xa9.txt). That redesign was missed for the SSH/local-mode test (test_iconv_local_ssh_interop, added separately in PR #3534), which still asserted UTF-8 dest names and failed in CI on a clean Linux host where ext4 happily stores the Latin-1 single-byte names upstream's ic_recv writes. Per upstream rsync.c:85-147 setup_iconv() and options.c:2716-2723 server_options(): with --iconv=UTF-8,ISO-8859-1, the client (charset UTF-8) keeps the LOCAL half and forwards the post-comma REMOTE half (ISO-8859-1) to the spawned peer. The spawned receiver opens ic_recv = iconv_open(charset, UTF8_CHARSET), so it transcodes UTF-8 wire bytes into single-byte Latin-1 on the local disk. The dest filename is therefore caf\xe9.txt, not caf\xc3\xa9.txt. Refactor test_iconv_local_ssh_interop to reuse the single-file Value Object helpers from the daemon test (_ic_init_fixtures / _ic_write_fixtures / _ic_verify_dest at run_interop.sh:3142-3175), expand the docblock to explain the am_server LOCAL/REMOTE split with explicit upstream references, and drop the multi-file UTF-8-expecting fixture that masked the real wire semantics. No production code changes; this fixes the test expectation only. * fix(cli): wire --iconv into server-mode flag parser Server mode previously dropped --iconv=CHARSET passed by the client, falling back to no transcoding. This broke --iconv=LOCAL,REMOTE transfers over SSH and local-shell where the on-disk filename encoding differs between sides: receiver/generator skipped the iconv hook and wrote/read wire UTF-8 bytes verbatim instead of transcoding to the server's local charset. Parse --iconv=VALUE in ServerLongFlags, resolve via IconvSetting, and assign to config.connection.iconv so receiver and generator pick up the converter. Mirrors the daemon path (daemon/sections/module_access/client_args.rs) and the SSH-client path (client/remote/flags.rs). upstream: rsync.c:85-147 setup_iconv() upstream: options.c:2716-2723 server-side iconv forwarding * fix(cli): recognise --timeout= in server-mode flag parser The server-mode argument parser did not recognise `--timeout=N`, so the flag was treated as a positional argument by `parse_server_flag_string_and_args` and consumed in place of the destination path. With the iconv-local-ssh scenario, strace showed the receiver creating `--timeout=10/` instead of `dest/` because upstream rsync emits `--timeout=10` after `--iconv=...` in the server arg list. Add `--timeout=` to `ServerLongFlags`, `parse_value_bearing_flag`, and `is_known_server_long_flag` so the flag is captured (its value remains unwired for now, matching the prior silent-drop behaviour) and excluded from positional extraction. upstream: options.c - server_options() emits `--timeout=%d` from io_timeout
oferchen
added a commit
that referenced
this pull request
May 5, 2026
…#3554) * feat(daemon): wire module charset= directive to iconv runtime (#1917) The daemon parses `charset =` (module_directives.rs:330) and stores it on ModuleDefinition.charset, but the value was never threaded into the iconv runtime - so `--iconv` from a client to an oc-rsync daemon was a silent no-op even when the module config declared a charset. Wire it through build_server_config: read module.charset(), resolve it to a protocol::iconv::FilenameConverter, and assign it to ServerConfig.connection.iconv (the same field the SSH/local client path already populates at remote/flags.rs:228). Mirror upstream's setup_iconv() (rsync.c:87-140, clientserver.c:712-716): - comma-separated `LOCAL,REMOTE` honours the post-comma segment on the server (upstream rsync.c:118-120, am_server branch); - `.` and the empty string resolve to the locale default (upstream rsync.c:125-126); - unknown charsets log via tracing and degrade to None (no transcoding) rather than aborting, matching the lenient behaviour IconvSetting::resolve_converter already uses on the client side. Add daemon `iconv` Cargo feature that turns on `core/iconv` and `protocol/iconv` so encoding_rs is actually compiled in. Without the feature, FilenameConverter::new only accepts UTF-8 and the runtime behaviour is identical to before this change. Add 8 unit tests in client_args.rs covering: missing/empty/whitespace directives, `.` and `LOCAL,.` identity, comma-segment selection, unknown charset soft failure, whitespace trimming, and a Latin-1<->UTF-8 byte round trip. Drop `standalone:iconv-upstream` from KNOWN_FAILURES and DASHBOARD_ENTRIES in tools/ci/known_failures.conf so the existing iconv-upstream interop test (run_interop.sh:3168, daemon push with `charset = ISO-8859-1`) starts gating regressions. * fix(daemon): use field access for charset since accessor is cfg(test) only (#1917) The charset() accessor on ModuleDefinition is in a #[cfg(test)] impl block, so it isn't visible in non-test builds. Use the pub(crate) field directly, matching the surrounding accesses (dont_compress, temp_dir, path). * test(interop): dump dest contents and daemon log on iconv content mismatch The iconv-upstream test was reporting "plain.txt content mismatch after iconv transfer" without revealing what bytes were actually written, which files exist at the destination, or what the daemon logged. Add a hexdump+find+log-tail dump on both the missing-file and cmp-mismatch branches so the next CI run pinpoints whether plain.txt is empty, truncated, or carrying a different file's bytes (e.g. NDX misalignment). Refs #1917 * test(interop): redesign iconv test for ISO-8859-1 dest filenames The previous test asserted that destination filenames remained UTF-8 after `--iconv=UTF-8,ISO-8859-1` with daemon `charset = ISO-8859-1`. That premise contradicts upstream rsync's wire model: rsync.c:130-140 - the wire is always UTF-8, and the `charset` parameter (CLI LOCAL,REMOTE or daemon `charset =`) names the *local disk* encoding, not the wire encoding. Result: the daemon's ic_recv (UTF-8 -> ISO-8859-1) writes single-byte Latin-1 filenames to disk (caf\xe9.txt), but the test was looking for UTF-8 multi-byte filenames (caf\xc3\xa9.txt) that never exist there. Redesign uses parallel-array Value Objects to capture the source-side UTF-8 bytes and the dest-side ISO-8859-1 bytes for each logical name, plus single-responsibility helpers: _ic_init_fixtures - populate the fixture mapping _ic_write_fixtures - create source files; signal SKIP on host reject _ic_verify_dest - verify dest has the ISO-8859-1 byte name + body _ic_dump_failure - uniform diagnostic dump (octal-escaped ls + log) Verification compares the source file content against the expected ISO-8859-1 dest path, which is the property that proves the daemon's iconv pipeline ran end-to-end. * test(interop): single-file iconv fixture isolates #1917 from #1913 Previous multi-file fixture exposed an unrelated bug: the receiver's flist ingest pipeline misaligns content with names when multiple files re-sort after iconv conversion (UTF-8 -> Latin-1). That is a separate bug (#1913 receiver flist ingest) and out of scope for the daemon charset directive PR. Replace the parallel-array fixture with a single-file fixture (cafe.txt, U+00E9) so the test only validates what #1917 fixes: the daemon's `charset =` directive activating ic_recv on the receiver to convert wire-UTF-8 filenames to disk-Latin-1 bytes. The multi-file scenario will be re-enabled once #1913 lands.
oferchen
added a commit
that referenced
this pull request
May 5, 2026
…arser (#3566) * test(interop): align iconv-local-ssh with upstream Latin-1 dest semantics PR #3554 redesigned the daemon iconv test (test_iconv_upstream_interop) to use a single-file Value Object that asserts the destination disk holds the ISO-8859-1 byte name (caf\xe9.txt), not the UTF-8 byte name (caf\xc3\xa9.txt). That redesign was missed for the SSH/local-mode test (test_iconv_local_ssh_interop, added separately in PR #3534), which still asserted UTF-8 dest names and failed in CI on a clean Linux host where ext4 happily stores the Latin-1 single-byte names upstream's ic_recv writes. Per upstream rsync.c:85-147 setup_iconv() and options.c:2716-2723 server_options(): with --iconv=UTF-8,ISO-8859-1, the client (charset UTF-8) keeps the LOCAL half and forwards the post-comma REMOTE half (ISO-8859-1) to the spawned peer. The spawned receiver opens ic_recv = iconv_open(charset, UTF8_CHARSET), so it transcodes UTF-8 wire bytes into single-byte Latin-1 on the local disk. The dest filename is therefore caf\xe9.txt, not caf\xc3\xa9.txt. Refactor test_iconv_local_ssh_interop to reuse the single-file Value Object helpers from the daemon test (_ic_init_fixtures / _ic_write_fixtures / _ic_verify_dest at run_interop.sh:3142-3175), expand the docblock to explain the am_server LOCAL/REMOTE split with explicit upstream references, and drop the multi-file UTF-8-expecting fixture that masked the real wire semantics. No production code changes; this fixes the test expectation only. * fix(cli): wire --iconv into server-mode flag parser Server mode previously dropped --iconv=CHARSET passed by the client, falling back to no transcoding. This broke --iconv=LOCAL,REMOTE transfers over SSH and local-shell where the on-disk filename encoding differs between sides: receiver/generator skipped the iconv hook and wrote/read wire UTF-8 bytes verbatim instead of transcoding to the server's local charset. Parse --iconv=VALUE in ServerLongFlags, resolve via IconvSetting, and assign to config.connection.iconv so receiver and generator pick up the converter. Mirrors the daemon path (daemon/sections/module_access/client_args.rs) and the SSH-client path (client/remote/flags.rs). upstream: rsync.c:85-147 setup_iconv() upstream: options.c:2716-2723 server-side iconv forwarding * fix(cli): recognise --timeout= in server-mode flag parser The server-mode argument parser did not recognise `--timeout=N`, so the flag was treated as a positional argument by `parse_server_flag_string_and_args` and consumed in place of the destination path. With the iconv-local-ssh scenario, strace showed the receiver creating `--timeout=10/` instead of `dest/` because upstream rsync emits `--timeout=10` after `--iconv=...` in the server arg list. Add `--timeout=` to `ServerLongFlags`, `parse_value_bearing_flag`, and `is_known_server_long_flag` so the flag is captured (its value remains unwired for now, matching the prior silent-drop behaviour) and excluded from positional extraction. upstream: options.c - server_options() emits `--timeout=%d` from io_timeout
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
Closes #1917. Bridges the parsed daemon module
charset =directive into the iconv runtime so--iconvfrom a client to an oc-rsync daemon actually transcodes filenames instead of silently no-op'ing.build_server_confignow resolvesmodule.charset()to aprotocol::iconv::FilenameConverterand assigns it toServerConfig.connection.iconv- the same field the SSH/local client path already populates atcrates/core/src/client/remote/flags.rs:228.resolve_module_charset_convertermirrors upstreamsetup_iconv()(rsync.c:87-140, clientserver.c:712-716): post-comma segment wins on the server side (rsync.c:118-120am_serverbranch),.and empty resolve to locale default (rsync.c:125-126), unknown charsets degrade toNonewith a tracing warning (lenient behaviour matchingIconvSetting::resolve_converteron the client side).iconvCargo feature on thedaemoncrate turns oncore/iconv+protocol/iconvsoencoding_rsis compiled in. Without the feature,FilenameConverter::newonly accepts UTF-8 and runtime behaviour is unchanged.standalone:iconv-upstreamfromKNOWN_FAILURESandDASHBOARD_ENTRIESintools/ci/known_failures.confso the existingtest_iconv_upstream_interopdaemon push test (tools/ci/run_interop.sh:3168,charset = ISO-8859-1,--iconv=UTF-8,ISO-8859-1) starts gating regressions.Tests
8 new unit tests in
crates/daemon/src/daemon/sections/module_access/client_args.rs::iconv_charset_converter_tests:iconv_charset_returns_none_for_missing_directiveiconv_charset_returns_none_for_empty_directiveiconv_charset_dot_means_locale_defaulticonv_charset_comma_with_dot_resolves_to_identityiconv_charset_resolves_simple_charset(iconv-gated)iconv_charset_uses_segment_after_comma(iconv-gated)iconv_charset_returns_none_for_unknown_charset(iconv-gated)iconv_charset_trims_whitespace(iconv-gated)iconv_charset_round_trip_latin1_utf8(iconv-gated; verifiescaf\xe9.txtLatin-1 -> UTF-8café.txtand back)Test plan
cargo nextest run -p daemon --all-features -E 'test(iconv)'(CI)cargo nextest run -p protocol --all-features -E 'test(iconv)'(CI)test_iconv_upstream_interopagainst rsync 3.4.1 (no longer in known-failures list)Upstream references
clientserver.c:712-716-iconv_opt = lp_charset(i); if (*iconv_opt) setup_iconv();rsync.c:87-140-setup_iconv()opensic_sendandic_recviconv handlesrsync.c:118-120- server side honours post-comma segmentrsync.c:125-126-./ empty means locale defaultloadparm.c-charsetmodule parameter