Repository navigation
fix: convert a forwarded --files-from list only under -s - #8874
Merged
Merged
Conversation
rsync 3.5.2 converts a --files-from list carried over the connection only when protect_args is set: compat.c:820-827 gates filesfrom_convert on protect_args && files_from, and io.c:502 (forwarding) and flist.c:2766 (reading) consult it. An oc sender converted the list whenever --iconv was set, so a 3.5.2 client pulling without -s got a file 3.5.2 reports missing. An oc server receiver never converted a list it opened, so a 3.5.2 client pushing with --files-from=:list and -s missed its file. ConnectionConfig now carries protect_args, set from the server's -s (main.c:1960-1962), the daemon client's option args (clientserver.c:1165-1167) and the client's own option, and files_from_converter() yields the converter only under it. Both directions now use the ICB_INCLUDE_BAD converters (io.c:505, io.c:1462): valid characters are converted and each bad byte is copied through (rsync.c:262), where the strict path kept the whole name raw.
APFS and HFS+ refuse a name that is not valid UTF-8 (EILSEQ), so the ISO-8859-1 fixture cannot be created there and every cell panicked on macOS before reaching the transfer. Also wrap a line rustfmt splits.
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.
What rsync 3.5.2 does
A
--files-fromlist carried over the connection is converted with--iconvonly under--protect-args/--secluded-args:compat.c:820-827-if (protect_args && files_from)setsfilesfrom_convert:filesfrom_host && ic_send != -1on the sender,!filesfrom_host && ic_recv != -1on the receiver.io.c:502-forward_filesfrom_data()converts each forwarded name withic_sendonly underfilesfrom_convert.flist.c:2766-send_file_list()addsRL_CONVERTto itsread_line()flags only underfilesfrom_convert.io.c:505andio.c:1462- both conversions useICB_INCLUDE_BAD, which converts what it can and copies each unconvertible byte through verbatim (rsync.c:262).A server learns
protect_argsfrom the client's-s(main.c:1960-1962over a remote shell,clientserver.c:1165-1167on a daemon).What oc did
--files-from=-) converted it whenever--iconvwas set, with or without-s. Against a 3.5.2 client pulling without-s, oc copied a file 3.5.2 reports missing.--files-from=:liston a push) never converted it, even under-s, so a 3.5.2 client pushing with-smissed its file.The fix
ConnectionConfiggainsprotect_args, set by the remote-shell server from its-sdetection, by the daemon from the client's option args, and by the client from its resolved--protect-args.ConnectionConfig::files_from_converter()returns the--iconvconverter only underprotect_args. Both the reading sender and the forwarding server receiver use it.forward_files_fromandread_files_from_streamuse theICB_INCLUDE_BADconverters (local_to_remote_lossy/remote_to_local_lossy), which already exist forread_line(RL_CONVERT)and secluded args.The implied-include code is not touched.
Measured (host, glibc)
Client
--iconv=UTF-8,ISO-8859-1over a remote shell.latin1iscafé: UTF-8 on the client, ISO-8859-1 on the server.badisbad\xff. A local list is in the client's charset, a remote (:list) list in the server's. Each cell shows the exit code and what reached the destination.After the fix, all 16 cells of the 3.5.2-client, oc-server pairing match 3.5.2 exactly, and so do the oc-to-oc exit codes and destinations. Both binaries were built from this branch and its base in a target dir used by this branch alone.
The exit-4
badpull cells are the receiver rejecting the converted name as unrequested. 3.5.2 does the same, and that path is the implied-include check, which this change leaves alone.Tests
crates/cli/tests/files_from_iconv_protect_args.rs(new, 8 cells): pull, push from a remote list, daemon pull withcharset = ISO-8859-1, and a push from an ISO-8859-1 client, each with and without-s. The expected values are the 3.5.2 results. WithOC_RSYNC_UPSTREAM_COMPAT=1each cell also runs 3.5.2 at both ends and with one end each.generator::tests::files_from- a stream name is looked up unconverted withoutprotect_argsand converted with it.files_from_forwarding_framing_tests- a server receiver forwards unconverted withoutprotect_argsand converted with it.protocol::files_from- a name holding one invalid byte has its valid characters converted and the bad byte copied, on both the forward and the read side.Mutation results (each fix site reverted on its own; each revert fails at least one new test):
filters.rs)-scontext.rs)-sICB_INCLUDE_BADconversion (files_from.rs)-swiring (run.rs)-s-swiring (server_config.rs)-sprotect_argswiring (flags.rs)-sRemaining differences (not fixed here)
-spulling from a 3.5.2 daemon reads the list unconverted and exits 23, where 3.5.2 at both ends exits 0. The behaviour is the same before this change. The oc client sends--secluded-args --iconv=ISO-8859-1in the first pass, while 3.5.2 sends-sinside its flag string and--iconv=UTF-8(its client truncatesiconv_optinsetup_iconv(),rsync.c:119-123, beforeserver_options()runs). The test leaves out that one pairing and says so in a comment.link_statline showscaf\357\277\275where 3.5.2 printscaf\#351. The lookup used the raw bytes, and the exit code and result match. Only the message text is lossy, because sender diagnostics are built as RustStrings.bad\xff): exit 23 matches, but oc reports[receiver] cannot convert filenameplus extradelete_file/could not make waylines, where 3.5.2 reports[sender] cannot convert filename. That is flist iconv, not files-from.Closes #8864