mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-05-25 15:25:30 -04:00
Compare commits
126 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c8ca91c73 | ||
|
|
079e74a30f | ||
|
|
abc3c74652 | ||
|
|
99ab59464b | ||
|
|
a47ae6fad9 | ||
|
|
2f9b963aba | ||
|
|
3476caea3e | ||
|
|
6f3c5eccee | ||
|
|
79fda35342 | ||
|
|
cd76993461 | ||
|
|
05a683900f | ||
|
|
86f41650fb | ||
|
|
9a06b2edb0 | ||
|
|
273dced284 | ||
|
|
b6e2321973 | ||
|
|
fe95a9369a | ||
|
|
6ae7f4085a | ||
|
|
0f599d3641 | ||
|
|
c3d3b49d72 | ||
|
|
c69dc7a5ab | ||
|
|
2c82006b1f | ||
|
|
0698ea9aeb | ||
|
|
90df93e446 | ||
|
|
5c93dedf45 | ||
|
|
f1e3434b59 | ||
|
|
48252c3c2b | ||
|
|
5b67ff2a86 | ||
|
|
8990ad96de | ||
|
|
0f44e864d4 | ||
|
|
ab0d5021ed | ||
|
|
7402896523 | ||
|
|
5374994089 | ||
|
|
526366129a | ||
|
|
556a2c5bc2 | ||
|
|
27feda0436 | ||
|
|
bf96cd314c | ||
|
|
1b2688807d | ||
|
|
08ec80ac65 | ||
|
|
6b5ae825db | ||
|
|
3b719d1d6e | ||
|
|
ebe1af749c | ||
|
|
de6848ed97 | ||
|
|
42f8386823 | ||
|
|
ad6245f394 | ||
|
|
ca980b5863 | ||
|
|
677aa0dc91 | ||
|
|
025596757c | ||
|
|
449d9bf950 | ||
|
|
35ecec972a | ||
|
|
d76cabe54f | ||
|
|
b5544a95b1 | ||
|
|
11bd2a4fd6 | ||
|
|
6ba434de5c | ||
|
|
3296351442 | ||
|
|
0088a85aeb | ||
|
|
4923c4dc0c | ||
|
|
76c4fa8b54 | ||
|
|
25efa10802 | ||
|
|
fdf5e577f5 | ||
|
|
19bd0dd340 | ||
|
|
ed4b3448be | ||
|
|
4d44bf122d | ||
|
|
6af27a538e | ||
|
|
f9e29dfb09 | ||
|
|
591de7ce5c | ||
|
|
c8c627756a | ||
|
|
46884e4ff6 | ||
|
|
97e02bf21a | ||
|
|
77d762ced8 | ||
|
|
5b27d2e6f3 | ||
|
|
7e634f5355 | ||
|
|
8fe8cfd60a | ||
|
|
7a2dbf7177 | ||
|
|
8449539a0f | ||
|
|
71c2b5d0e3 | ||
|
|
f3f5d8420f | ||
|
|
8b1b81e054 | ||
|
|
e8161304f7 | ||
|
|
b012cde1ed | ||
|
|
464555ea92 | ||
|
|
df904f590e | ||
|
|
208d6ad1cd | ||
|
|
51dae12c92 | ||
|
|
950730313d | ||
|
|
81c5c81381 | ||
|
|
a6a0d2f77c | ||
|
|
418e38a878 | ||
|
|
b2dcabdbb9 | ||
|
|
ad53a9b5a0 | ||
|
|
1750288660 | ||
|
|
087fffaa2b | ||
|
|
5c1fa2a21d | ||
|
|
0efa63f2e6 | ||
|
|
ae16850dc5 | ||
|
|
7e2711bb2b | ||
|
|
b8c2fde3a5 | ||
|
|
1f12b196fd | ||
|
|
bafe73dd5c | ||
|
|
db5bfe67a5 | ||
|
|
5447d038c6 | ||
|
|
711773631b | ||
|
|
bf3e49b453 | ||
|
|
034d5e8770 | ||
|
|
ad8917437a | ||
|
|
1b664d30e4 | ||
|
|
ea38f34d02 | ||
|
|
44d4727664 | ||
|
|
1f2f413167 | ||
|
|
0a09df2c5e | ||
|
|
cc861cf8c0 | ||
|
|
5183c0d6f0 | ||
|
|
706bff9176 | ||
|
|
2c1204032b | ||
|
|
8adc2240e0 | ||
|
|
84ad83525b | ||
|
|
9a3449a398 | ||
|
|
3258534e99 | ||
|
|
b94bba4036 | ||
|
|
a182507bef | ||
|
|
2895b65f53 | ||
|
|
def595c559 | ||
|
|
68b1ce1dc3 | ||
|
|
5a4116e553 | ||
|
|
024bf1d831 | ||
|
|
db4f919ebe | ||
|
|
6ac2c7b682 |
@@ -1,7 +1,7 @@
|
||||
freebsd_task:
|
||||
name: FreeBSD
|
||||
freebsd_instance:
|
||||
image_family: freebsd-13-0
|
||||
image_family: freebsd-13-1
|
||||
env:
|
||||
PATH: /usr/local/bin:$PATH
|
||||
prep_script:
|
||||
|
||||
12
.github/workflows/build.yml
vendored
12
.github/workflows/build.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
||||
ubuntu-build:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: prep
|
||||
run: |
|
||||
sudo apt-get install acl libacl1-dev attr libattr1-dev liblz4-dev libzstd-dev libxxhash-dev python3-cmarkgfm openssl wget
|
||||
@@ -38,7 +38,7 @@ jobs:
|
||||
- name: ssl file list
|
||||
run: rsync-ssl --no-motd download.samba.org::rsyncftp/ || true
|
||||
- name: save artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ubuntu-bin
|
||||
path: |
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
macos-build:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: prep
|
||||
run: |
|
||||
brew install automake openssl xxhash zstd lz4 wget
|
||||
@@ -73,7 +73,7 @@ jobs:
|
||||
- name: ssl file list
|
||||
run: rsync-ssl --no-motd download.samba.org::rsyncftp/ || true
|
||||
- name: save artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: macos-bin
|
||||
path: |
|
||||
@@ -89,7 +89,7 @@ jobs:
|
||||
runs-on: windows-2022
|
||||
if: (github.event_name == 'schedule' || contains(github.event.head_commit.message, '[buildall]'))
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: cygwin
|
||||
run: choco install -y --no-progress cygwin cyg-get
|
||||
- name: prep
|
||||
@@ -112,7 +112,7 @@ jobs:
|
||||
- name: ssl file list
|
||||
run: bash -c 'PATH="/usr/local/bin:$PATH" rsync-ssl --no-motd download.samba.org::rsyncftp/ || true'
|
||||
- name: save artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: cygwin-bin
|
||||
path: |
|
||||
|
||||
@@ -70,6 +70,8 @@ CHECK_OBJS=tls.o testrun.o getgroups.o getfsdev.o t_stub.o t_unsafe.o trimslash.
|
||||
$(CC) -I. -I$(srcdir) $(CFLAGS) $(CPPFLAGS) -c $< @CC_SHOBJ_FLAG@
|
||||
@OBJ_RESTORE@
|
||||
|
||||
# NOTE: consider running "packaging/smart-make" instead of "make" to auto-handle
|
||||
# any changes to configure.sh and the main Makefile prior to a "make all".
|
||||
all: Makefile rsync$(EXEEXT) stunnel-rsyncd.conf @MAKE_RRSYNC@ @MAKE_MAN@
|
||||
.PHONY: all
|
||||
|
||||
|
||||
242
NEWS.md
242
NEWS.md
@@ -1,3 +1,219 @@
|
||||
# NEWS for rsync 3.3.0 (6 Apr 2024)
|
||||
|
||||
## Changes in this version:
|
||||
|
||||
### BUG FIXES:
|
||||
|
||||
- Fixed a bug with `--sparse --inplace` where a trailing gap in the source
|
||||
file would not clear out the trailing data in the destination file.
|
||||
|
||||
- Fixed an buffer overflow in the checksum2 code if SHA1 is being used for
|
||||
the checksum2 algorithm.
|
||||
|
||||
- Fixed an issue when rsync is compiled using `_FORTIFY_SOURCE` so that the
|
||||
extra tests don't complain about a strlcpy() limit value (which was too
|
||||
large, even though it wasn't possible for the larger value to cause an
|
||||
overflow).
|
||||
|
||||
- Add a backtick to the list of characters that the filename quoting needs to
|
||||
escape using backslashes.
|
||||
|
||||
- Fixed a string-comparison issue in the internal handling of `--progress` (a
|
||||
locale such as tr_TR.utf-8 needed the internal triggering of `--info` options
|
||||
to use upper-case flag names to ensure that they match).
|
||||
|
||||
- Make sure that a local transfer marks the sender side as trusted.
|
||||
|
||||
- Change the argv handling to work with a newer popt library -- one that likes
|
||||
to free more data than it used to.
|
||||
|
||||
- Rsync now calls `OpenSSL_add_all_algorithms()` when compiled against an older
|
||||
openssl library.
|
||||
|
||||
- Fixed a problem in the daemon auth for older protocols (29 and before) if the
|
||||
openssl library is being used to compute MD4 checksums.
|
||||
|
||||
- Fixed `rsync -VV` on Cygwin -- it needed a flush of stdout.
|
||||
|
||||
- Fixed an old stats bug that counted devices as symlinks.
|
||||
|
||||
### ENHANCEMENTS:
|
||||
|
||||
- Enhanced rrsync with the `-no-overwrite` option that allows you to ensure
|
||||
that existing files on your restricted but writable directory can't be
|
||||
modified.
|
||||
|
||||
- Enhanced the manpages to mark links with .UR & .UE. If your nroff doesn't
|
||||
support these idioms, touch the file `.md2man-force` in the source directory
|
||||
so that `md-convert` gets called with the `--force-link-text` option, and
|
||||
that should ensure that your manpages are still readable even with the
|
||||
ignored markup.
|
||||
|
||||
- Some manpage improvements on the handling of [global] modules.
|
||||
|
||||
- Changed the mapfrom & mapto perl scripts (in the support dir) into a single
|
||||
python script named idmap. Converted a couple more perl scripts into python.
|
||||
|
||||
- Changed the mnt-excl perl script (in the support dir) into a python script.
|
||||
|
||||
### DEVELOPER RELATED:
|
||||
|
||||
- Updated config.guess (timestamp 2023-01-01) and config.sub (timestamp
|
||||
2023-01-21).
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
# NEWS for rsync 3.2.7 (20 Oct 2022)
|
||||
|
||||
## Changes in this version:
|
||||
|
||||
### BUG FIXES:
|
||||
|
||||
- Fixed the client-side validating of the remote sender's filtering behavior.
|
||||
|
||||
- More fixes for the "unrequested file-list name" name, including a copy of
|
||||
"/" with `--relative` enabled and a copy with a lot of related paths with
|
||||
`--relative` enabled (often derived from a `--files-from` list).
|
||||
|
||||
- When rsync gets an unpack error on an ACL, mention the filename.
|
||||
|
||||
- Avoid over-setting sanitize_paths when a daemon is serving "/" (even if
|
||||
"use chroot" is false).
|
||||
|
||||
### ENHANCEMENTS:
|
||||
|
||||
- Added negotiated daemon-auth support that allows a stronger checksum digest
|
||||
to be used to validate a user's login to the daemon. Added SHA512, SHA256,
|
||||
and SHA1 digests to MD5 & MD4. These new digests are at the highest priority
|
||||
in the new daemon-auth negotiation list.
|
||||
|
||||
- Added support for the SHA1 digest in file checksums. While this tends to be
|
||||
overkill, it is available if someone really needs it. This overly-long
|
||||
checksum is at the lowest priority in the normal checksum negotiation list.
|
||||
See [`--checksum-choice`](rsync.1#opt) (`--cc`) and the `RSYNC_CHECKSUM_LIST`
|
||||
environment var for how to customize this.
|
||||
|
||||
- Improved the xattr hash table to use a 64-bit key without slowing down the
|
||||
key's computation. This should make extra sure that a hash collision doesn't
|
||||
happen.
|
||||
|
||||
- If the `--version` option is repeated (e.g. `-VV`) then the information is
|
||||
output in a (still readable) JSON format. Client side only.
|
||||
|
||||
- The script `support/json-rsync-version` is available to get the JSON style
|
||||
version output from any rsync. The script accepts either text on stdin
|
||||
**or** an arg that specifies an rsync executable to run with a doubled
|
||||
`--version` option. If the text we get isn't already in JSON format, it is
|
||||
converted. Newer rsync versions will provide more complete json info than
|
||||
older rsync versions. Various tweaks are made to keep the flag names
|
||||
consistent across versions.
|
||||
|
||||
- The [`use chroot`](rsyncd.conf.5#) daemon parameter now defaults to "unset"
|
||||
so that rsync can use chroot when it works and a sanitized copy when chroot
|
||||
is not supported (e.g., for a non-root daemon). Explicitly setting the
|
||||
parameter to true or false (on or off) behaves the same way as before.
|
||||
|
||||
- The `--fuzzy` option was optimized a bit to try to cut down on the amount of
|
||||
computations when considering a big pool of files. The simple heuristic from
|
||||
Kenneth Finnegan resulted in about a 2x speedup.
|
||||
|
||||
- If rsync is forced to use protocol 29 or before (perhaps due to talking to an
|
||||
rsync before 3.0.0), the modify time of a file is limited to 4-bytes. Rsync
|
||||
now interprets this value as an unsigned integer so that a current year past
|
||||
2038 can continue to be represented. This does mean that years prior to 1970
|
||||
cannot be represented in an older protocol, but this trade-off seems like the
|
||||
right choice given that (1) 2038 is very rapidly approaching, and (2) newer
|
||||
protocols support a much wider range of old and new dates.
|
||||
|
||||
- The rsync client now treats an empty destination arg as an error, just like
|
||||
it does for an empty source arg. This doesn't affect a `host:` arg (which is
|
||||
treated the same as `host:.`) since the arg is not completely empty. The use
|
||||
of [`--old-args`](rsync.1#opt) (including via `RSYNC_OLD_ARGS`) allows the
|
||||
prior behavior of treating an empty destination arg as a ".".
|
||||
|
||||
### PACKAGING RELATED:
|
||||
|
||||
- The checksum code now uses openssl's EVP methods, which gets rid of various
|
||||
deprecation warnings and makes it easy to support more digest methods. On
|
||||
newer systems, the MD4 digest is marked as legacy in the openssl code, which
|
||||
makes openssl refuse to support it via EVP. You can choose to ignore this
|
||||
and allow rsync's MD4 code to be used for older rsync connections (when
|
||||
talking to an rsync prior to 3.0.0) or you can choose to configure rsync to
|
||||
tell openssl to enable legacy algorithms (see below).
|
||||
|
||||
- A simple openssl config file is supplied that can be installed for rsync to
|
||||
use. If you install packaging/openssl-rsync.cnf to a public spot (such as
|
||||
`/etc/ssl/openssl-rsync.cnf`) and then run configure with the option
|
||||
`--with-openssl-conf=/path/name.cnf`, this will cause rsync to export the
|
||||
configured path in the OPENSSL_CONF environment variable (when the variable
|
||||
is not already set). This will enable openssl's MD4 code for rsync to use.
|
||||
|
||||
- The packager may wish to include an explicit "use chroot = true" in the top
|
||||
section of their supplied /etc/rsyncd.conf file if the daemon is being
|
||||
installed to run as the root user (though rsync should behave the same even
|
||||
with the value unset, a little extra paranoia doesn't hurt).
|
||||
|
||||
- I've noticed that some packagers haven't installed support/nameconvert for
|
||||
users to use in their chrooted rsync configs. Even if it is not installed
|
||||
as an executable script (to avoid a python3 dependency) it would be good to
|
||||
install it with the other rsync-related support scripts.
|
||||
|
||||
- It would be good to add support/json-rsync-version to the list of installed
|
||||
support scripts.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
# NEWS for rsync 3.2.6 (9 Sep 2022)
|
||||
|
||||
## Changes in this version:
|
||||
|
||||
### BUG FIXES:
|
||||
|
||||
- More path-cleaning improvements in the file-list validation code to avoid
|
||||
rejecting of valid args.
|
||||
|
||||
- A file-list validation fix for a [`--files-from`](rsync.1#opt) file that ends
|
||||
without a line-terminating character.
|
||||
|
||||
- Added a safety check that prevents the sender from removing destination files
|
||||
when a local copy using [`--remove-source-files`](rsync.1#opt) has some files
|
||||
that are shared between the sending & receiving hierarchies, including the
|
||||
case where the source dir & destination dir are identical.
|
||||
|
||||
- Fixed a bug in the internal MD4 checksum code that could cause the digest
|
||||
to be sporadically incorrect (the openssl version was/is fine).
|
||||
|
||||
- A minor tweak to rrsync added "copy-devices" to the list of known args, but
|
||||
left it disabled by default.
|
||||
|
||||
### ENHANCEMENTS:
|
||||
|
||||
- Rename `--protect-args` to [`--secluded-args`](rsync.1#opt) to make it
|
||||
clearer how it differs from the default backslash-escaped arg-protecting
|
||||
behavior of rsync. The old option names are still accepted. The
|
||||
environment-variable override did not change its name.
|
||||
|
||||
### PACKAGING RELATED:
|
||||
|
||||
- The configure option `--with-protected-args` was renamed to
|
||||
`--with-secluded-args`. This option makes `--secluded-args` the default
|
||||
rsync behavior instead of using backslash escaping for protecting args.
|
||||
|
||||
- The mkgitver script now makes sure that a `.git` dir/file is in the top-level
|
||||
source dir before calling `git describe`. It also runs a basic check on the
|
||||
version value. This should avoid using an unrelated git description for
|
||||
rsync's version.
|
||||
|
||||
### DEVELOPER RELATED:
|
||||
|
||||
- The configure script no longer sets the -pedantic-errors CFLAG (which it
|
||||
used to try to do only for gcc).
|
||||
|
||||
- The name_num_obj struct was modified to allow its dynamic name_num_item list
|
||||
to be initialized in a better way.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
# NEWS for rsync 3.2.5 (14 Aug 2022)
|
||||
|
||||
## Changes in this version:
|
||||
@@ -64,11 +280,12 @@
|
||||
### BEHAVIOR CHANGES:
|
||||
|
||||
- A new form of arg protection was added that works similarly to the older
|
||||
[`--protect-args`](rsync.1#opt) (`-s`) option but in a way that avoids
|
||||
`--protect-args` ([`-s`](rsync.1#opt)) option but in a way that avoids
|
||||
breaking things like rrsync (the restricted rsync script): rsync now uses
|
||||
backslash escaping for sending "shell-active" characters to the remote
|
||||
shell. This includes spaces, so fetching a remote file via a simple quoted
|
||||
filename value now works by default without any extra quoting:
|
||||
backslash escaping for sending "shell-active" characters to the remote shell
|
||||
(such as `$(){}<>#&` and others). This includes spaces, so fetching a remote
|
||||
file via a quoted filename value now works by default without any extra
|
||||
quoting:
|
||||
|
||||
```shell
|
||||
rsync -aiv host:'a simple file.pdf' .
|
||||
@@ -76,10 +293,14 @@
|
||||
|
||||
Wildcards are not escaped in filename args, but they are escaped in options
|
||||
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. See also the [ADVANCED USAGE](rsync.1#)
|
||||
section of rsync's manpage for how to use a more modern arg style.
|
||||
|
||||
If a script depends on the old arg behavior (perhaps because it quotes or
|
||||
protects the args already, or perhaps because it expects arg splitting),
|
||||
there are two easy ways to get things going with a modern rsync: either
|
||||
`export RSYNC_OLD_ARGS=1` in the script's environment (perhaps in the script
|
||||
itself) or add the option [`--old-args`](rsync.1#opt) to the rsync commands
|
||||
that are run. See also the [ADVANCED USAGE](rsync.1#) section of rsync's
|
||||
manpage for how to use a more modern arg style.
|
||||
|
||||
- A long-standing bug was preventing rsync from figuring out the current
|
||||
locale's decimal point character, which made rsync always output numbers
|
||||
@@ -168,7 +389,7 @@
|
||||
|
||||
- Fixed a potential issue in git-set-file-times when handling commits with
|
||||
high-bit characters in the description & when handling a description that
|
||||
might mimick the git raw-commit deliniators. (See the support dir.)
|
||||
might mimic the git raw-commit deliniators. (See the support dir.)
|
||||
|
||||
- The bundled systemd/rsync.service file now includes `Restart=on-failure`.
|
||||
|
||||
@@ -4541,6 +4762,9 @@
|
||||
|
||||
| RELEASE DATE | VER. | DATE OF COMMIT\* | PROTOCOL |
|
||||
|--------------|--------|------------------|-------------|
|
||||
| 06 Apr 2024 | 3.3.0 | | 31 |
|
||||
| 20 Oct 2022 | 3.2.7 | | 31 |
|
||||
| 09 Sep 2022 | 3.2.6 | | 31 |
|
||||
| 14 Aug 2022 | 3.2.5 | | 31 |
|
||||
| 15 Apr 2022 | 3.2.4 | | 31 |
|
||||
| 06 Aug 2020 | 3.2.3 | | 31 |
|
||||
|
||||
1
acls.c
1
acls.c
@@ -519,6 +519,7 @@ static int get_rsync_acl(const char *fname, rsync_acl *racl,
|
||||
|
||||
sys_acl_free_acl(sacl);
|
||||
if (!ok) {
|
||||
rsyserr(FERROR_XFER, errno, "get_acl: unpack_smb_acl(%s)", fname);
|
||||
return -1;
|
||||
}
|
||||
} else if (no_acl_syscall_error(errno)) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Support rsync daemon authentication.
|
||||
*
|
||||
* Copyright (C) 1998-2000 Andrew Tridgell
|
||||
* Copyright (C) 2002-2020 Wayne Davison
|
||||
* Copyright (C) 2002-2022 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
extern int read_only;
|
||||
extern char *password_file;
|
||||
extern struct name_num_obj valid_auth_checksums;
|
||||
|
||||
/***************************************************************************
|
||||
encode a buffer using base64 - simple and slow algorithm. null terminates
|
||||
@@ -72,9 +73,9 @@ static void gen_challenge(const char *addr, char *challenge)
|
||||
SIVAL(input, 20, tv.tv_usec);
|
||||
SIVAL(input, 24, getpid());
|
||||
|
||||
sum_init(-1, 0);
|
||||
len = sum_init(valid_auth_checksums.negotiated_nni, 0);
|
||||
sum_update(input, sizeof input);
|
||||
len = sum_end(digest);
|
||||
sum_end(digest);
|
||||
|
||||
base64_encode(digest, len, challenge, 0);
|
||||
}
|
||||
@@ -86,10 +87,10 @@ static void generate_hash(const char *in, const char *challenge, char *out)
|
||||
char buf[MAX_DIGEST_LEN];
|
||||
int len;
|
||||
|
||||
sum_init(-1, 0);
|
||||
len = sum_init(valid_auth_checksums.negotiated_nni, 0);
|
||||
sum_update(in, strlen(in));
|
||||
sum_update(challenge, strlen(challenge));
|
||||
len = sum_end(buf);
|
||||
sum_end(buf);
|
||||
|
||||
base64_encode(buf, len, out, 0);
|
||||
}
|
||||
@@ -238,6 +239,7 @@ char *auth_server(int f_in, int f_out, int module, const char *host,
|
||||
if (!users || !*users)
|
||||
return "";
|
||||
|
||||
negotiate_daemon_auth(f_out, 0);
|
||||
gen_challenge(addr, challenge);
|
||||
|
||||
io_printf(f_out, "%s%s\n", leader, challenge);
|
||||
@@ -350,6 +352,7 @@ void auth_client(int fd, const char *user, const char *challenge)
|
||||
|
||||
if (!user || !*user)
|
||||
user = "nobody";
|
||||
negotiate_daemon_auth(-1, 1);
|
||||
|
||||
if (!(pass = getpassf(password_file))
|
||||
&& !(pass = getenv("RSYNC_PASSWORD"))) {
|
||||
|
||||
470
checksum.c
470
checksum.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1996 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2004-2022 Wayne Davison
|
||||
* Copyright (C) 2004-2023 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -42,47 +42,95 @@ extern int protocol_version;
|
||||
extern int proper_seed_order;
|
||||
extern const char *checksum_choice;
|
||||
|
||||
struct name_num_obj valid_checksums = {
|
||||
"checksum", NULL, NULL, 0, 0, {
|
||||
#define NNI_BUILTIN (1<<0)
|
||||
#define NNI_EVP (1<<1)
|
||||
#define NNI_EVP_OK (1<<2)
|
||||
|
||||
struct name_num_item valid_checksums_items[] = {
|
||||
#ifdef SUPPORT_XXH3
|
||||
{ CSUM_XXH3_128, "xxh128", NULL },
|
||||
{ CSUM_XXH3_64, "xxh3", NULL },
|
||||
{ CSUM_XXH3_128, 0, "xxh128", NULL },
|
||||
{ CSUM_XXH3_64, 0, "xxh3", NULL },
|
||||
#endif
|
||||
#ifdef SUPPORT_XXHASH
|
||||
{ CSUM_XXH64, "xxh64", NULL },
|
||||
{ CSUM_XXH64, "xxhash", NULL },
|
||||
{ CSUM_XXH64, 0, "xxh64", NULL },
|
||||
{ CSUM_XXH64, 0, "xxhash", NULL },
|
||||
#endif
|
||||
{ CSUM_MD5, "md5", NULL },
|
||||
{ CSUM_MD4, "md4", NULL },
|
||||
{ CSUM_NONE, "none", NULL },
|
||||
{ 0, NULL, NULL }
|
||||
}
|
||||
{ CSUM_MD5, NNI_BUILTIN|NNI_EVP, "md5", NULL },
|
||||
{ CSUM_MD4, NNI_BUILTIN|NNI_EVP, "md4", NULL },
|
||||
#ifdef SHA_DIGEST_LENGTH
|
||||
{ CSUM_SHA1, NNI_EVP, "sha1", NULL },
|
||||
#endif
|
||||
{ CSUM_NONE, 0, "none", NULL },
|
||||
{ 0, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
int xfersum_type = 0; /* used for the file transfer checksums */
|
||||
int checksum_type = 0; /* used for the pre-transfer (--checksum) checksums */
|
||||
struct name_num_obj valid_checksums = {
|
||||
"checksum", NULL, 0, 0, valid_checksums_items
|
||||
};
|
||||
|
||||
struct name_num_item valid_auth_checksums_items[] = {
|
||||
#ifdef SHA512_DIGEST_LENGTH
|
||||
{ CSUM_SHA512, NNI_EVP, "sha512", NULL },
|
||||
#endif
|
||||
#ifdef SHA256_DIGEST_LENGTH
|
||||
{ CSUM_SHA256, NNI_EVP, "sha256", NULL },
|
||||
#endif
|
||||
#ifdef SHA_DIGEST_LENGTH
|
||||
{ CSUM_SHA1, NNI_EVP, "sha1", NULL },
|
||||
#endif
|
||||
{ CSUM_MD5, NNI_BUILTIN|NNI_EVP, "md5", NULL },
|
||||
{ CSUM_MD4, NNI_BUILTIN|NNI_EVP, "md4", NULL },
|
||||
{ 0, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
struct name_num_obj valid_auth_checksums = {
|
||||
"daemon auth checksum", NULL, 0, 0, valid_auth_checksums_items
|
||||
};
|
||||
|
||||
/* These cannot make use of openssl, so they're marked just as built-in */
|
||||
struct name_num_item implied_checksum_md4 =
|
||||
{ CSUM_MD4, NNI_BUILTIN, "md4", NULL };
|
||||
struct name_num_item implied_checksum_md5 =
|
||||
{ CSUM_MD5, NNI_BUILTIN, "md5", NULL };
|
||||
|
||||
struct name_num_item *xfer_sum_nni; /* used for the transfer checksum2 computations */
|
||||
int xfer_sum_len;
|
||||
struct name_num_item *file_sum_nni; /* used for the pre-transfer --checksum computations */
|
||||
int file_sum_len, file_sum_extra_cnt;
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
const EVP_MD *xfer_sum_evp_md;
|
||||
const EVP_MD *file_sum_evp_md;
|
||||
EVP_MD_CTX *ctx_evp = NULL;
|
||||
#endif
|
||||
|
||||
static int initialized_choices = 0;
|
||||
|
||||
int parse_csum_name(const char *name, int len)
|
||||
struct name_num_item *parse_csum_name(const char *name, int len)
|
||||
{
|
||||
struct name_num_item *nni;
|
||||
|
||||
if (len < 0 && name)
|
||||
len = strlen(name);
|
||||
|
||||
if (!name || (len == 4 && strncasecmp(name, "auto", 4) == 0)) {
|
||||
if (protocol_version >= 30)
|
||||
return CSUM_MD5;
|
||||
if (protocol_version >= 27)
|
||||
return CSUM_MD4_OLD;
|
||||
if (protocol_version >= 21)
|
||||
return CSUM_MD4_BUSTED;
|
||||
return CSUM_MD4_ARCHAIC;
|
||||
}
|
||||
init_checksum_choices();
|
||||
|
||||
if (!initialized_choices)
|
||||
init_checksum_choices();
|
||||
if (!name || (len == 4 && strncasecmp(name, "auto", 4) == 0)) {
|
||||
if (protocol_version >= 30) {
|
||||
if (!proper_seed_order)
|
||||
return &implied_checksum_md5;
|
||||
name = "md5";
|
||||
len = 3;
|
||||
} else {
|
||||
if (protocol_version >= 27)
|
||||
implied_checksum_md4.num = CSUM_MD4_OLD;
|
||||
else if (protocol_version >= 21)
|
||||
implied_checksum_md4.num = CSUM_MD4_BUSTED;
|
||||
else
|
||||
implied_checksum_md4.num = CSUM_MD4_ARCHAIC;
|
||||
return &implied_checksum_md4;
|
||||
}
|
||||
}
|
||||
|
||||
nni = get_nni_by_name(&valid_checksums, name, len);
|
||||
|
||||
@@ -91,44 +139,74 @@ int parse_csum_name(const char *name, int len)
|
||||
exit_cleanup(RERR_UNSUPPORTED);
|
||||
}
|
||||
|
||||
return nni->num;
|
||||
return nni;
|
||||
}
|
||||
|
||||
static const char *checksum_name(int num)
|
||||
#ifdef USE_OPENSSL
|
||||
static const EVP_MD *csum_evp_md(struct name_num_item *nni)
|
||||
{
|
||||
struct name_num_item *nni = get_nni_by_num(&valid_checksums, num);
|
||||
const EVP_MD *emd;
|
||||
if (!(nni->flags & NNI_EVP))
|
||||
return NULL;
|
||||
|
||||
return nni ? nni->name : num < CSUM_MD4 ? "md4" : "UNKNOWN";
|
||||
#ifdef USE_MD5_ASM
|
||||
if (nni->num == CSUM_MD5)
|
||||
emd = NULL;
|
||||
else
|
||||
#endif
|
||||
emd = EVP_get_digestbyname(nni->name);
|
||||
if (emd && !(nni->flags & NNI_EVP_OK)) { /* Make sure it works before we advertise it */
|
||||
if (!ctx_evp && !(ctx_evp = EVP_MD_CTX_create()))
|
||||
out_of_memory("csum_evp_md");
|
||||
/* Some routines are marked as legacy and are not enabled in the openssl.cnf file.
|
||||
* If we can't init the emd, we'll fall back to our built-in code. */
|
||||
if (EVP_DigestInit_ex(ctx_evp, emd, NULL) == 0)
|
||||
emd = NULL;
|
||||
else
|
||||
nni->flags = (nni->flags & ~NNI_BUILTIN) | NNI_EVP_OK;
|
||||
}
|
||||
if (!emd)
|
||||
nni->flags &= ~NNI_EVP;
|
||||
return emd;
|
||||
}
|
||||
#endif
|
||||
|
||||
void parse_checksum_choice(int final_call)
|
||||
{
|
||||
if (valid_checksums.negotiated_name)
|
||||
xfersum_type = checksum_type = valid_checksums.negotiated_num;
|
||||
if (valid_checksums.negotiated_nni)
|
||||
xfer_sum_nni = file_sum_nni = valid_checksums.negotiated_nni;
|
||||
else {
|
||||
char *cp = checksum_choice ? strchr(checksum_choice, ',') : NULL;
|
||||
if (cp) {
|
||||
xfersum_type = parse_csum_name(checksum_choice, cp - checksum_choice);
|
||||
checksum_type = parse_csum_name(cp+1, -1);
|
||||
xfer_sum_nni = parse_csum_name(checksum_choice, cp - checksum_choice);
|
||||
file_sum_nni = parse_csum_name(cp+1, -1);
|
||||
} else
|
||||
xfersum_type = checksum_type = parse_csum_name(checksum_choice, -1);
|
||||
xfer_sum_nni = file_sum_nni = parse_csum_name(checksum_choice, -1);
|
||||
if (am_server && checksum_choice)
|
||||
validate_choice_vs_env(NSTR_CHECKSUM, xfersum_type, checksum_type);
|
||||
validate_choice_vs_env(NSTR_CHECKSUM, xfer_sum_nni->num, file_sum_nni->num);
|
||||
}
|
||||
xfer_sum_len = csum_len_for_type(xfer_sum_nni->num, 0);
|
||||
file_sum_len = csum_len_for_type(file_sum_nni->num, 0);
|
||||
#ifdef USE_OPENSSL
|
||||
xfer_sum_evp_md = csum_evp_md(xfer_sum_nni);
|
||||
file_sum_evp_md = csum_evp_md(file_sum_nni);
|
||||
#endif
|
||||
|
||||
if (xfersum_type == CSUM_NONE)
|
||||
file_sum_extra_cnt = (file_sum_len + EXTRA_LEN - 1) / EXTRA_LEN;
|
||||
|
||||
if (xfer_sum_nni->num == CSUM_NONE)
|
||||
whole_file = 1;
|
||||
|
||||
/* Snag the checksum name for both write_batch's option output & the following debug output. */
|
||||
if (valid_checksums.negotiated_name)
|
||||
checksum_choice = valid_checksums.negotiated_name;
|
||||
if (valid_checksums.negotiated_nni)
|
||||
checksum_choice = valid_checksums.negotiated_nni->name;
|
||||
else if (checksum_choice == NULL)
|
||||
checksum_choice = checksum_name(xfersum_type);
|
||||
checksum_choice = xfer_sum_nni->name;
|
||||
|
||||
if (final_call && DEBUG_GTE(NSTR, am_server ? 3 : 1)) {
|
||||
rprintf(FINFO, "%s%s checksum: %s\n",
|
||||
am_server ? "Server" : "Client",
|
||||
valid_checksums.negotiated_name ? " negotiated" : "",
|
||||
valid_checksums.negotiated_nni ? " negotiated" : "",
|
||||
checksum_choice);
|
||||
}
|
||||
}
|
||||
@@ -148,6 +226,18 @@ int csum_len_for_type(int cst, BOOL flist_csum)
|
||||
return MD4_DIGEST_LEN;
|
||||
case CSUM_MD5:
|
||||
return MD5_DIGEST_LEN;
|
||||
#ifdef SHA_DIGEST_LENGTH
|
||||
case CSUM_SHA1:
|
||||
return SHA_DIGEST_LENGTH;
|
||||
#endif
|
||||
#ifdef SHA256_DIGEST_LENGTH
|
||||
case CSUM_SHA256:
|
||||
return SHA256_DIGEST_LENGTH;
|
||||
#endif
|
||||
#ifdef SHA512_DIGEST_LENGTH
|
||||
case CSUM_SHA512:
|
||||
return SHA512_DIGEST_LENGTH;
|
||||
#endif
|
||||
case CSUM_XXH64:
|
||||
case CSUM_XXH3_64:
|
||||
return 64/8;
|
||||
@@ -173,6 +263,9 @@ int canonical_checksum(int csum_type)
|
||||
break;
|
||||
case CSUM_MD4:
|
||||
case CSUM_MD5:
|
||||
case CSUM_SHA1:
|
||||
case CSUM_SHA256:
|
||||
case CSUM_SHA512:
|
||||
return -1;
|
||||
case CSUM_XXH64:
|
||||
case CSUM_XXH3_64:
|
||||
@@ -207,9 +300,25 @@ uint32 get_checksum1(char *buf1, int32 len)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* The "sum" buffer must be at least MAX_DIGEST_LEN bytes! */
|
||||
void get_checksum2(char *buf, int32 len, char *sum)
|
||||
{
|
||||
switch (xfersum_type) {
|
||||
#ifdef USE_OPENSSL
|
||||
if (xfer_sum_evp_md) {
|
||||
static EVP_MD_CTX *evp = NULL;
|
||||
uchar seedbuf[4];
|
||||
if (!evp && !(evp = EVP_MD_CTX_create()))
|
||||
out_of_memory("get_checksum2");
|
||||
EVP_DigestInit_ex(evp, xfer_sum_evp_md, NULL);
|
||||
if (checksum_seed) {
|
||||
SIVALu(seedbuf, 0, checksum_seed);
|
||||
EVP_DigestUpdate(evp, seedbuf, 4);
|
||||
}
|
||||
EVP_DigestUpdate(evp, (uchar *)buf, len);
|
||||
EVP_DigestFinal_ex(evp, (uchar *)sum, NULL);
|
||||
} else
|
||||
#endif
|
||||
switch (xfer_sum_nni->num) {
|
||||
#ifdef SUPPORT_XXHASH
|
||||
case CSUM_XXH64:
|
||||
SIVAL64(sum, 0, XXH64(buf, len, checksum_seed));
|
||||
@@ -227,7 +336,7 @@ void get_checksum2(char *buf, int32 len, char *sum)
|
||||
}
|
||||
#endif
|
||||
case CSUM_MD5: {
|
||||
md5_context m5;
|
||||
md_context m5;
|
||||
uchar seedbuf[4];
|
||||
md5_begin(&m5);
|
||||
if (proper_seed_order) {
|
||||
@@ -247,20 +356,6 @@ void get_checksum2(char *buf, int32 len, char *sum)
|
||||
break;
|
||||
}
|
||||
case CSUM_MD4:
|
||||
#ifdef USE_OPENSSL
|
||||
{
|
||||
MD4_CTX m4;
|
||||
MD4_Init(&m4);
|
||||
MD4_Update(&m4, (uchar *)buf, len);
|
||||
if (checksum_seed) {
|
||||
uchar seedbuf[4];
|
||||
SIVALu(seedbuf, 0, checksum_seed);
|
||||
MD4_Update(&m4, seedbuf, 4);
|
||||
}
|
||||
MD4_Final((uchar *)sum, &m4);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case CSUM_MD4_OLD:
|
||||
case CSUM_MD4_BUSTED:
|
||||
case CSUM_MD4_ARCHAIC: {
|
||||
@@ -293,7 +388,7 @@ void get_checksum2(char *buf, int32 len, char *sum)
|
||||
* are multiples of 64. This is fixed by calling mdfour_update()
|
||||
* even when there are no more bytes.
|
||||
*/
|
||||
if (len - i > 0 || xfersum_type > CSUM_MD4_BUSTED)
|
||||
if (len - i > 0 || xfer_sum_nni->num > CSUM_MD4_BUSTED)
|
||||
mdfour_update(&m, (uchar *)(buf1+i), len-i);
|
||||
|
||||
mdfour_result(&m, (uchar *)sum);
|
||||
@@ -311,15 +406,33 @@ void file_checksum(const char *fname, const STRUCT_STAT *st_p, char *sum)
|
||||
int32 remainder;
|
||||
int fd;
|
||||
|
||||
memset(sum, 0, MAX_DIGEST_LEN);
|
||||
|
||||
fd = do_open(fname, O_RDONLY, 0);
|
||||
if (fd == -1)
|
||||
if (fd == -1) {
|
||||
memset(sum, 0, file_sum_len);
|
||||
return;
|
||||
}
|
||||
|
||||
buf = map_file(fd, len, MAX_MAP_SIZE, CHUNK_SIZE);
|
||||
|
||||
switch (checksum_type) {
|
||||
#ifdef USE_OPENSSL
|
||||
if (file_sum_evp_md) {
|
||||
static EVP_MD_CTX *evp = NULL;
|
||||
if (!evp && !(evp = EVP_MD_CTX_create()))
|
||||
out_of_memory("file_checksum");
|
||||
|
||||
EVP_DigestInit_ex(evp, file_sum_evp_md, NULL);
|
||||
|
||||
for (i = 0; i + CHUNK_SIZE <= len; i += CHUNK_SIZE)
|
||||
EVP_DigestUpdate(evp, (uchar *)map_ptr(buf, i, CHUNK_SIZE), CHUNK_SIZE);
|
||||
|
||||
remainder = (int32)(len - i);
|
||||
if (remainder > 0)
|
||||
EVP_DigestUpdate(evp, (uchar *)map_ptr(buf, i, remainder), remainder);
|
||||
|
||||
EVP_DigestFinal_ex(evp, (uchar *)sum, NULL);
|
||||
} else
|
||||
#endif
|
||||
switch (file_sum_nni->num) {
|
||||
#ifdef SUPPORT_XXHASH
|
||||
case CSUM_XXH64: {
|
||||
static XXH64_state_t* state = NULL;
|
||||
@@ -379,7 +492,7 @@ void file_checksum(const char *fname, const STRUCT_STAT *st_p, char *sum)
|
||||
}
|
||||
#endif
|
||||
case CSUM_MD5: {
|
||||
md5_context m5;
|
||||
md_context m5;
|
||||
|
||||
md5_begin(&m5);
|
||||
|
||||
@@ -394,23 +507,6 @@ void file_checksum(const char *fname, const STRUCT_STAT *st_p, char *sum)
|
||||
break;
|
||||
}
|
||||
case CSUM_MD4:
|
||||
#ifdef USE_OPENSSL
|
||||
{
|
||||
MD4_CTX m4;
|
||||
|
||||
MD4_Init(&m4);
|
||||
|
||||
for (i = 0; i + CHUNK_SIZE <= len; i += CHUNK_SIZE)
|
||||
MD4_Update(&m4, (uchar *)map_ptr(buf, i, CHUNK_SIZE), CHUNK_SIZE);
|
||||
|
||||
remainder = (int32)(len - i);
|
||||
if (remainder > 0)
|
||||
MD4_Update(&m4, (uchar *)map_ptr(buf, i, remainder), remainder);
|
||||
|
||||
MD4_Final((uchar *)sum, &m4);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case CSUM_MD4_OLD:
|
||||
case CSUM_MD4_BUSTED:
|
||||
case CSUM_MD4_ARCHAIC: {
|
||||
@@ -418,15 +514,15 @@ void file_checksum(const char *fname, const STRUCT_STAT *st_p, char *sum)
|
||||
|
||||
mdfour_begin(&m);
|
||||
|
||||
for (i = 0; i + CHUNK_SIZE <= len; i += CHUNK_SIZE)
|
||||
mdfour_update(&m, (uchar *)map_ptr(buf, i, CHUNK_SIZE), CHUNK_SIZE);
|
||||
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK)
|
||||
mdfour_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK), CSUM_CHUNK);
|
||||
|
||||
/* Prior to version 27 an incorrect MD4 checksum was computed
|
||||
* by failing to call mdfour_tail() for block sizes that
|
||||
* are multiples of 64. This is fixed by calling mdfour_update()
|
||||
* even when there are no more bytes. */
|
||||
remainder = (int32)(len - i);
|
||||
if (remainder > 0 || checksum_type > CSUM_MD4_BUSTED)
|
||||
if (remainder > 0 || file_sum_nni->num > CSUM_MD4_BUSTED)
|
||||
mdfour_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
|
||||
|
||||
mdfour_result(&m, (uchar *)sum);
|
||||
@@ -434,7 +530,7 @@ void file_checksum(const char *fname, const STRUCT_STAT *st_p, char *sum)
|
||||
}
|
||||
default:
|
||||
rprintf(FERROR, "Invalid checksum-choice for --checksum: %s (%d)\n",
|
||||
checksum_name(checksum_type), checksum_type);
|
||||
file_sum_nni->name, file_sum_nni->num);
|
||||
exit_cleanup(RERR_UNSUPPORTED);
|
||||
}
|
||||
|
||||
@@ -443,30 +539,43 @@ void file_checksum(const char *fname, const STRUCT_STAT *st_p, char *sum)
|
||||
}
|
||||
|
||||
static int32 sumresidue;
|
||||
static union {
|
||||
md_context md;
|
||||
#ifdef USE_OPENSSL
|
||||
MD4_CTX m4;
|
||||
#endif
|
||||
md5_context m5;
|
||||
} ctx;
|
||||
static md_context ctx_md;
|
||||
#ifdef SUPPORT_XXHASH
|
||||
static XXH64_state_t* xxh64_state;
|
||||
#endif
|
||||
#ifdef SUPPORT_XXH3
|
||||
static XXH3_state_t* xxh3_state;
|
||||
#endif
|
||||
static int cursum_type;
|
||||
static struct name_num_item *cur_sum_nni;
|
||||
int cur_sum_len;
|
||||
|
||||
void sum_init(int csum_type, int seed)
|
||||
#ifdef USE_OPENSSL
|
||||
static const EVP_MD *cur_sum_evp_md;
|
||||
#endif
|
||||
|
||||
/* Initialize a hash digest accumulator. Data is supplied via
|
||||
* sum_update() and the resulting binary digest is retrieved via
|
||||
* sum_end(). This only supports one active sum at a time. */
|
||||
int sum_init(struct name_num_item *nni, int seed)
|
||||
{
|
||||
char s[4];
|
||||
|
||||
if (csum_type < 0)
|
||||
csum_type = parse_csum_name(NULL, 0);
|
||||
cursum_type = csum_type;
|
||||
if (!nni)
|
||||
nni = parse_csum_name(NULL, 0);
|
||||
cur_sum_nni = nni;
|
||||
cur_sum_len = csum_len_for_type(nni->num, 0);
|
||||
#ifdef USE_OPENSSL
|
||||
cur_sum_evp_md = csum_evp_md(nni);
|
||||
#endif
|
||||
|
||||
switch (csum_type) {
|
||||
#ifdef USE_OPENSSL
|
||||
if (cur_sum_evp_md) {
|
||||
if (!ctx_evp && !(ctx_evp = EVP_MD_CTX_create()))
|
||||
out_of_memory("file_checksum");
|
||||
EVP_DigestInit_ex(ctx_evp, cur_sum_evp_md, NULL);
|
||||
} else
|
||||
#endif
|
||||
switch (cur_sum_nni->num) {
|
||||
#ifdef SUPPORT_XXHASH
|
||||
case CSUM_XXH64:
|
||||
if (!xxh64_state && !(xxh64_state = XXH64_createState()))
|
||||
@@ -487,20 +596,16 @@ void sum_init(int csum_type, int seed)
|
||||
break;
|
||||
#endif
|
||||
case CSUM_MD5:
|
||||
md5_begin(&ctx.m5);
|
||||
md5_begin(&ctx_md);
|
||||
break;
|
||||
case CSUM_MD4:
|
||||
#ifdef USE_OPENSSL
|
||||
MD4_Init(&ctx.m4);
|
||||
#else
|
||||
mdfour_begin(&ctx.md);
|
||||
mdfour_begin(&ctx_md);
|
||||
sumresidue = 0;
|
||||
#endif
|
||||
break;
|
||||
case CSUM_MD4_OLD:
|
||||
case CSUM_MD4_BUSTED:
|
||||
case CSUM_MD4_ARCHAIC:
|
||||
mdfour_begin(&ctx.md);
|
||||
mdfour_begin(&ctx_md);
|
||||
sumresidue = 0;
|
||||
SIVAL(s, 0, seed);
|
||||
sum_update(s, 4);
|
||||
@@ -510,19 +615,19 @@ void sum_init(int csum_type, int seed)
|
||||
default: /* paranoia to prevent missing case values */
|
||||
exit_cleanup(RERR_UNSUPPORTED);
|
||||
}
|
||||
|
||||
return cur_sum_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Feed data into an MD4 accumulator, md. The results may be
|
||||
* retrieved using sum_end(). md is used for different purposes at
|
||||
* different points during execution.
|
||||
*
|
||||
* @todo Perhaps get rid of md and just pass in the address each time.
|
||||
* Very slightly clearer and slower.
|
||||
**/
|
||||
/* Feed data into a hash digest accumulator. */
|
||||
void sum_update(const char *p, int32 len)
|
||||
{
|
||||
switch (cursum_type) {
|
||||
#ifdef USE_OPENSSL
|
||||
if (cur_sum_evp_md) {
|
||||
EVP_DigestUpdate(ctx_evp, (uchar *)p, len);
|
||||
} else
|
||||
#endif
|
||||
switch (cur_sum_nni->num) {
|
||||
#ifdef SUPPORT_XXHASH
|
||||
case CSUM_XXH64:
|
||||
XXH64_update(xxh64_state, p, len);
|
||||
@@ -537,39 +642,35 @@ void sum_update(const char *p, int32 len)
|
||||
break;
|
||||
#endif
|
||||
case CSUM_MD5:
|
||||
md5_update(&ctx.m5, (uchar *)p, len);
|
||||
md5_update(&ctx_md, (uchar *)p, len);
|
||||
break;
|
||||
case CSUM_MD4:
|
||||
#ifdef USE_OPENSSL
|
||||
MD4_Update(&ctx.m4, (uchar *)p, len);
|
||||
break;
|
||||
#endif
|
||||
case CSUM_MD4_OLD:
|
||||
case CSUM_MD4_BUSTED:
|
||||
case CSUM_MD4_ARCHAIC:
|
||||
if (len + sumresidue < CSUM_CHUNK) {
|
||||
memcpy(ctx.md.buffer + sumresidue, p, len);
|
||||
memcpy(ctx_md.buffer + sumresidue, p, len);
|
||||
sumresidue += len;
|
||||
break;
|
||||
}
|
||||
|
||||
if (sumresidue) {
|
||||
int32 i = CSUM_CHUNK - sumresidue;
|
||||
memcpy(ctx.md.buffer + sumresidue, p, i);
|
||||
mdfour_update(&ctx.md, (uchar *)ctx.md.buffer, CSUM_CHUNK);
|
||||
memcpy(ctx_md.buffer + sumresidue, p, i);
|
||||
mdfour_update(&ctx_md, (uchar *)ctx_md.buffer, CSUM_CHUNK);
|
||||
len -= i;
|
||||
p += i;
|
||||
}
|
||||
|
||||
while (len >= CSUM_CHUNK) {
|
||||
mdfour_update(&ctx.md, (uchar *)p, CSUM_CHUNK);
|
||||
mdfour_update(&ctx_md, (uchar *)p, CSUM_CHUNK);
|
||||
len -= CSUM_CHUNK;
|
||||
p += CSUM_CHUNK;
|
||||
}
|
||||
|
||||
sumresidue = len;
|
||||
if (sumresidue)
|
||||
memcpy(ctx.md.buffer, p, sumresidue);
|
||||
memcpy(ctx_md.buffer, p, sumresidue);
|
||||
break;
|
||||
case CSUM_NONE:
|
||||
break;
|
||||
@@ -578,13 +679,18 @@ void sum_update(const char *p, int32 len)
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTE: all the callers of sum_end() pass in a pointer to a buffer that is
|
||||
* MAX_DIGEST_LEN in size, so even if the csum-len is shorter than that (i.e.
|
||||
* CSUM_MD4_ARCHAIC), we don't have to worry about limiting the data we write
|
||||
* into the "sum" buffer. */
|
||||
int sum_end(char *sum)
|
||||
/* The sum buffer only needs to be as long as the current checksum's digest
|
||||
* len, not MAX_DIGEST_LEN. Note that for CSUM_MD4_ARCHAIC that is the full
|
||||
* MD4_DIGEST_LEN even if the file-list code is going to ignore all but the
|
||||
* first 2 bytes of it. */
|
||||
void sum_end(char *sum)
|
||||
{
|
||||
switch (cursum_type) {
|
||||
#ifdef USE_OPENSSL
|
||||
if (cur_sum_evp_md) {
|
||||
EVP_DigestFinal_ex(ctx_evp, (uchar *)sum, NULL);
|
||||
} else
|
||||
#endif
|
||||
switch (cur_sum_nni->num) {
|
||||
#ifdef SUPPORT_XXHASH
|
||||
case CSUM_XXH64:
|
||||
SIVAL64(sum, 0, XXH64_digest(xxh64_state));
|
||||
@@ -602,22 +708,18 @@ int sum_end(char *sum)
|
||||
}
|
||||
#endif
|
||||
case CSUM_MD5:
|
||||
md5_result(&ctx.m5, (uchar *)sum);
|
||||
md5_result(&ctx_md, (uchar *)sum);
|
||||
break;
|
||||
case CSUM_MD4:
|
||||
#ifdef USE_OPENSSL
|
||||
MD4_Final((uchar *)sum, &ctx.m4);
|
||||
break;
|
||||
#endif
|
||||
case CSUM_MD4_OLD:
|
||||
mdfour_update(&ctx.md, (uchar *)ctx.md.buffer, sumresidue);
|
||||
mdfour_result(&ctx.md, (uchar *)sum);
|
||||
mdfour_update(&ctx_md, (uchar *)ctx_md.buffer, sumresidue);
|
||||
mdfour_result(&ctx_md, (uchar *)sum);
|
||||
break;
|
||||
case CSUM_MD4_BUSTED:
|
||||
case CSUM_MD4_ARCHAIC:
|
||||
if (sumresidue)
|
||||
mdfour_update(&ctx.md, (uchar *)ctx.md.buffer, sumresidue);
|
||||
mdfour_result(&ctx.md, (uchar *)sum);
|
||||
mdfour_update(&ctx_md, (uchar *)ctx_md.buffer, sumresidue);
|
||||
mdfour_result(&ctx_md, (uchar *)sum);
|
||||
break;
|
||||
case CSUM_NONE:
|
||||
*sum = '\0';
|
||||
@@ -625,34 +727,78 @@ int sum_end(char *sum)
|
||||
default: /* paranoia to prevent missing case values */
|
||||
exit_cleanup(RERR_UNSUPPORTED);
|
||||
}
|
||||
|
||||
return csum_len_for_type(cursum_type, 0);
|
||||
}
|
||||
|
||||
#if defined SUPPORT_XXH3 || defined USE_OPENSSL
|
||||
static void verify_digest(struct name_num_item *nni, BOOL check_auth_list)
|
||||
{
|
||||
#ifdef SUPPORT_XXH3
|
||||
static int xxh3_result = 0;
|
||||
#endif
|
||||
#ifdef USE_OPENSSL
|
||||
static int prior_num = 0, prior_flags = 0, prior_result = 0;
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_XXH3
|
||||
if (nni->num == CSUM_XXH3_64 || nni->num == CSUM_XXH3_128) {
|
||||
if (!xxh3_result) {
|
||||
char buf[32816];
|
||||
int j;
|
||||
for (j = 0; j < (int)sizeof buf; j++)
|
||||
buf[j] = ' ' + (j % 96);
|
||||
sum_init(nni, 0);
|
||||
sum_update(buf, 32816);
|
||||
sum_update(buf, 31152);
|
||||
sum_update(buf, 32474);
|
||||
sum_update(buf, 9322);
|
||||
xxh3_result = XXH3_64bits_digest(xxh3_state) != 0xadbcf16d4678d1de ? -1 : 1;
|
||||
}
|
||||
if (xxh3_result < 0)
|
||||
nni->num = CSUM_gone;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
if (BITS_SETnUNSET(nni->flags, NNI_EVP, NNI_BUILTIN|NNI_EVP_OK)) {
|
||||
if (nni->num == prior_num && nni->flags == prior_flags) {
|
||||
nni->flags = prior_result;
|
||||
if (!(nni->flags & NNI_EVP))
|
||||
nni->num = CSUM_gone;
|
||||
} else {
|
||||
prior_num = nni->num;
|
||||
prior_flags = nni->flags;
|
||||
if (!csum_evp_md(nni))
|
||||
nni->num = CSUM_gone;
|
||||
prior_result = nni->flags;
|
||||
if (check_auth_list && (nni = get_nni_by_num(&valid_auth_checksums, prior_num)) != NULL)
|
||||
verify_digest(nni, False);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void init_checksum_choices()
|
||||
{
|
||||
#ifdef SUPPORT_XXH3
|
||||
char buf[32816];
|
||||
int j;
|
||||
for (j = 0; j < (int)sizeof buf; j++) {
|
||||
buf[j] = ' ' + (j % 96);
|
||||
}
|
||||
sum_init(CSUM_XXH3_64, 0);
|
||||
sum_update(buf, 32816);
|
||||
sum_update(buf, 31152);
|
||||
sum_update(buf, 32474);
|
||||
sum_update(buf, 9322);
|
||||
if (XXH3_64bits_digest(xxh3_state) != 0xadbcf16d4678d1de) {
|
||||
int t, f;
|
||||
struct name_num_item *nni = valid_checksums.list;
|
||||
for (t = f = 0; nni[f].name; f++) {
|
||||
if (nni[f].num == CSUM_XXH3_64 || nni[f].num == CSUM_XXH3_128)
|
||||
continue;
|
||||
if (t != f)
|
||||
nni[t++] = nni[f];
|
||||
}
|
||||
nni[t].name = NULL;
|
||||
}
|
||||
#if defined SUPPORT_XXH3 || defined USE_OPENSSL
|
||||
struct name_num_item *nni;
|
||||
#endif
|
||||
|
||||
if (initialized_choices)
|
||||
return;
|
||||
|
||||
#if defined USE_OPENSSL && OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
OpenSSL_add_all_algorithms();
|
||||
#endif
|
||||
|
||||
#if defined SUPPORT_XXH3 || defined USE_OPENSSL
|
||||
for (nni = valid_checksums.list; nni->name; nni++)
|
||||
verify_digest(nni, True);
|
||||
|
||||
for (nni = valid_auth_checksums.list; nni->name; nni++)
|
||||
verify_digest(nni, False);
|
||||
#endif
|
||||
|
||||
initialized_choices = 1;
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ extern uid_t our_uid;
|
||||
extern gid_t our_gid;
|
||||
|
||||
char *auth_user;
|
||||
char *daemon_auth_choices;
|
||||
int read_only = 0;
|
||||
int module_id = -1;
|
||||
int pid_file_fd = -1;
|
||||
@@ -149,13 +150,9 @@ int start_socket_client(char *host, int remote_argc, char *remote_argv[],
|
||||
static int exchange_protocols(int f_in, int f_out, char *buf, size_t bufsiz, int am_client)
|
||||
{
|
||||
int remote_sub = -1;
|
||||
#if SUBPROTOCOL_VERSION != 0
|
||||
int our_sub = protocol_version < PROTOCOL_VERSION ? 0 : SUBPROTOCOL_VERSION;
|
||||
#else
|
||||
int our_sub = 0;
|
||||
#endif
|
||||
int our_sub = get_subprotocol_version();
|
||||
|
||||
io_printf(f_out, "@RSYNCD: %d.%d\n", protocol_version, our_sub);
|
||||
output_daemon_greeting(f_out, am_client);
|
||||
if (!am_client) {
|
||||
char *motd = lp_motd_file();
|
||||
if (motd && *motd) {
|
||||
@@ -187,16 +184,30 @@ static int exchange_protocols(int f_in, int f_out, char *buf, size_t bufsiz, int
|
||||
}
|
||||
|
||||
if (remote_sub < 0) {
|
||||
if (remote_protocol == 30) {
|
||||
if (remote_protocol >= 30) {
|
||||
if (am_client)
|
||||
rprintf(FERROR, "rsync: server is speaking an incompatible beta of protocol 30\n");
|
||||
rprintf(FERROR, "rsync: the server omitted the subprotocol value: %s\n", buf);
|
||||
else
|
||||
io_printf(f_out, "@ERROR: your client is speaking an incompatible beta of protocol 30\n");
|
||||
io_printf(f_out, "@ERROR: your client omitted the subprotocol value: %s\n", buf);
|
||||
return -1;
|
||||
}
|
||||
remote_sub = 0;
|
||||
}
|
||||
|
||||
daemon_auth_choices = strchr(buf + 9, ' ');
|
||||
if (daemon_auth_choices) {
|
||||
char *cp;
|
||||
daemon_auth_choices = strdup(daemon_auth_choices + 1);
|
||||
if ((cp = strchr(daemon_auth_choices, '\n')) != NULL)
|
||||
*cp = '\0';
|
||||
} else if (remote_protocol > 31) {
|
||||
if (am_client)
|
||||
rprintf(FERROR, "rsync: the server omitted the digest name list: %s\n", buf);
|
||||
else
|
||||
io_printf(f_out, "@ERROR: your client omitted the digest name list: %s\n", buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (protocol_version > remote_protocol) {
|
||||
protocol_version = remote_protocol;
|
||||
if (remote_sub)
|
||||
@@ -381,7 +392,7 @@ int start_inband_exchange(int f_in, int f_out, const char *user, int argc, char
|
||||
|
||||
if (rl_nulls) {
|
||||
for (i = 0; i < sargc; i++) {
|
||||
if (!sargs[i]) /* stop at --protect-args NULL */
|
||||
if (!sargs[i]) /* stop at --secluded-args NULL */
|
||||
break;
|
||||
write_sbuf(f_out, sargs[i]);
|
||||
write_byte(f_out, 0);
|
||||
@@ -429,7 +440,7 @@ static int read_arg_from_pipe(int fd, char *buf, int limit)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void set_env_str(const char *var, const char *str)
|
||||
void set_env_str(const char *var, const char *str)
|
||||
{
|
||||
#ifdef HAVE_SETENV
|
||||
if (setenv(var, str, 1) < 0)
|
||||
@@ -690,7 +701,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
|
||||
int set_uid;
|
||||
char *p, *err_msg = NULL;
|
||||
char *name = lp_name(i);
|
||||
int use_chroot = lp_use_chroot(i);
|
||||
int use_chroot = lp_use_chroot(i); /* might be 1 (yes), 0 (no), or -1 (unset) */
|
||||
int ret, pre_exec_arg_fd = -1, pre_exec_error_fd = -1;
|
||||
int save_munge_symlinks;
|
||||
pid_t pre_exec_pid = 0;
|
||||
@@ -815,6 +826,20 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
|
||||
io_printf(f_out, "@ERROR: no path setting.\n");
|
||||
return -1;
|
||||
}
|
||||
if (use_chroot < 0) {
|
||||
if (strstr(module_dir, "/./") != NULL)
|
||||
use_chroot = 1; /* The module is expecting a chroot inner & outer path. */
|
||||
else if (chroot("/") < 0) {
|
||||
rprintf(FLOG, "chroot test failed: %s. "
|
||||
"Switching 'use chroot' from unset to false.\n",
|
||||
strerror(errno));
|
||||
use_chroot = 0;
|
||||
} else {
|
||||
if (chdir("/") < 0)
|
||||
rsyserr(FLOG, errno, "chdir(\"/\") failed");
|
||||
use_chroot = 1;
|
||||
}
|
||||
}
|
||||
if (use_chroot) {
|
||||
if ((p = strstr(module_dir, "/./")) != NULL) {
|
||||
*p = '\0'; /* Temporary... */
|
||||
@@ -951,20 +976,8 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
|
||||
}
|
||||
|
||||
if (use_chroot) {
|
||||
/*
|
||||
* XXX: The 'use chroot' flag is a fairly reliable
|
||||
* source of confusion, because it fails under two
|
||||
* important circumstances: running as non-root,
|
||||
* running on Win32 (or possibly others). On the
|
||||
* other hand, if you are running as root, then it
|
||||
* might be better to always use chroot.
|
||||
*
|
||||
* So, perhaps if we can't chroot we should just issue
|
||||
* a warning, unless a "require chroot" flag is set,
|
||||
* in which case we fail.
|
||||
*/
|
||||
if (chroot(module_chdir)) {
|
||||
rsyserr(FLOG, errno, "chroot %s failed", module_chdir);
|
||||
rsyserr(FLOG, errno, "chroot(\"%s\") failed", module_chdir);
|
||||
io_printf(f_out, "@ERROR: chroot failed\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -973,7 +986,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
|
||||
|
||||
if (!change_dir(module_chdir, CD_NORMAL))
|
||||
return path_failure(f_out, module_chdir, True);
|
||||
if (module_dirlen || (!use_chroot && !*lp_daemon_chroot()))
|
||||
if (module_dirlen)
|
||||
sanitize_paths = 1;
|
||||
|
||||
if ((munge_symlinks = lp_munge_symlinks(module_id)) < 0)
|
||||
@@ -1288,8 +1301,12 @@ int start_daemon(int f_in, int f_out)
|
||||
p = lp_daemon_chroot();
|
||||
if (*p) {
|
||||
log_init(0); /* Make use we've initialized syslog before chrooting. */
|
||||
if (chroot(p) < 0 || chdir("/") < 0) {
|
||||
rsyserr(FLOG, errno, "daemon chroot %s failed", p);
|
||||
if (chroot(p) < 0) {
|
||||
rsyserr(FLOG, errno, "daemon chroot(\"%s\") failed", p);
|
||||
return -1;
|
||||
}
|
||||
if (chdir("/") < 0) {
|
||||
rsyserr(FLOG, errno, "daemon chdir(\"/\") failed");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
200
compat.c
200
compat.c
@@ -60,13 +60,16 @@ extern char *files_from;
|
||||
extern char *filesfrom_host;
|
||||
extern const char *checksum_choice;
|
||||
extern const char *compress_choice;
|
||||
extern char *daemon_auth_choices;
|
||||
extern filter_rule_list filter_list;
|
||||
extern int need_unsorted_flist;
|
||||
#ifdef ICONV_OPTION
|
||||
extern iconv_t ic_send, ic_recv;
|
||||
extern char *iconv_opt;
|
||||
#endif
|
||||
extern struct name_num_obj valid_checksums;
|
||||
extern struct name_num_obj valid_checksums, valid_auth_checksums;
|
||||
|
||||
extern struct name_num_item *xfer_sum_nni;
|
||||
|
||||
int remote_protocol = 0;
|
||||
int file_extra_cnt = 0; /* count of file-list extras that everyone gets */
|
||||
@@ -79,6 +82,9 @@ int inplace_partial = 0;
|
||||
int do_negotiated_strings = 0;
|
||||
int xmit_id0_names = 0;
|
||||
|
||||
struct name_num_item *xattr_sum_nni;
|
||||
int xattr_sum_len = 0;
|
||||
|
||||
/* These index values are for the file-list's extra-attribute array. */
|
||||
int pathname_ndx, depth_ndx, atimes_ndx, crtimes_ndx, uid_ndx, gid_ndx, acls_ndx, xattrs_ndx, unsort_ndx;
|
||||
|
||||
@@ -91,19 +97,21 @@ int filesfrom_convert = 0;
|
||||
|
||||
#define MAX_NSTR_STRLEN 256
|
||||
|
||||
struct name_num_obj valid_compressions = {
|
||||
"compress", NULL, NULL, 0, 0, {
|
||||
struct name_num_item valid_compressions_items[] = {
|
||||
#ifdef SUPPORT_ZSTD
|
||||
{ CPRES_ZSTD, "zstd", NULL },
|
||||
{ CPRES_ZSTD, 0, "zstd", NULL },
|
||||
#endif
|
||||
#ifdef SUPPORT_LZ4
|
||||
{ CPRES_LZ4, "lz4", NULL },
|
||||
{ CPRES_LZ4, 0, "lz4", NULL },
|
||||
#endif
|
||||
{ CPRES_ZLIBX, "zlibx", NULL },
|
||||
{ CPRES_ZLIB, "zlib", NULL },
|
||||
{ CPRES_NONE, "none", NULL },
|
||||
{ 0, NULL, NULL }
|
||||
}
|
||||
{ CPRES_ZLIBX, 0, "zlibx", NULL },
|
||||
{ CPRES_ZLIB, 0, "zlib", NULL },
|
||||
{ CPRES_NONE, 0, "none", NULL },
|
||||
{ 0, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
struct name_num_obj valid_compressions = {
|
||||
"compress", NULL, 0, 0, valid_compressions_items
|
||||
};
|
||||
|
||||
#define CF_INC_RECURSE (1<<0)
|
||||
@@ -125,11 +133,7 @@ static void check_sub_protocol(void)
|
||||
{
|
||||
char *dot;
|
||||
int their_protocol, their_sub;
|
||||
#if SUBPROTOCOL_VERSION != 0
|
||||
int our_sub = protocol_version < PROTOCOL_VERSION ? 0 : SUBPROTOCOL_VERSION;
|
||||
#else
|
||||
int our_sub = 0;
|
||||
#endif
|
||||
int our_sub = get_subprotocol_version();
|
||||
|
||||
/* client_info starts with VER.SUB string if client is a pre-release. */
|
||||
if (!(their_protocol = atoi(client_info))
|
||||
@@ -176,8 +180,8 @@ void set_allow_inc_recurse(void)
|
||||
|
||||
void parse_compress_choice(int final_call)
|
||||
{
|
||||
if (valid_compressions.negotiated_name)
|
||||
do_compression = valid_compressions.negotiated_num;
|
||||
if (valid_compressions.negotiated_nni)
|
||||
do_compression = valid_compressions.negotiated_nni->num;
|
||||
else if (compress_choice) {
|
||||
struct name_num_item *nni = get_nni_by_name(&valid_compressions, compress_choice, -1);
|
||||
if (!nni) {
|
||||
@@ -199,8 +203,8 @@ void parse_compress_choice(int final_call)
|
||||
compress_choice = NULL;
|
||||
|
||||
/* Snag the compression name for both write_batch's option output & the following debug output. */
|
||||
if (valid_compressions.negotiated_name)
|
||||
compress_choice = valid_compressions.negotiated_name;
|
||||
if (valid_compressions.negotiated_nni)
|
||||
compress_choice = valid_compressions.negotiated_nni->name;
|
||||
else if (compress_choice == NULL) {
|
||||
struct name_num_item *nni = get_nni_by_num(&valid_compressions, do_compression);
|
||||
compress_choice = nni ? nni->name : "UNKNOWN";
|
||||
@@ -210,7 +214,7 @@ void parse_compress_choice(int final_call)
|
||||
&& (do_compression != CPRES_NONE || do_compression_level != CLVL_NOT_SPECIFIED)) {
|
||||
rprintf(FINFO, "%s%s compress: %s (level %d)\n",
|
||||
am_server ? "Server" : "Client",
|
||||
valid_compressions.negotiated_name ? " negotiated" : "",
|
||||
valid_compressions.negotiated_nni ? " negotiated" : "",
|
||||
compress_choice, do_compression_level);
|
||||
}
|
||||
}
|
||||
@@ -223,6 +227,8 @@ struct name_num_item *get_nni_by_name(struct name_num_obj *nno, const char *name
|
||||
len = strlen(name);
|
||||
|
||||
for (nni = nno->list; nni->name; nni++) {
|
||||
if (nni->num == CSUM_gone)
|
||||
continue;
|
||||
if (strncasecmp(name, nni->name, len) == 0 && nni->name[len] == '\0')
|
||||
return nni;
|
||||
}
|
||||
@@ -257,10 +263,12 @@ static void init_nno_saw(struct name_num_obj *nno, int val)
|
||||
if (!nno->saw) {
|
||||
nno->saw = new_array0(uchar, nno->saw_len);
|
||||
|
||||
/* We'll take this opportunity to make sure that the main_name values are set right. */
|
||||
/* We'll take this opportunity to set the main_nni values for duplicates. */
|
||||
for (cnt = 1, nni = nno->list; nni->name; nni++, cnt++) {
|
||||
if (nni->num == CSUM_gone)
|
||||
continue;
|
||||
if (nno->saw[nni->num])
|
||||
nni->main_name = nno->list[nno->saw[nni->num]-1].name;
|
||||
nni->main_nni = &nno->list[nno->saw[nni->num]-1];
|
||||
else
|
||||
nno->saw[nni->num] = cnt;
|
||||
}
|
||||
@@ -286,8 +294,8 @@ static int parse_nni_str(struct name_num_obj *nno, const char *from, char *tobuf
|
||||
struct name_num_item *nni = get_nni_by_name(nno, tok, to - tok);
|
||||
if (nni && !nno->saw[nni->num]) {
|
||||
nno->saw[nni->num] = ++cnt;
|
||||
if (nni->main_name) {
|
||||
to = tok + strlcpy(tok, nni->main_name, tobuf_len - (tok - tobuf));
|
||||
if (nni->main_nni) {
|
||||
to = tok + strlcpy(tok, nni->main_nni->name, tobuf_len - (tok - tobuf));
|
||||
if (to - tobuf >= tobuf_len) {
|
||||
to = tok - 1;
|
||||
break;
|
||||
@@ -321,13 +329,44 @@ static int parse_nni_str(struct name_num_obj *nno, const char *from, char *tobuf
|
||||
return to - tobuf;
|
||||
}
|
||||
|
||||
static int parse_negotiate_str(struct name_num_obj *nno, char *tmpbuf)
|
||||
{
|
||||
struct name_num_item *nni, *ret = NULL;
|
||||
int best = nno->saw_len; /* We want best == 1 from the client list, so start with a big number. */
|
||||
char *space, *tok = tmpbuf;
|
||||
while (tok) {
|
||||
while (*tok == ' ') tok++; /* Should be unneeded... */
|
||||
if (!*tok)
|
||||
break;
|
||||
if ((space = strchr(tok, ' ')) != NULL)
|
||||
*space = '\0';
|
||||
nni = get_nni_by_name(nno, tok, -1);
|
||||
if (space) {
|
||||
*space = ' ';
|
||||
tok = space + 1;
|
||||
} else
|
||||
tok = NULL;
|
||||
if (!nni || !nno->saw[nni->num] || best <= nno->saw[nni->num])
|
||||
continue;
|
||||
ret = nni;
|
||||
best = nno->saw[nni->num];
|
||||
if (best == 1 || am_server) /* The server side stops at the first acceptable client choice */
|
||||
break;
|
||||
}
|
||||
if (ret) {
|
||||
free(nno->saw);
|
||||
nno->saw = NULL;
|
||||
nno->negotiated_nni = ret->main_nni ? ret->main_nni : ret;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This routine is always called with a tmpbuf of MAX_NSTR_STRLEN length, but the
|
||||
* buffer may be pre-populated with a "len" length string to use OR a len of -1
|
||||
* to tell us to read a string from the fd. */
|
||||
static void recv_negotiate_str(int f_in, struct name_num_obj *nno, char *tmpbuf, int len)
|
||||
{
|
||||
struct name_num_item *ret = NULL;
|
||||
|
||||
if (len < 0)
|
||||
len = read_vstring(f_in, tmpbuf, MAX_NSTR_STRLEN);
|
||||
|
||||
@@ -338,37 +377,8 @@ static void recv_negotiate_str(int f_in, struct name_num_obj *nno, char *tmpbuf,
|
||||
rprintf(FINFO, "Server %s list (on client): %s\n", nno->type, tmpbuf);
|
||||
}
|
||||
|
||||
if (len > 0) {
|
||||
struct name_num_item *nni;
|
||||
int best = nno->saw_len; /* We want best == 1 from the client list, so start with a big number. */
|
||||
char *space, *tok = tmpbuf;
|
||||
while (tok) {
|
||||
while (*tok == ' ') tok++; /* Should be unneeded... */
|
||||
if (!*tok)
|
||||
break;
|
||||
if ((space = strchr(tok, ' ')) != NULL)
|
||||
*space = '\0';
|
||||
nni = get_nni_by_name(nno, tok, -1);
|
||||
if (space) {
|
||||
*space = ' ';
|
||||
tok = space + 1;
|
||||
} else
|
||||
tok = NULL;
|
||||
if (!nni || !nno->saw[nni->num] || best <= nno->saw[nni->num])
|
||||
continue;
|
||||
ret = nni;
|
||||
best = nno->saw[nni->num];
|
||||
if (best == 1 || am_server) /* The server side stops at the first acceptable client choice */
|
||||
break;
|
||||
}
|
||||
if (ret) {
|
||||
free(nno->saw);
|
||||
nno->saw = NULL;
|
||||
nno->negotiated_name = ret->main_name ? ret->main_name : ret->name;
|
||||
nno->negotiated_num = ret->num;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (len > 0 && parse_negotiate_str(nno, tmpbuf))
|
||||
return;
|
||||
|
||||
if (!am_server || !do_negotiated_strings) {
|
||||
char *cp = tmpbuf;
|
||||
@@ -464,8 +474,10 @@ int get_default_nno_list(struct name_num_obj *nno, char *to_buf, int to_buf_len,
|
||||
init_nno_saw(nno, 0);
|
||||
|
||||
for (nni = nno->list, len = 0; nni->name; nni++) {
|
||||
if (nni->main_name) {
|
||||
if (!dup_markup)
|
||||
if (nni->num == CSUM_gone)
|
||||
continue;
|
||||
if (nni->main_nni) {
|
||||
if (!dup_markup || nni->main_nni->num == CSUM_gone)
|
||||
continue;
|
||||
delim = dup_markup;
|
||||
}
|
||||
@@ -554,7 +566,7 @@ static void negotiate_the_strings(int f_in, int f_out)
|
||||
/* If the other side is too old to negotiate, the above steps just made sure that
|
||||
* the env didn't disallow the old algorithm. Mark things as non-negotiated. */
|
||||
if (!do_negotiated_strings)
|
||||
valid_checksums.negotiated_name = valid_compressions.negotiated_name = NULL;
|
||||
valid_checksums.negotiated_nni = valid_compressions.negotiated_nni = NULL;
|
||||
}
|
||||
|
||||
void setup_protocol(int f_out,int f_in)
|
||||
@@ -803,11 +815,77 @@ void setup_protocol(int f_out,int f_in)
|
||||
checksum_seed = read_int(f_in);
|
||||
}
|
||||
|
||||
parse_checksum_choice(1); /* Sets checksum_type & xfersum_type */
|
||||
parse_checksum_choice(1); /* Sets file_sum_nni & xfer_sum_nni */
|
||||
parse_compress_choice(1); /* Sets do_compression */
|
||||
|
||||
/* TODO in the future allow this algorithm to be chosen somehow, but it can't get too
|
||||
* long or the size starts to cause a problem in the xattr abbrev/non-abbrev code. */
|
||||
xattr_sum_nni = parse_csum_name(NULL, 0);
|
||||
xattr_sum_len = csum_len_for_type(xattr_sum_nni->num, 0);
|
||||
|
||||
if (write_batch && !am_server)
|
||||
write_batch_shell_file();
|
||||
|
||||
init_flist();
|
||||
}
|
||||
|
||||
void output_daemon_greeting(int f_out, int am_client)
|
||||
{
|
||||
char tmpbuf[MAX_NSTR_STRLEN];
|
||||
int our_sub = get_subprotocol_version();
|
||||
|
||||
init_checksum_choices();
|
||||
|
||||
get_default_nno_list(&valid_auth_checksums, tmpbuf, MAX_NSTR_STRLEN, '\0');
|
||||
|
||||
io_printf(f_out, "@RSYNCD: %d.%d %s\n", protocol_version, our_sub, tmpbuf);
|
||||
|
||||
if (am_client && DEBUG_GTE(NSTR, 2))
|
||||
rprintf(FINFO, "Client %s list (on client): %s\n", valid_auth_checksums.type, tmpbuf);
|
||||
}
|
||||
|
||||
void negotiate_daemon_auth(int f_out, int am_client)
|
||||
{
|
||||
char tmpbuf[MAX_NSTR_STRLEN];
|
||||
int save_am_server = am_server;
|
||||
int md4_is_old = 0;
|
||||
|
||||
if (!am_client)
|
||||
am_server = 1;
|
||||
|
||||
if (daemon_auth_choices)
|
||||
strlcpy(tmpbuf, daemon_auth_choices, MAX_NSTR_STRLEN);
|
||||
else {
|
||||
strlcpy(tmpbuf, protocol_version >= 30 ? "md5" : "md4", MAX_NSTR_STRLEN);
|
||||
md4_is_old = 1;
|
||||
}
|
||||
|
||||
if (am_client) {
|
||||
recv_negotiate_str(-1, &valid_auth_checksums, tmpbuf, strlen(tmpbuf));
|
||||
if (DEBUG_GTE(NSTR, 1)) {
|
||||
rprintf(FINFO, "Client negotiated %s: %s\n", valid_auth_checksums.type,
|
||||
valid_auth_checksums.negotiated_nni->name);
|
||||
}
|
||||
} else {
|
||||
if (!parse_negotiate_str(&valid_auth_checksums, tmpbuf)) {
|
||||
get_default_nno_list(&valid_auth_checksums, tmpbuf, MAX_NSTR_STRLEN, '\0');
|
||||
io_printf(f_out, "@ERROR: your client does not support one of our daemon-auth checksums: %s\n",
|
||||
tmpbuf);
|
||||
exit_cleanup(RERR_UNSUPPORTED);
|
||||
}
|
||||
}
|
||||
am_server = save_am_server;
|
||||
if (md4_is_old && valid_auth_checksums.negotiated_nni->num == CSUM_MD4) {
|
||||
valid_auth_checksums.negotiated_nni->num = CSUM_MD4_OLD;
|
||||
valid_auth_checksums.negotiated_nni->flags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int get_subprotocol_version()
|
||||
{
|
||||
#if SUBPROTOCOL_VERSION != 0
|
||||
return protocol_version < PROTOCOL_VERSION ? 0 : SUBPROTOCOL_VERSION;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
1210
config.guess
vendored
1210
config.guess
vendored
File diff suppressed because it is too large
Load Diff
676
config.sub
vendored
676
config.sub
vendored
File diff suppressed because it is too large
Load Diff
57
configure.ac
57
configure.ac
@@ -4,7 +4,6 @@ AC_INIT([rsync],[ ],[https://rsync.samba.org/bug-tracking.html])
|
||||
|
||||
AC_C_BIGENDIAN
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_TIME
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h \
|
||||
unistd.h utime.h compat.h sys/param.h ctype.h sys/wait.h sys/stat.h \
|
||||
@@ -20,7 +19,7 @@ AC_HEADER_MAJOR_FIXED
|
||||
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_SRCDIR([byteorder.h])
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_PREREQ([2.69])
|
||||
|
||||
PACKAGE_VERSION=`sed -n 's/.*RSYNC_VERSION.*"\(.*\)".*/\1/p' <$srcdir/version.h`
|
||||
@@ -61,7 +60,6 @@ AC_PROG_AWK
|
||||
AC_PROG_EGREP
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MKDIR_P
|
||||
AC_PROG_CC_STDC
|
||||
AC_SUBST(SHELL)
|
||||
AC_PATH_PROG([PERL], [perl])
|
||||
AC_PATH_PROG([PYTHON3], [python3])
|
||||
@@ -136,6 +134,16 @@ if test x"$GCC" = x"yes"; then
|
||||
CFLAGS="$CFLAGS -Wall -W"
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(openssl-conf,
|
||||
AS_HELP_STRING([--with-openssl-conf=PATH],[set default OPENSSL_CONF path for rsync]))
|
||||
case "$with_openssl_conf" in
|
||||
*[^-/a-zA-Z0-9.,=@+_]*) AC_MSG_ERROR([Invalid path given to --with-openssl-conf]) ;;
|
||||
/*) CFLAGS="$CFLAGS -DSET_OPENSSL_CONF=$with_openssl_conf" ;;
|
||||
no|'') ;;
|
||||
yes) AC_MSG_ERROR([No path given to --with-openssl-conf]) ;;
|
||||
*) AC_MSG_ERROR([Non absolute path given to --with-openssl-conf]) ;;
|
||||
esac
|
||||
|
||||
AC_ARG_WITH(rrsync,
|
||||
AS_HELP_STRING([--with-rrsync],[also install the rrsync script and its manpage]))
|
||||
if test x"$with_rrsync" != x"yes"; then
|
||||
@@ -153,10 +161,10 @@ AC_ARG_WITH(included-popt,
|
||||
AC_ARG_WITH(included-zlib,
|
||||
AS_HELP_STRING([--with-included-zlib],[use bundled zlib library, not from system]))
|
||||
|
||||
AC_ARG_WITH(protected-args,
|
||||
AS_HELP_STRING([--with-protected-args],[make --protected-args option the default]))
|
||||
if test x"$with_protected_args" = x"yes"; then
|
||||
AC_DEFINE_UNQUOTED(RSYNC_USE_PROTECTED_ARGS, 1, [Define to 1 if --protected-args should be the default])
|
||||
AC_ARG_WITH(secluded-args,
|
||||
AS_HELP_STRING([--with-secluded-args],[make --secluded-args option the default]))
|
||||
if test x"$with_secluded_args" = x"yes"; then
|
||||
AC_DEFINE_UNQUOTED(RSYNC_USE_SECLUDED_ARGS, 1, [Define to 1 if --secluded-args should be the default])
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(rsync-path,
|
||||
@@ -380,7 +388,7 @@ AS_HELP_STRING([--disable-ipv6],[disable to omit ipv6 support]),
|
||||
;;
|
||||
esac ],
|
||||
|
||||
AC_TRY_RUN([ /* AF_INET6 availability check */
|
||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 availability check */
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -391,11 +399,11 @@ main()
|
||||
else
|
||||
exit(0);
|
||||
}
|
||||
],
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(INET6, 1, [true if you have IPv6]),
|
||||
AC_MSG_RESULT(no),
|
||||
AC_MSG_RESULT(no)
|
||||
]])],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(INET6, 1, true if you have IPv6)],
|
||||
[AC_MSG_RESULT(no)],
|
||||
[AC_MSG_RESULT(no)]
|
||||
))
|
||||
|
||||
dnl Do you want to disable use of locale functions
|
||||
@@ -424,10 +432,10 @@ AH_TEMPLATE([USE_OPENSSL],
|
||||
if test x"$enable_openssl" != x"no"; then
|
||||
if test x"$ac_cv_header_openssl_md4_h" = x"yes" && test x"$ac_cv_header_openssl_md5_h" = x"yes"; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_SEARCH_LIBS(MD5_Init, crypto,
|
||||
AC_SEARCH_LIBS(EVP_MD_CTX_copy, crypto,
|
||||
[AC_DEFINE(USE_OPENSSL)
|
||||
enable_openssl=yes],
|
||||
[err_msg="$err_msg$nl- Failed to find MD5_Init function in openssl crypto lib.";
|
||||
[err_msg="$err_msg$nl- Failed to find EVP_MD_CTX_copy function in openssl crypto lib.";
|
||||
no_lib="$no_lib openssl"])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
@@ -518,7 +526,7 @@ fi
|
||||
|
||||
AC_MSG_CHECKING([whether to enable zstd compression])
|
||||
AC_ARG_ENABLE([zstd],
|
||||
AC_HELP_STRING([--disable-zstd], [disable to omit zstd compression]))
|
||||
AS_HELP_STRING([--disable-zstd], [disable to omit zstd compression]))
|
||||
AH_TEMPLATE([SUPPORT_ZSTD],
|
||||
[Undefine if you do not want zstd compression. By default this is defined.])
|
||||
if test x"$enable_zstd" != x"no"; then
|
||||
@@ -539,7 +547,7 @@ fi
|
||||
|
||||
AC_MSG_CHECKING([whether to enable LZ4 compression])
|
||||
AC_ARG_ENABLE([lz4],
|
||||
AC_HELP_STRING([--disable-lz4], [disable to omit LZ4 compression]))
|
||||
AS_HELP_STRING([--disable-lz4], [disable to omit LZ4 compression]))
|
||||
AH_TEMPLATE([SUPPORT_LZ4],
|
||||
[Undefine if you do not want LZ4 compression. By default this is defined.])
|
||||
if test x"$enable_lz4" != x"no"; then
|
||||
@@ -1071,21 +1079,6 @@ elif test x"$ac_cv_header_popt_h" != x"yes"; then
|
||||
with_included_popt=yes
|
||||
fi
|
||||
|
||||
if test x"$GCC" = x"yes"; then
|
||||
if test x"$with_included_popt" != x"yes"; then
|
||||
# Turn pedantic warnings into errors to ensure an array-init overflow is an error.
|
||||
CFLAGS="$CFLAGS -pedantic-errors"
|
||||
else
|
||||
# Our internal popt code cannot be compiled with pedantic warnings as errors, so try to
|
||||
# turn off pedantic warnings (which will not lose the error for array-init overflow).
|
||||
# Older gcc versions don't understand -Wno-pedantic, so check if --help=warnings lists
|
||||
# -Wpedantic and use that as a flag.
|
||||
case `$CC --help=warnings 2>/dev/null | grep Wpedantic` in
|
||||
*-Wpedantic*) CFLAGS="$CFLAGS -pedantic-errors -Wno-pedantic" ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([whether to use included libpopt])
|
||||
if test x"$with_included_popt" = x"yes"; then
|
||||
AC_MSG_RESULT($srcdir/popt)
|
||||
|
||||
@@ -7,39 +7,54 @@ basically a summary of clientserver.c and authenticate.c.
|
||||
This is the protocol used for rsync --daemon; i.e. connections to port
|
||||
873 rather than invocations over a remote shell.
|
||||
|
||||
When the server accepts a connection, it prints a greeting
|
||||
When the server accepts a connection, it prints a newline-terminated
|
||||
greeting line:
|
||||
|
||||
@RSYNCD: <version>.<subprotocol>
|
||||
@RSYNCD: <version>.<subprotocol> <digest1> <digestN>
|
||||
|
||||
where <version> is the numeric version (see PROTOCOL_VERSION in rsync.h)
|
||||
'.' is a literal period, and <subprotocol> is the numeric subprotocol
|
||||
version (see SUBPROTOCOL_VERSION -- it will be 0 for final releases).
|
||||
Protocols prior to 30 only output <version> alone. The daemon expects
|
||||
to see a similar greeting back from the client. For protocols prior to
|
||||
30, an absent ".<subprotocol>" value is assumed to be 0. For protocol
|
||||
30, an absent value is a fatal error. The daemon then follows this line
|
||||
with a free-format text message-of-the-day (if any is defined).
|
||||
The <version> is the numeric version (see PROTOCOL_VERSION in rsync.h)
|
||||
The <subprotocol> is the numeric subprotocol version (which is 0 for a
|
||||
final protocol version, as the SUBPROTOCOL_VERSION define discusses).
|
||||
The <digestN> names are the authentication digest algorithms that the
|
||||
daemon supports, listed in order of preference.
|
||||
|
||||
An rsync prior to 3.2.7 omits the digest names. An rsync prior to 3.0.0
|
||||
also omits the period and the <subprotocol> value. Since a final
|
||||
protocol has a subprotocol value of 0, a missing subprotocol value is
|
||||
assumed to be 0 for any protocol prior to 30. It is considered a fatal
|
||||
error for protocol 30 and above to omit it. It is considered a fatal
|
||||
error for protocol 32 and above to omit the digest name list (currently
|
||||
31 is the newest protocol).
|
||||
|
||||
The daemon expects to see a similar greeting line back from the client.
|
||||
Once received, the daemon follows the opening line with a free-format
|
||||
text message-of-the-day (if any is defined).
|
||||
|
||||
The server is now in the connected state. The client can either send
|
||||
the command
|
||||
the command:
|
||||
|
||||
#list
|
||||
|
||||
to get a listing of modules, or the name of a module. After this, the
|
||||
(to get a listing of modules) or the name of a module. After this, the
|
||||
connection is now bound to a particular module. Access per host for
|
||||
this module is now checked, as is per-module connection limits.
|
||||
|
||||
If authentication is required to use this module, the server will say
|
||||
If authentication is required to use this module, the server will say:
|
||||
|
||||
@RSYNCD: AUTHREQD <challenge>
|
||||
|
||||
where <challenge> is a random string of base64 characters. The client
|
||||
must respond with
|
||||
must respond with:
|
||||
|
||||
<user> <response>
|
||||
|
||||
where <user> is the username they claim to be, and <response> is the
|
||||
base64 form of the MD4 hash of challenge+password.
|
||||
The <user> is the username they claim to be. The <response> is the
|
||||
base64 form of the digest hash of the challenge+password string. The
|
||||
chosen digest method is the most preferred client method that is also in
|
||||
the server's list. If no digest list was explicitly provided, the side
|
||||
expecting a list assumes the other side provided either the single name
|
||||
"md5" (for a negotiated protocol 30 or 31), or the single name "md4"
|
||||
(for an older protocol).
|
||||
|
||||
At this point the server applies all remaining constraints before
|
||||
handing control to the client, including switching uid/gid, setting up
|
||||
@@ -76,6 +91,13 @@ stay tuned (or write it yourself!).
|
||||
------------
|
||||
Protocol version changes
|
||||
|
||||
31 (2013-09-28, 3.1.0)
|
||||
|
||||
Initial release of protocol 31 had no changes. Rsync 3.2.7
|
||||
introduced the suffixed list of digest names on the greeting
|
||||
line. The presence of the list is allowed even if the greeting
|
||||
indicates an older protocol version number.
|
||||
|
||||
30 (2007-10-04, 3.0.0pre1)
|
||||
|
||||
The use of a ".<subprotocol>" number was added to
|
||||
|
||||
@@ -60,9 +60,9 @@ BOOL read_only True
|
||||
BOOL reverse_lookup True
|
||||
BOOL strict_modes True
|
||||
BOOL transfer_logging False
|
||||
BOOL use_chroot True
|
||||
BOOL write_only False
|
||||
|
||||
BOOL3 munge_symlinks Unset
|
||||
BOOL3 numeric_ids Unset
|
||||
BOOL3 open_noatime Unset
|
||||
BOOL3 use_chroot Unset
|
||||
|
||||
4
delete.c
4
delete.c
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996-2000 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2003-2020 Wayne Davison
|
||||
* Copyright (C) 2003-2024 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -188,7 +188,7 @@ enum delret delete_item(char *fbuf, uint16 mode, uint16 flags)
|
||||
stats.deleted_symlinks++;
|
||||
#endif
|
||||
else if (IS_DEVICE(mode))
|
||||
stats.deleted_symlinks++;
|
||||
stats.deleted_devices++;
|
||||
else
|
||||
stats.deleted_specials++;
|
||||
}
|
||||
|
||||
184
exclude.c
184
exclude.c
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996-2001 Andrew Tridgell <tridge@samba.org>
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2002 Martin Pool
|
||||
* Copyright (C) 2003-2022 Wayne Davison
|
||||
* Copyright (C) 2003-2024 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -78,6 +78,10 @@ static filter_rule **mergelist_parents;
|
||||
static int mergelist_cnt = 0;
|
||||
static int mergelist_size = 0;
|
||||
|
||||
#define LOCAL_RULE 1
|
||||
#define REMOTE_RULE 2
|
||||
static uchar cur_elide_value = REMOTE_RULE;
|
||||
|
||||
/* Each filter_list_struct describes a singly-linked list by keeping track
|
||||
* of both the head and tail pointers. The list is slightly unusual in that
|
||||
* a parent-dir's content can be appended to the end of the local list in a
|
||||
@@ -220,6 +224,7 @@ static void add_rule(filter_rule_list *listp, const char *pat, unsigned int pat_
|
||||
slash_cnt++;
|
||||
}
|
||||
}
|
||||
rule->elide = 0;
|
||||
strlcpy(rule->pattern + pre_len, pat, pat_len + 1);
|
||||
pat_len += pre_len;
|
||||
if (suf_len) {
|
||||
@@ -361,6 +366,8 @@ void implied_include_partial_string(const char *s_start, const char *s_end)
|
||||
void free_implied_include_partial_string()
|
||||
{
|
||||
if (partial_string_buf) {
|
||||
if (partial_string_len)
|
||||
add_implied_include("", 0);
|
||||
free(partial_string_buf);
|
||||
partial_string_buf = NULL;
|
||||
}
|
||||
@@ -371,9 +378,8 @@ void free_implied_include_partial_string()
|
||||
* that the receiver uses to validate the file list from the sender. */
|
||||
void add_implied_include(const char *arg, int skip_daemon_module)
|
||||
{
|
||||
filter_rule *rule;
|
||||
int arg_len, saw_wild = 0, saw_live_open_brkt = 0, backslash_cnt = 0;
|
||||
int slash_cnt = 1; /* We know we're adding a leading slash. */
|
||||
int slash_cnt = 0;
|
||||
const char *cp;
|
||||
char *p;
|
||||
if (trust_sender_args)
|
||||
@@ -404,6 +410,7 @@ void add_implied_include(const char *arg, int skip_daemon_module)
|
||||
arg++;
|
||||
arg_len = strlen(arg);
|
||||
if (arg_len) {
|
||||
char *new_pat;
|
||||
if (strpbrk(arg, "*[?")) {
|
||||
/* We need to add room to escape backslashes if wildcard chars are present. */
|
||||
for (cp = arg; (cp = strchr(cp, '\\')) != NULL; cp++)
|
||||
@@ -411,16 +418,9 @@ void add_implied_include(const char *arg, int skip_daemon_module)
|
||||
saw_wild = 1;
|
||||
}
|
||||
arg_len++; /* Leave room for the prefixed slash */
|
||||
rule = new0(filter_rule);
|
||||
if (!implied_filter_list.head)
|
||||
implied_filter_list.head = implied_filter_list.tail = rule;
|
||||
else {
|
||||
rule->next = implied_filter_list.head;
|
||||
implied_filter_list.head = rule;
|
||||
}
|
||||
rule->rflags = FILTRULE_INCLUDE + (saw_wild ? FILTRULE_WILD : 0);
|
||||
p = rule->pattern = new_array(char, arg_len + 1);
|
||||
p = new_pat = new_array(char, arg_len + 1);
|
||||
*p++ = '/';
|
||||
slash_cnt++;
|
||||
for (cp = arg; *cp; ) {
|
||||
switch (*cp) {
|
||||
case '\\':
|
||||
@@ -436,39 +436,33 @@ void add_implied_include(const char *arg, int skip_daemon_module)
|
||||
break;
|
||||
case '/':
|
||||
if (p[-1] == '/') { /* This is safe because of the initial slash. */
|
||||
if (*++cp == '\0') {
|
||||
slash_cnt--;
|
||||
p--;
|
||||
}
|
||||
} else if (cp[1] == '\0') {
|
||||
cp++;
|
||||
break;
|
||||
} else {
|
||||
slash_cnt++;
|
||||
*p++ = *cp++;
|
||||
}
|
||||
if (relative_paths) {
|
||||
filter_rule const *ent;
|
||||
int found = 0;
|
||||
*p = '\0';
|
||||
for (ent = implied_filter_list.head; ent; ent = ent->next) {
|
||||
if (ent != rule && strcmp(ent->pattern, rule->pattern) == 0) {
|
||||
found = 1;
|
||||
break;
|
||||
break;
|
||||
case '.':
|
||||
if (p[-1] == '/') {
|
||||
if (cp[1] == '/') {
|
||||
cp += 2;
|
||||
if (!*cp) {
|
||||
slash_cnt--;
|
||||
p--;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
filter_rule *R_rule = new0(filter_rule);
|
||||
R_rule->rflags = FILTRULE_INCLUDE | FILTRULE_DIRECTORY;
|
||||
/* Check if our sub-path has wildcards or escaped backslashes */
|
||||
if (saw_wild && strpbrk(rule->pattern, "*[?\\"))
|
||||
R_rule->rflags |= FILTRULE_WILD;
|
||||
R_rule->pattern = strdup(rule->pattern);
|
||||
R_rule->u.slash_cnt = slash_cnt;
|
||||
R_rule->next = implied_filter_list.head;
|
||||
implied_filter_list.head = R_rule;
|
||||
if (DEBUG_GTE(FILTER, 3)) {
|
||||
rprintf(FINFO, "[%s] add_implied_include(%s/)\n",
|
||||
who_am_i(), R_rule->pattern);
|
||||
}
|
||||
if (saw_live_open_brkt)
|
||||
maybe_add_literal_brackets_rule(R_rule, -1);
|
||||
}
|
||||
}
|
||||
slash_cnt++;
|
||||
*p++ = *cp++;
|
||||
} else if (cp[1] == '\0') {
|
||||
cp++;
|
||||
slash_cnt--;
|
||||
p--;
|
||||
} else
|
||||
*p++ = *cp++;
|
||||
} else
|
||||
*p++ = *cp++;
|
||||
break;
|
||||
case '[':
|
||||
saw_live_open_brkt = 1;
|
||||
@@ -480,18 +474,68 @@ void add_implied_include(const char *arg, int skip_daemon_module)
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
rule->u.slash_cnt = slash_cnt;
|
||||
arg = rule->pattern;
|
||||
arg_len = p - arg; /* We recompute it due to backslash weirdness. */
|
||||
if (DEBUG_GTE(FILTER, 3))
|
||||
rprintf(FINFO, "[%s] add_implied_include(%s)\n", who_am_i(), rule->pattern);
|
||||
if (saw_live_open_brkt)
|
||||
maybe_add_literal_brackets_rule(rule, arg_len);
|
||||
arg_len = p - new_pat;
|
||||
if (!arg_len)
|
||||
free(new_pat);
|
||||
else {
|
||||
filter_rule *rule = new0(filter_rule);
|
||||
rule->rflags = FILTRULE_INCLUDE + (saw_wild ? FILTRULE_WILD : 0);
|
||||
rule->u.slash_cnt = slash_cnt;
|
||||
arg = rule->pattern = new_pat;
|
||||
if (!implied_filter_list.head)
|
||||
implied_filter_list.head = implied_filter_list.tail = rule;
|
||||
else {
|
||||
rule->next = implied_filter_list.head;
|
||||
implied_filter_list.head = rule;
|
||||
}
|
||||
if (DEBUG_GTE(FILTER, 3))
|
||||
rprintf(FINFO, "[%s] add_implied_include(%s)\n", who_am_i(), arg);
|
||||
if (saw_live_open_brkt)
|
||||
maybe_add_literal_brackets_rule(rule, arg_len);
|
||||
if (relative_paths && slash_cnt) {
|
||||
int sub_slash_cnt = slash_cnt;
|
||||
while ((p = strrchr(new_pat, '/')) != NULL && p != new_pat) {
|
||||
filter_rule const *ent;
|
||||
filter_rule *R_rule;
|
||||
int found = 0;
|
||||
*p = '\0';
|
||||
for (ent = implied_filter_list.head; ent; ent = ent->next) {
|
||||
if (ent != rule && strcmp(ent->pattern, new_pat) == 0) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
*p = '/';
|
||||
break; /* We added all parent dirs already */
|
||||
}
|
||||
R_rule = new0(filter_rule);
|
||||
R_rule->rflags = FILTRULE_INCLUDE | FILTRULE_DIRECTORY;
|
||||
/* Check if our sub-path has wildcards or escaped backslashes */
|
||||
if (saw_wild && strpbrk(new_pat, "*[?\\"))
|
||||
R_rule->rflags |= FILTRULE_WILD;
|
||||
R_rule->pattern = strdup(new_pat);
|
||||
R_rule->u.slash_cnt = --sub_slash_cnt;
|
||||
R_rule->next = implied_filter_list.head;
|
||||
implied_filter_list.head = R_rule;
|
||||
if (DEBUG_GTE(FILTER, 3)) {
|
||||
rprintf(FINFO, "[%s] add_implied_include(%s/)\n",
|
||||
who_am_i(), R_rule->pattern);
|
||||
}
|
||||
if (saw_live_open_brkt)
|
||||
maybe_add_literal_brackets_rule(R_rule, -1);
|
||||
}
|
||||
for (p = new_pat; sub_slash_cnt < slash_cnt; sub_slash_cnt++) {
|
||||
p += strlen(p);
|
||||
*p = '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (recurse || xfer_dirs) {
|
||||
/* Now create a rule with an added "/" & "**" or "*" at the end */
|
||||
rule = new0(filter_rule);
|
||||
filter_rule *rule = new0(filter_rule);
|
||||
rule->rflags = FILTRULE_INCLUDE | FILTRULE_WILD;
|
||||
if (recurse)
|
||||
rule->rflags |= FILTRULE_WILD2;
|
||||
@@ -499,7 +543,7 @@ void add_implied_include(const char *arg, int skip_daemon_module)
|
||||
if (!saw_wild && backslash_cnt) {
|
||||
/* We are appending a wildcard, so now the backslashes need to be escaped. */
|
||||
p = rule->pattern = new_array(char, arg_len + backslash_cnt + 3 + 1);
|
||||
for (cp = arg; *cp; ) {
|
||||
for (cp = arg; *cp; ) { /* Note that arg_len != 0 because backslash_cnt > 0 */
|
||||
if (*cp == '\\')
|
||||
*p++ = '\\';
|
||||
*p++ = *cp++;
|
||||
@@ -511,8 +555,7 @@ void add_implied_include(const char *arg, int skip_daemon_module)
|
||||
p += arg_len;
|
||||
}
|
||||
}
|
||||
if (p[-1] != '/')
|
||||
*p++ = '/';
|
||||
*p++ = '/';
|
||||
*p++ = '*';
|
||||
if (recurse)
|
||||
*p++ = '*';
|
||||
@@ -677,7 +720,8 @@ static BOOL setup_merge_file(int mergelist_num, filter_rule *ex,
|
||||
parent_dirscan = True;
|
||||
while (*y) {
|
||||
char save[MAXPATHLEN];
|
||||
strlcpy(save, y, MAXPATHLEN);
|
||||
/* copylen is strlen(y) which is < MAXPATHLEN. +1 for \0 */
|
||||
size_t copylen = strlcpy(save, y, MAXPATHLEN) + 1;
|
||||
*y = '\0';
|
||||
dirbuf_len = y - dirbuf;
|
||||
strlcpy(x, ex->pattern, MAXPATHLEN - (x - buf));
|
||||
@@ -691,7 +735,7 @@ static BOOL setup_merge_file(int mergelist_num, filter_rule *ex,
|
||||
lp->head = NULL;
|
||||
}
|
||||
lp->tail = NULL;
|
||||
strlcpy(y, save, MAXPATHLEN);
|
||||
strlcpy(y, save, copylen);
|
||||
while ((*x++ = *y++) != '/') {}
|
||||
}
|
||||
parent_dirscan = False;
|
||||
@@ -864,7 +908,7 @@ static int rule_matches(const char *fname, filter_rule *ex, int name_flags)
|
||||
const char *strings[16]; /* more than enough */
|
||||
const char *name = fname + (*fname == '/');
|
||||
|
||||
if (!*name)
|
||||
if (!*name || ex->elide == cur_elide_value)
|
||||
return 0;
|
||||
|
||||
if (!(name_flags & NAME_IS_XATTR) ^ !(ex->rflags & FILTRULE_XATTR))
|
||||
@@ -980,6 +1024,15 @@ int name_is_excluded(const char *fname, int name_flags, int filter_level)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int check_server_filter(filter_rule_list *listp, enum logcode code, const char *name, int name_flags)
|
||||
{
|
||||
int ret;
|
||||
cur_elide_value = LOCAL_RULE;
|
||||
ret = check_filter(listp, code, name, name_flags);
|
||||
cur_elide_value = REMOTE_RULE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Return -1 if file "name" is defined to be excluded by the specified
|
||||
* exclude list, 1 if it is included, and 0 if it was not matched. */
|
||||
int check_filter(filter_rule_list *listp, enum logcode code,
|
||||
@@ -1535,7 +1588,7 @@ char *get_rule_prefix(filter_rule *rule, const char *pat, int for_xfer,
|
||||
|
||||
static void send_rules(int f_out, filter_rule_list *flp)
|
||||
{
|
||||
filter_rule *ent, *prev = NULL;
|
||||
filter_rule *ent;
|
||||
|
||||
for (ent = flp->head; ent; ent = ent->next) {
|
||||
unsigned int len, plen, dlen;
|
||||
@@ -1550,21 +1603,15 @@ static void send_rules(int f_out, filter_rule_list *flp)
|
||||
* merge files as an optimization (since they can only have
|
||||
* include/exclude rules). */
|
||||
if (ent->rflags & FILTRULE_SENDER_SIDE)
|
||||
elide = am_sender ? 1 : -1;
|
||||
elide = am_sender ? LOCAL_RULE : REMOTE_RULE;
|
||||
if (ent->rflags & FILTRULE_RECEIVER_SIDE)
|
||||
elide = elide ? 0 : am_sender ? -1 : 1;
|
||||
elide = elide ? 0 : am_sender ? REMOTE_RULE : LOCAL_RULE;
|
||||
else if (delete_excluded && !elide
|
||||
&& (!(ent->rflags & FILTRULE_PERDIR_MERGE)
|
||||
|| ent->rflags & FILTRULE_NO_PREFIXES))
|
||||
elide = am_sender ? 1 : -1;
|
||||
if (elide < 0) {
|
||||
if (prev)
|
||||
prev->next = ent->next;
|
||||
else
|
||||
flp->head = ent->next;
|
||||
} else
|
||||
prev = ent;
|
||||
if (elide > 0)
|
||||
elide = am_sender ? LOCAL_RULE : REMOTE_RULE;
|
||||
ent->elide = elide;
|
||||
if (elide == LOCAL_RULE)
|
||||
continue;
|
||||
if (ent->rflags & FILTRULE_CVS_IGNORE
|
||||
&& !(ent->rflags & FILTRULE_MERGE_FILE)) {
|
||||
@@ -1592,7 +1639,6 @@ static void send_rules(int f_out, filter_rule_list *flp)
|
||||
if (dlen)
|
||||
write_byte(f_out, '/');
|
||||
}
|
||||
flp->tail = prev;
|
||||
}
|
||||
|
||||
/* This is only called by the client. */
|
||||
|
||||
46
fileio.c
46
fileio.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1998 Andrew Tridgell
|
||||
* Copyright (C) 2002 Martin Pool
|
||||
* Copyright (C) 2004-2020 Wayne Davison
|
||||
* Copyright (C) 2004-2023 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -40,30 +40,34 @@ OFF_T preallocated_len = 0;
|
||||
static OFF_T sparse_seek = 0;
|
||||
static OFF_T sparse_past_write = 0;
|
||||
|
||||
int sparse_end(int f, OFF_T size)
|
||||
int sparse_end(int f, OFF_T size, int updating_basis_or_equiv)
|
||||
{
|
||||
int ret;
|
||||
int ret = 0;
|
||||
|
||||
sparse_past_write = 0;
|
||||
|
||||
if (!sparse_seek)
|
||||
return 0;
|
||||
|
||||
#ifdef HAVE_FTRUNCATE
|
||||
ret = do_ftruncate(f, size);
|
||||
#else
|
||||
if (do_lseek(f, sparse_seek-1, SEEK_CUR) != size-1)
|
||||
ret = -1;
|
||||
else {
|
||||
do {
|
||||
ret = write(f, "", 1);
|
||||
} while (ret < 0 && errno == EINTR);
|
||||
|
||||
ret = ret <= 0 ? -1 : 0;
|
||||
}
|
||||
if (updating_basis_or_equiv) {
|
||||
if (sparse_seek && do_punch_hole(f, sparse_past_write, sparse_seek) < 0)
|
||||
ret = -1;
|
||||
#ifdef HAVE_FTRUNCATE /* A compilation formality -- in-place requires ftruncate() */
|
||||
else /* Just in case the original file was longer */
|
||||
ret = do_ftruncate(f, size);
|
||||
#endif
|
||||
} else if (sparse_seek) {
|
||||
#ifdef HAVE_FTRUNCATE
|
||||
ret = do_ftruncate(f, size);
|
||||
#else
|
||||
if (do_lseek(f, sparse_seek-1, SEEK_CUR) != size-1)
|
||||
ret = -1;
|
||||
else {
|
||||
do {
|
||||
ret = write(f, "", 1);
|
||||
} while (ret < 0 && errno == EINTR);
|
||||
|
||||
sparse_seek = 0;
|
||||
ret = ret <= 0 ? -1 : 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
sparse_past_write = sparse_seek = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
26
flist.c
26
flist.c
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2002-2022 Wayne Davison
|
||||
* Copyright (C) 2002-2023 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -33,7 +33,6 @@ extern int am_sender;
|
||||
extern int am_generator;
|
||||
extern int inc_recurse;
|
||||
extern int always_checksum;
|
||||
extern int checksum_type;
|
||||
extern int module_id;
|
||||
extern int ignore_errors;
|
||||
extern int numeric_ids;
|
||||
@@ -80,6 +79,8 @@ extern struct stats stats;
|
||||
extern char *filesfrom_host;
|
||||
extern char *usermap, *groupmap;
|
||||
|
||||
extern struct name_num_item *file_sum_nni;
|
||||
|
||||
extern char curr_dir[MAXPATHLEN];
|
||||
|
||||
extern struct chmod_mode_struct *chmod_modes;
|
||||
@@ -145,7 +146,8 @@ void init_flist(void)
|
||||
rprintf(FINFO, "FILE_STRUCT_LEN=%d, EXTRA_LEN=%d\n",
|
||||
(int)FILE_STRUCT_LEN, (int)EXTRA_LEN);
|
||||
}
|
||||
flist_csum_len = csum_len_for_type(checksum_type, 1);
|
||||
/* Note that this isn't identical to file_sum_len in the case of CSUM_MD4_ARCHAIC: */
|
||||
flist_csum_len = csum_len_for_type(file_sum_nni->num, 1);
|
||||
|
||||
show_filelist_progress = INFO_GTE(FLIST, 1) && xfer_dirs && !am_server && !inc_recurse;
|
||||
}
|
||||
@@ -754,7 +756,7 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
|
||||
if (*thisname
|
||||
&& (clean_fname(thisname, CFN_REFUSE_DOT_DOT_DIRS) < 0 || (!relative_paths && *thisname == '/'))) {
|
||||
rprintf(FERROR, "ABORTING due to unsafe pathname from sender: %s\n", thisname);
|
||||
exit_cleanup(RERR_PROTOCOL);
|
||||
exit_cleanup(RERR_UNSUPPORTED);
|
||||
}
|
||||
|
||||
if (sanitize_paths)
|
||||
@@ -834,7 +836,7 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
|
||||
}
|
||||
#endif
|
||||
} else
|
||||
modtime = read_int(f);
|
||||
modtime = read_uint(f);
|
||||
}
|
||||
if (xflags & XMIT_MOD_NSEC)
|
||||
#ifndef CAN_SET_NSEC
|
||||
@@ -986,16 +988,16 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
|
||||
exit_cleanup(RERR_UNSUPPORTED);
|
||||
}
|
||||
|
||||
if (*thisname != '.' || thisname[1] != '\0') {
|
||||
if (*thisname == '/' ? thisname[1] != '.' || thisname[2] != '\0' : *thisname != '.' || thisname[1] != '\0') {
|
||||
int filt_flags = S_ISDIR(mode) ? NAME_IS_DIR : NAME_IS_FILE;
|
||||
if (!trust_sender_filter /* a per-dir filter rule means we must trust the sender's filtering */
|
||||
&& filter_list.head && check_filter(&filter_list, FINFO, thisname, filt_flags) < 0) {
|
||||
&& filter_list.head && check_server_filter(&filter_list, FINFO, thisname, filt_flags) < 0) {
|
||||
rprintf(FERROR, "ERROR: rejecting excluded file-list name: %s\n", thisname);
|
||||
exit_cleanup(RERR_PROTOCOL);
|
||||
exit_cleanup(RERR_UNSUPPORTED);
|
||||
}
|
||||
if (implied_filter_list.head && check_filter(&implied_filter_list, FINFO, thisname, filt_flags) <= 0) {
|
||||
rprintf(FERROR, "ERROR: rejecting unrequested file-list name: %s\n", thisname);
|
||||
exit_cleanup(RERR_PROTOCOL);
|
||||
exit_cleanup(RERR_UNSUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2365,7 +2367,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
||||
}
|
||||
|
||||
dirlen = dir ? strlen(dir) : 0;
|
||||
if (dirlen != lastdir_len || memcmp(lastdir, dir, dirlen) != 0) {
|
||||
if (dirlen != lastdir_len || (dirlen && memcmp(lastdir, dir, dirlen) != 0)) {
|
||||
if (!change_pathname(NULL, dir, -dirlen))
|
||||
goto bad_path;
|
||||
lastdir = pathname;
|
||||
@@ -2640,7 +2642,7 @@ struct file_list *recv_file_list(int f, int dir_ndx)
|
||||
rprintf(FERROR,
|
||||
"ABORTING due to invalid path from sender: %s/%s\n",
|
||||
cur_dir, file->basename);
|
||||
exit_cleanup(RERR_PROTOCOL);
|
||||
exit_cleanup(RERR_UNSUPPORTED);
|
||||
}
|
||||
good_dirname = cur_dir;
|
||||
}
|
||||
@@ -2657,7 +2659,7 @@ struct file_list *recv_file_list(int f, int dir_ndx)
|
||||
} else if (S_ISLNK(file->mode))
|
||||
stats.num_symlinks++;
|
||||
else if (IS_DEVICE(file->mode))
|
||||
stats.num_symlinks++;
|
||||
stats.num_devices++;
|
||||
else
|
||||
stats.num_specials++;
|
||||
|
||||
|
||||
15
generator.c
15
generator.c
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996-2000 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2003-2022 Wayne Davison
|
||||
* Copyright (C) 2003-2023 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -783,7 +783,7 @@ static int generate_and_send_sums(int fd, OFF_T len, int f_out, int f_copy)
|
||||
for (i = 0; i < sum.count; i++) {
|
||||
int32 n1 = (int32)MIN(len, (OFF_T)sum.blength);
|
||||
char *map = map_ptr(mapbuf, offset, n1);
|
||||
char sum2[SUM_LENGTH];
|
||||
char sum2[MAX_DIGEST_LEN];
|
||||
uint32 sum1;
|
||||
|
||||
len -= n1;
|
||||
@@ -875,9 +875,12 @@ static struct file_struct *find_fuzzy(struct file_struct *file, struct file_list
|
||||
len = strlen(name);
|
||||
suf = find_filename_suffix(name, len, &suf_len);
|
||||
|
||||
dist = fuzzy_distance(name, len, fname, fname_len);
|
||||
/* Add some extra weight to how well the suffixes match. */
|
||||
dist += fuzzy_distance(suf, suf_len, fname_suf, fname_suf_len) * 10;
|
||||
dist = fuzzy_distance(name, len, fname, fname_len, lowest_dist);
|
||||
/* Add some extra weight to how well the suffixes match unless we've already disqualified
|
||||
* this file based on a heuristic. */
|
||||
if (dist < 0xFFFF0000U) {
|
||||
dist += fuzzy_distance(suf, suf_len, fname_suf, fname_suf_len, 0xFFFF0000U) * 10;
|
||||
}
|
||||
if (DEBUG_GTE(FUZZY, 2)) {
|
||||
rprintf(FINFO, "fuzzy distance for %s = %d.%05d\n",
|
||||
f_name(fp, NULL), (int)(dist>>16), (int)(dist&0xFFFF));
|
||||
@@ -1819,7 +1822,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
|
||||
goto cleanup;
|
||||
return_with_success:
|
||||
if (!dry_run)
|
||||
send_msg_int(MSG_SUCCESS, ndx);
|
||||
send_msg_success(fname, ndx);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
||||
174
hashtable.c
174
hashtable.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Routines to provide a memory-efficient hashtable.
|
||||
*
|
||||
* Copyright (C) 2007-2020 Wayne Davison
|
||||
* Copyright (C) 2007-2022 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -350,6 +350,9 @@ void *hashtable_find(struct hashtable *tbl, int64 key, void *data_when_new)
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define NON_ZERO_32(x) ((x) ? (x) : (uint32_t)1)
|
||||
#define NON_ZERO_64(x, y) ((x) || (y) ? (y) | (int64)(x) << 32 | (y) : (int64)1)
|
||||
|
||||
uint32_t hashlittle(const void *key, size_t length)
|
||||
{
|
||||
uint32_t a,b,c; /* internal state */
|
||||
@@ -390,7 +393,7 @@ uint32_t hashlittle(const void *key, size_t length)
|
||||
case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
|
||||
case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */
|
||||
case 1 : a+=k8[0]; break;
|
||||
case 0 : return c;
|
||||
case 0 : return NON_ZERO_32(c);
|
||||
}
|
||||
} else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) {
|
||||
const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */
|
||||
@@ -436,7 +439,7 @@ uint32_t hashlittle(const void *key, size_t length)
|
||||
break;
|
||||
case 1 : a+=k8[0];
|
||||
break;
|
||||
case 0 : return c; /* zero length requires no mixing */
|
||||
case 0 : return NON_ZERO_32(c); /* zero length requires no mixing */
|
||||
}
|
||||
|
||||
} else { /* need to read the key one byte at a time */
|
||||
@@ -489,10 +492,171 @@ uint32_t hashlittle(const void *key, size_t length)
|
||||
/* FALLTHROUGH */
|
||||
case 1 : a+=k[0];
|
||||
break;
|
||||
case 0 : return c;
|
||||
case 0 : return NON_ZERO_32(c);
|
||||
}
|
||||
}
|
||||
|
||||
final(a,b,c);
|
||||
return c;
|
||||
return NON_ZERO_32(c);
|
||||
}
|
||||
|
||||
#if SIZEOF_INT64 >= 8
|
||||
/*
|
||||
* hashlittle2: return 2 32-bit hash values joined into an int64.
|
||||
*
|
||||
* This is identical to hashlittle(), except it returns two 32-bit hash
|
||||
* values instead of just one. This is good enough for hash table
|
||||
* lookup with 2^^64 buckets, or if you want a second hash if you're not
|
||||
* happy with the first, or if you want a probably-unique 64-bit ID for
|
||||
* the key. *pc is better mixed than *pb, so use *pc first. If you want
|
||||
* a 64-bit value do something like "*pc + (((uint64_t)*pb)<<32)".
|
||||
*/
|
||||
int64 hashlittle2(const void *key, size_t length)
|
||||
{
|
||||
uint32_t a,b,c; /* internal state */
|
||||
union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */
|
||||
|
||||
/* Set up the internal state */
|
||||
a = b = c = 0xdeadbeef + ((uint32_t)length);
|
||||
|
||||
u.ptr = key;
|
||||
if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) {
|
||||
const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */
|
||||
const uint8_t *k8;
|
||||
|
||||
/*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
|
||||
while (length > 12)
|
||||
{
|
||||
a += k[0];
|
||||
b += k[1];
|
||||
c += k[2];
|
||||
mix(a,b,c);
|
||||
length -= 12;
|
||||
k += 3;
|
||||
}
|
||||
|
||||
/*----------------------------- handle the last (probably partial) block */
|
||||
k8 = (const uint8_t *)k;
|
||||
switch(length)
|
||||
{
|
||||
case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
|
||||
case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
|
||||
case 10: c+=((uint32_t)k8[9])<<8; /* fall through */
|
||||
case 9 : c+=k8[8]; /* fall through */
|
||||
case 8 : b+=k[1]; a+=k[0]; break;
|
||||
case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
|
||||
case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */
|
||||
case 5 : b+=k8[4]; /* fall through */
|
||||
case 4 : a+=k[0]; break;
|
||||
case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
|
||||
case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */
|
||||
case 1 : a+=k8[0]; break;
|
||||
case 0 : return NON_ZERO_64(b, c);
|
||||
}
|
||||
} else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) {
|
||||
const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */
|
||||
const uint8_t *k8;
|
||||
|
||||
/*--------------- all but last block: aligned reads and different mixing */
|
||||
while (length > 12)
|
||||
{
|
||||
a += k[0] + (((uint32_t)k[1])<<16);
|
||||
b += k[2] + (((uint32_t)k[3])<<16);
|
||||
c += k[4] + (((uint32_t)k[5])<<16);
|
||||
mix(a,b,c);
|
||||
length -= 12;
|
||||
k += 6;
|
||||
}
|
||||
|
||||
/*----------------------------- handle the last (probably partial) block */
|
||||
k8 = (const uint8_t *)k;
|
||||
switch(length)
|
||||
{
|
||||
case 12: c+=k[4]+(((uint32_t)k[5])<<16);
|
||||
b+=k[2]+(((uint32_t)k[3])<<16);
|
||||
a+=k[0]+(((uint32_t)k[1])<<16);
|
||||
break;
|
||||
case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
|
||||
case 10: c+=k[4];
|
||||
b+=k[2]+(((uint32_t)k[3])<<16);
|
||||
a+=k[0]+(((uint32_t)k[1])<<16);
|
||||
break;
|
||||
case 9 : c+=k8[8]; /* fall through */
|
||||
case 8 : b+=k[2]+(((uint32_t)k[3])<<16);
|
||||
a+=k[0]+(((uint32_t)k[1])<<16);
|
||||
break;
|
||||
case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
|
||||
case 6 : b+=k[2];
|
||||
a+=k[0]+(((uint32_t)k[1])<<16);
|
||||
break;
|
||||
case 5 : b+=k8[4]; /* fall through */
|
||||
case 4 : a+=k[0]+(((uint32_t)k[1])<<16);
|
||||
break;
|
||||
case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
|
||||
case 2 : a+=k[0];
|
||||
break;
|
||||
case 1 : a+=k8[0];
|
||||
break;
|
||||
case 0 : return NON_ZERO_64(b, c); /* zero length strings require no mixing */
|
||||
}
|
||||
|
||||
} else { /* need to read the key one byte at a time */
|
||||
const uint8_t *k = (const uint8_t *)key;
|
||||
|
||||
/*--------------- all but the last block: affect some 32 bits of (a,b,c) */
|
||||
while (length > 12)
|
||||
{
|
||||
a += k[0];
|
||||
a += ((uint32_t)k[1])<<8;
|
||||
a += ((uint32_t)k[2])<<16;
|
||||
a += ((uint32_t)k[3])<<24;
|
||||
b += k[4];
|
||||
b += ((uint32_t)k[5])<<8;
|
||||
b += ((uint32_t)k[6])<<16;
|
||||
b += ((uint32_t)k[7])<<24;
|
||||
c += k[8];
|
||||
c += ((uint32_t)k[9])<<8;
|
||||
c += ((uint32_t)k[10])<<16;
|
||||
c += ((uint32_t)k[11])<<24;
|
||||
mix(a,b,c);
|
||||
length -= 12;
|
||||
k += 12;
|
||||
}
|
||||
|
||||
/*-------------------------------- last block: affect all 32 bits of (c) */
|
||||
switch(length) /* all the case statements fall through */
|
||||
{
|
||||
case 12: c+=((uint32_t)k[11])<<24;
|
||||
/* FALLTHROUGH */
|
||||
case 11: c+=((uint32_t)k[10])<<16;
|
||||
/* FALLTHROUGH */
|
||||
case 10: c+=((uint32_t)k[9])<<8;
|
||||
/* FALLTHROUGH */
|
||||
case 9 : c+=k[8];
|
||||
/* FALLTHROUGH */
|
||||
case 8 : b+=((uint32_t)k[7])<<24;
|
||||
/* FALLTHROUGH */
|
||||
case 7 : b+=((uint32_t)k[6])<<16;
|
||||
/* FALLTHROUGH */
|
||||
case 6 : b+=((uint32_t)k[5])<<8;
|
||||
/* FALLTHROUGH */
|
||||
case 5 : b+=k[4];
|
||||
/* FALLTHROUGH */
|
||||
case 4 : a+=((uint32_t)k[3])<<24;
|
||||
/* FALLTHROUGH */
|
||||
case 3 : a+=((uint32_t)k[2])<<16;
|
||||
/* FALLTHROUGH */
|
||||
case 2 : a+=((uint32_t)k[1])<<8;
|
||||
/* FALLTHROUGH */
|
||||
case 1 : a+=k[0];
|
||||
break;
|
||||
case 0 : return NON_ZERO_64(b, c);
|
||||
}
|
||||
}
|
||||
|
||||
final(a,b,c);
|
||||
return NON_ZERO_64(b, c);
|
||||
}
|
||||
#else
|
||||
#define hashlittle2(key, len) hashlittle(key, len)
|
||||
#endif
|
||||
|
||||
6
hlink.c
6
hlink.c
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2004-2020 Wayne Davison
|
||||
* Copyright (C) 2004-2022 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -446,7 +446,7 @@ int hard_link_check(struct file_struct *file, int ndx, char *fname,
|
||||
return -1;
|
||||
|
||||
if (remove_source_files == 1 && do_xfers)
|
||||
send_msg_int(MSG_SUCCESS, ndx);
|
||||
send_msg_success(fname, ndx);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -519,7 +519,7 @@ void finish_hard_link(struct file_struct *file, const char *fname, int fin_ndx,
|
||||
if (val < 0)
|
||||
continue;
|
||||
if (remove_source_files == 1 && do_xfers)
|
||||
send_msg_int(MSG_SUCCESS, ndx);
|
||||
send_msg_success(fname, ndx);
|
||||
}
|
||||
|
||||
if (inc_recurse) {
|
||||
|
||||
41
io.c
41
io.c
@@ -41,6 +41,7 @@ extern int am_server;
|
||||
extern int am_sender;
|
||||
extern int am_receiver;
|
||||
extern int am_generator;
|
||||
extern int local_server;
|
||||
extern int msgs2stderr;
|
||||
extern int inc_recurse;
|
||||
extern int io_error;
|
||||
@@ -84,6 +85,8 @@ int sock_f_out = -1;
|
||||
int64 total_data_read = 0;
|
||||
int64 total_data_written = 0;
|
||||
|
||||
char num_dev_ino_buf[4 + 8 + 8];
|
||||
|
||||
static struct {
|
||||
xbuf in, out, msg;
|
||||
int in_fd;
|
||||
@@ -1064,6 +1067,24 @@ void send_msg_int(enum msgcode code, int num)
|
||||
send_msg(code, numbuf, 4, -1);
|
||||
}
|
||||
|
||||
void send_msg_success(const char *fname, int num)
|
||||
{
|
||||
if (local_server) {
|
||||
STRUCT_STAT st;
|
||||
|
||||
if (DEBUG_GTE(IO, 1))
|
||||
rprintf(FINFO, "[%s] send_msg_success(%d)\n", who_am_i(), num);
|
||||
|
||||
if (stat(fname, &st) < 0)
|
||||
memset(&st, 0, sizeof (STRUCT_STAT));
|
||||
SIVAL(num_dev_ino_buf, 0, num);
|
||||
SIVAL64(num_dev_ino_buf, 4, st.st_dev);
|
||||
SIVAL64(num_dev_ino_buf, 4+8, st.st_ino);
|
||||
send_msg(MSG_SUCCESS, num_dev_ino_buf, sizeof num_dev_ino_buf, -1);
|
||||
} else
|
||||
send_msg_int(MSG_SUCCESS, num);
|
||||
}
|
||||
|
||||
static void got_flist_entry_status(enum festatus status, int ndx)
|
||||
{
|
||||
struct file_list *flist = flist_for_ndx(ndx, "got_flist_entry_status");
|
||||
@@ -1078,8 +1099,12 @@ static void got_flist_entry_status(enum festatus status, int ndx)
|
||||
|
||||
switch (status) {
|
||||
case FES_SUCCESS:
|
||||
if (remove_source_files)
|
||||
send_msg_int(MSG_SUCCESS, ndx);
|
||||
if (remove_source_files) {
|
||||
if (local_server)
|
||||
send_msg(MSG_SUCCESS, num_dev_ino_buf, sizeof num_dev_ino_buf, -1);
|
||||
else
|
||||
send_msg_int(MSG_SUCCESS, ndx);
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
case FES_NO_SEND:
|
||||
#ifdef SUPPORT_HARD_LINKS
|
||||
@@ -1574,14 +1599,15 @@ static void read_a_msg(void)
|
||||
}
|
||||
break;
|
||||
case MSG_SUCCESS:
|
||||
if (msg_bytes != 4) {
|
||||
if (msg_bytes != (local_server ? 4+8+8 : 4)) {
|
||||
invalid_msg:
|
||||
rprintf(FERROR, "invalid multi-message %d:%lu [%s%s]\n",
|
||||
tag, (unsigned long)msg_bytes, who_am_i(),
|
||||
inc_recurse ? "/inc" : "");
|
||||
exit_cleanup(RERR_STREAMIO);
|
||||
}
|
||||
val = raw_read_int();
|
||||
raw_read_buf(num_dev_ino_buf, msg_bytes);
|
||||
val = IVAL(num_dev_ino_buf, 0);
|
||||
iobuf.in_multiplexed = 1;
|
||||
if (am_generator)
|
||||
got_flist_entry_status(FES_SUCCESS, val);
|
||||
@@ -1758,6 +1784,13 @@ int32 read_int(int f)
|
||||
return num;
|
||||
}
|
||||
|
||||
uint32 read_uint(int f)
|
||||
{
|
||||
char b[4];
|
||||
read_buf(f, b, 4);
|
||||
return IVAL(b, 0);
|
||||
}
|
||||
|
||||
int32 read_varint(int f)
|
||||
{
|
||||
union {
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define LATEST_YEAR "2022"
|
||||
#define LATEST_YEAR "2024"
|
||||
|
||||
@@ -1,11 +1,28 @@
|
||||
/* Keep this simple so both C and ASM can use it */
|
||||
|
||||
/* These allow something like CFLAGS=-DDISABLE_SHA512_DIGEST */
|
||||
#ifdef DISABLE_SHA256_DIGEST
|
||||
#undef SHA256_DIGEST_LENGTH
|
||||
#endif
|
||||
#ifdef DISABLE_SHA512_DIGEST
|
||||
#undef SHA512_DIGEST_LENGTH
|
||||
#endif
|
||||
|
||||
#define MD4_DIGEST_LEN 16
|
||||
#define MD5_DIGEST_LEN 16
|
||||
#if defined SHA512_DIGEST_LENGTH
|
||||
#define MAX_DIGEST_LEN SHA512_DIGEST_LENGTH
|
||||
#elif defined SHA256_DIGEST_LENGTH
|
||||
#define MAX_DIGEST_LEN SHA256_DIGEST_LENGTH
|
||||
#elif defined SHA_DIGEST_LENGTH
|
||||
#define MAX_DIGEST_LEN SHA_DIGEST_LENGTH
|
||||
#else
|
||||
#define MAX_DIGEST_LEN MD5_DIGEST_LEN
|
||||
#endif
|
||||
|
||||
#define CSUM_CHUNK 64
|
||||
|
||||
#define CSUM_gone -1
|
||||
#define CSUM_NONE 0
|
||||
#define CSUM_MD4_ARCHAIC 1
|
||||
#define CSUM_MD4_BUSTED 2
|
||||
@@ -15,3 +32,6 @@
|
||||
#define CSUM_XXH64 6
|
||||
#define CSUM_XXH3_64 7
|
||||
#define CSUM_XXH3_128 8
|
||||
#define CSUM_SHA1 9
|
||||
#define CSUM_SHA256 10
|
||||
#define CSUM_SHA512 11
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "rsync.h"
|
||||
|
||||
#if !defined USE_OPENSSL || USE_MD5_ASM /* { */
|
||||
void md5_begin(md_context *ctx)
|
||||
{
|
||||
ctx->A = 0x67452301;
|
||||
@@ -224,7 +223,6 @@ void md5_result(md_context *ctx, uchar digest[MD5_DIGEST_LEN])
|
||||
SIVALu(digest, 8, ctx->C);
|
||||
SIVALu(digest, 12, ctx->D);
|
||||
}
|
||||
#endif /* } */
|
||||
|
||||
#ifdef TEST_MD5 /* { */
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* The include file for both the MD4 and MD5 routines. */
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
#include "openssl/md4.h"
|
||||
#include "openssl/md5.h"
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/evp.h>
|
||||
#endif
|
||||
#include "md-defines.h"
|
||||
|
||||
@@ -17,14 +17,6 @@ void mdfour_begin(md_context *md);
|
||||
void mdfour_update(md_context *md, const uchar *in, uint32 length);
|
||||
void mdfour_result(md_context *md, uchar digest[MD4_DIGEST_LEN]);
|
||||
|
||||
#if defined USE_OPENSSL && !defined USE_MD5_ASM
|
||||
#define md5_context MD5_CTX
|
||||
#define md5_begin MD5_Init
|
||||
#define md5_update MD5_Update
|
||||
#define md5_result(cptr, digest) MD5_Final(digest, cptr)
|
||||
#else
|
||||
#define md5_context md_context
|
||||
void md5_begin(md_context *ctx);
|
||||
void md5_update(md_context *ctx, const uchar *input, uint32 length);
|
||||
void md5_result(md_context *ctx, uchar digest[MD5_DIGEST_LEN]);
|
||||
#endif
|
||||
|
||||
10
log.c
10
log.c
@@ -36,8 +36,6 @@ extern int protocol_version;
|
||||
extern int always_checksum;
|
||||
extern int preserve_mtimes;
|
||||
extern int msgs2stderr;
|
||||
extern int xfersum_type;
|
||||
extern int checksum_type;
|
||||
extern int stdout_format_has_i;
|
||||
extern int stdout_format_has_o_or_i;
|
||||
extern int logfile_format_has_i;
|
||||
@@ -62,6 +60,8 @@ extern unsigned int module_dirlen;
|
||||
extern char sender_file_sum[MAX_DIGEST_LEN];
|
||||
extern const char undetermined_hostname[];
|
||||
|
||||
extern struct name_num_item *xfer_sum_nni, *file_sum_nni;
|
||||
|
||||
static int log_initialised;
|
||||
static int logfile_was_closed;
|
||||
static FILE *logfile_fp;
|
||||
@@ -680,12 +680,12 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
|
||||
n = NULL;
|
||||
if (S_ISREG(file->mode)) {
|
||||
if (always_checksum)
|
||||
n = sum_as_hex(checksum_type, F_SUM(file), 1);
|
||||
n = sum_as_hex(file_sum_nni->num, F_SUM(file), 1);
|
||||
else if (iflags & ITEM_TRANSFER)
|
||||
n = sum_as_hex(xfersum_type, sender_file_sum, 0);
|
||||
n = sum_as_hex(xfer_sum_nni->num, sender_file_sum, 0);
|
||||
}
|
||||
if (!n) {
|
||||
int sum_len = csum_len_for_type(always_checksum ? checksum_type : xfersum_type,
|
||||
int sum_len = csum_len_for_type(always_checksum ? file_sum_nni->num : xfer_sum_nni->num,
|
||||
always_checksum);
|
||||
memset(buf2, ' ', sum_len*2);
|
||||
buf2[sum_len*2] = '\0';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
dnl AC_HAVE_TYPE(TYPE,INCLUDES)
|
||||
AC_DEFUN([AC_HAVE_TYPE], [
|
||||
AC_REQUIRE([AC_HEADER_STDC])
|
||||
cv=`echo "$1" | sed 'y%./+- %__p__%'`
|
||||
AC_MSG_CHECKING(for $1)
|
||||
AC_CACHE_VAL([ac_cv_type_$cv],
|
||||
|
||||
45
main.c
45
main.c
@@ -89,6 +89,8 @@ extern int backup_dir_len;
|
||||
extern int basis_dir_cnt;
|
||||
extern int default_af_hint;
|
||||
extern int stdout_format_has_i;
|
||||
extern int trust_sender_filter;
|
||||
extern int trust_sender_args;
|
||||
extern struct stats stats;
|
||||
extern char *stdout_format;
|
||||
extern char *logfile_format;
|
||||
@@ -660,6 +662,16 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, in
|
||||
return pid;
|
||||
}
|
||||
|
||||
/* Older versions turn an empty string as a reference to the current directory.
|
||||
* We now treat this as an error unless --old-args was used. */
|
||||
static char *dot_dir_or_error()
|
||||
{
|
||||
if (old_style_args || am_server)
|
||||
return ".";
|
||||
rprintf(FERROR, "Empty destination arg specified (use \".\" or see --old-args).\n");
|
||||
exit_cleanup(RERR_SYNTAX);
|
||||
}
|
||||
|
||||
/* The receiving side operates in one of two modes:
|
||||
*
|
||||
* 1. it receives any number of files into a destination directory,
|
||||
@@ -687,9 +699,8 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
|
||||
if (!dest_path || list_only)
|
||||
return NULL;
|
||||
|
||||
/* Treat an empty string as a copy into the current directory. */
|
||||
if (!*dest_path)
|
||||
dest_path = ".";
|
||||
dest_path = dot_dir_or_error();
|
||||
|
||||
if (daemon_filter_list.head) {
|
||||
char *slash = strrchr(dest_path, '/');
|
||||
@@ -1372,15 +1383,6 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
|
||||
return MAX(exit_code, exit_code2);
|
||||
}
|
||||
|
||||
static void dup_argv(char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; argv[i]; i++)
|
||||
argv[i] = strdup(argv[i]);
|
||||
}
|
||||
|
||||
|
||||
/* Start a client for either type of remote connection. Work out
|
||||
* whether the arguments request a remote shell or rsyncd connection,
|
||||
* and call the appropriate connection function, then run_client.
|
||||
@@ -1396,10 +1398,6 @@ static int start_client(int argc, char *argv[])
|
||||
int ret;
|
||||
pid_t pid;
|
||||
|
||||
/* Don't clobber argv[] so that ps(1) can still show the right
|
||||
* command line. */
|
||||
dup_argv(argv);
|
||||
|
||||
if (!read_batch) { /* for read_batch, NO source is specified */
|
||||
char *path = check_for_hostspec(argv[0], &shell_machine, &rsync_port);
|
||||
if (path) { /* source is remote */
|
||||
@@ -1432,6 +1430,8 @@ static int start_client(int argc, char *argv[])
|
||||
|
||||
if (argc > 1) {
|
||||
p = argv[--argc];
|
||||
if (!*p)
|
||||
p = dot_dir_or_error();
|
||||
remote_argv = argv + argc;
|
||||
} else {
|
||||
static char *dotarg[1] = { "." };
|
||||
@@ -1473,8 +1473,10 @@ static int start_client(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* A local transfer doesn't unbackslash anything, so leave the args alone. */
|
||||
if (local_server)
|
||||
if (local_server) {
|
||||
old_style_args = 2;
|
||||
trust_sender_args = trust_sender_filter = 1;
|
||||
}
|
||||
|
||||
if (!rsync_port && remote_argc && !**remote_argv) /* Turn an empty arg into a dot dir. */
|
||||
*remote_argv = ".";
|
||||
@@ -1743,6 +1745,17 @@ int main(int argc,char *argv[])
|
||||
|
||||
unset_env_var("DISPLAY");
|
||||
|
||||
#if defined USE_OPENSSL && defined SET_OPENSSL_CONF
|
||||
#define TO_STR2(x) #x
|
||||
#define TO_STR(x) TO_STR2(x)
|
||||
/* ./configure --with-openssl-conf=/etc/ssl/openssl-rsync.cnf
|
||||
* defines SET_OPENSSL_CONF as that unquoted pathname. */
|
||||
if (!getenv("OPENSSL_CONF")) /* Don't override it if it's already set. */
|
||||
set_env_str("OPENSSL_CONF", TO_STR(SET_OPENSSL_CONF));
|
||||
#undef TO_STR
|
||||
#undef TO_STR2
|
||||
#endif
|
||||
|
||||
memset(&stats, 0, sizeof(stats));
|
||||
|
||||
/* Even a non-daemon runs needs the default config values to be set, e.g.
|
||||
|
||||
22
match.c
22
match.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1996 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2003-2020 Wayne Davison
|
||||
* Copyright (C) 2003-2023 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -24,7 +24,9 @@
|
||||
|
||||
extern int checksum_seed;
|
||||
extern int append_mode;
|
||||
extern int xfersum_type;
|
||||
|
||||
extern struct name_num_item *xfer_sum_nni;
|
||||
extern int xfer_sum_len;
|
||||
|
||||
int updating_basis_file;
|
||||
char sender_file_sum[MAX_DIGEST_LEN];
|
||||
@@ -140,7 +142,7 @@ static void hash_search(int f,struct sum_struct *s,
|
||||
{
|
||||
OFF_T offset, aligned_offset, end;
|
||||
int32 k, want_i, aligned_i, backup;
|
||||
char sum2[SUM_LENGTH];
|
||||
char sum2[MAX_DIGEST_LEN];
|
||||
uint32 s1, s2, sum;
|
||||
int more;
|
||||
schar *map;
|
||||
@@ -356,15 +358,13 @@ static void hash_search(int f,struct sum_struct *s,
|
||||
**/
|
||||
void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len)
|
||||
{
|
||||
int sum_len;
|
||||
|
||||
last_match = 0;
|
||||
false_alarms = 0;
|
||||
hash_hits = 0;
|
||||
matches = 0;
|
||||
data_transfer = 0;
|
||||
|
||||
sum_init(xfersum_type, checksum_seed);
|
||||
sum_init(xfer_sum_nni, checksum_seed);
|
||||
|
||||
if (append_mode > 0) {
|
||||
if (append_mode == 2) {
|
||||
@@ -405,22 +405,22 @@ void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len)
|
||||
matched(f, s, buf, len, -1);
|
||||
}
|
||||
|
||||
sum_len = sum_end(sender_file_sum);
|
||||
sum_end(sender_file_sum);
|
||||
|
||||
/* If we had a read error, send a bad checksum. We use all bits
|
||||
* off as long as the checksum doesn't happen to be that, in
|
||||
* which case we turn the last 0 bit into a 1. */
|
||||
if (buf && buf->status != 0) {
|
||||
int i;
|
||||
for (i = 0; i < sum_len && sender_file_sum[i] == 0; i++) {}
|
||||
memset(sender_file_sum, 0, sum_len);
|
||||
if (i == sum_len)
|
||||
for (i = 0; i < xfer_sum_len && sender_file_sum[i] == 0; i++) {}
|
||||
memset(sender_file_sum, 0, xfer_sum_len);
|
||||
if (i == xfer_sum_len)
|
||||
sender_file_sum[i-1]++;
|
||||
}
|
||||
|
||||
if (DEBUG_GTE(DELTASUM, 2))
|
||||
rprintf(FINFO,"sending file_sum\n");
|
||||
write_buf(f, sender_file_sum, sum_len);
|
||||
write_buf(f, sender_file_sum, xfer_sum_len);
|
||||
|
||||
if (DEBUG_GTE(DELTASUM, 2)) {
|
||||
rprintf(FINFO, "false_alarms=%d hash_hits=%d matches=%d\n",
|
||||
|
||||
@@ -8,6 +8,7 @@ fi
|
||||
inname="$1"
|
||||
srcdir=`dirname "$0"`
|
||||
flagfile="$srcdir/.md2man-works"
|
||||
force_flagfile="$srcdir/.md2man-force"
|
||||
|
||||
if [ ! -f "$flagfile" ]; then
|
||||
# We test our smallest manpage just to see if the python setup works.
|
||||
@@ -32,4 +33,10 @@ if [ ! -f "$flagfile" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
"$srcdir/md-convert" "$srcdir/$inname"
|
||||
if [ -f "$force_flagfile" ]; then
|
||||
opt='--force-link-text'
|
||||
else
|
||||
opt=''
|
||||
fi
|
||||
|
||||
"$srcdir/md-convert" $opt "$srcdir/$inname"
|
||||
|
||||
36
md-convert
36
md-convert
@@ -276,7 +276,10 @@ class TransformHtml(HTMLParser):
|
||||
bad_hashtags = set(),
|
||||
latest_targets = [ ],
|
||||
opt_prefix = 'opt',
|
||||
a_href = None,
|
||||
a_href_external = False,
|
||||
a_txt_start = None,
|
||||
after_a_tag = False,
|
||||
target_suf = '',
|
||||
)
|
||||
|
||||
@@ -315,6 +318,13 @@ class TransformHtml(HTMLParser):
|
||||
for bad in st.referenced_hashtags - st.created_hashtags:
|
||||
warn('Unknown hashtag link in', self.fn + ':', '#' + bad)
|
||||
|
||||
def handle_UE(self):
|
||||
st = self.state
|
||||
if st.txt.startswith(('.', ',', '!', '?', ';', ':')):
|
||||
st.man_out[-1] = ".UE " + st.txt[0] + "\n"
|
||||
st.txt = st.txt[1:]
|
||||
st.after_a_tag = False
|
||||
|
||||
def handle_starttag(self, tag, attrs_list):
|
||||
st = self.state
|
||||
if args.debug:
|
||||
@@ -387,13 +397,20 @@ class TransformHtml(HTMLParser):
|
||||
for var, val in attrs_list:
|
||||
if var == 'href':
|
||||
if val.startswith(('https://', 'http://', 'mailto:', 'ftp:')):
|
||||
pass # nothing to check
|
||||
if st.after_a_tag:
|
||||
self.handle_UE()
|
||||
st.man_out.append(manify(st.txt.strip()) + "\n")
|
||||
st.man_out.append(".UR " + val + "\n")
|
||||
st.txt = ''
|
||||
st.a_href = val
|
||||
st.a_href_external = True
|
||||
elif '#' in val:
|
||||
pg, tgt = val.split('#', 2)
|
||||
pg, tgt = val.split('#', 1)
|
||||
if pg and pg not in VALID_PAGES or '#' in tgt:
|
||||
st.bad_hashtags.add(val)
|
||||
elif tgt in ('', 'opt', 'dopt'):
|
||||
st.a_href = val
|
||||
st.a_href_external = False
|
||||
elif pg == '':
|
||||
st.referenced_hashtags.add(tgt)
|
||||
if tgt in st.latest_targets:
|
||||
@@ -409,6 +426,8 @@ class TransformHtml(HTMLParser):
|
||||
st = self.state
|
||||
if args.debug:
|
||||
self.output_debug('END', (tag,))
|
||||
if st.after_a_tag:
|
||||
self.handle_UE()
|
||||
if tag in CONSUMES_TXT or st.dt_from == tag:
|
||||
txt = st.txt.strip()
|
||||
st.txt = ''
|
||||
@@ -473,12 +492,20 @@ class TransformHtml(HTMLParser):
|
||||
elif tag == 'hr':
|
||||
return
|
||||
elif tag == 'a':
|
||||
if st.a_href:
|
||||
if st.a_href_external:
|
||||
st.txt = st.txt.strip()
|
||||
if args.force_link_text or st.a_href != st.txt:
|
||||
st.man_out.append(manify(st.txt) + "\n")
|
||||
st.man_out.append(".UE\n") # This might get replaced with a punctuation version in handle_UE()
|
||||
st.after_a_tag = True
|
||||
st.a_href_external = False
|
||||
st.txt = ''
|
||||
elif st.a_href:
|
||||
atxt = st.txt[st.a_txt_start:]
|
||||
find = 'href="' + st.a_href + '"'
|
||||
for j in range(len(st.html_out)-1, 0, -1):
|
||||
if find in st.html_out[j]:
|
||||
pg, tgt = st.a_href.split('#', 2)
|
||||
pg, tgt = st.a_href.split('#', 1)
|
||||
derived = txt2target(atxt, tgt)
|
||||
if pg == '':
|
||||
if derived in st.latest_targets:
|
||||
@@ -612,6 +639,7 @@ if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description="Convert markdown into html and (optionally) nroff. Each input filename must have a .md suffix, which is changed to .html for the output filename. If the input filename ends with .num.md (e.g. foo.1.md) then a nroff file is also output with the input filename's .md suffix removed (e.g. foo.1).", add_help=False)
|
||||
parser.add_argument('--test', action='store_true', help="Just test the parsing without outputting any files.")
|
||||
parser.add_argument('--dest', metavar='DIR', help="Create files in DIR instead of the current directory.")
|
||||
parser.add_argument('--force-link-text', action='store_true', help="Don't remove the link text if it matches the link href. Useful when nroff doesn't understand .UR and .UE.")
|
||||
parser.add_argument('--debug', '-D', action='count', default=0, help='Output copious info on the html parsing. Repeat for even more.')
|
||||
parser.add_argument("--help", "-h", action="help", help="Output this help message and exit.")
|
||||
parser.add_argument("mdfiles", metavar='FILE.md', nargs='+', help="One or more .md files to convert.")
|
||||
|
||||
12
mkgitver
12
mkgitver
@@ -1,14 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
srcdir=`dirname $0`
|
||||
gitver=`git describe --abbrev=8 2>/dev/null`
|
||||
|
||||
if [ ! -f git-version.h ]; then
|
||||
touch git-version.h
|
||||
fi
|
||||
|
||||
case "$gitver" in
|
||||
*.*)
|
||||
if test -d "$srcdir/.git" || test -f "$srcdir/.git"; then
|
||||
gitver=`git describe --abbrev=8 2>/dev/null`
|
||||
# NOTE: I'm avoiding "|" in sed since I'm not sure if sed -r is portable and "\|" fails on some OSes.
|
||||
verchk=`echo "$gitver-" | sed -n '/^v3\.[0-9][0-9]*\.[0-9][0-9]*\(pre[0-9]*\)*-/p'`
|
||||
if [ -n "$verchk" ]; then
|
||||
echo "#define RSYNC_GITVER \"$gitver\"" >git-version.h.new
|
||||
if ! diff git-version.h.new git-version.h >/dev/null; then
|
||||
echo "Updating git-version.h"
|
||||
@@ -16,5 +18,5 @@ case "$gitver" in
|
||||
else
|
||||
rm git-version.h.new
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
184
options.c
184
options.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1998-2001 Andrew Tridgell <tridge@samba.org>
|
||||
* Copyright (C) 2000, 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2002-2022 Wayne Davison
|
||||
* Copyright (C) 2002-2023 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -200,6 +200,7 @@ int remote_option_cnt = 0;
|
||||
const char **remote_options = NULL;
|
||||
const char *checksum_choice = NULL;
|
||||
const char *compress_choice = NULL;
|
||||
static const char *empty_argv[1];
|
||||
|
||||
int quiet = 0;
|
||||
int output_motd = 1;
|
||||
@@ -788,7 +789,9 @@ static struct poptOption long_options[] = {
|
||||
{"no-from0", 0, POPT_ARG_VAL, &eol_nulls, 0, 0, 0},
|
||||
{"old-args", 0, POPT_ARG_NONE, 0, OPT_OLD_ARGS, 0, 0},
|
||||
{"no-old-args", 0, POPT_ARG_VAL, &old_style_args, 0, 0, 0},
|
||||
{"protect-args", 's', POPT_ARG_VAL, &protect_args, 1, 0, 0},
|
||||
{"secluded-args", 's', POPT_ARG_VAL, &protect_args, 1, 0, 0},
|
||||
{"no-secluded-args", 0, POPT_ARG_VAL, &protect_args, 0, 0, 0},
|
||||
{"protect-args", 0, POPT_ARG_VAL, &protect_args, 1, 0, 0},
|
||||
{"no-protect-args", 0, POPT_ARG_VAL, &protect_args, 0, 0, 0},
|
||||
{"no-s", 0, POPT_ARG_VAL, &protect_args, 0, 0, 0},
|
||||
{"trust-sender", 0, POPT_ARG_VAL, &trust_sender, 1, 0, 0},
|
||||
@@ -950,7 +953,7 @@ static void set_refuse_options(void)
|
||||
if (!am_daemon
|
||||
|| op->shortName == 'e' /* Required for compatibility flags */
|
||||
|| op->shortName == '0' /* --from0 just modifies --files-from, so refuse that instead (or not) */
|
||||
|| op->shortName == 's' /* --protect-args is always OK */
|
||||
|| op->shortName == 's' /* --secluded-args is always OK */
|
||||
|| op->shortName == 'n' /* --dry-run is always OK */
|
||||
|| strcmp("iconv", longName) == 0
|
||||
|| strcmp("no-iconv", longName) == 0
|
||||
@@ -1345,7 +1348,7 @@ char *alt_dest_opt(int type)
|
||||
**/
|
||||
int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
{
|
||||
static poptContext pc;
|
||||
poptContext pc;
|
||||
const char *arg, **argv = *argv_p;
|
||||
int argc = *argc_p;
|
||||
int opt, want_dest_type;
|
||||
@@ -1365,10 +1368,6 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
|
||||
/* TODO: Call poptReadDefaultConfig; handle errors. */
|
||||
|
||||
/* The context leaks in case of an error, but if there's a
|
||||
* problem we always exit anyhow. */
|
||||
if (pc)
|
||||
poptFreeContext(pc);
|
||||
pc = poptGetContext(RSYNC_NAME, argc, argv, long_options, 0);
|
||||
if (!am_server) {
|
||||
poptReadDefaultConfig(pc, 0);
|
||||
@@ -1411,7 +1410,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
strlcpy(err_buf,
|
||||
"Attempt to hack rsync thwarted!\n",
|
||||
sizeof err_buf);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
#ifdef ICONV_OPTION
|
||||
iconv_opt = NULL;
|
||||
@@ -1457,7 +1456,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (tmpdir && strlen(tmpdir) >= MAXPATHLEN - 10) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"the --temp-dir path is WAY too long.\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!daemon_opt) {
|
||||
@@ -1467,8 +1466,16 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
exit_cleanup(RERR_SYNTAX);
|
||||
}
|
||||
|
||||
*argv_p = argv = poptGetArgs(pc);
|
||||
*argc_p = argc = count_args(argv);
|
||||
argv = poptGetArgs(pc);
|
||||
argc = count_args(argv);
|
||||
if (!argc) {
|
||||
*argv_p = empty_argv;
|
||||
*argc_p = 0;
|
||||
} else if (poptDupArgv(argc, argv, argc_p, argv_p) != 0)
|
||||
out_of_memory("parse_arguments");
|
||||
argv = *argv_p;
|
||||
poptFreeContext(pc);
|
||||
|
||||
am_starting_up = 0;
|
||||
daemon_opt = 0;
|
||||
am_daemon = 1;
|
||||
@@ -1523,7 +1530,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
case 'a':
|
||||
if (refused_archive_part) {
|
||||
create_refuse_error(refused_archive_part);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if (!recurse) /* preserve recurse == 2 */
|
||||
recurse = 1;
|
||||
@@ -1593,7 +1600,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
case 'P':
|
||||
if (refused_partial || refused_progress) {
|
||||
create_refuse_error(refused_partial ? refused_partial : refused_progress);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
do_progress = 1;
|
||||
keep_partial = 1;
|
||||
@@ -1628,7 +1635,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (*arg != '-') {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"Remote option must start with a dash: %s\n", arg);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if (remote_option_cnt+2 >= remote_option_alloc) {
|
||||
remote_option_alloc += 16;
|
||||
@@ -1670,27 +1677,27 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
ssize_t size;
|
||||
arg = poptGetOptArg(pc);
|
||||
if ((size = parse_size_arg(arg, 'b', "block-size", 0, max_blength, False)) < 0)
|
||||
return 0;
|
||||
goto cleanup;
|
||||
block_size = (int32)size;
|
||||
break;
|
||||
}
|
||||
|
||||
case OPT_MAX_SIZE:
|
||||
if ((max_size = parse_size_arg(max_size_arg, 'b', "max-size", 0, -1, False)) < 0)
|
||||
return 0;
|
||||
goto cleanup;
|
||||
max_size_arg = strdup(do_big_num(max_size, 0, NULL));
|
||||
break;
|
||||
|
||||
case OPT_MIN_SIZE:
|
||||
if ((min_size = parse_size_arg(min_size_arg, 'b', "min-size", 0, -1, False)) < 0)
|
||||
return 0;
|
||||
goto cleanup;
|
||||
min_size_arg = strdup(do_big_num(min_size, 0, NULL));
|
||||
break;
|
||||
|
||||
case OPT_BWLIMIT: {
|
||||
ssize_t size = parse_size_arg(bwlimit_arg, 'K', "bwlimit", 512, -1, True);
|
||||
if (size < 0)
|
||||
return 0;
|
||||
goto cleanup;
|
||||
bwlimit_arg = strdup(do_big_num(size, 0, NULL));
|
||||
bwlimit = (size + 512) / 1024;
|
||||
break;
|
||||
@@ -1719,7 +1726,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"ERROR: the %s option conflicts with the %s option\n",
|
||||
alt_dest_opt(want_dest_type), alt_dest_opt(0));
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
alt_dest_type = want_dest_type;
|
||||
|
||||
@@ -1727,7 +1734,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"ERROR: at most %d %s args may be specified\n",
|
||||
MAX_BASIS_DIRS, alt_dest_opt(0));
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
/* We defer sanitizing this arg until we know what
|
||||
* our destination directory is going to be. */
|
||||
@@ -1740,7 +1747,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"Invalid argument passed to --chmod (%s)\n",
|
||||
arg);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1759,11 +1766,11 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (usermap_via_chown) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--usermap conflicts with prior --chown.\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"You can only specify --usermap once.\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
usermap = (char *)poptGetOptArg(pc);
|
||||
usermap_via_chown = False;
|
||||
@@ -1775,11 +1782,11 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (groupmap_via_chown) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--groupmap conflicts with prior --chown.\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"You can only specify --groupmap once.\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
groupmap = (char *)poptGetOptArg(pc);
|
||||
groupmap_via_chown = False;
|
||||
@@ -1798,11 +1805,11 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (!usermap_via_chown) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--chown conflicts with prior --usermap.\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"You can only specify a user-affecting --chown once.\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if (asprintf(&usermap, "*:%.*s", len, chown) < 0)
|
||||
out_of_memory("parse_arguments");
|
||||
@@ -1814,11 +1821,11 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (!groupmap_via_chown) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--chown conflicts with prior --groupmap.\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"You can only specify a group-affecting --chown once.\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if (asprintf(&groupmap, "*:%s", arg) < 0)
|
||||
out_of_memory("parse_arguments");
|
||||
@@ -1846,7 +1853,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
snprintf(err_buf,sizeof(err_buf),
|
||||
"ACLs are not supported on this %s\n",
|
||||
am_server ? "server" : "client");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
#endif
|
||||
|
||||
case 'X':
|
||||
@@ -1857,7 +1864,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
snprintf(err_buf,sizeof(err_buf),
|
||||
"extended attributes are not supported on this %s\n",
|
||||
am_server ? "server" : "client");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
#endif
|
||||
|
||||
case OPT_STOP_AFTER: {
|
||||
@@ -1866,7 +1873,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
stop_at_utime = time(NULL);
|
||||
if ((val = atol(arg) * 60) <= 0 || LONG_MAX - val < stop_at_utime || (long)(time_t)val != val) {
|
||||
snprintf(err_buf, sizeof err_buf, "invalid --stop-after value: %s\n", arg);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
stop_at_utime += val;
|
||||
break;
|
||||
@@ -1877,11 +1884,11 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
arg = poptGetOptArg(pc);
|
||||
if ((stop_at_utime = parse_time(arg)) == (time_t)-1) {
|
||||
snprintf(err_buf, sizeof err_buf, "invalid --stop-at format: %s\n", arg);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if (stop_at_utime <= time(NULL)) {
|
||||
snprintf(err_buf, sizeof err_buf, "--stop-at time is not in the future: %s\n", arg);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
@@ -1899,7 +1906,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
else {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--stderr mode \"%s\" is not one of errors, all, or client\n", arg);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
saw_stderr_opt = 1;
|
||||
break;
|
||||
@@ -1910,13 +1917,13 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
* turned this option off. */
|
||||
if (opt >= OPT_REFUSED_BASE) {
|
||||
create_refuse_error(opt);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
snprintf(err_buf, sizeof err_buf, "%s%s: %s\n",
|
||||
am_server ? "on remote machine: " : "",
|
||||
poptBadOption(pc, POPT_BADOPTION_NOALIAS),
|
||||
poptStrerror(opt));
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1924,7 +1931,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
saw_stderr_opt = 1;
|
||||
|
||||
if (version_opt_cnt) {
|
||||
print_rsync_version(FINFO);
|
||||
print_rsync_version(version_opt_cnt > 1 && !am_server ? FNONE : FINFO);
|
||||
exit_cleanup(0);
|
||||
}
|
||||
|
||||
@@ -1936,9 +1943,11 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (max_alloc_arg) {
|
||||
ssize_t size = parse_size_arg(max_alloc_arg, 'B', "max-alloc", 1024*1024, -1, True);
|
||||
if (size < 0)
|
||||
return 0;
|
||||
goto cleanup;
|
||||
max_alloc = size;
|
||||
}
|
||||
if (!max_alloc)
|
||||
max_alloc = SIZE_MAX;
|
||||
|
||||
if (old_style_args < 0) {
|
||||
if (!am_server && protect_args <= 0 && (arg = getenv("RSYNC_OLD_ARGS")) != NULL && *arg) {
|
||||
@@ -1949,8 +1958,8 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
} else if (old_style_args) {
|
||||
if (protect_args > 0) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--protect-args conflicts with --old-args.\n");
|
||||
return 0;
|
||||
"--secluded-args conflicts with --old-args.\n");
|
||||
goto cleanup;
|
||||
}
|
||||
protect_args = 0;
|
||||
}
|
||||
@@ -1961,7 +1970,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
else if ((arg = getenv("RSYNC_PROTECT_ARGS")) != NULL && *arg)
|
||||
protect_args = atoi(arg) ? 1 : 0;
|
||||
else {
|
||||
#ifdef RSYNC_USE_PROTECTED_ARGS
|
||||
#ifdef RSYNC_USE_SECLUDED_ARGS
|
||||
protect_args = 1;
|
||||
#else
|
||||
protect_args = 0;
|
||||
@@ -1995,7 +2004,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
do_compression = CPRES_AUTO;
|
||||
if (do_compression && refused_compress) {
|
||||
create_refuse_error(refused_compress);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2020,7 +2029,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
default:
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"Invalid --outbuf setting -- specify N, L, or B.\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
setvbuf(stdout, (char *)NULL, mode, 0);
|
||||
}
|
||||
@@ -2048,7 +2057,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
}
|
||||
if (refused_no_iconv && !iconv_opt) {
|
||||
create_refuse_error(refused_no_iconv);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2059,18 +2068,30 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (orig_protect_args == 2 && am_server)
|
||||
protect_args = orig_protect_args;
|
||||
|
||||
if (protect_args == 1 && am_server)
|
||||
if (protect_args == 1 && am_server) {
|
||||
poptFreeContext(pc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
*argv_p = argv = poptGetArgs(pc);
|
||||
*argc_p = argc = count_args(argv);
|
||||
/* Because popt 1.19 has started to free the returned args data, we now
|
||||
* make a copy of the array and then do an immediate cleanup. */
|
||||
argv = poptGetArgs(pc);
|
||||
argc = count_args(argv);
|
||||
if (!argc) {
|
||||
*argv_p = empty_argv;
|
||||
*argc_p = 0;
|
||||
} else if (poptDupArgv(argc, argv, argc_p, argv_p) != 0)
|
||||
out_of_memory("parse_arguments");
|
||||
argv = *argv_p;
|
||||
poptFreeContext(pc);
|
||||
pc = NULL;
|
||||
|
||||
#ifndef SUPPORT_LINKS
|
||||
if (preserve_links && !am_sender) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"symlinks are not supported on this %s\n",
|
||||
am_server ? "server" : "client");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2079,7 +2100,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"hard links are not supported on this %s\n",
|
||||
am_server ? "server" : "client");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2087,20 +2108,20 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (am_root < 0 && preserve_xattrs > 1) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--fake-super conflicts with -XX\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
#else
|
||||
if (am_root < 0) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--fake-super requires an rsync with extended attributes enabled\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (write_batch && read_batch) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--write-batch and --read-batch can not be used together\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if (write_batch > 0 || read_batch) {
|
||||
if (am_server) {
|
||||
@@ -2119,25 +2140,25 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (read_batch && files_from) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--read-batch cannot be used with --files-from\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if (read_batch && remove_source_files) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--read-batch cannot be used with --remove-%s-files\n",
|
||||
remove_source_files == 1 ? "source" : "sent");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if (batch_name && strlen(batch_name) > MAX_BATCH_NAME_LEN) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"the batch-file name must be %d characters or less.\n",
|
||||
MAX_BATCH_NAME_LEN);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (tmpdir && strlen(tmpdir) >= MAXPATHLEN - 10) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"the --temp-dir path is WAY too long.\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (max_delete < 0 && max_delete != INT_MIN) {
|
||||
@@ -2171,7 +2192,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (delete_before + !!delete_during + delete_after > 1) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"You may not combine multiple --delete-WHEN options.\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if (delete_before || delete_during || delete_after)
|
||||
delete_mode = 1;
|
||||
@@ -2182,7 +2203,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
delete_during = 1;
|
||||
else {
|
||||
create_refuse_error(refused_delete_before);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
} else if (refused_delete_during)
|
||||
delete_before = 1;
|
||||
@@ -2191,14 +2212,14 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (!xfer_dirs && delete_mode) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--delete does not work without --recursive (-r) or --dirs (-d).\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (missing_args == 3) /* simplify if both options were specified */
|
||||
missing_args = 2;
|
||||
if (refused_delete && (delete_mode || missing_args == 2)) {
|
||||
create_refuse_error(refused_delete);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (remove_source_files) {
|
||||
@@ -2207,7 +2228,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
* options. */
|
||||
if (refused_delete && am_sender) {
|
||||
create_refuse_error(refused_delete);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
need_messages_from_generator = 1;
|
||||
}
|
||||
@@ -2261,7 +2282,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--suffix cannot contain slashes: %s\n",
|
||||
backup_suffix);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if (backup_dir) {
|
||||
size_t len;
|
||||
@@ -2274,7 +2295,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (len > sizeof backup_dir_buf - 128) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"the --backup-dir path is WAY too long.\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
backup_dir_len = (int)len;
|
||||
if (!backup_dir_len) {
|
||||
@@ -2293,7 +2314,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
"--suffix cannot be empty %s\n", backup_dir_len < 0
|
||||
? "when --backup-dir is the same as the dest dir"
|
||||
: "without a --backup-dir");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
} else if (make_backups && delete_mode && !delete_excluded && !am_server) {
|
||||
snprintf(backup_dir_buf, sizeof backup_dir_buf,
|
||||
"P *%s", backup_suffix);
|
||||
@@ -2321,7 +2342,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (do_progress && !am_server) {
|
||||
if (!log_before_transfer && INFO_EQ(NAME, 0))
|
||||
parse_output_words(info_words, info_levels, "name", DEFAULT_PRIORITY);
|
||||
parse_output_words(info_words, info_levels, "flist2,progress", DEFAULT_PRIORITY);
|
||||
parse_output_words(info_words, info_levels, "FLIST2,PROGRESS", DEFAULT_PRIORITY);
|
||||
}
|
||||
|
||||
if (dry_run)
|
||||
@@ -2362,11 +2383,11 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (whole_file > 0) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--append cannot be used with --whole-file\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if (refused_inplace) {
|
||||
create_refuse_error(refused_inplace);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
inplace = 1;
|
||||
}
|
||||
@@ -2374,7 +2395,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (write_devices) {
|
||||
if (refused_inplace) {
|
||||
create_refuse_error(refused_inplace);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
inplace = 1;
|
||||
}
|
||||
@@ -2389,13 +2410,13 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
"--%s cannot be used with --%s\n",
|
||||
append_mode ? "append" : "inplace",
|
||||
delay_updates ? "delay-updates" : "partial-dir");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
/* --inplace implies --partial for refusal purposes, but we
|
||||
* clear the keep_partial flag for internal logic purposes. */
|
||||
if (refused_partial) {
|
||||
create_refuse_error(refused_partial);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
keep_partial = 0;
|
||||
#else
|
||||
@@ -2403,7 +2424,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
"--%s is not supported on this %s\n",
|
||||
append_mode ? "append" : "inplace",
|
||||
am_server ? "server" : "client");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
#endif
|
||||
} else {
|
||||
if (keep_partial && !partial_dir && !am_server) {
|
||||
@@ -2417,7 +2438,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
partial_dir = NULL;
|
||||
if (!partial_dir && refused_partial) {
|
||||
create_refuse_error(refused_partial);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
keep_partial = 1;
|
||||
}
|
||||
@@ -2438,14 +2459,14 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
if (am_server) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"The --files-from sent to the server cannot specify a host.\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
files_from = p;
|
||||
filesfrom_host = h;
|
||||
if (strcmp(files_from, "-") == 0) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"Invalid --files-from remote filename\n");
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
if (sanitize_paths)
|
||||
@@ -2464,7 +2485,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"failed to open files-from file %s: %s\n",
|
||||
files_from, strerror(errno));
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2481,6 +2502,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
options_rejected:
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"Your options have been rejected by the server.\n");
|
||||
cleanup:
|
||||
if (pc)
|
||||
poptFreeContext(pc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2496,7 +2520,7 @@ static char SPLIT_ARG_WHEN_OLD[1];
|
||||
**/
|
||||
char *safe_arg(const char *opt, const char *arg)
|
||||
{
|
||||
#define SHELL_CHARS "!#$&;|<>(){}\"' \t\\"
|
||||
#define SHELL_CHARS "!#$&;|<>(){}\"'` \t\\"
|
||||
#define WILD_CHARS "*?[]" /* We don't allow remote brace expansion */
|
||||
BOOL is_filename_arg = !opt;
|
||||
char *escapes = is_filename_arg ? SHELL_CHARS : WILD_CHARS SHELL_CHARS;
|
||||
@@ -2508,7 +2532,9 @@ char *safe_arg(const char *opt, const char *arg)
|
||||
char *ret;
|
||||
if (!protect_args && old_style_args < 2 && (!old_style_args || (!is_filename_arg && opt != SPLIT_ARG_WHEN_OLD))) {
|
||||
const char *f;
|
||||
if (!trust_sender_args && *arg == '~' && (relative_paths || !strchr(arg, '/'))) {
|
||||
if (*arg == '~' && is_filename_arg && !am_sender && !trust_sender_args
|
||||
&& ((relative_paths && !strstr(arg, "/./"))
|
||||
|| !strchr(arg, '/'))) {
|
||||
extras++;
|
||||
escape_leading_tilde = 1;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ long_opts = { # These include some extra long-args that BackupPC uses:
|
||||
'recursive': 0,
|
||||
'stderr': 1,
|
||||
'times': 0,
|
||||
'copy-devices': -1,
|
||||
'write-devices': -1,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Summary: A fast, versatile, remote (and local) file-copying tool
|
||||
Name: rsync
|
||||
Version: 3.2.5
|
||||
Version: 3.3.0
|
||||
%define fullversion %{version}
|
||||
Release: 1
|
||||
%define srcdir src
|
||||
@@ -79,8 +79,8 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%dir /etc/rsync-ssl/certs
|
||||
|
||||
%changelog
|
||||
* Sun Aug 14 2022 Wayne Davison <wayne@opencoder.net>
|
||||
Released 3.2.5.
|
||||
* Sat Apr 06 2024 Wayne Davison <wayne@opencoder.net>
|
||||
Released 3.3.0.
|
||||
|
||||
* Fri Mar 21 2008 Wayne Davison <wayne@opencoder.net>
|
||||
Added installation of /etc/xinetd.d/rsync file and some commented-out
|
||||
|
||||
18
packaging/openssl-rsync.cnf
Normal file
18
packaging/openssl-rsync.cnf
Normal file
@@ -0,0 +1,18 @@
|
||||
# This config file can be used with rsync to enable legacy digests
|
||||
# (such as MD4) by using the OPENSSL_CONF environment variable.
|
||||
# See rsync's configure --with-openssl-conf=/path/name option.
|
||||
|
||||
openssl_conf = openssl_init
|
||||
|
||||
[openssl_init]
|
||||
providers = provider_sect
|
||||
|
||||
[provider_sect]
|
||||
default = default_sect
|
||||
legacy = legacy_sect
|
||||
|
||||
[default_sect]
|
||||
activate = 1
|
||||
|
||||
[legacy_sect]
|
||||
activate = 1
|
||||
@@ -32,7 +32,7 @@ def _tweak_opts(cmd, opts, **maybe_set_args):
|
||||
opts = opts.copy()
|
||||
_maybe_set(opts, **maybe_set_args)
|
||||
|
||||
if type(cmd) == str:
|
||||
if isinstance(cmd, str):
|
||||
_maybe_set(opts, shell=True)
|
||||
|
||||
want_raw = opts.pop('raw', False)
|
||||
@@ -176,7 +176,7 @@ def mandate_gensend_hook():
|
||||
print('Creating hook file:', hook)
|
||||
cmd_chk(['./rsync', '-a', 'packaging/pre-push', hook])
|
||||
else:
|
||||
ct = cmd_txt(['fgrep', 'make gensend', hook], discard='output')
|
||||
ct = cmd_txt(['grep', 'make gensend', hook], discard='output')
|
||||
if ct.rc:
|
||||
die('Please add a "make gensend" into your', hook, 'script.')
|
||||
|
||||
|
||||
@@ -105,6 +105,8 @@ def main():
|
||||
if not re.match(r'^del', ans, flags=re.I):
|
||||
die("Aborted")
|
||||
cmd_chk(['git', 'tag', '-d', v_ver])
|
||||
if os.path.isdir('patches/.git'):
|
||||
cmd_chk(f"cd patches && git tag -d '{v_ver}'")
|
||||
|
||||
version = re.sub(r'[-.]*pre[-.]*', 'pre', version)
|
||||
if 'pre' in version and not curversion.endswith('dev'):
|
||||
@@ -232,7 +234,7 @@ About to:
|
||||
cmd_chk(['packaging/year-tweak'])
|
||||
|
||||
print(dash_line)
|
||||
cmd_run("git diff")
|
||||
cmd_run("git diff".split())
|
||||
|
||||
srctar_name = f"{rsync_ver}.tar.gz"
|
||||
pattar_name = f"rsync-patches-{version}.tar.gz"
|
||||
@@ -247,20 +249,20 @@ About to:
|
||||
|
||||
About to:
|
||||
- git commit all changes
|
||||
- generate the manpages
|
||||
- run a full build, ensuring that the manpages & configure.sh are up-to-date
|
||||
- merge the {args.master_branch} branch into the patch/{args.master_branch}/* branches
|
||||
- update the files in the "patches" dir and OPTIONALLY (if you type 'y') to
|
||||
run patch-update with the --make option (which opens a shell on error)
|
||||
""")
|
||||
ans = input("<Press Enter OR 'y' to continue> ")
|
||||
|
||||
s = cmd_run(['git', 'commit', '-a', '-m', f'Preparing for release of {version}'])
|
||||
s = cmd_run(['git', 'commit', '-a', '-m', f'Preparing for release of {version} [buildall]'])
|
||||
if s.returncode:
|
||||
die('Aborting')
|
||||
|
||||
cmd_chk('make gen')
|
||||
cmd_chk('touch configure.ac && packaging/smart-make && make gen')
|
||||
|
||||
print(f'Creating any missing patch branches.')
|
||||
print('Creating any missing patch branches.')
|
||||
s = cmd_run(f'packaging/branch-from-patch --branch={args.master_branch} --add-missing')
|
||||
if s.returncode:
|
||||
die('Aborting')
|
||||
|
||||
29
receiver.c
29
receiver.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1996-2000 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2003-2022 Wayne Davison
|
||||
* Copyright (C) 2003-2023 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -56,7 +56,6 @@ extern int inplace;
|
||||
extern int inplace_partial;
|
||||
extern int allowed_lull;
|
||||
extern int delay_updates;
|
||||
extern int xfersum_type;
|
||||
extern BOOL want_progress_now;
|
||||
extern mode_t orig_umask;
|
||||
extern struct stats stats;
|
||||
@@ -68,6 +67,9 @@ extern struct file_list *cur_flist, *first_flist, *dir_flist;
|
||||
extern filter_rule_list daemon_filter_list;
|
||||
extern OFF_T preallocated_len;
|
||||
|
||||
extern struct name_num_item *xfer_sum_nni;
|
||||
extern int xfer_sum_len;
|
||||
|
||||
static struct bitbag *delayed_bits = NULL;
|
||||
static int phase = 0, redoing = 0;
|
||||
static flist_ndx_list batch_redo_list;
|
||||
@@ -240,7 +242,6 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
|
||||
static char file_sum1[MAX_DIGEST_LEN];
|
||||
struct map_struct *mapbuf;
|
||||
struct sum_struct sum;
|
||||
int sum_len;
|
||||
int32 len;
|
||||
OFF_T total_size = F_LENGTH(file);
|
||||
OFF_T offset = 0;
|
||||
@@ -280,7 +281,7 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
|
||||
} else
|
||||
mapbuf = NULL;
|
||||
|
||||
sum_init(xfersum_type, checksum_seed);
|
||||
sum_init(xfer_sum_nni, checksum_seed);
|
||||
|
||||
if (append_mode > 0) {
|
||||
OFF_T j;
|
||||
@@ -371,7 +372,7 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
|
||||
|
||||
if (fd != -1 && offset > 0) {
|
||||
if (sparse_files > 0) {
|
||||
if (sparse_end(fd, offset) != 0)
|
||||
if (sparse_end(fd, offset, updating_basis_or_equiv) != 0)
|
||||
goto report_write_error;
|
||||
} else if (flush_write_file(fd) < 0) {
|
||||
report_write_error:
|
||||
@@ -393,7 +394,7 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
|
||||
if (INFO_GTE(PROGRESS, 1))
|
||||
end_progress(total_size);
|
||||
|
||||
sum_len = sum_end(file_sum1);
|
||||
sum_end(file_sum1);
|
||||
|
||||
if (do_fsync && fd != -1 && fsync(fd) != 0) {
|
||||
rsyserr(FERROR, errno, "fsync failed on %s", full_fname(fname));
|
||||
@@ -403,10 +404,10 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
|
||||
if (mapbuf)
|
||||
unmap_file(mapbuf);
|
||||
|
||||
read_buf(f_in, sender_file_sum, sum_len);
|
||||
read_buf(f_in, sender_file_sum, xfer_sum_len);
|
||||
if (DEBUG_GTE(DELTASUM, 2))
|
||||
rprintf(FINFO,"got file_sum\n");
|
||||
if (fd != -1 && memcmp(file_sum1, sender_file_sum, sum_len) != 0)
|
||||
if (fd != -1 && memcmp(file_sum1, sender_file_sum, xfer_sum_len) != 0)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
@@ -439,9 +440,8 @@ static void handle_delayed_updates(char *local_name)
|
||||
"rename failed for %s (from %s)",
|
||||
full_fname(fname), partialptr);
|
||||
} else {
|
||||
if (remove_source_files
|
||||
|| (preserve_hard_links && F_IS_HLINKED(file)))
|
||||
send_msg_int(MSG_SUCCESS, ndx);
|
||||
if (remove_source_files || (preserve_hard_links && F_IS_HLINKED(file)))
|
||||
send_msg_success(fname, ndx);
|
||||
handle_partial_dir(partialptr, PDIR_DELETE);
|
||||
}
|
||||
}
|
||||
@@ -698,7 +698,7 @@ int recv_files(int f_in, int f_out, char *local_name)
|
||||
if (!am_server)
|
||||
discard_receive_data(f_in, file);
|
||||
if (inc_recurse)
|
||||
send_msg_int(MSG_SUCCESS, ndx);
|
||||
send_msg_success(fname, ndx);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -926,9 +926,8 @@ int recv_files(int f_in, int f_out, char *local_name)
|
||||
case 2:
|
||||
break;
|
||||
case 1:
|
||||
if (remove_source_files || inc_recurse
|
||||
|| (preserve_hard_links && F_IS_HLINKED(file)))
|
||||
send_msg_int(MSG_SUCCESS, ndx);
|
||||
if (remove_source_files || inc_recurse || (preserve_hard_links && F_IS_HLINKED(file)))
|
||||
send_msg_success(fname, ndx);
|
||||
break;
|
||||
case 0: {
|
||||
enum logcode msgtype = redoing ? FERROR_XFER : FWARNING;
|
||||
|
||||
244
rsync.1.md
244
rsync.1.md
@@ -152,7 +152,43 @@ rsync daemon by leaving off the module name:
|
||||
|
||||
> rsync somehost.mydomain.com::
|
||||
|
||||
See the following section for more details.
|
||||
## COPYING TO A DIFFERENT NAME
|
||||
|
||||
When you want to copy a directory to a different name, use a trailing slash on
|
||||
the source directory to put the contents of the directory into any destination
|
||||
directory you like:
|
||||
|
||||
> rsync -ai foo/ bar/
|
||||
|
||||
Rsync also has the ability to customize a destination file's name when copying
|
||||
a single item. The rules for this are:
|
||||
|
||||
- The transfer list must consist of a single item (either a file or an empty
|
||||
directory)
|
||||
- The final element of the destination path must not exist as a directory
|
||||
- The destination path must not have been specified with a trailing slash
|
||||
|
||||
Under those circumstances, rsync will set the name of the destination's single
|
||||
item to the last element of the destination path. Keep in mind that it is best
|
||||
to only use this idiom when copying a file and use the above trailing-slash
|
||||
idiom when copying a directory.
|
||||
|
||||
The following example copies the `foo.c` file as `bar.c` in the `save` dir
|
||||
(assuming that `bar.c` isn't a directory):
|
||||
|
||||
> rsync -ai src/foo.c save/bar.c
|
||||
|
||||
The single-item copy rule might accidentally bite you if you unknowingly copy a
|
||||
single item and specify a destination dir that doesn't exist (without using a
|
||||
trailing slash). For example, if `src/*.c` matches one file and `save/dir`
|
||||
doesn't exist, this will confuse you by naming the destination file `save/dir`:
|
||||
|
||||
> rsync -ai src/*.c save/dir
|
||||
|
||||
To prevent such an accident, either make sure the destination dir exists or
|
||||
specify the destination path with a trailing slash:
|
||||
|
||||
> rsync -ai src/*.c save/dir/
|
||||
|
||||
## SORTED TRANSFER ORDER
|
||||
|
||||
@@ -195,6 +231,24 @@ Dedicate a "host1-files" dir to the remote content:
|
||||
|
||||
See the [`--trust-sender`](#opt) option for additional details.
|
||||
|
||||
CAUTION: it is not particularly safe to use rsync to copy files from a
|
||||
case-preserving filesystem to a case-ignoring filesystem. If you must perform
|
||||
such a copy, you should either disable symlinks via `--no-links` or enable the
|
||||
munging of symlinks via [`--munge-links`](#opt) (and make sure you use the
|
||||
right local or remote option). This will prevent rsync from doing potentially
|
||||
dangerous things if a symlink name overlaps with a file or directory. It does
|
||||
not, however, ensure that you get a full copy of all the files (since that may
|
||||
not be possible when the names overlap). A potentially better solution is to
|
||||
list all the source files and create a safe list of filenames that you pass to
|
||||
the [`--files-from`](#opt) option. Any files that conflict in name would need
|
||||
to be copied to different destination directories using more than one copy.
|
||||
|
||||
While a copy of a case-ignoring filesystem to a case-ignoring filesystem can
|
||||
work out fairly well, if no `--delete-during` or `--delete-before` option is
|
||||
active, rsync can potentially update an existing file on the receiving side
|
||||
without noticing that the upper-/lower-case of the filename should be changed
|
||||
to match the sender.
|
||||
|
||||
## ADVANCED USAGE
|
||||
|
||||
The syntax for requesting multiple files from a remote host is done by
|
||||
@@ -203,7 +257,12 @@ the hostname omitted. For instance, all these work:
|
||||
|
||||
> 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/
|
||||
> rsync -aiv host::modname/first ::extra-file{1,2} /dest/
|
||||
|
||||
Note that a daemon connection only supports accessing one module per copy
|
||||
command, so if the start of a follow-up path doesn't begin with the
|
||||
modname of the first path, it is assumed to be a path in the module (such as
|
||||
the extra-file1 & extra-file2 that are grabbed above).
|
||||
|
||||
Really old versions of rsync (2.6.9 and before) only allowed specifying one
|
||||
remote-source arg, so some people have instead relied on the remote-shell
|
||||
@@ -235,17 +294,19 @@ section below for information on that.)
|
||||
Using rsync in this way is the same as using it with a remote shell except
|
||||
that:
|
||||
|
||||
- you either use a double colon :: instead of a single colon to separate the
|
||||
hostname from the path, or you use an rsync:// URL.
|
||||
- the first word of the "path" is actually a module name.
|
||||
- the remote daemon may print a message of the day when you connect.
|
||||
- if you specify no path name on the remote daemon then the list of accessible
|
||||
paths on the daemon will be shown.
|
||||
- if you specify no local destination then a listing of the specified files on
|
||||
the remote daemon is provided.
|
||||
- you must not specify the [`--rsh`](#opt) (`-e`) option (since that overrides
|
||||
the daemon connection to use ssh -- see [USING RSYNC-DAEMON FEATURES VIA A
|
||||
REMOTE-SHELL CONNECTION](#) below).
|
||||
- Use either double-colon syntax or rsync:// URL syntax instead of the
|
||||
single-colon (remote shell) syntax.
|
||||
- The first element of the "path" is actually a module name.
|
||||
- Additional remote source args can use an abbreviated syntax that omits the
|
||||
hostname and/or the module name, as discussed in [ADVANCED USAGE](#).
|
||||
- The remote daemon may print a "message of the day" when you connect.
|
||||
- If you specify only the host (with no module or path) then a list of
|
||||
accessible modules on the daemon is output.
|
||||
- If you specify a remote source path but no destination, a listing of the
|
||||
matching files on the remote daemon is output.
|
||||
- The [`--rsh`](#opt) (`-e`) option must be omitted to avoid changing the
|
||||
connection style from using a socket connection to [USING RSYNC-DAEMON
|
||||
FEATURES VIA A REMOTE-SHELL CONNECTION](#).
|
||||
|
||||
An example that copies all the files in a remote module named "src":
|
||||
|
||||
@@ -375,7 +436,7 @@ has its own detailed description later in this manpage.
|
||||
--append-verify --append w/old data in file checksum
|
||||
--dirs, -d transfer directories without recursing
|
||||
--old-dirs, --old-d works like --dirs when talking to old rsync
|
||||
--mkpath create the destination's path component
|
||||
--mkpath create destination's missing path components
|
||||
--links, -l copy symlinks as symlinks
|
||||
--copy-links, -L transform symlink into referent file/dir
|
||||
--copy-unsafe-links only "unsafe" symlinks are transformed
|
||||
@@ -464,7 +525,7 @@ has its own detailed description later in this manpage.
|
||||
--files-from=FILE read list of source-file names from FILE
|
||||
--from0, -0 all *-from/filter files are delimited by 0s
|
||||
--old-args disable the modern arg-protection idiom
|
||||
--protect-args, -s no space-splitting; wildcard chars only
|
||||
--secluded-args, -s use the protocol to safely send the args
|
||||
--trust-sender trust the remote sender's file list
|
||||
--copy-as=USER[:GROUP] specify user & optional group for the copy
|
||||
--address=ADDRESS bind address for outgoing socket to daemon
|
||||
@@ -555,11 +616,14 @@ expand it.
|
||||
|
||||
0. `--version`, `-V`
|
||||
|
||||
Print the rsync version plus other info and exit.
|
||||
Print the rsync version plus other info and exit. When repeated, the
|
||||
information is output is a JSON format that is still fairly readable
|
||||
(client side only).
|
||||
|
||||
The output includes the default list of checksum algorithms, the default
|
||||
list of compression algorithms, a list of compiled-in capabilities, a link
|
||||
to the rsync web site, and some license/copyright info.
|
||||
The output includes a list of compiled-in capabilities, a list of
|
||||
optimizations, the default list of checksum algorithms, the default list of
|
||||
compression algorithms, the default list of daemon auth digests, a link to
|
||||
the rsync web site, and a few other items.
|
||||
|
||||
0. `--verbose`, `-v`
|
||||
|
||||
@@ -831,7 +895,7 @@ expand it.
|
||||
that until a bunch of recursive copying has finished). However, these
|
||||
early directories don't yet have their completed mode, mtime, or ownership
|
||||
set -- they have more restrictive rights until the subdirectory's copying
|
||||
actually begins. This early-creation idiom can be avoiding by using the
|
||||
actually begins. This early-creation idiom can be avoided by using the
|
||||
[`--omit-dir-times`](#opt) option.
|
||||
|
||||
Incremental recursion can be disabled using the
|
||||
@@ -1085,23 +1149,28 @@ expand it.
|
||||
|
||||
0. `--mkpath`
|
||||
|
||||
Create a missing path component of the destination arg. This allows rsync
|
||||
to create multiple levels of missing destination dirs and to create a path
|
||||
in which to put a single renamed file. Keep in mind that you'll need to
|
||||
supply a trailing slash if you want the entire destination path to be
|
||||
treated as a directory when copying a single arg (making rsync behave the
|
||||
same way that it would if the path component of the destination had already
|
||||
existed).
|
||||
Create all missing path components of the destination path.
|
||||
|
||||
For example, the following creates a copy of file foo as bar in the sub/dir
|
||||
directory, creating dirs "sub" and "sub/dir" if either do not yet exist:
|
||||
By default, rsync allows only the final component of the destination path
|
||||
to not exist, which is an attempt to help you to validate your destination
|
||||
path. With this option, rsync creates all the missing destination-path
|
||||
components, just as if `mkdir -p $DEST_PATH` had been run on the receiving
|
||||
side.
|
||||
|
||||
> rsync -ai --mkpath foo sub/dir/bar
|
||||
When specifying a destination path, including a trailing slash ensures that
|
||||
the whole path is treated as directory names to be created, even when the
|
||||
file list has a single item. See the [COPYING TO A DIFFERENT NAME](#)
|
||||
section for full details on how rsync decides if a final destination-path
|
||||
component should be created as a directory or not.
|
||||
|
||||
If you instead ran the following, it would have created file foo in the
|
||||
sub/dir/bar directory:
|
||||
If you would like the newly-created destination dirs to match the dirs on
|
||||
the sending side, you should be using [`--relative`](#opt) (`-R`) instead
|
||||
of `--mkpath`. For instance, the following two commands result in the same
|
||||
destination tree, but only the second command ensures that the
|
||||
"some/extra/path" components match the dirs on the sending side:
|
||||
|
||||
> rsync -ai --mkpath foo sub/dir/bar/
|
||||
> rsync -ai --mkpath host:some/extra/path/*.c some/extra/path/
|
||||
> rsync -aiR host:some/extra/path/*.c ./
|
||||
|
||||
0. `--links`, `-l`
|
||||
|
||||
@@ -1532,6 +1601,15 @@ expand it.
|
||||
will make the update fairly efficient if the files haven't actually
|
||||
changed, you're much better off using `-t`).
|
||||
|
||||
A modern rsync that is using transfer protocol 30 or 31 conveys a modify
|
||||
time using up to 8-bytes. If rsync is forced to speak an older protocol
|
||||
(perhaps due to the remote rsync being older than 3.0.0) a modify time is
|
||||
conveyed using 4-bytes. Prior to 3.2.7, these shorter values could convey
|
||||
a date range of 13-Dec-1901 to 19-Jan-2038. Beginning with 3.2.7, these
|
||||
4-byte values now convey a date range of 1-Jan-1970 to 7-Feb-2106. If you
|
||||
have files dated older than 1970, make sure your rsync executables are
|
||||
upgraded so that the full range of dates can be conveyed.
|
||||
|
||||
0. `--atimes`, `-U`
|
||||
|
||||
This tells rsync to set the access (use) times of the destination files to
|
||||
@@ -1558,7 +1636,9 @@ expand it.
|
||||
0. `--crtimes`, `-N,`
|
||||
|
||||
This tells rsync to set the create times (newness) of the destination
|
||||
files to the same value as the source files.
|
||||
files to the same value as the source files. Your OS & filesystem must
|
||||
support the setting of arbitrary creation (birth) times for this option
|
||||
to be supported.
|
||||
|
||||
0. `--omit-dir-times`, `-O`
|
||||
|
||||
@@ -1702,6 +1782,7 @@ expand it.
|
||||
- `xxh64` (aka `xxhash`)
|
||||
- `md5`
|
||||
- `md4`
|
||||
- `sha1`
|
||||
- `none`
|
||||
|
||||
Run `rsync --version` to see the default checksum list compiled into your
|
||||
@@ -1808,6 +1889,10 @@ expand it.
|
||||
Starting with 3.1.0, rsync will skip the sender-side removal (and output an
|
||||
error) if the file's size or modify time has not stayed unchanged.
|
||||
|
||||
Starting with 3.2.6, a local rsync copy will ensure that the sender does
|
||||
not remove a file the receiver just verified, such as when the user
|
||||
accidentally makes the source and destination directory the same path.
|
||||
|
||||
0. `--delete`
|
||||
|
||||
This tells rsync to delete extraneous files from the receiving side (ones
|
||||
@@ -1904,13 +1989,13 @@ expand it.
|
||||
|
||||
By default, an exclude or include has both a server-side effect (to "hide"
|
||||
and "show" files when building the server's file list) and a receiver-side
|
||||
effect (to "protect" and "risk" files when deletions are occuring). Any
|
||||
effect (to "protect" and "risk" files when deletions are occurring). Any
|
||||
rule that has no modifier to specify what sides it is executed on will be
|
||||
instead treated as if it were a server-side rule only, avoiding any
|
||||
"protect" effects of the rules.
|
||||
|
||||
A rule can still apply to both sides even with this option specified if the
|
||||
rule is given both the sender & receiver modifer letters (e.g., `-f'-sr
|
||||
rule is given both the sender & receiver modifier letters (e.g., `-f'-sr
|
||||
foo'`). Receiver-side protect/risk rules can also be explicitly specified
|
||||
to limit the deletions. This saves you from having to edit a bunch of
|
||||
`-f'- foo'` rules into `-f'-s foo'` (aka `-f'H foo'`) rules (not to mention
|
||||
@@ -2021,7 +2106,8 @@ expand it.
|
||||
See the [`--max-size`](#opt) option for a description of how SIZE can be
|
||||
specified. The default suffix if none is given is bytes.
|
||||
|
||||
Beginning in 3.2.3, a value of 0 specifies no limit.
|
||||
Beginning in 3.2.7, a value of 0 is an easy way to specify SIZE_MAX (the
|
||||
largest limit possible).
|
||||
|
||||
You can set a default value using the environment variable
|
||||
[`RSYNC_MAX_ALLOC`](#) using the same SIZE values as supported by this
|
||||
@@ -2330,7 +2416,7 @@ expand it.
|
||||
This would copy all the files specified in the /path/file-list file that
|
||||
was located on the remote "src" host.
|
||||
|
||||
If the [`--iconv`](#opt) and [`--protect-args`](#opt) options are specified
|
||||
If the [`--iconv`](#opt) and [`--secluded-args`](#opt) options are specified
|
||||
and the `--files-from` filenames are being sent from one host to another,
|
||||
the filenames will be translated from the sending host's charset to the
|
||||
receiving host's charset.
|
||||
@@ -2355,6 +2441,8 @@ expand it.
|
||||
|
||||
This option tells rsync to stop trying to protect the arg values on the
|
||||
remote side from unintended word-splitting or other misinterpretation.
|
||||
It also allows the client to treat an empty arg as a "." instead of
|
||||
generating an error.
|
||||
|
||||
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
|
||||
@@ -2379,38 +2467,46 @@ expand it.
|
||||
because we can't know for sure what names to expect when the remote shell
|
||||
is interpreting the args.
|
||||
|
||||
This option conflicts with the [`--protect-args`](#opt) option.
|
||||
This option conflicts with the [`--secluded-args`](#opt) option.
|
||||
|
||||
0. `--protect-args`, `-s`
|
||||
0. `--secluded-args`, `-s`
|
||||
|
||||
This option sends all filenames and most options to the remote rsync
|
||||
without allowing the remote shell to interpret them. Wildcards are
|
||||
expanded on the remote host by rsync instead of the shell doing it.
|
||||
This option sends all filenames and most options to the remote rsync via
|
||||
the protocol (not the remote shell command line) which avoids letting the
|
||||
remote shell modify them. Wildcards are expanded on the remote host by
|
||||
rsync instead of a shell.
|
||||
|
||||
This is similar to the new-style backslash-escaping of args that was added
|
||||
in 3.2.4, but supports some extra features and doesn't rely on backslash
|
||||
escaping in the remote shell.
|
||||
This is similar to the default backslash-escaping of args that was added
|
||||
in 3.2.4 (see [`--old-args`](#opt)) in that it prevents things like space
|
||||
splitting and unwanted special-character side-effects. However, it has the
|
||||
drawbacks of being incompatible with older rsync versions (prior to 3.0.0)
|
||||
and of being refused by restricted shells that want to be able to inspect
|
||||
all the option values for safety.
|
||||
|
||||
If you use this option with [`--iconv`](#opt), the args related to the
|
||||
remote side will also be translated from the local to the remote
|
||||
character-set. The translation happens before wild-cards are expanded.
|
||||
See also the [`--files-from`](#opt) option.
|
||||
This option is useful for those times that you need the argument's
|
||||
character set to be converted for the remote host, if the remote shell is
|
||||
incompatible with the default backslash-escpaing method, or there is some
|
||||
other reason that you want the majority of the options and arguments to
|
||||
bypass the command-line of the remote shell.
|
||||
|
||||
If you combine this option with [`--iconv`](#opt), the args related to the
|
||||
remote side will be translated from the local to the remote 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
|
||||
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
|
||||
option (note that `--no-s` and `--no-secluded-args` are the negative
|
||||
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.
|
||||
This option used to be called `--protect-args` (before 3.2.6) and that
|
||||
older name can still be used (though specifying it as `-s` is always the
|
||||
easiest and most compatible choice).
|
||||
|
||||
0. `--trust-sender`
|
||||
|
||||
@@ -2918,9 +3014,8 @@ expand it.
|
||||
[`--group`](#opt) (`-g`) option (since rsync needs to have those options
|
||||
enabled for the mapping options to work).
|
||||
|
||||
An older rsync client may need to use [`--protect-args`](#opt) (`-s`) to
|
||||
avoid a complaint about wildcard characters, but a modern rsync handles
|
||||
this automatically.
|
||||
An older rsync client may need to use [`-s`](#opt) to avoid a complaint
|
||||
about wildcard characters, but a modern rsync handles this automatically.
|
||||
|
||||
0. `--chown=USER:GROUP`
|
||||
|
||||
@@ -2935,9 +3030,8 @@ expand it.
|
||||
"`--usermap=*:foo --groupmap=*:bar`", only easier (and with the same
|
||||
implied [`--owner`](#opt) and/or [`--group`](#opt) options).
|
||||
|
||||
An older rsync client may need to use [`--protect-args`](#opt) (`-s`) to
|
||||
avoid a complaint about wildcard characters, but a modern rsync handles
|
||||
this automatically.
|
||||
An older rsync client may need to use [`-s`](#opt) to avoid a complaint
|
||||
about wildcard characters, but a modern rsync handles this automatically.
|
||||
|
||||
0. `--timeout=SECONDS`
|
||||
|
||||
@@ -3489,13 +3583,17 @@ expand it.
|
||||
|
||||
> rsync -av --list-only foo* dest/
|
||||
|
||||
Starting with rsync 3.1.0, the sizes output by `--list-only` are affected
|
||||
by the [`--human-readable`](#opt) option. By default they will contain
|
||||
digit separators, but higher levels of readability will output the sizes
|
||||
with unit suffixes. Note also that the column width for the size output
|
||||
has increased from 11 to 14 characters for all human-readable levels. Use
|
||||
`--no-h` if you want just digits in the sizes, and the old column width of
|
||||
11 characters.
|
||||
This option always uses an output format that looks similar to this:
|
||||
|
||||
> drwxrwxr-x 4,096 2022/09/30 12:53:11 support
|
||||
> -rw-rw-r-- 80 2005/01/11 10:37:37 support/Makefile
|
||||
|
||||
The only option that affects this output style is (as of 3.1.0) the
|
||||
[`--human-readable`](#opt) (`-h`) option. The default is to output sizes
|
||||
as byte counts with digit separators (in a 14-character-width column).
|
||||
Specifying at least one `-h` option makes the sizes output with unit
|
||||
suffixes. If you want old-style bytecount sizes without digit separators
|
||||
(and an 11-character-width column) use `--no-h`.
|
||||
|
||||
Compatibility note: when requesting a remote listing of files from an rsync
|
||||
that is version 2.6.3 or older, you may encounter an error if you ask for a
|
||||
@@ -3641,7 +3739,7 @@ expand it.
|
||||
For a list of what charset names your local iconv library supports, you can
|
||||
run "`iconv --list`".
|
||||
|
||||
If you specify the [`--protect-args`](#opt) (`-s`) option, rsync will
|
||||
If you specify the [`--secluded-args`](#opt) (`-s`) option, rsync will
|
||||
translate the filenames you specify on the command-line that are being sent
|
||||
to the remote host. See also the [`--files-from`](#opt) option.
|
||||
|
||||
@@ -4589,17 +4687,17 @@ file is included or excluded.
|
||||
supersedes the [`RSYNC_PROTECT_ARGS`](#) variable.
|
||||
|
||||
This variable is ignored if [`--old-args`](#opt), `--no-old-args`, or
|
||||
[`--protect-args`](#opt) is specified on the command line.
|
||||
[`--secluded-args`](#opt) is specified on the command line.
|
||||
|
||||
First supported in 3.2.4.
|
||||
|
||||
0. `RSYNC_PROTECT_ARGS`
|
||||
|
||||
Specify a non-zero numeric value if you want the [`--protect-args`](#opt)
|
||||
Specify a non-zero numeric value if you want the [`--secluded-args`](#opt)
|
||||
option to be enabled by default, or a zero value to make sure that it is
|
||||
disabled by default.
|
||||
|
||||
This variable is ignored if [`--protect-args`](#opt), `--no-protect-args`,
|
||||
This variable is ignored if [`--secluded-args`](#opt), `--no-secluded-args`,
|
||||
or [`--old-args`](#opt) is specified on the command line.
|
||||
|
||||
First supported in 3.1.0. Starting in 3.2.4, this variable is ignored if
|
||||
|
||||
22
rsync.h
22
rsync.h
@@ -366,16 +366,10 @@ enum delret {
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#else
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#else
|
||||
#endif
|
||||
#include <time.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
@@ -826,6 +820,7 @@ extern int uid_ndx;
|
||||
extern int gid_ndx;
|
||||
extern int acls_ndx;
|
||||
extern int xattrs_ndx;
|
||||
extern int file_sum_extra_cnt;
|
||||
|
||||
#ifdef USE_FLEXIBLE_ARRAY
|
||||
#define FILE_STRUCT_LEN (sizeof (struct file_struct))
|
||||
@@ -836,7 +831,7 @@ extern int xattrs_ndx;
|
||||
#define DEV_EXTRA_CNT 2
|
||||
#define DIRNODE_EXTRA_CNT 3
|
||||
#define EXTRA64_CNT ((sizeof (union file_extras64) + EXTRA_LEN - 1) / EXTRA_LEN)
|
||||
#define SUM_EXTRA_CNT ((MAX_DIGEST_LEN + EXTRA_LEN - 1) / EXTRA_LEN)
|
||||
#define SUM_EXTRA_CNT file_sum_extra_cnt
|
||||
|
||||
#define REQ_EXTRA(f,ndx) ((union file_extras*)(f) - (ndx))
|
||||
#define OPT_EXTRA(f,bump) ((union file_extras*)(f) - file_extra_cnt - 1 - (bump))
|
||||
@@ -1023,6 +1018,7 @@ typedef struct filter_struct {
|
||||
int slash_cnt;
|
||||
struct filter_list_struct *mergelist;
|
||||
} u;
|
||||
uchar elide;
|
||||
} filter_rule;
|
||||
|
||||
typedef struct filter_list_struct {
|
||||
@@ -1162,17 +1158,17 @@ typedef struct {
|
||||
#define NSTR_COMPRESS 1
|
||||
|
||||
struct name_num_item {
|
||||
int num;
|
||||
const char *name, *main_name;
|
||||
int num, flags;
|
||||
const char *name;
|
||||
struct name_num_item *main_nni;
|
||||
};
|
||||
|
||||
struct name_num_obj {
|
||||
const char *type;
|
||||
const char *negotiated_name;
|
||||
struct name_num_item *negotiated_nni;
|
||||
uchar *saw;
|
||||
int saw_len;
|
||||
int negotiated_num;
|
||||
struct name_num_item list[10]; /* we'll get a compile error/warning if this is ever too small */
|
||||
struct name_num_item *list;
|
||||
};
|
||||
|
||||
#ifdef EXTERNAL_ZLIB
|
||||
|
||||
126
rsyncd.conf.5.md
126
rsyncd.conf.5.md
@@ -74,25 +74,7 @@ reread the `rsyncd.conf` file. The file is re-read on each client connection.
|
||||
## GLOBAL PARAMETERS
|
||||
|
||||
The first parameters in the file (before a [module] header) are the global
|
||||
parameters. Rsync also allows for the use of a "[global]" module name to
|
||||
indicate the start of one or more global-parameter sections (the name must be
|
||||
lower case).
|
||||
|
||||
You may also include any module parameters in the global part of the config
|
||||
file in which case the supplied value will override the default for that
|
||||
parameter.
|
||||
|
||||
You may use references to environment variables in the values of parameters.
|
||||
String parameters will have %VAR% references expanded as late as possible (when
|
||||
the string is first used in the program), allowing for the use of variables
|
||||
that rsync sets at connection time, such as RSYNC_USER_NAME. Non-string
|
||||
parameters (such as true/false settings) are expanded when read from the config
|
||||
file. If a variable does not exist in the environment, or if a sequence of
|
||||
characters is not a valid reference (such as an un-paired percent sign), the
|
||||
raw characters are passed through unchanged. This helps with backward
|
||||
compatibility and safety (e.g. expanding a non-existent %VAR% to an empty
|
||||
string in a path could result in a very unsafe path). The safest way to insert
|
||||
a literal % into a value is to use %%.
|
||||
parameters:
|
||||
|
||||
[comment]: # (An OL starting at 0 is converted into a DL by the parser.)
|
||||
|
||||
@@ -138,6 +120,22 @@ a literal % into a value is to use %%.
|
||||
You can override the default backlog value when the daemon listens for
|
||||
connections. It defaults to 5.
|
||||
|
||||
You may also include any [MODULE PARAMETERS](#) in the global part of the
|
||||
config file, in which case the supplied value will override the default for
|
||||
that parameter.
|
||||
|
||||
You may use references to environment variables in the values of parameters.
|
||||
String parameters will have %VAR% references expanded as late as possible (when
|
||||
the string is first used in the program), allowing for the use of variables
|
||||
that rsync sets at connection time, such as RSYNC_USER_NAME. Non-string
|
||||
parameters (such as true/false settings) are expanded when read from the config
|
||||
file. If a variable does not exist in the environment, or if a sequence of
|
||||
characters is not a valid reference (such as an un-paired percent sign), the
|
||||
raw characters are passed through unchanged. This helps with backward
|
||||
compatibility and safety (e.g. expanding a non-existent %VAR% to an empty
|
||||
string in a path could result in a very unsafe path). The safest way to insert
|
||||
a literal % into a value is to use %%.
|
||||
|
||||
## MODULE PARAMETERS
|
||||
|
||||
After the global parameters you should define a number of modules, each module
|
||||
@@ -146,11 +144,17 @@ a module name in square brackets [module] followed by the parameters for that
|
||||
module. The module name cannot contain a slash or a closing square bracket.
|
||||
If the name contains whitespace, each internal sequence of whitespace will be
|
||||
changed into a single space, while leading or trailing whitespace will be
|
||||
discarded. Also, the name cannot be "global" as that exact name indicates that
|
||||
global parameters follow (see above).
|
||||
discarded.
|
||||
|
||||
As with GLOBAL PARAMETERS, you may use references to environment variables in
|
||||
the values of parameters. See the GLOBAL PARAMETERS section for more details.
|
||||
There is also a special module name of "[global]" that does not define a module
|
||||
but instead switches back to the global settings context where default
|
||||
parameters can be specified. Because each defined module gets its full set of
|
||||
parameters as a combination of the default values that are set at that position
|
||||
in the config file plus its own parameter list, the use of a "[global]" section
|
||||
can help to maintain shared config values for multiple modules.
|
||||
|
||||
As with [GLOBAL PARAMETERS](#), you may use references to environment variables
|
||||
in the values of parameters. See that section for details.
|
||||
|
||||
0. `comment`
|
||||
|
||||
@@ -164,6 +168,16 @@ the values of parameters. See the GLOBAL PARAMETERS section for more details.
|
||||
available in this module. You must specify this parameter for each module
|
||||
in `rsyncd.conf`.
|
||||
|
||||
If the value contains a "/./" element then the path will be divided at that
|
||||
point into a chroot dir and an inner-chroot subdir. If [`use chroot`](#)
|
||||
is set to false, though, the extraneous dot dir is just cleaned out of the
|
||||
path. An example of this idiom is:
|
||||
|
||||
> path = /var/rsync/./module1
|
||||
|
||||
This will (when chrooting) chroot to "/var/rsync" and set the inside-chroot
|
||||
path to "/module1".
|
||||
|
||||
You may base the path's value off of an environment variable by surrounding
|
||||
the variable name with percent signs. You can even reference a variable
|
||||
that is set by rsync when the user connects. For example, this would use
|
||||
@@ -187,29 +201,47 @@ the values of parameters. See the GLOBAL PARAMETERS section for more details.
|
||||
path, and of complicating the preservation of users and groups by name (see
|
||||
below).
|
||||
|
||||
As an additional safety feature, you can specify a dot-dir in the module's
|
||||
"[path](#)" to indicate the point where the chroot should occur. This allows
|
||||
rsync to run in a chroot with a non-"/" path for the top of the transfer
|
||||
hierarchy. Doing this guards against unintended library loading (since
|
||||
those absolute paths will not be inside the transfer hierarchy unless you
|
||||
have used an unwise pathname), and lets you setup libraries for the chroot
|
||||
that are outside of the transfer. For example, specifying
|
||||
"/var/rsync/./module1" will chroot to the "/var/rsync" directory and set
|
||||
the inside-chroot path to "/module1". If you had omitted the dot-dir, the
|
||||
chroot would have used the whole path, and the inside-chroot path would
|
||||
have been "/".
|
||||
If `use chroot` is not set, it defaults to trying to enable a chroot but
|
||||
allows the daemon to continue (after logging a warning) if it fails. The
|
||||
one exception to this is when a module's [`path`](#) has a "/./" chroot
|
||||
divider in it -- this causes an unset value to be treated as true for that
|
||||
module.
|
||||
|
||||
When both "use chroot" and "[daemon chroot](#)" are false, OR the inside-chroot
|
||||
path of "use chroot" is not "/", rsync will: (1) munge symlinks by default
|
||||
for security reasons (see "[munge symlinks](#)" for a way to turn this off, but
|
||||
only if you trust your users), (2) substitute leading slashes in absolute
|
||||
paths with the module's path (so that options such as `--backup-dir`,
|
||||
`--compare-dest`, etc. interpret an absolute path as rooted in the module's
|
||||
"[path](#)" dir), and (3) trim ".." path elements from args if rsync believes
|
||||
they would escape the module hierarchy. The default for "use chroot" is
|
||||
true, and is the safer choice (especially if the module is not read-only).
|
||||
Prior to rsync 3.2.7, the default value was "true". The new "unset"
|
||||
default makes it easier to setup an rsync daemon as a non-root user or to
|
||||
run a daemon on a system where chroot fails. Explicitly setting the value
|
||||
to "true" in rsyncd.conf will always require the chroot to succeed.
|
||||
|
||||
When this parameter is enabled *and* the "[name converter](#)" parameter is
|
||||
It is also possible to specify a dot-dir in the module's "[path](#)" to
|
||||
indicate that you want to chdir to the earlier part of the path and then
|
||||
serve files from inside the latter part of the path (with sanitizing and
|
||||
default symlink munging). This can be useful if you need some library dirs
|
||||
inside the chroot (typically for uid & gid lookups) but don't want to put
|
||||
the lib dir into the top of the served path (even though they can be hidden
|
||||
with an [`exclude`](#) directive). However, a better choice for a modern
|
||||
rsync setup is to use a [`name converter`](#)" and try to avoid inner lib
|
||||
dirs altogether. See also the [`daemon chroot`](#) parameter, which causes
|
||||
rsync to chroot into its own chroot area before doing any path-related
|
||||
chrooting.
|
||||
|
||||
If the daemon is serving the "/" dir (either directly or due to being
|
||||
chrooted to the module's path), rsync does not do any path sanitizing or
|
||||
(default) munging.
|
||||
|
||||
When it has to limit access to a particular subdir (either due to chroot
|
||||
being disabled or having an inside-chroot path set), rsync will munge
|
||||
symlinks (by default) and sanitize paths. Those that dislike munged
|
||||
symlinks (and really, really trust their users to not break out of the
|
||||
subdir) can disable the symlink munging via the "[munge symlinks](#)"
|
||||
parameter.
|
||||
|
||||
When rsync is sanitizing paths, it trims ".." path elements from args that
|
||||
it believes would escape the module hierarchy. It also substitutes leading
|
||||
slashes in absolute paths with the module's path (so that options such as
|
||||
`--backup-dir` & `--compare-dest` interpret an absolute path as rooted in
|
||||
the module's "[path](#)" dir).
|
||||
|
||||
When a chroot is in effect *and* the "[name converter](#)" parameter is
|
||||
*not* set, the "[numeric ids](#)" parameter will default to being enabled
|
||||
(disabling name lookups). This means that if you manually setup
|
||||
name-lookup libraries in your chroot (instead of using a name converter)
|
||||
@@ -894,7 +926,7 @@ the values of parameters. See the GLOBAL PARAMETERS section for more details.
|
||||
> refuse options = * !a !v !compress*
|
||||
|
||||
Don't worry that the "`*`" will refuse certain vital options such as
|
||||
`--dry-run`, `--server`, `--no-iconv`, `--protect-args`, etc. These
|
||||
`--dry-run`, `--server`, `--no-iconv`, `--seclude-args`, etc. These
|
||||
important options are not matched by wild-card, so they must be overridden
|
||||
by their exact name. For instance, if you're forcing iconv transfers you
|
||||
could use something like this:
|
||||
@@ -948,7 +980,7 @@ the values of parameters. See the GLOBAL PARAMETERS section for more details.
|
||||
`--log-file-format`.
|
||||
- `--sender`: Use "[write only](#)" parameter instead of refusing this.
|
||||
- `--dry-run`, `-n`: Who would want to disable this?
|
||||
- `--protect-args`, `-s`: This actually makes transfers safer.
|
||||
- `--seclude-args`, `-s`: Is the oldest arg-protection method.
|
||||
- `--from0`, `-0`: Makes it easier to accept/refuse `--files-from` without
|
||||
affecting this helpful modifier.
|
||||
- `--iconv`: This is auto-disabled based on "[charset](#)" parameter.
|
||||
@@ -991,7 +1023,7 @@ the values of parameters. See the GLOBAL PARAMETERS section for more details.
|
||||
_not_ displayed if the script returns success. The other programs cannot
|
||||
send any text to the user. All output except for the `pre-xfer exec`
|
||||
stdout goes to the corresponding daemon's stdout/stderr, which is typically
|
||||
discarded. See the `--no-detatch` option for a way to see the daemon's
|
||||
discarded. See the `--no-detach` option for a way to see the daemon's
|
||||
output, which can assist with debugging.
|
||||
|
||||
Note that the `early exec` command runs before any part of the transfer
|
||||
|
||||
9
sender.c
9
sender.c
@@ -25,6 +25,7 @@
|
||||
extern int do_xfers;
|
||||
extern int am_server;
|
||||
extern int am_daemon;
|
||||
extern int local_server;
|
||||
extern int inc_recurse;
|
||||
extern int log_before_transfer;
|
||||
extern int stdout_format_has_i;
|
||||
@@ -51,6 +52,7 @@ extern int file_old_total;
|
||||
extern BOOL want_progress_now;
|
||||
extern struct stats stats;
|
||||
extern struct file_list *cur_flist, *first_flist, *dir_flist;
|
||||
extern char num_dev_ino_buf[4 + 8 + 8];
|
||||
|
||||
BOOL extra_flist_sending_enabled;
|
||||
|
||||
@@ -144,6 +146,13 @@ void successful_send(int ndx)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (local_server
|
||||
&& (int64)st.st_dev == IVAL64(num_dev_ino_buf, 4)
|
||||
&& (int64)st.st_ino == IVAL64(num_dev_ino_buf, 4 + 8)) {
|
||||
rprintf(FERROR_XFER, "ERROR: Skipping sender remove of destination file: %s\n", fname);
|
||||
return;
|
||||
}
|
||||
|
||||
if (st.st_size != F_LENGTH(file) || st.st_mtime != file->modtime
|
||||
#ifdef ST_MTIME_NSEC
|
||||
|| (NSEC_BUMP(file) && (uint32)st.ST_MTIME_NSEC != F_MOD_NSEC(file))
|
||||
|
||||
@@ -1,42 +1,63 @@
|
||||
#!/usr/bin/env perl
|
||||
#
|
||||
#!/usr/bin/env python3
|
||||
# This script finds all CVS/Entries files in the current directory and below
|
||||
# and creates a local .cvsinclude file with non-inherited rules including each
|
||||
# checked-in file. Then, use this option whenever using --cvs-exclude (-C):
|
||||
#
|
||||
# -f ': .cvsinclude'
|
||||
# -f ': .cvsinclude'
|
||||
#
|
||||
# That ensures that all checked-in files/dirs are included in the transfer.
|
||||
# (You could alternately put ": .cvsinclude" into an .rsync-filter file and
|
||||
# use the -F option, which is easier to type.)
|
||||
#
|
||||
# The downside is that you need to remember to re-run cvs2includes whenever
|
||||
# you add a new file to the project.
|
||||
use strict;
|
||||
# CVS gets an added or removed file. Maybe just run it before every copy.
|
||||
|
||||
open(FIND, 'find . -name CVS -type d |') or die $!;
|
||||
while (<FIND>) {
|
||||
chomp;
|
||||
s#^\./##;
|
||||
import os, argparse
|
||||
|
||||
my $entries = "$_/Entries";
|
||||
s/CVS$/.cvsinclude/;
|
||||
my $filter = $_;
|
||||
INC_NAME = '.cvsinclude'
|
||||
|
||||
open(ENTRIES, $entries) or die "Unable to open $entries: $!\n";
|
||||
my @includes;
|
||||
while (<ENTRIES>) {
|
||||
push(@includes, $1) if m#/(.+?)/#;
|
||||
}
|
||||
close ENTRIES;
|
||||
if (@includes) {
|
||||
open(FILTER, ">$filter") or die "Unable to write $filter: $!\n";
|
||||
print FILTER map "+ /$_\n", @includes;
|
||||
close FILTER;
|
||||
print "Updated $filter\n";
|
||||
} elsif (-f $filter) {
|
||||
unlink($filter);
|
||||
print "Removed $filter\n";
|
||||
}
|
||||
}
|
||||
close FIND;
|
||||
def main():
|
||||
if args.dir:
|
||||
os.chdir(args.dir)
|
||||
|
||||
cvs_includes = set()
|
||||
for root, dirs, files in os.walk('.'):
|
||||
if INC_NAME in files:
|
||||
cvs_includes.add((root + '/' + INC_NAME)[2:])
|
||||
if root.endswith('/CVS') and 'Entries' in files:
|
||||
entries = root[2:] + '/Entries'
|
||||
includes = [ ]
|
||||
with open(entries) as fh:
|
||||
for line in fh:
|
||||
if line.startswith(('/', 'D/')):
|
||||
includes.append(line.split('/', 2)[1])
|
||||
if includes:
|
||||
inc = root[2:-3] + INC_NAME
|
||||
cvs_includes.discard(inc)
|
||||
try:
|
||||
with open(inc) as fh:
|
||||
old_txt = fh.read()
|
||||
except OSError:
|
||||
old_txt = ''
|
||||
txt = ''.join(f"+ /{x}\n" for x in includes)
|
||||
if txt == old_txt:
|
||||
print("Unchanged", inc)
|
||||
else:
|
||||
print("Updating", inc)
|
||||
with open(inc, 'w') as fh:
|
||||
fh.write(txt)
|
||||
dirs.sort()
|
||||
|
||||
for inc in sorted(cvs_includes):
|
||||
print("Removing", inc)
|
||||
os.unlink(inc)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=f"Transform CVS/Entries into {INC_NAME} files.", add_help=False)
|
||||
parser.add_argument("--help", "-h", action="help", help="Output this help message and exit.")
|
||||
parser.add_argument("dir", nargs='?', help="The top CVS dir. Defaults to the current directory.")
|
||||
args = parser.parse_args()
|
||||
main()
|
||||
|
||||
# vim: sw=4 et
|
||||
|
||||
@@ -1,27 +1,37 @@
|
||||
#!/usr/bin/env perl
|
||||
# This script takes an input of filenames and outputs a set of
|
||||
# include/exclude directives that can be used by rsync to copy
|
||||
# just the indicated files using an --exclude-from=FILE option.
|
||||
use strict;
|
||||
#!/usr/bin/env python3
|
||||
# This script takes an input of filenames and outputs a set of include/exclude
|
||||
# directives that can be used by rsync to copy just the indicated files using
|
||||
# an --exclude-from=FILE or -f'. FILE' option. To be able to delete files on
|
||||
# the receiving side, either use --delete-excluded or change the exclude (-)
|
||||
# rules to hide filter rules (H) that only affect the sending side.
|
||||
|
||||
my %hash;
|
||||
import os, fileinput, argparse
|
||||
|
||||
while (<>) {
|
||||
chomp;
|
||||
s#^/+##;
|
||||
my $path = '/';
|
||||
while (m#([^/]+/)/*#g) {
|
||||
$path .= $1;
|
||||
print "+ $path\n" unless $hash{$path}++;
|
||||
}
|
||||
if (m#([^/]+)$#) {
|
||||
print "+ $path$1\n";
|
||||
} else {
|
||||
delete $hash{$path};
|
||||
}
|
||||
}
|
||||
def main():
|
||||
paths = set()
|
||||
for line in fileinput.input(args.files):
|
||||
dirs = line.strip().lstrip('/').split('/')
|
||||
if not dirs:
|
||||
continue
|
||||
for j in range(1, len(dirs)):
|
||||
if dirs[j] == '':
|
||||
continue
|
||||
path = '/' + '/'.join(dirs[:j]) + '/'
|
||||
if path not in paths:
|
||||
print('+', path)
|
||||
paths.add(path)
|
||||
print('+', '/' + '/'.join(dirs))
|
||||
|
||||
foreach (sort keys %hash) {
|
||||
print "- $_*\n";
|
||||
}
|
||||
print "- /*\n";
|
||||
for path in sorted(paths):
|
||||
print('-', path + '*')
|
||||
print('-', '/*')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description="Transform a list of files into a set of include/exclude rules.", add_help=False)
|
||||
parser.add_argument("--help", "-h", action="help", help="Output this help message and exit.")
|
||||
parser.add_argument("files", metavar="FILE", default='-', nargs='*', help="The file(s) that hold the pathnames to translate. Defaults to stdin.")
|
||||
args = parser.parse_args()
|
||||
main()
|
||||
|
||||
# vim: sw=4 et
|
||||
|
||||
45
support/idmap
Executable file
45
support/idmap
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
# This helper script makes it easy to use a passwd or group file to map values
|
||||
# in a LOCAL transfer. For instance, if you mount a backup that does not have
|
||||
# the same passwd setup as the local machine, you can do a copy to/from the
|
||||
# backup area as follows and get the differing ID values mapped just like a
|
||||
# remote transfer to/from the backed-up machine would do:
|
||||
#
|
||||
# rsync -av --usermap=`idmap --to /mnt/backup/etc/passwd` \
|
||||
# --groupmap=`idmap --to /mnt/backup/etc/group` \
|
||||
# /some/src/ /mnt/backup/some/dest/
|
||||
#
|
||||
# rsync -av --usermap=`idmap --from /mnt/backup/etc/passwd` \
|
||||
# --groupmap=`idmap --from /mnt/backup/etc/group` \
|
||||
# /mnt/backup/some/src/ /some/dest/
|
||||
|
||||
import re, fileinput, argparse
|
||||
|
||||
NAME_ID_RE = re.compile(r'^(\w+):[^:]+:(\d+)')
|
||||
|
||||
def main():
|
||||
maps = [ ]
|
||||
for line in fileinput.input(args.files):
|
||||
m = NAME_ID_RE.match(line)
|
||||
if not m:
|
||||
continue
|
||||
if args.to:
|
||||
pair = (m[1], m[2])
|
||||
else:
|
||||
pair = (m[2], m[1])
|
||||
maps.append(':'.join(pair))
|
||||
print(','.join(maps))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description="Output usermap or groupmap args for rsync.", add_help=False)
|
||||
action = parser.add_argument_group()
|
||||
action = parser.add_mutually_exclusive_group(required=True)
|
||||
action.add_argument("--from", action="store_true", help="Output the map for use on the sending side.")
|
||||
action.add_argument("--to", action="store_true", help="Output the map for use on the receiving side.")
|
||||
parser.add_argument("--help", "-h", action="help", help="Output this help message and exit.")
|
||||
parser.add_argument("files", metavar="FILE", default='-', nargs='*', help="The file(s) that hold the name & id pairs. Defaults to stdin.")
|
||||
args = parser.parse_args()
|
||||
main()
|
||||
|
||||
# vim: sw=4 et
|
||||
93
support/json-rsync-version
Executable file
93
support/json-rsync-version
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys, argparse, subprocess, json
|
||||
|
||||
TWEAK_NAME = {
|
||||
'asm': 'asm_roll',
|
||||
'ASM': 'asm_roll',
|
||||
'hardlink_special': 'hardlink_specials',
|
||||
'protect_args': 'secluded_args',
|
||||
'protected_args': 'secluded_args',
|
||||
'SIMD': 'SIMD_roll',
|
||||
}
|
||||
|
||||
MOVE_OPTIM = set('asm_roll SIMD_roll'.split())
|
||||
|
||||
def main():
|
||||
if not args.rsync or args.rsync == '-':
|
||||
ver_out = sys.stdin.read().strip()
|
||||
else:
|
||||
ver_out = subprocess.check_output([args.rsync, '--version', '--version'], encoding='utf-8').strip()
|
||||
if ver_out.startswith('{'):
|
||||
print(ver_out)
|
||||
return
|
||||
info = { }
|
||||
misplaced_optims = { }
|
||||
for line in ver_out.splitlines():
|
||||
if line.startswith('rsync '):
|
||||
prog, vstr, ver, pstr, vstr2, proto = line.split()
|
||||
info['program'] = prog
|
||||
if ver.startswith('v'):
|
||||
ver = ver[1:]
|
||||
info[vstr] = ver
|
||||
if '.' not in proto:
|
||||
proto += '.0'
|
||||
else:
|
||||
proto = proto.replace('.PR', '.')
|
||||
info[pstr] = proto
|
||||
elif line.startswith('Copyright '):
|
||||
info['copyright'] = line[10:]
|
||||
elif line.startswith('Web site: '):
|
||||
info['url'] = line[10:]
|
||||
elif line.startswith(' '):
|
||||
if not saw_comma and ',' in line:
|
||||
saw_comma = True
|
||||
info[sect_name] = { }
|
||||
if saw_comma:
|
||||
for x in line.strip(' ,').split(', '):
|
||||
if ' ' in x:
|
||||
val, var = x.split(' ', 1)
|
||||
if val == 'no':
|
||||
val = False
|
||||
elif val.endswith('-bit'):
|
||||
var = var[:-1] + '_bits'
|
||||
val = int(val.split('-')[0])
|
||||
else:
|
||||
var = x
|
||||
val = True
|
||||
var = var.replace(' ', '_').replace('-', '_')
|
||||
if var in TWEAK_NAME:
|
||||
var = TWEAK_NAME[var]
|
||||
if sect_name[0] != 'o' and var in MOVE_OPTIM:
|
||||
misplaced_optims[var] = val
|
||||
else:
|
||||
info[sect_name][var] = val
|
||||
else:
|
||||
info[sect_name] += [ x for x in line.split() if not x.startswith('(') ]
|
||||
elif line == '':
|
||||
break
|
||||
else:
|
||||
sect_name = line.strip(' :').replace(' ', '_').lower()
|
||||
info[sect_name] = [ ]
|
||||
saw_comma = False
|
||||
for chk in 'capabilities optimizations'.split():
|
||||
if chk not in info:
|
||||
info[chk] = { }
|
||||
if misplaced_optims:
|
||||
info['optimizations'].update(misplaced_optims)
|
||||
for chk in 'checksum_list compress_list daemon_auth_list'.split():
|
||||
if chk not in info:
|
||||
info[chk] = [ ]
|
||||
info['license'] = 'GPLv3' if ver[0] == '3' else 'GPLv2'
|
||||
info['caveat'] = 'rsync comes with ABSOLUTELY NO WARRANTY'
|
||||
print(json.dumps(info))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description="Output rsync's version data in JSON format, even if the rsync doesn't support a native json-output method.", add_help=False)
|
||||
parser.add_argument('rsync', nargs='?', help="Specify an rsync command to run. Otherwise stdin is consumed.")
|
||||
parser.add_argument("--help", "-h", action="help", help="Output this help message and exit.")
|
||||
args = parser.parse_args()
|
||||
main()
|
||||
|
||||
# vim: sw=4 et
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
# This helper script makes it easy to use a passwd or group file to map
|
||||
# values in a LOCAL transfer. For instance, if you mount a backup that
|
||||
# does not have the same passwd setup as the local machine, you can do
|
||||
# a copy FROM the backup area as follows and get the differing ID values
|
||||
# mapped just like a remote transfer FROM the backed-up machine would do:
|
||||
#
|
||||
# rsync -av --usermap=`mapfrom /mnt/backup/etc/passwd` \
|
||||
# --groupmap=`mapfrom /mnt/backup/etc/group` \
|
||||
# /mnt/backup/some/src/ /some/dest/
|
||||
|
||||
while (<>) {
|
||||
push @_, "$2:$1" if /^(\w+):[^:]+:(\d+)/;
|
||||
}
|
||||
print join(',', @_), "\n";
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
# This helper script makes it easy to use a passwd or group file to map
|
||||
# values in a LOCAL transfer. For instance, if you mount a backup that
|
||||
# does not have the same passwd setup as the local machine, you can do
|
||||
# a copy TO the backup area as follows and get the differing ID values
|
||||
# mapped just like a remote transfer TO the backed-up machine would do:
|
||||
#
|
||||
# rsync -av --usermap=`mapto /mnt/backup/etc/passwd` \
|
||||
# --groupmap=`mapto /mnt/backup/etc/group` \
|
||||
# /some/src/ /mnt/backup/some/dest/
|
||||
|
||||
while (<>) {
|
||||
push @_, "$1:$2" if /^(\w+):[^:]+:(\d+)/;
|
||||
}
|
||||
print join(',', @_), "\n";
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env perl
|
||||
#!/usr/bin/env python3
|
||||
# This script takes a command-line arg of a source directory
|
||||
# that will be passed to rsync, and generates a set of excludes
|
||||
# that will exclude all mount points from the list. This is
|
||||
@@ -27,23 +27,33 @@
|
||||
# awk '{print $2}' /proc/mounts | grep -v '^/$' | \
|
||||
# rsync -avf 'merge,/- -' /dir host:/dest/
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Cwd 'abs_path';
|
||||
import os, argparse
|
||||
|
||||
my $file = '/proc/mounts';
|
||||
my $dir = shift || '/';
|
||||
my $trailing_slash = $dir =~ m{./$} ? '/' : '';
|
||||
$dir = abs_path($dir) . $trailing_slash;
|
||||
$dir =~ s{([^/]*)$}{};
|
||||
my $trailing = $1;
|
||||
$trailing = '' if $trailing eq '.' || !-d "$dir$trailing";
|
||||
$trailing .= '/' if $trailing ne '';
|
||||
MNT_FILE = '/proc/mounts';
|
||||
|
||||
open(IN, $file) or die "Unable to open $file: $!\n";
|
||||
while (<IN>) {
|
||||
$_ = (split)[1];
|
||||
next unless s{^\Q$dir$trailing\E}{}o && $_ ne '';
|
||||
print "- /$trailing$_\n";
|
||||
}
|
||||
close IN;
|
||||
def main():
|
||||
trailing_slash = '/' if args.path.endswith(('/', '/.')) and args.path != '/' else ''
|
||||
args.path = os.path.realpath(args.path) + trailing_slash
|
||||
parent_dir = os.path.dirname(args.path)
|
||||
trailing = os.path.basename(args.path)
|
||||
if not os.path.isdir(args.path):
|
||||
trailing = ''
|
||||
elif trailing != '':
|
||||
trailing += '/'
|
||||
want_path = os.path.join(parent_dir, trailing)
|
||||
wp_len = len(want_path)
|
||||
|
||||
with open(MNT_FILE) as fh:
|
||||
for line in fh:
|
||||
mnt_path = line.split()[1]
|
||||
if mnt_path.startswith(want_path) and mnt_path != want_path:
|
||||
print(f"- /{trailing}{mnt_path[wp_len:]}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description="Output mount points as rsync excludes.", add_help=False)
|
||||
parser.add_argument("--help", "-h", action="help", help="Output this help message and exit.")
|
||||
parser.add_argument('path', metavar='PATH', nargs='?', default='/', help="Limit output to those within the PATH hierarchy.")
|
||||
args = parser.parse_args()
|
||||
main()
|
||||
|
||||
# vim: sw=4 et
|
||||
|
||||
@@ -47,6 +47,7 @@ long_opts = {
|
||||
'compress-choice': 1,
|
||||
'compress-level': 1,
|
||||
'copy-dest': 2,
|
||||
'copy-devices': -1,
|
||||
'copy-unsafe-links': 0,
|
||||
'daemon': -1,
|
||||
'debug': 1,
|
||||
@@ -257,6 +258,9 @@ def main():
|
||||
|
||||
if args.munge:
|
||||
rsync_opts.append('--munge-links')
|
||||
|
||||
if args.no_overwrite:
|
||||
rsync_opts.append('--ignore-existing')
|
||||
|
||||
if not rsync_args:
|
||||
rsync_args = [ '.' ]
|
||||
@@ -363,6 +367,7 @@ if __name__ == '__main__':
|
||||
arg_parser.add_argument('-munge', action='store_true', help="Enable rsync's --munge-links on the server side.")
|
||||
arg_parser.add_argument('-no-del', action='store_true', help="Disable rsync's --delete* and --remove* options.")
|
||||
arg_parser.add_argument('-no-lock', action='store_true', help="Avoid the single-run (per-user) lock check.")
|
||||
arg_parser.add_argument('-no-overwrite', action='store_true', help="Prevent overwriting existing files by enforcing --ignore-existing")
|
||||
arg_parser.add_argument('-help', '-h', action='help', help="Output this help message and exit.")
|
||||
arg_parser.add_argument('dir', metavar='DIR', help="The restricted directory to use.")
|
||||
args = arg_parser.parse_args()
|
||||
|
||||
@@ -5,7 +5,7 @@ rrsync - a script to setup restricted rsync users via ssh logins
|
||||
## SYNOPSIS
|
||||
|
||||
```
|
||||
rrsync [-ro|-rw] [-munge] [-no-del] [-no-lock] DIR
|
||||
rrsync [-ro|-rw] [-munge] [-no-del] [-no-lock] [-no-overwrite] DIR
|
||||
```
|
||||
|
||||
The single non-option argument specifies the restricted _DIR_ to use. It can be
|
||||
@@ -22,6 +22,10 @@ transfer in one of two easy ways:
|
||||
* forcing the running of the rrsync script
|
||||
* forcing the running of an rsync daemon-over-ssh command.
|
||||
|
||||
Both of these setups use a feature of ssh that allows a command to be forced to
|
||||
run instead of an interactive shell. However, if the user's home shell is bash,
|
||||
please see [BASH SECURITY ISSUE](#) for a potential issue.
|
||||
|
||||
To use the rrsync script, edit the user's `~/.ssh/authorized_keys` file and add
|
||||
a prefix like one of the following (followed by a space) in front of each
|
||||
ssh-key line that should be restricted:
|
||||
@@ -81,6 +85,11 @@ The remainder of this manpage is dedicated to using the rrsync script.
|
||||
|
||||
Avoid the single-run (per-user) lock check. Useful with [`-munge`](#opt).
|
||||
|
||||
0. `-no-overwrite`
|
||||
|
||||
Enforce `--ignore-existing` on the server. Prevents overwriting existing
|
||||
files when the server is the receiver.
|
||||
|
||||
0. `-help`, `-h`
|
||||
|
||||
Output this help message and exit.
|
||||
@@ -107,6 +116,26 @@ overrides.
|
||||
The script (or a copy of it) can be manually edited if you want it to customize
|
||||
the option handling.
|
||||
|
||||
## BASH SECURITY ISSUE
|
||||
|
||||
If your users have bash set as their home shell, bash may try to be overly
|
||||
helpful and ensure that the user's login bashrc files are run prior to
|
||||
executing the forced command. This can be a problem if the user can somehow
|
||||
update their home bashrc files, perhaps via the restricted copy, a shared home
|
||||
directory, or something similar.
|
||||
|
||||
One simple way to avoid the issue is to switch the user to a simpler shell,
|
||||
such as dash. When choosing the new home shell, make sure that you're not
|
||||
choosing bash in disguise, as it is unclear if it avoids the security issue.
|
||||
|
||||
Another potential fix is to ensure that the user's home directory is not a
|
||||
shared mount and that they have no means of copying files outside of their
|
||||
restricted directories. This may require you to force the enabling of symlink
|
||||
munging on the server side.
|
||||
|
||||
A future version of openssh may have a change to the handling of forced
|
||||
commands that allows it to avoid using the user's home shell.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
The `~/.ssh/authorized_keys` file might have lines in it like this:
|
||||
|
||||
1
t_stub.c
1
t_stub.c
@@ -29,7 +29,6 @@ int protect_args = 0;
|
||||
int module_id = -1;
|
||||
int relative_paths = 0;
|
||||
int module_dirlen = 0;
|
||||
int preserve_mtimes = 0;
|
||||
int preserve_xattrs = 0;
|
||||
int preserve_perms = 0;
|
||||
int preserve_executability = 0;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
. $suitedir/rsync.fns
|
||||
|
||||
$RSYNC --version | grep "[, ] ACLs" >/dev/null || test_skipped "Rsync is configured without ACL support"
|
||||
$RSYNC -VV | grep '"ACLs": true' >/dev/null || test_skipped "Rsync is configured without ACL support"
|
||||
|
||||
case "$setfacl_nodef" in
|
||||
true) test_skipped "I don't know how to use your setfacl command" ;;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
. $suitedir/rsync.fns
|
||||
|
||||
$RSYNC --version | grep "[, ] ACLs" >/dev/null || test_skipped "Rsync is configured without ACL support"
|
||||
$RSYNC -VV | grep '"ACLs": true' >/dev/null || test_skipped "Rsync is configured without ACL support"
|
||||
|
||||
makepath "$fromdir/foo"
|
||||
echo something >"$fromdir/file1"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
. "$suitedir/rsync.fns"
|
||||
|
||||
$RSYNC --version | grep "[, ] atimes" >/dev/null || test_skipped "Rsync is configured without atimes support"
|
||||
$RSYNC -VV | grep '"atimes": true' >/dev/null || test_skipped "Rsync is configured without atimes support"
|
||||
|
||||
mkdir "$fromdir"
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
case $0 in
|
||||
*fake*)
|
||||
$RSYNC --version | grep "[, ] xattrs" >/dev/null || test_skipped "Rsync needs xattrs for fake device tests"
|
||||
$RSYNC -VV | grep '"xattrs": true' >/dev/null || test_skipped "Rsync needs xattrs for fake device tests"
|
||||
RSYNC="$RSYNC --fake-super"
|
||||
TLS_ARGS="$TLS_ARGS --fake-super"
|
||||
case "$HOST_OS" in
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
. "$suitedir/rsync.fns"
|
||||
|
||||
$RSYNC --version | grep "[, ] crtimes" >/dev/null || test_skipped "Rsync is configured without crtimes support"
|
||||
$RSYNC -VV | grep '"crtimes": true' >/dev/null || test_skipped "Rsync is configured without crtimes support"
|
||||
|
||||
# Setting an older time via touch sets the create time to the mtime.
|
||||
# Setting it to a newer time affects just the mtime.
|
||||
|
||||
@@ -81,7 +81,7 @@ drwxr-xr-x DIR ####/##/## ##:##:## foo
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
|
||||
|
||||
if $RSYNC --version | grep "[, ] atimes" >/dev/null; then
|
||||
if $RSYNC -VV | grep '"atimes": true' >/dev/null; then
|
||||
checkdiff "$RSYNC -rU localhost::test-from/f*" \
|
||||
"sed -e '$FILE_REPL' -e '$DIR_REPL' -e '$LS_REPL'" <<EOT
|
||||
drwxr-xr-x DIR ####/##/## ##:##:## foo
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
case $0 in
|
||||
*fake*)
|
||||
$RSYNC --version | grep "[, ] xattrs" >/dev/null || test_skipped "Rsync needs xattrs for fake device tests"
|
||||
$RSYNC -VV | grep '"xattrs": true' >/dev/null || test_skipped "Rsync needs xattrs for fake device tests"
|
||||
RSYNC="$RSYNC --fake-super"
|
||||
TLS_ARGS="$TLS_ARGS --fake-super"
|
||||
case "$HOST_OS" in
|
||||
@@ -94,7 +94,7 @@ esac
|
||||
|
||||
# TODO: Need to test whether hardlinks are possible on this OS/filesystem
|
||||
|
||||
$RSYNC --version | grep "[, ] hardlink-special" >/dev/null && CAN_HLINK_SPECIAL=yes || CAN_HLINK_SPECIAL=no
|
||||
$RSYNC -VV | grep '"hardlink_specials": true' >/dev/null && CAN_HLINK_SPECIAL=yes || CAN_HLINK_SPECIAL=no
|
||||
|
||||
mkdir "$fromdir"
|
||||
mkdir "$todir"
|
||||
|
||||
1
testsuite/exclude-lsh.test
Symbolic link
1
testsuite/exclude-lsh.test
Symbolic link
@@ -0,0 +1 @@
|
||||
exclude.test
|
||||
@@ -15,6 +15,19 @@
|
||||
CVSIGNORE='*.junk'
|
||||
export CVSIGNORE
|
||||
|
||||
case $0 in
|
||||
*-lsh.*)
|
||||
RSYNC_RSH="$scratchdir/src/support/lsh.sh"
|
||||
export RSYNC_RSH
|
||||
rpath=" --rsync-path='$RSYNC'"
|
||||
host='lh:'
|
||||
;;
|
||||
*)
|
||||
rpath=''
|
||||
host=''
|
||||
;;
|
||||
esac
|
||||
|
||||
# Build some files/dirs/links to copy
|
||||
|
||||
makepath "$fromdir/foo/down/to/you"
|
||||
@@ -106,8 +119,8 @@ home-cvs-exclude
|
||||
EOF
|
||||
|
||||
# Start with a check of --prune-empty-dirs:
|
||||
$RSYNC -av -f -_foo/too/ -f -_foo/down/ -f -_foo/and/ -f -_new/ "$fromdir/" "$chkdir/"
|
||||
checkit "$RSYNC -av --prune-empty-dirs '$fromdir/' '$todir/'" "$chkdir" "$todir"
|
||||
$RSYNC -av --rsync-path="$RSYNC" -f -_foo/too/ -f -_foo/down/ -f -_foo/and/ -f -_new/ "$host$fromdir/" "$chkdir/"
|
||||
checkit "$RSYNC -av$rpath --prune-empty-dirs '$host$fromdir/' '$todir/'" "$chkdir" "$todir"
|
||||
rm -rf "$todir"
|
||||
|
||||
# Add a directory symlink.
|
||||
@@ -120,7 +133,7 @@ touch "$scratchdir/up1/same-newness" "$scratchdir/up2/same-newness"
|
||||
touch "$scratchdir/up1/extra-src" "$scratchdir/up2/extra-dest"
|
||||
|
||||
# Create chkdir with what we expect to be excluded.
|
||||
checkit "$RSYNC -avv '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir"
|
||||
checkit "$RSYNC -avv$rpath '$host$fromdir/' '$chkdir/'" "$fromdir" "$chkdir"
|
||||
sleep 1 # Ensures that the rm commands will tweak the directory times.
|
||||
rm -r "$chkdir"/foo/down
|
||||
rm -r "$chkdir"/mid/for/foo/and
|
||||
@@ -135,12 +148,12 @@ touch "$scratchdir/up1/src-newness" "$scratchdir/up2/dst-newness"
|
||||
|
||||
# Un-tweak the directory times in our first (weak) exclude test (though
|
||||
# it's a good test of the --existing option).
|
||||
$RSYNC -av --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
|
||||
$RSYNC -av --rsync-path="$RSYNC" --existing --include='*/' --exclude='*' "$host$fromdir/" "$chkdir/"
|
||||
|
||||
# Now, test if rsync excludes the same files.
|
||||
|
||||
checkit "$RSYNC -avv --exclude-from='$excl' \
|
||||
--delete-during '$fromdir/' '$todir/'" "$chkdir" "$todir"
|
||||
checkit "$RSYNC -avv$rpath --exclude-from='$excl' \
|
||||
--delete-during '$host$fromdir/' '$todir/'" "$chkdir" "$todir"
|
||||
|
||||
# Modify the chk dir by removing cvs-ignored files and then tweaking the dir times.
|
||||
|
||||
@@ -150,13 +163,15 @@ rm "$chkdir"/bar/down/to/foo/*.junk
|
||||
rm "$chkdir"/bar/down/to/home-cvs-exclude
|
||||
rm "$chkdir"/mid/one-in-one-out
|
||||
|
||||
$RSYNC -av --existing --filter='exclude,! */' "$fromdir/" "$chkdir/"
|
||||
$RSYNC -av --rsync-path="$RSYNC" --existing --filter='exclude,! */' "$host$fromdir/" "$chkdir/"
|
||||
|
||||
# Now, test if rsync excludes the same files, this time with --cvs-exclude
|
||||
# and --delete-excluded.
|
||||
|
||||
checkit "$RSYNC -avvC --filter='merge $excl' --delete-excluded \
|
||||
--delete-during '$fromdir/' '$todir/'" "$chkdir" "$todir"
|
||||
# The -C option gets applied in a different order when pushing & pulling, so we instead
|
||||
# add the 2 --cvs-exclude filter rules (":C" & "-C") via -f to keep the order the same.
|
||||
checkit "$RSYNC -avv$rpath --filter='merge $excl' -f:C -f-C --delete-excluded \
|
||||
--delete-during '$host$fromdir/' '$todir/'" "$chkdir" "$todir"
|
||||
|
||||
# Modify the chk dir for our merge-exclude test and then tweak the dir times.
|
||||
|
||||
@@ -165,19 +180,19 @@ rm "$chkdir"/bar/down/to/bar/baz/*.deep
|
||||
cp_touch "$fromdir"/bar/down/to/foo/*.junk "$chkdir"/bar/down/to/foo
|
||||
cp_touch "$fromdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo
|
||||
|
||||
$RSYNC -av --existing -f 'show .filt*' -f 'hide,! */' --del "$fromdir/" "$todir/"
|
||||
$RSYNC -av --rsync-path="$RSYNC" --existing -f 'show .filt*' -f 'hide,! */' --del "$host$fromdir/" "$todir/"
|
||||
|
||||
echo retained >"$todir"/bar/down/to/bar/baz/nodel.deep
|
||||
cp_touch "$todir"/bar/down/to/bar/baz/nodel.deep "$chkdir"/bar/down/to/bar/baz
|
||||
|
||||
$RSYNC -av --existing --filter='-! */' "$fromdir/" "$chkdir/"
|
||||
$RSYNC -av --rsync-path="$RSYNC" --existing --filter='-! */' "$host$fromdir/" "$chkdir/"
|
||||
|
||||
# Now, test if rsync excludes the same files, this time with a merge-exclude
|
||||
# file.
|
||||
|
||||
checkit "sed '/!/d' '$excl' |
|
||||
$RSYNC -avv -f dir-merge_.filt -f merge_- \
|
||||
--delete-during '$fromdir/' '$todir/'" "$chkdir" "$todir"
|
||||
$RSYNC -avv$rpath -f dir-merge_.filt -f merge_- \
|
||||
--delete-during '$host$fromdir/' '$todir/'" "$chkdir" "$todir"
|
||||
|
||||
# Remove the files that will be deleted.
|
||||
|
||||
@@ -188,14 +203,14 @@ rm "$chkdir"/bar/down/to/foo/.filt2
|
||||
rm "$chkdir"/bar/down/to/bar/.filt2
|
||||
rm "$chkdir"/mid/.filt
|
||||
|
||||
$RSYNC -av --protocol=28 --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
|
||||
$RSYNC -av --rsync-path="$RSYNC" --existing --include='*/' --exclude='*' "$host$fromdir/" "$chkdir/"
|
||||
|
||||
# Now, try the prior command with --delete-before and some side-specific
|
||||
# rules.
|
||||
|
||||
checkit "sed '/!/d' '$excl' |
|
||||
$RSYNC -avv -f :s_.filt -f .s_- -f P_nodel.deep \
|
||||
--delete-before '$fromdir/' '$todir/'" "$chkdir" "$todir"
|
||||
$RSYNC -avv$rpath -f :s_.filt -f .s_- -f P_nodel.deep \
|
||||
--delete-before '$host$fromdir/' '$todir/'" "$chkdir" "$todir"
|
||||
|
||||
# Next, we'll test some rule-restricted filter files.
|
||||
|
||||
@@ -206,26 +221,26 @@ cat >"$fromdir/bar/down/to/foo/.excl" <<EOF
|
||||
+ file3
|
||||
*.bak
|
||||
EOF
|
||||
$RSYNC -av --del "$fromdir/" "$chkdir/"
|
||||
$RSYNC -av --rsync-path="$RSYNC" --del "$host$fromdir/" "$chkdir/"
|
||||
rm "$chkdir/bar/down/to/foo/file1.bak"
|
||||
rm "$chkdir/bar/down/to/foo/file3"
|
||||
rm "$chkdir/bar/down/to/foo/+ file3"
|
||||
$RSYNC -av --existing --filter='-! */' "$fromdir/" "$chkdir/"
|
||||
$RSYNC -av --delete-excluded --exclude='*' "$fromdir/" "$todir/"
|
||||
$RSYNC -av --rsync-path="$RSYNC" --existing --filter='-! */' "$host$fromdir/" "$chkdir/"
|
||||
$RSYNC -av --rsync-path="$RSYNC" --delete-excluded --exclude='*' "$host$fromdir/" "$todir/"
|
||||
|
||||
checkit "$RSYNC -avv -f dir-merge,-_.excl \
|
||||
'$fromdir/' '$todir/'" "$chkdir" "$todir"
|
||||
checkit "$RSYNC -avv$rpath -f dir-merge,-_.excl \
|
||||
'$host$fromdir/' '$todir/'" "$chkdir" "$todir"
|
||||
|
||||
relative_opts='--relative --chmod=Du+w --copy-unsafe-links'
|
||||
$RSYNC -av $relative_opts "$fromdir/foo" "$chkdir/"
|
||||
$RSYNC -av --rsync-path="$RSYNC" $relative_opts "$host$fromdir/foo" "$chkdir/"
|
||||
rm -rf "$chkdir$fromdir/foo/down"
|
||||
$RSYNC -av $relative_opts --existing --filter='-! */' "$fromdir/foo" "$chkdir/"
|
||||
|
||||
checkit "$RSYNC -avv $relative_opts --exclude='$fromdir/foo/down' \
|
||||
'$fromdir/foo' '$todir'" "$chkdir$fromdir/foo" "$todir$fromdir/foo"
|
||||
checkit "$RSYNC -avv$rpath $relative_opts --exclude='$fromdir/foo/down' \
|
||||
'$host$fromdir/foo' '$todir'" "$chkdir$fromdir/foo" "$todir$fromdir/foo"
|
||||
|
||||
# Now we'll test the --update option.
|
||||
checkdiff "$RSYNC -aiiO --update --info=skip '$scratchdir/up1/' '$scratchdir/up2/'" \
|
||||
checkdiff "$RSYNC -aiiO$rpath --update --info=skip '$host$scratchdir/up1/' '$scratchdir/up2/'" \
|
||||
"grep -v '^\.d$allspace'" <<EOT
|
||||
dst-newness is newer
|
||||
>f$all_plus extra-src
|
||||
|
||||
@@ -25,7 +25,7 @@ ln "$fromdir/foo/config1" "$fromdir/foo/extra"
|
||||
rm -f "$to2dir"
|
||||
|
||||
# Check if rsync is set to hard-link symlinks.
|
||||
if $RSYNC --version | grep "[, ] hardlink-symlinks" >/dev/null; then
|
||||
if $RSYNC -VV | grep '"hardlink_symlinks": true' >/dev/null; then
|
||||
L=hL
|
||||
sym_dots="$allspace"
|
||||
L_sym_dots=".L$allspace"
|
||||
@@ -45,7 +45,7 @@ case "$RSYNC" in
|
||||
T=.T
|
||||
;;
|
||||
*)
|
||||
if $RSYNC --version | grep "[, ] symtimes" >/dev/null; then
|
||||
if $RSYNC -VV | grep '"symtimes": true' >/dev/null; then
|
||||
T=.t
|
||||
else
|
||||
T=.T
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
. $suitedir/rsync.fns
|
||||
lnkdir="$tmpdir/lnk"
|
||||
|
||||
$RSYNC --version | grep "[, ] xattrs" >/dev/null || test_skipped "Rsync is configured without xattr support"
|
||||
$RSYNC -VV | grep '"xattrs": true' >/dev/null || test_skipped "Rsync is configured without xattr support"
|
||||
|
||||
case "$HOST_OS" in
|
||||
darwin*)
|
||||
|
||||
146
usage.c
146
usage.c
@@ -22,9 +22,9 @@
|
||||
#include "latest-year.h"
|
||||
#include "git-version.h"
|
||||
#include "default-cvsignore.h"
|
||||
#include "itypes.h"
|
||||
|
||||
extern struct name_num_obj valid_checksums;
|
||||
extern struct name_num_obj valid_compressions;
|
||||
extern struct name_num_obj valid_checksums, valid_compressions, valid_auth_checksums;
|
||||
|
||||
static char *istring(const char *fmt, int val)
|
||||
{
|
||||
@@ -37,7 +37,8 @@ static char *istring(const char *fmt, int val)
|
||||
static void print_info_flags(enum logcode f)
|
||||
{
|
||||
STRUCT_STAT *dumstat;
|
||||
char line_buf[75];
|
||||
BOOL as_json = f == FNONE ? 1 : 0; /* We use 1 == first attribute, 2 == need closing array */
|
||||
char line_buf[75], item_buf[32];
|
||||
int line_len, j;
|
||||
char *info_flags[] = {
|
||||
|
||||
@@ -110,12 +111,12 @@ static void print_info_flags(enum logcode f)
|
||||
#endif
|
||||
"xattrs",
|
||||
|
||||
#ifdef RSYNC_USE_PROTECTED_ARGS
|
||||
#ifdef RSYNC_USE_SECLUDED_ARGS
|
||||
"default "
|
||||
#else
|
||||
"optional "
|
||||
#endif
|
||||
"protect-args",
|
||||
"secluded-args",
|
||||
|
||||
#ifndef ICONV_OPTION
|
||||
"no "
|
||||
@@ -164,46 +165,137 @@ static void print_info_flags(enum logcode f)
|
||||
|
||||
for (line_len = 0, j = 0; ; j++) {
|
||||
char *str = info_flags[j], *next_nfo = str ? info_flags[j+1] : NULL;
|
||||
int str_len = str && *str != '*' ? strlen(str) : 1000;
|
||||
int need_comma = next_nfo && *next_nfo != '*' ? 1 : 0;
|
||||
if (line_len && line_len + 1 + str_len + need_comma >= (int)sizeof line_buf) {
|
||||
rprintf(f, " %s\n", line_buf);
|
||||
int item_len;
|
||||
if (!str || *str == '*')
|
||||
item_len = 1000;
|
||||
else if (as_json) {
|
||||
char *space = strchr(str, ' ');
|
||||
int is_no = space && strncmp(str, "no ", 3) == 0;
|
||||
int is_bits = space && isDigit(str);
|
||||
char *quot = space && !is_no && !is_bits ? "\"" : "";
|
||||
char *item = space ? space + 1 : str;
|
||||
char *val = !space ? "true" : is_no ? "false" : str;
|
||||
int val_len = !space ? 4 : is_no ? 5 : space - str;
|
||||
if (is_bits && (space = strchr(val, '-')) != NULL)
|
||||
val_len = space - str;
|
||||
item_len = snprintf(item_buf, sizeof item_buf,
|
||||
" \"%s%s\": %s%.*s%s%s", item, is_bits ? "bits" : "",
|
||||
quot, val_len, val, quot, need_comma ? "," : "");
|
||||
if (is_bits)
|
||||
item_buf[strlen(item)+2-1] = '_'; /* Turn the 's' into a '_' */
|
||||
for (space = item; (space = strpbrk(space, " -")) != NULL; space++)
|
||||
item_buf[space - item + 2] = '_';
|
||||
} else
|
||||
item_len = snprintf(item_buf, sizeof item_buf, " %s%s", str, need_comma ? "," : "");
|
||||
if (line_len && line_len + item_len >= (int)sizeof line_buf) {
|
||||
if (as_json)
|
||||
printf(" %s\n", line_buf);
|
||||
else
|
||||
rprintf(f, " %s\n", line_buf);
|
||||
line_len = 0;
|
||||
}
|
||||
if (!str)
|
||||
break;
|
||||
if (*str == '*') {
|
||||
rprintf(f, "%s:\n", str+1);
|
||||
continue;
|
||||
if (as_json) {
|
||||
if (as_json == 2)
|
||||
printf(" }");
|
||||
else
|
||||
as_json = 2;
|
||||
printf(",\n \"%c%s\": {\n", toLower(str+1), str+2);
|
||||
} else
|
||||
rprintf(f, "%s:\n", str+1);
|
||||
} else {
|
||||
strlcpy(line_buf + line_len, item_buf, sizeof line_buf - line_len);
|
||||
line_len += item_len;
|
||||
}
|
||||
line_len += snprintf(line_buf+line_len, sizeof line_buf - line_len, " %s%s", str, need_comma ? "," : "");
|
||||
}
|
||||
if (as_json == 2)
|
||||
printf(" }");
|
||||
}
|
||||
|
||||
static void output_nno_list(enum logcode f, const char *name, struct name_num_obj *nno)
|
||||
{
|
||||
char namebuf[64], tmpbuf[256];
|
||||
char *tok, *next_tok, *comma = ",";
|
||||
char *cp;
|
||||
|
||||
/* Using '(' ensures that we get a trailing "none" but also includes aliases. */
|
||||
get_default_nno_list(nno, tmpbuf, sizeof tmpbuf - 1, '(');
|
||||
if (f != FNONE) {
|
||||
rprintf(f, "%s:\n", name);
|
||||
rprintf(f, " %s\n", tmpbuf);
|
||||
return;
|
||||
}
|
||||
|
||||
strlcpy(namebuf, name, sizeof namebuf);
|
||||
for (cp = namebuf; *cp; cp++) {
|
||||
if (*cp == ' ')
|
||||
*cp = '_';
|
||||
else if (isUpper(cp))
|
||||
*cp = toLower(cp);
|
||||
}
|
||||
|
||||
printf(",\n \"%s\": [\n ", namebuf);
|
||||
|
||||
for (tok = strtok(tmpbuf, " "); tok; tok = next_tok) {
|
||||
next_tok = strtok(NULL, " ");
|
||||
if (*tok != '(') /* Ignore the alises in the JSON output */
|
||||
printf(" \"%s\"%s", tok, comma + (next_tok ? 0 : 1));
|
||||
}
|
||||
|
||||
printf("\n ]");
|
||||
}
|
||||
|
||||
/* A request of f == FNONE wants json on stdout. */
|
||||
void print_rsync_version(enum logcode f)
|
||||
{
|
||||
char tmpbuf[256], *subprotocol = "";
|
||||
char copyright[] = "(C) 1996-" LATEST_YEAR " by Andrew Tridgell, Wayne Davison, and others.";
|
||||
char url[] = "https://rsync.samba.org/";
|
||||
BOOL first_line = 1;
|
||||
|
||||
#define json_line(name, value) \
|
||||
do { \
|
||||
printf("%c\n \"%s\": \"%s\"", first_line ? '{' : ',', name, value); \
|
||||
first_line = 0; \
|
||||
} while (0)
|
||||
|
||||
if (f == FNONE) {
|
||||
char verbuf[32];
|
||||
json_line("program", RSYNC_NAME);
|
||||
json_line("version", rsync_version());
|
||||
(void)snprintf(verbuf, sizeof verbuf, "%d.%d", PROTOCOL_VERSION, SUBPROTOCOL_VERSION);
|
||||
json_line("protocol", verbuf);
|
||||
json_line("copyright", copyright);
|
||||
json_line("url", url);
|
||||
} else {
|
||||
#if SUBPROTOCOL_VERSION != 0
|
||||
subprotocol = istring(".PR%d", SUBPROTOCOL_VERSION);
|
||||
char *subprotocol = istring(".PR%d", SUBPROTOCOL_VERSION);
|
||||
#else
|
||||
char *subprotocol = "";
|
||||
#endif
|
||||
rprintf(f, "%s version %s protocol version %d%s\n",
|
||||
RSYNC_NAME, rsync_version(), PROTOCOL_VERSION, subprotocol);
|
||||
|
||||
rprintf(f, "Copyright (C) 1996-" LATEST_YEAR " by Andrew Tridgell, Wayne Davison, and others.\n");
|
||||
rprintf(f, "Web site: https://rsync.samba.org/\n");
|
||||
rprintf(f, "%s version %s protocol version %d%s\n",
|
||||
RSYNC_NAME, rsync_version(), PROTOCOL_VERSION, subprotocol);
|
||||
rprintf(f, "Copyright %s\n", copyright);
|
||||
rprintf(f, "Web site: %s\n", url);
|
||||
}
|
||||
|
||||
print_info_flags(f);
|
||||
|
||||
init_checksum_choices();
|
||||
|
||||
rprintf(f, "Checksum list:\n");
|
||||
get_default_nno_list(&valid_checksums, tmpbuf, sizeof tmpbuf, '(');
|
||||
rprintf(f, " %s\n", tmpbuf);
|
||||
output_nno_list(f, "Checksum list", &valid_checksums);
|
||||
output_nno_list(f, "Compress list", &valid_compressions);
|
||||
output_nno_list(f, "Daemon auth list", &valid_auth_checksums);
|
||||
|
||||
rprintf(f, "Compress list:\n");
|
||||
get_default_nno_list(&valid_compressions, tmpbuf, sizeof tmpbuf, '(');
|
||||
rprintf(f, " %s\n", tmpbuf);
|
||||
if (f == FNONE) {
|
||||
json_line("license", "GPLv3");
|
||||
json_line("caveat", "rsync comes with ABSOLUTELY NO WARRANTY");
|
||||
printf("\n}\n");
|
||||
fflush(stdout);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef MAINTAINER_MODE
|
||||
rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
|
||||
@@ -265,11 +357,13 @@ void daemon_usage(enum logcode F)
|
||||
|
||||
const char *rsync_version(void)
|
||||
{
|
||||
char *ver;
|
||||
#ifdef RSYNC_GITVER
|
||||
return RSYNC_GITVER;
|
||||
ver = RSYNC_GITVER;
|
||||
#else
|
||||
return RSYNC_VERSION;
|
||||
ver = RSYNC_VERSION;
|
||||
#endif
|
||||
return *ver == 'v' ? ver+1 : ver;
|
||||
}
|
||||
|
||||
const char *default_cvsignore(void)
|
||||
|
||||
10
util1.c
10
util1.c
@@ -31,7 +31,6 @@ extern int do_fsync;
|
||||
extern int protect_args;
|
||||
extern int modify_window;
|
||||
extern int relative_paths;
|
||||
extern int preserve_mtimes;
|
||||
extern int preserve_xattrs;
|
||||
extern int omit_link_times;
|
||||
extern int preallocate_files;
|
||||
@@ -1488,12 +1487,19 @@ const char *find_filename_suffix(const char *fn, int fn_len, int *len_ptr)
|
||||
|
||||
#define UNIT (1 << 16)
|
||||
|
||||
uint32 fuzzy_distance(const char *s1, unsigned len1, const char *s2, unsigned len2)
|
||||
uint32 fuzzy_distance(const char *s1, unsigned len1, const char *s2, unsigned len2, uint32 upperlimit)
|
||||
{
|
||||
uint32 a[MAXPATHLEN], diag, above, left, diag_inc, above_inc, left_inc;
|
||||
int32 cost;
|
||||
unsigned i1, i2;
|
||||
|
||||
/* Check to see if the Levenshtein distance must be greater than the
|
||||
* upper limit defined by the previously found lowest distance using
|
||||
* the heuristic that the Levenshtein distance is greater than the
|
||||
* difference in length of the two strings */
|
||||
if ((len1 > len2 ? len1 - len2 : len2 - len1) * UNIT > upperlimit)
|
||||
return 0xFFFFU * UNIT + 1;
|
||||
|
||||
if (!len1 || !len2) {
|
||||
if (!len1) {
|
||||
s1 = s2;
|
||||
|
||||
4
util2.c
4
util2.c
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996-2000 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2003-2020 Wayne Davison
|
||||
* Copyright (C) 2003-2024 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -72,7 +72,7 @@ int msleep(int t)
|
||||
|
||||
void *my_alloc(void *ptr, size_t num, size_t size, const char *file, int line)
|
||||
{
|
||||
if (max_alloc && num >= max_alloc/size) {
|
||||
if (num >= max_alloc/size) {
|
||||
if (!file)
|
||||
return NULL;
|
||||
rprintf(FERROR, "[%s] exceeded --max-alloc=%s setting (file=%s, line=%d)\n",
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#define RSYNC_VERSION "3.2.5"
|
||||
#define RSYNC_VERSION "3.3.0"
|
||||
#define MAINTAINER_TZ_OFFSET -7.0
|
||||
|
||||
43
xattrs.c
43
xattrs.c
@@ -39,9 +39,13 @@ extern int preserve_specials;
|
||||
extern int checksum_seed;
|
||||
extern int saw_xattr_filter;
|
||||
|
||||
extern struct name_num_item *xattr_sum_nni;
|
||||
extern int xattr_sum_len;
|
||||
|
||||
#define RSYNC_XAL_INITIAL 5
|
||||
#define RSYNC_XAL_LIST_INITIAL 100
|
||||
|
||||
#define MAX_XATTR_DIGEST_LEN MD5_DIGEST_LEN
|
||||
#define MAX_FULL_DATUM 32
|
||||
|
||||
#define HAS_PREFIX(str, prfx) (*(str) == *(prfx) && strncmp(str, prfx, sizeof (prfx) - 1) == 0)
|
||||
@@ -269,8 +273,8 @@ static int rsync_xal_get(const char *fname, item_list *xalp)
|
||||
|
||||
if (datum_len > MAX_FULL_DATUM) {
|
||||
/* For large datums, we store a flag and a checksum. */
|
||||
name_offset = 1 + MAX_DIGEST_LEN;
|
||||
sum_init(-1, checksum_seed);
|
||||
name_offset = 1 + MAX_XATTR_DIGEST_LEN;
|
||||
sum_init(xattr_sum_nni, checksum_seed);
|
||||
sum_update(ptr, datum_len);
|
||||
free(ptr);
|
||||
|
||||
@@ -377,20 +381,14 @@ static int64 xattr_lookup_hash(const item_list *xalp)
|
||||
{
|
||||
const rsync_xa *rxas = xalp->items;
|
||||
size_t i;
|
||||
int64 key = hashlittle(&xalp->count, sizeof xalp->count);
|
||||
int64 key = hashlittle2(&xalp->count, sizeof xalp->count);
|
||||
|
||||
for (i = 0; i < xalp->count; i++) {
|
||||
key += hashlittle(rxas[i].name, rxas[i].name_len);
|
||||
key += hashlittle2(rxas[i].name, rxas[i].name_len);
|
||||
if (rxas[i].datum_len > MAX_FULL_DATUM)
|
||||
key += hashlittle(rxas[i].datum, MAX_DIGEST_LEN);
|
||||
key += hashlittle2(rxas[i].datum, xattr_sum_len);
|
||||
else
|
||||
key += hashlittle(rxas[i].datum, rxas[i].datum_len);
|
||||
}
|
||||
|
||||
if (key == 0) {
|
||||
/* This is very unlikely, but we should never
|
||||
* return 0 as hashtable_find() doesn't like it. */
|
||||
return 1;
|
||||
key += hashlittle2(rxas[i].datum, rxas[i].datum_len);
|
||||
}
|
||||
|
||||
return key;
|
||||
@@ -435,7 +433,7 @@ static int find_matching_xattr(const item_list *xalp)
|
||||
if (rxas1[j].datum_len > MAX_FULL_DATUM) {
|
||||
if (memcmp(rxas1[j].datum + 1,
|
||||
rxas2[j].datum + 1,
|
||||
MAX_DIGEST_LEN) != 0)
|
||||
xattr_sum_len) != 0)
|
||||
break;
|
||||
} else {
|
||||
if (memcmp(rxas1[j].datum, rxas2[j].datum,
|
||||
@@ -471,8 +469,6 @@ static int rsync_xal_store(item_list *xalp)
|
||||
|
||||
if (rsync_xal_h == NULL)
|
||||
rsync_xal_h = hashtable_create(512, HT_KEY64);
|
||||
if (rsync_xal_h == NULL)
|
||||
out_of_memory("rsync_xal_h hashtable_create()");
|
||||
|
||||
new_ref = new0(rsync_xa_list_ref);
|
||||
new_ref->ndx = ndx;
|
||||
@@ -535,7 +531,7 @@ int send_xattr(int f, stat_x *sxp)
|
||||
#endif
|
||||
write_buf(f, name, name_len);
|
||||
if (rxa->datum_len > MAX_FULL_DATUM)
|
||||
write_buf(f, rxa->datum + 1, MAX_DIGEST_LEN);
|
||||
write_buf(f, rxa->datum + 1, xattr_sum_len);
|
||||
else
|
||||
write_bigbuf(f, rxa->datum, rxa->datum_len);
|
||||
}
|
||||
@@ -588,7 +584,7 @@ int xattr_diff(struct file_struct *file, stat_x *sxp, int find_all)
|
||||
else if (snd_rxa->datum_len > MAX_FULL_DATUM) {
|
||||
same = cmp == 0 && snd_rxa->datum_len == rec_rxa->datum_len
|
||||
&& memcmp(snd_rxa->datum + 1, rec_rxa->datum + 1,
|
||||
MAX_DIGEST_LEN) == 0;
|
||||
xattr_sum_len) == 0;
|
||||
/* Flag unrequested items that we need. */
|
||||
if (!same && find_all && snd_rxa->datum[0] == XSTATE_ABBREV)
|
||||
snd_rxa->datum[0] = XSTATE_TODO;
|
||||
@@ -797,7 +793,7 @@ void receive_xattr(int f, struct file_struct *file)
|
||||
rsync_xa *rxa;
|
||||
size_t name_len = read_varint(f);
|
||||
size_t datum_len = read_varint(f);
|
||||
size_t dget_len = datum_len > MAX_FULL_DATUM ? 1 + MAX_DIGEST_LEN : datum_len;
|
||||
size_t dget_len = datum_len > MAX_FULL_DATUM ? 1 + (size_t)xattr_sum_len : datum_len;
|
||||
size_t extra_len = MIGHT_NEED_RPRE ? RPRE_LEN : 0;
|
||||
if (SIZE_MAX - dget_len < extra_len || SIZE_MAX - dget_len - extra_len < name_len)
|
||||
overflow_exit("receive_xattr");
|
||||
@@ -812,7 +808,7 @@ void receive_xattr(int f, struct file_struct *file)
|
||||
read_buf(f, ptr, dget_len);
|
||||
else {
|
||||
*ptr = XSTATE_ABBREV;
|
||||
read_buf(f, ptr + 1, MAX_DIGEST_LEN);
|
||||
read_buf(f, ptr + 1, xattr_sum_len);
|
||||
}
|
||||
|
||||
if (saw_xattr_filter) {
|
||||
@@ -943,7 +939,7 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
|
||||
rsync_xa *rxas = xalp->items;
|
||||
ssize_t list_len;
|
||||
size_t i, len;
|
||||
char *name, *ptr, sum[MAX_DIGEST_LEN];
|
||||
char *name, *ptr, sum[MAX_XATTR_DIGEST_LEN];
|
||||
#ifdef HAVE_LINUX_XATTRS
|
||||
int user_only = am_root <= 0;
|
||||
#endif
|
||||
@@ -958,7 +954,6 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
|
||||
name = rxas[i].name;
|
||||
|
||||
if (XATTR_ABBREV(rxas[i])) {
|
||||
int sum_len;
|
||||
/* See if the fnamecmp version is identical. */
|
||||
len = name_len = rxas[i].name_len;
|
||||
if ((ptr = get_xattr_data(fnamecmp, name, &len, 1)) == NULL) {
|
||||
@@ -975,10 +970,10 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
|
||||
goto still_abbrev;
|
||||
}
|
||||
|
||||
sum_init(-1, checksum_seed);
|
||||
sum_init(xattr_sum_nni, checksum_seed);
|
||||
sum_update(ptr, len);
|
||||
sum_len = sum_end(sum);
|
||||
if (memcmp(sum, rxas[i].datum + 1, sum_len) != 0) {
|
||||
sum_end(sum);
|
||||
if (memcmp(sum, rxas[i].datum + 1, xattr_sum_len) != 0) {
|
||||
free(ptr);
|
||||
goto still_abbrev;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user