Repository navigation
fix: send the daemon -s argv split the way server_options() does - #8880
Merged
Merged
Conversation
Under -s an oc client sent "--secluded-args --iconv=REMOTE" in the first pass and repeated --server, --sender and the flag string in the protected args. An rsync 3.5.2 daemon parses that second --server, which clears iconv_opt (options.c:1535-1547), so rsync_module() closes the module charset converters (clientserver.c:1279-1289). filesfrom_convert then stays 0 (compat.c:820-826) and a forwarded --files-from list is looked up unconverted, exiting 23. The first pass is now what server_options() puts before its NULL (options.c:2850-2986): --server, --sender on a pull, the flag string with s first, and --iconv. The protected args are "rsync" plus only what follows (rsync.c:284-296). The daemon is sent the local charset, because a daemon client runs setup_iconv() before server_options() (clientserver.c:171-172, main.c:678-679) and rsync.c:119-123 truncates iconv_opt at the comma. --checksum-choice moves to its upstream place after --suffix (options.c:3052-3056). The remote-shell argv already matched and is unchanged.
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
Under
-s,server_options()builds--server,--sender(on a pull), the compact flag string withsas its first letter (options.c:2858-2859) and--iconv=...(options.c:2975-2983), then inserts aNULL(options.c:2985-2986).start_inband_exchange()sends the args before thatNULLin the first pass (clientserver.c:443-450).send_protected_args()then sendsrsyncand only the args after theNULL(rsync.c:284-296).A daemon client runs
setup_iconv()beforeserver_options()(clientserver.c:171-172 for a socket, main.c:678-679 beforestart_inband_exchange()over a remote shell).rsync.c:119-123truncatesiconv_optat the comma there, so the daemon is sent the local charset. A remote-shell server is different:main.c:624runsserver_options()beforesetup_iconv(), so it gets the post-comma half. oc already sends that correctly.Why the 3.5.2 daemon read the list unconverted
I captured the daemon's stdin with strace (
--iconv=UTF-8,ISO-8859-1 -s --files-from=list, modulecharset = ISO-8859-1):oc's second pass repeated
--server. The daemon's secondparse_arguments()handlesOPT_SERVERand setsiconv_opt = NULL(options.c:1535-1547).rsync_module()then sees noiconv_optand closes theic_send/ic_recvconverters that came from the modulecharset(clientserver.c:1279-1289). With no converters,filesfrom_convertstays 0 (compat.c:820-826). The daemon sender looked up the raw UTF-8 name and failed withlink_stat "caf\#303\#251" (in src) failed, which gives exit 23.The
--iconvvalue itself does not matter on the daemon, because its converters come only from the modulecharset(clientserver.c:763-768). Only the repeated--serverbreaks the transfer.The fix
Daemon client argv only (
orchestration/arguments.rs):sunder-s, and--iconv=follows it directly, as in upstream.--server,--senderon a pull, the flag string and--iconv. The protected args arersyncplus everything after it. Nothing from the first pass is repeated.--iconv=forwards the local charset (the pre-comma half).--checksum-choicemoves from before the flag string to after--suffix, its upstream position (options.c:3052-3056). It has to move out of the first-pass prefix.build_minimal_daemon_args(the old--secluded-argsfirst pass) is removed.The remote-shell argv already matched 3.5.2 for both pull and push (captured:
--server [--sender] -srRe.iLsfxCIvu --iconv=ISO-8859-1, thenrsync ... . path). It is unchanged.Measured (oc client, rsync 3.5.2 daemon over a remote shell, module charset ISO-8859-1)
-s-srRe.iLsfxCIvu --iconv=UTF-8/rsync --files-from=- --from0 . src/café--secluded-args --iconv=ISO-8859-1/rsync --server --sender -rRe... ...café-rRe.iLsfxCIvu --iconv=UTF-8 --files-from=- --from0 . src/-rRe... --files-from=- --from0 --iconv=ISO-8859-1 . src/Tests
crates/cli/tests/files_from_iconv_protect_args.rs: the skip of the oc client to rsync 3.5.2 daemon pairing under-sis removed, soa_daemon_pull_with_protect_args_converts_the_listnow covers it.a_daemon_pull_without_protect_args_sends_the_list_unconvertedcovers the case without-s.orchestration/tests.rs: four wire tests check the bytes sent for each pass: a protected pull's first pass (flag string withs, local--iconv), a protected pull's second pass (rsync . test/only), a protected push without iconv, and an unprotected pull with--iconvright after the flag string.arguments.rsto the base makes all 4 new unit tests fail, and makesa_daemon_pull_with_protect_args_converts_the_listfail in the oc client to rsync 3.5.2 daemon pairing (exit 23, nothing copied, where 3.5.2 gives exit 0 andcafé). With the fix all 8 cells pass withOC_RSYNC_UPSTREAM_COMPAT=1, and the daemonmodule_accesstests pass (342).Remaining differences (separate issues)
caf\357\277\275where 3.5.2 printscaf\#351).[receiver] cannot convert filenameplus extradelete_file/could not make waylines. 3.5.2 prints[sender] cannot convert filename.--secluded-args), so older oc clients keep working.Closes #8877