RsyncProject / rsync

An open source utility that provides fast incremental file transfer. It also has useful features for backup and restore operations among many other use cases.
https://rsync.samba.org
Other
2.79k stars 332 forks source link

Local --M--fake-super fails and creates local directory copy #505

Open za3k opened 1 year ago

za3k commented 1 year ago

(Also posted to mailing list as https://lists.samba.org/archive/rsync/2023-July/033045.html)

I am on rsync version 3.2.7 protocol version 31, currently on an Arch Linux.

The following I would expect to copy the contents of 'a' to 'c', based on my understanding of the the advice in man rsync for using --fake-super locally:

mkdir a b c
touch a/hello
rsync -M--fake-super -a a/ b/
rsync --super -M--fake-super -a b/ c/

Instead I see 'c' unchanged, and a garbage directory created with the expected contents in the local directory:

~/tmp $ ls
''$'\001'   a   b   c
~/tmp $ ls -la *
''$'\001':
total 8
drwxr-xr-x 2 zachary users 4096 Jul 15 02:10 .
drwxr-xr-x 6 zachary users 4096 Jul 15 02:10 ..
-rw-r--r-- 1 zachary users    0 Jul 15 02:10 hello

a:
total 8
drwxr-xr-x 2 zachary users 4096 Jul 15 02:10 .
drwxr-xr-x 6 zachary users 4096 Jul 15 02:10 ..
-rw-r--r-- 1 zachary users    0 Jul 15 02:10 hello

b:
total 8
drwxr-xr-x 2 zachary users 4096 Jul 15 02:10 .
drwxr-xr-x 6 zachary users 4096 Jul 15 02:10 ..

c:
total 8
drwxr-xr-x 2 zachary users 4096 Jul 15 02:10 .
drwxr-xr-x 6 zachary users 4096 Jul 15 02:10 ..

Note, this always writes the garbage directory into the current directory, even if it is on a different filesystem than the source, destination, and (/tmp or -T).

A workaround is to use rsync to/from localhost: instead.

SIGSEGV111 commented 6 months ago

You can use this script as --rsh=/path/to/script to work around this bug without the need to setup SSH and authentication.

#!/bin/bash -eu
shift 3
exec "$@"