The branch, master has been updated via f44e76b6 Handle html link targets in a better way. via 1174d970 Fix `--old-args` interaction with a daemon via d9eaffe5 Complain about --old-args with --protect-args. via 6197385d More man & NEWS enhancements, including linking to env vars. from d07272d6 More man page and NEWS improvements.
https://git.samba.org/?p=rsync.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit f44e76b65c5819edb1a5b2fbbe732d5d214b35de Author: Wayne Davison <wa...@opencoder.net> Date: Mon Jan 17 17:59:18 2022 -0800 Handle html link targets in a better way. commit 1174d97072c0ebcfcf810b6d4ca26d7b277464ce Author: Wayne Davison <wa...@opencoder.net> Date: Mon Jan 17 17:12:43 2022 -0800 Fix `--old-args` interaction with a daemon Ensure that a remote rsync daemon will not split a filename arg unless the user asked for `--old-args`. commit d9eaffe5643328eaa465c19e34940c29ea470641 Author: Wayne Davison <wa...@opencoder.net> Date: Mon Jan 17 17:11:58 2022 -0800 Complain about --old-args with --protect-args. commit 6197385d1f83b75f12c85b5445f00a7c94b0bf3c Author: Wayne Davison <wa...@opencoder.net> Date: Mon Jan 17 17:10:08 2022 -0800 More man & NEWS enhancements, including linking to env vars. ----------------------------------------------------------------------- Summary of changes: NEWS.md | 3 +- clientserver.c | 40 +++++++-- main.c | 2 +- md-convert | 27 +++--- options.c | 12 ++- rsync-ssl.1.md | 2 +- rsync.1.md | 265 ++++++++++++++++++++++++++++++++++++--------------------- 7 files changed, 231 insertions(+), 120 deletions(-) Changeset truncated at 500 lines: diff --git a/NEWS.md b/NEWS.md index 4f2411b3..502d2d6c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -20,7 +20,8 @@ like the [`--suffix`](rsync.1#opt) and [`--usermap`](rsync.1#opt) values. If your rsync script depends on the old arg-splitting behavior, either run it with the [`--old-args`](rsync.1#opt) option or `export RSYNC_OLD_ARGS=1` - in the script's environment. + in the script's environment. See also the [ADVANCED USAGE](rsync.1#) + section of rsync's man page. - A long-standing bug was preventing rsync from figuring out the current locale's decimal point character, which made rsync always output numbers diff --git a/clientserver.c b/clientserver.c index 8e30f99f..66311d3e 100644 --- a/clientserver.c +++ b/clientserver.c @@ -47,6 +47,7 @@ extern int protocol_version; extern int io_timeout; extern int no_detach; extern int write_batch; +extern int old_style_args; extern int default_af_hint; extern int logfile_format_has_i; extern int logfile_format_has_o_or_i; @@ -288,20 +289,45 @@ int start_inband_exchange(int f_in, int f_out, const char *user, int argc, char sargs[sargc++] = "."; + if (!old_style_args) + snprintf(line, sizeof line, " %.*s/", modlen, modname); + while (argc > 0) { if (sargc >= MAX_ARGS - 1) { arg_overflow: rprintf(FERROR, "internal: args[] overflowed in do_cmd()\n"); exit_cleanup(RERR_SYNTAX); } - if (strncmp(*argv, modname, modlen) == 0 - && argv[0][modlen] == '\0') + if (strncmp(*argv, modname, modlen) == 0 && argv[0][modlen] == '\0') sargs[sargc++] = modname; /* we send "modname/" */ - else if (**argv == '-') { - if (asprintf(sargs + sargc++, "./%s", *argv) < 0) - out_of_memory("start_inband_exchange"); - } else - sargs[sargc++] = *argv; + else { + char *arg = *argv; + int extra_chars = *arg == '-' ? 2 : 0; /* a leading dash needs a "./" prefix. */ + /* If --old-args was not specified, make sure that the arg won't split at a mod name! */ + if (!old_style_args && (p = strstr(arg, line)) != NULL) { + do { + extra_chars += 2; + } while ((p = strstr(p+1, line)) != NULL); + } + if (extra_chars) { + char *f = arg; + char *t = arg = new_array(char, strlen(arg) + extra_chars + 1); + if (*f == '-') { + *t++ = '.'; + *t++ = '/'; + } + while (*f) { + if (*f == ' ' && strncmp(f, line, modlen+2) == 0) { + *t++ = '['; + *t++ = *f++; + *t++ = ']'; + } else + *t++ = *f++; + } + *t = '\0'; + } + sargs[sargc++] = arg; + } argv++; argc--; } diff --git a/main.c b/main.c index 31a28f51..9019a9e9 100644 --- a/main.c +++ b/main.c @@ -477,7 +477,7 @@ static void show_malloc_stats(void) #define PRINT_ALLOC_NUM(title, descr, num) \ rprintf(FINFO, " %-11s%10" SIZE_T_FMT_MOD "d (" descr ")\n", \ - title ":", (SIZE_T_FMT_CAST)(num)); + title ":", (SIZE_T_FMT_CAST)(num)); PRINT_ALLOC_NUM("arena", "bytes from sbrk", mi.arena); PRINT_ALLOC_NUM("ordblks", "chunks not in use", mi.ordblks); diff --git a/md-convert b/md-convert index 9275d874..ffe9b289 100755 --- a/md-convert +++ b/md-convert @@ -49,7 +49,7 @@ body { body, b, strong, u { font-family: 'Roboto', sans-serif; } -a.tgt { font-face: symbol; font-weight: 400; font-size: 70%; visibility: hidden; text-decoration: none; color: #ddd; padding: 0 4px; border: 0; vertical-align: top; } +a.tgt { font-face: symbol; font-weight: 400; font-size: 70%; visibility: hidden; text-decoration: none; color: #ddd; padding: 0 4px; border: 0; } a.tgt:after { content: 'ð'; } a.tgt:hover { color: #444; background-color: #eaeaea; } h1:hover > a.tgt, h2:hover > a.tgt, h3:hover > a.tgt, dt:hover > a.tgt { visibility: visible; } @@ -419,20 +419,20 @@ class TransformHtml(HTMLParser): if m: tgt = m.group(1) st.target_suf = '-' + tgt - self.add_targets(tgt) + self.add_targets(tag, tgt) elif tag == 'h2': st.man_out.append(st.p_macro + '.SH "' + manify(txt) + '"\n') - self.add_targets(txt, st.target_suf) + self.add_targets(tag, txt, st.target_suf) st.opt_prefix = 'dopt' if txt == 'DAEMON OPTIONS' else 'opt' elif tag == 'h3': st.man_out.append(st.p_macro + '.SS "' + manify(txt) + '"\n') - self.add_targets(txt, st.target_suf) + self.add_targets(tag, txt, st.target_suf) elif tag == 'p': if st.dt_from == 'p': tag = 'dt' st.man_out.append('.IP "' + manify(txt) + '"\n') if txt.startswith(BOLD_FONT[0]): - self.add_targets(txt) + self.add_targets(tag, txt) st.dt_from = None elif txt != '': st.man_out.append(manify(txt) + "\n") @@ -519,12 +519,13 @@ class TransformHtml(HTMLParser): st.txt += txt - def add_targets(self, txt, suf=None): + def add_targets(self, tag, txt, suf=None): st = self.state + tag = '<' + tag + '>' targets = CODE_BLOCK_RE.findall(txt) if not targets: targets = [ txt ] - first_one = True + tag_pos = 0 for txt in targets: txt = txt2target(txt, st.opt_prefix) if not txt: @@ -538,11 +539,15 @@ class TransformHtml(HTMLParser): print('Made link target unique:', chk) txt = chk break - if first_one: - st.html_out.append('<a id="' + txt + '" href="#' + txt + '" class="tgt"></a>') - first_one = False + if tag_pos == 0: + tag_pos -= 1 + while st.html_out[tag_pos] != tag: + tag_pos -= 1 + st.html_out[tag_pos] = tag[:-1] + ' id="' + txt + '">' + st.html_out.append('<a href="#' + txt + '" class="tgt"></a>') + tag_pos -= 1 # take into account the append else: - st.html_out.append('<span id="' + txt + '"></span>') + st.html_out[tag_pos] = '<span id="' + txt + '"></span>' + st.html_out[tag_pos] st.created_hashtags.add(txt) st.latest_targets = targets diff --git a/options.c b/options.c index 0a7b4cc7..d08f0003 100644 --- a/options.c +++ b/options.c @@ -1933,10 +1933,18 @@ int parse_arguments(int *argc_p, const char ***argv_p) } if (old_style_args < 0) { - if (!am_server && (arg = getenv("RSYNC_OLD_ARGS")) != NULL && *arg) + if (!am_server && protect_args <= 0 && (arg = getenv("RSYNC_OLD_ARGS")) != NULL && *arg) { + protect_args = 0; old_style_args = atoi(arg); - else + } else old_style_args = 0; + } else if (old_style_args) { + if (protect_args > 0) { + snprintf(err_buf, sizeof err_buf, + "--protect-args conflicts with --old-args.\n"); + return 0; + } + protect_args = 0; } if (protect_args < 0) { diff --git a/rsync-ssl.1.md b/rsync-ssl.1.md index c0aedb20..8170c1ac 100644 --- a/rsync-ssl.1.md +++ b/rsync-ssl.1.md @@ -9,7 +9,7 @@ rsync-ssl [--type=SSL_TYPE] RSYNC_ARGS ``` The online version of this man page (that includes cross-linking of topics) -is available at <https://download.samba.org/pub/rsync/rsync.1>. +is available at <https://download.samba.org/pub/rsync/rsync-ssl.1>. ## DESCRIPTION diff --git a/rsync.1.md b/rsync.1.md index 3e967be0..703d0f17 100644 --- a/rsync.1.md +++ b/rsync.1.md @@ -93,7 +93,7 @@ communications, but it may have been configured to use a different remote shell by default, such as rsh or remsh. You can also specify any remote shell you like, either by using the [`-e`](#opt) -command line option, or by setting the RSYNC_RSH environment variable. +command line option, or by setting the [`RSYNC_RSH`](#) environment variable. Note that rsync must be installed on both the source and destination machines. @@ -160,19 +160,24 @@ The syntax for requesting multiple files from a remote host is done by specifying additional remote-host args in the same style as the first, or with the hostname omitted. For instance, all these work: -> rsync -av host:file1 :file2 host:file{3,4} /dest/ -> rsync -av host::modname/file{1,2} host::modname/file3 /dest/ -> rsync -av host::modname/file1 ::modname/file{3,4} /dest/ +> rsync -aiv host:file1 :file2 host:file{3,4} /dest/ +> rsync -aiv host::modname/file{1,2} host::modname/extra /dest/ +> rsync -aiv host::modname/first ::modname/extra{1,2} /dest/ -**Older versions of rsync** required using quoted spaces in the SRC, like these -examples: +In a modern rsync, you only need to quote or backslash-escape things like +spaces from the local shell but not also from the remote shell: -> rsync -av host:'dir1/file1 dir2/file2' /dest -> rsync host::'modname/dir1/file1 modname/dir2/file2' /dest +> rsync -aiv host:'a simple file.pdf' /dest/ -This word-splitting only works in a modern rsync by using [`--old-args`](#opt) -(or its environment variable) and making sure that [`--protect-args`](#opt) is -not enabled. +Older versions of rsync only allowed specifying one remote-source arg, so it +required the remote side to split the args at a space. You can still get this +old-style arg splitting by using the [`--old-args`](#opt) option: + +> rsync -ai --old-args host:'dir1/file1 dir2/file2' /dest +> rsync -ai --old-args host::'modname/dir1/file1 modname/dir2/file2' /dest + +See that option's section for an environment variable that can be exported to +help old scripts. ## CONNECTING TO AN RSYNC DAEMON @@ -203,22 +208,23 @@ An example that copies all the files in a remote module named "src": Some modules on the remote daemon may require authentication. If so, you will receive a password prompt when you connect. You can avoid the password prompt -by setting the environment variable RSYNC_PASSWORD to the password you want to -use or using the [`--password-file`](#opt) option. This may be useful when -scripting rsync. +by setting the environment variable [`RSYNC_PASSWORD`](#) to the password you +want to use or using the [`--password-file`](#opt) option. This may be useful +when scripting rsync. WARNING: On some systems environment variables are visible to all users. On those systems using [`--password-file`](#opt) is recommended. You may establish the connection via a web proxy by setting the environment -variable RSYNC_PROXY to a hostname:port pair pointing to your web proxy. Note -that your web proxy's configuration must support proxy connections to port 873. +variable [`RSYNC_PROXY`](#) to a hostname:port pair pointing to your web proxy. +Note that your web proxy's configuration must support proxy connections to port +873. You may also establish a daemon connection using a program as a proxy by -setting the environment variable RSYNC_CONNECT_PROG to the commands you wish to -run in place of making a direct socket connection. The string may contain the -escape "%H" to represent the hostname specified in the rsync command (so use -"%%" if you need a single "%" in your string). For example: +setting the environment variable [`RSYNC_CONNECT_PROG`](#) to the commands you +wish to run in place of making a direct socket connection. The string may +contain the escape "%H" to represent the hostname specified in the rsync +command (so use "%%" if you need a single "%" in your string). For example: > export RSYNC_CONNECT_PROG='ssh proxyhost nc %H 873' > rsync -av targethost1::module/src/ /dest/ @@ -227,9 +233,9 @@ escape "%H" to represent the hostname specified in the rsync command (so use The command specified above uses ssh to run nc (netcat) on a proxyhost, which forwards all data to port 873 (the rsync daemon) on the targethost (%H). -Note also that if the RSYNC_SHELL environment variable is set, that program -will be used to run the RSYNC_CONNECT_PROG command instead of using the default -shell of the **system()** call. +Note also that if the [`RSYNC_SHELL`](#) environment variable is set, that +program will be used to run the `RSYNC_CONNECT_PROG` command instead of using +the default shell of the **system()** call. ## USING RSYNC-DAEMON FEATURES VIA A REMOTE-SHELL CONNECTION @@ -1681,14 +1687,14 @@ your home directory (remove the '=' for that). and various flavors of MD4 based on protocol age). The default order can be customized by setting the environment variable - RSYNC_CHECKSUM_LIST to a space-separated list of acceptable checksum names. - If the string contains a "`&`" character, it is separated into the "client - string & server string", otherwise the same string - applies to both. If the string (or string portion) contains no - non-whitespace characters, the default checksum list is used. This method - does not allow you to specify the transfer checksum separately from the - pre-transfer checksum, and it discards "auto" and all unknown checksum - names. A list with only invalid names results in a failed negotiation. + [`RSYNC_CHECKSUM_LIST`](#) to a space-separated list of acceptable checksum + names. If the string contains a "`&`" character, it is separated into the + "client string & server string", otherwise the same string applies to both. + If the string (or string portion) contains no non-whitespace characters, + the default checksum list is used. This method does not allow you to + specify the transfer checksum separately from the pre-transfer checksum, + and it discards "auto" and all unknown checksum names. A list with only + invalid names results in a failed negotiation. The use of the `--checksum-choice` option overrides this environment list. @@ -1972,11 +1978,12 @@ your home directory (remove the '=' for that). Beginning in 3.2.3, a value of 0 specifies no limit. - You can set a default value using the environment variable RSYNC_MAX_ALLOC - using the same SIZE values as supported by this option. If the remote - rsync doesn't understand the `--max-alloc` option, you can override an - environmental value by specifying `--max-alloc=1g`, which will make rsync - avoid sending the option to the remote side (because "1G" is the default). + You can set a default value using the environment variable + [`RSYNC_MAX_ALLOC`](#) using the same SIZE values as supported by this + option. If the remote rsync doesn't understand the `--max-alloc` option, + you can override an environmental value by specifying `--max-alloc=1g`, + which will make rsync avoid sending the option to the remote side (because + "1G" is the default). 0. `--block-size=SIZE`, `-B` @@ -2001,10 +2008,10 @@ your home directory (remove the '=' for that). remote host. See the [USING RSYNC-DAEMON FEATURES VIA A REMOTE-SHELL CONNECTION](#) section above. - Beginning with rsync 3.2.0, the RSYNC_PORT environment variable will be set - when a daemon connection is being made via a remote-shell connection. It - is set to 0 if the default daemon port is being assumed, or it is set to - the value of the rsync port that was specified via either the + Beginning with rsync 3.2.0, the [`RSYNC_PORT`](#) environment variable will + be set when a daemon connection is being made via a remote-shell + connection. It is set to 0 if the default daemon port is being assumed, or + it is set to the value of the rsync port that was specified via either the [`--port`](#opt) option or a non-empty port value in an `rsync://` URL. This allows the script to discern if a non-default port is being requested, allowing for things such as an SSL or stunnel helper script to connect to a @@ -2025,7 +2032,7 @@ your home directory (remove the '=' for that). (Note that ssh users can alternately customize site-specific connect options in their .ssh/config file.) - You can also choose the remote shell program using the RSYNC_RSH + You can also choose the remote shell program using the [`RSYNC_RSH`](#) environment variable, which accepts the same range of values as `-e`. See also the [`--blocking-io`](#opt) option which is affected by this @@ -2287,25 +2294,28 @@ your home directory (remove the '=' for that). 0. `--old-args` - This option tells rsync to stop trying to protect the arg values from - unintended word-splitting or other misinterpretation by using its new - backslash-escape idiom. The newest default is for remote filenames to only - allow wildcards characters to be interpretated by the shell while - protecting other shell-interpreted characters (and the args of options get - even wildcards escaped). The only active wildcard characters on the remote - side are: `*`, `?`, `[`, & `]`. + This option tells rsync to stop trying to protect the arg values on the + remote side from unintended word-splitting or other misinterpretation. - If you have a script that wants to use old-style arg splitting in the + The default in a modern rsync is for "shell-active" characters (including + spaces) to be backslash-escaped in the args that are sent to the remote + shell. The wildcard characters `*`, `?`, `[`, & `]` are not escaped in + filename args (allowing them to expand into multiple filenames) while being + protected in option args, such as [`--usermap`](#opt). + + If you have a script that wants to use old-style arg splitting in its filenames, specify this option once. If the remote shell has a problem - with any backslash escapes, specify the option twice. + with any backslash escapes at all, specify this option twice. - You may also control this setting via the RSYNC_OLD_ARGS environment + You may also control this setting via the [`RSYNC_OLD_ARGS`](#) environment variable. If it has the value "1", rsync will default to a single-option setting. If it has the value "2" (or more), rsync will default to a repeated-option setting. If it is "0", you'll get the default escaping behavior. The environment is always overridden by manually specified positive or negative options (the negative is `--no-old-args`). + This option conflicts with the [`--protect-args`](#opt) option. + 0. `--protect-args`, `-s` This option sends all filenames and most options to the remote rsync @@ -2321,16 +2331,19 @@ your home directory (remove the '=' for that). character-set. The translation happens before wild-cards are expanded. See also the [`--files-from`](#opt) option. - You may also control this setting via the RSYNC_PROTECT_ARGS environment - variable. If it has a non-zero value, this setting will be + You may also control this setting via the [`RSYNC_PROTECT_ARGS`)(#) + environment variable. If it has a non-zero value, this setting will be enabled by default, otherwise it will be disabled by default. Either state is overridden by a manually specified positive or negative version of this option (note that `--no-s` and `--no-protect-args` are the negative - versions). + versions). This environment variable is also superseded by a non-zero + [`RSYNC_OLD_ARGS`](#) export. You may need to disable this option when interacting with an older rsync (one prior to 3.0.0). + This option conflicts with the [`--old-args`](#opt) option. + Note that this option is incompatible with the use of the restricted rsync script (`rrsync`) since it hides options from the script's inspection. @@ -2530,10 +2543,10 @@ your home directory (remove the '=' for that). its list is assumed to be "zlib". The default order can be customized by setting the environment variable - RSYNC_COMPRESS_LIST to a space-separated list of acceptable compression - names. If the string contains a "`&`" character, it is separated into the - "client string & server string", otherwise the same string applies to both. - If the string (or string portion) contains no + [`RSYNC_COMPRESS_LIST`](#) to a space-separated list of acceptable + compression names. If the string contains a "`&`" character, it is + separated into the "client string & server string", otherwise the same + string applies to both. If the string (or string portion) contains no non-whitespace characters, the default compress list is used. Any unknown compression names are discarded from the list, but a list with only invalid names results in a failed negotiation. @@ -3122,32 +3135,34 @@ your home directory (remove the '=' for that). 0. `--partial-dir=DIR` - A better way to keep partial files than the [`--partial`](#opt) option is - to specify a _DIR_ that will be used to hold the partial data (instead of - writing it out to the destination file). On the next transfer, rsync will - use a file found in this dir as data to speed up the resumption of the + This option modifies the behavior of the [`--partial`](#opt) option while + also implying that it be enabled. This enhanced partial-file method puts + any partially transferred files into the specified _DIR_ instead of writing + the partial file out to the destination file. On the next transfer, rsync + will use a file found in this dir as data to speed up the resumption of the transfer and then delete it after it has served its purpose. Note that if [`--whole-file`](#opt) is specified (or implied), any - partial-dir file that is found for a file that is being updated will simply - be removed (since rsync is sending files without using rsync's + partial-dir files that are found for a file that is being updated will + simply be removed (since rsync is sending files without using rsync's delta-transfer algorithm). - Rsync will create the _DIR_ if it is missing (just the last dir -- not the - whole path). This makes it easy to use a relative path (such as + Rsync will create the _DIR_ if it is missing, but just the last dir -- not + the whole path. This makes it easy to use a relative path (such as "`--partial-dir=.rsync-partial`") to have rsync create the - partial-directory in the destination file's directory when needed, and then - remove it again when the partial file is deleted. Note that the directory - is only removed if it is a relative pathname, as it is expected that an - absolute path is to a directory that is reserved for partial-dir work. + partial-directory in the destination file's directory when it is needed, + and then remove it again when the partial file is deleted. Note that this + directory removal is only done for a relative pathname, as it is expected + that an absolute path is to a directory that is reserved for partial-dir + work. If the partial-dir value is not an absolute path, rsync will add an exclude rule at the end of all your existing excludes. This will prevent the sending of any partial-dir files that may exist on the sending side, and will also prevent the untimely deletion of partial-dir items on the receiving side. An example: the above `--partial-dir` option would add the - equivalent of "`-f '-p .rsync-partial/'`" at the end of any other filter - rules. + equivalent of this "perishable" exclude at the end of any other filter + rules: `-f '-p .rsync-partial/'` If you are supplying your own exclude rules, you may need to add your own exclude/hide/protect rule for the partial-dir because: @@ -3163,17 +3178,17 @@ your home directory (remove the '=' for that). run. IMPORTANT: the `--partial-dir` should not be writable by other users or it - is a security risk. E.g. AVOID "/tmp". + is a security risk! E.g. AVOID "/tmp"! - You can also set the partial-dir value the RSYNC_PARTIAL_DIR environment - variable. Setting this in the environment does not force + You can also set the partial-dir value the [`RSYNC_PARTIAL_DIR`](#) + environment variable. Setting this in the environment does not force -- The rsync repository.
_______________________________________________ rsync-cvs mailing list rsync-cvs@lists.samba.org https://lists.samba.org/mailman/listinfo/rsync-cvs