crstml at libero.it
2021-Nov-28 20:20 UTC
--copy-unsafe-links unexpected behavior with unsafe symlinks
Hello all I have a problem with the --copy-unsafe-links option. My environment is presented and the end of the message. I have the following directory structure (I hope the that it will be visible; commands below) TST/ +-- outside1 |??? | |??? +-- outside1-file.txt | +-- outside2-file.txt | +-- tree ???? +-- inside.txt ???? | ???? +-- lnk-ans.txt -> ../../ans.txt ???? | ???? +-- o1-file.txt -> ../outside1/outside1-file.txt ???? | ???? +-- o1-folder -> ../outside1 ???? | ???? +-- o2-file.txt -> ../outside2-file.txt The directory structure can be created with the following commands: mkdir -p TST/outside1 TST/tree echo "outside1" > TST/outside1/outside1-file.txt echo "outside2" > TST/outside2-file.txt echo "inside"? > TST/tree/inside.txt (cd TST/tree/; ln -s ../outside1 ./o1-folder; ln -s ../outside1/outside1-file.txt ./o1-file.txt;) (cd TST/tree/; ln -s ../outside2-file.txt ./o2-file.txt;) (cd TST/tree/; ln -s ../../ans.txt ./lnk-ans.txt) Now if I execute the commands $ cd TST $ rsync --copy-unsafe-links -avz --delete tree XXX ? sending incremental file list ? copying unsafe symlink "tree/lnk-ans.txt" -> "../../ans.txt" ? created directory XXX ? tree/ ? tree/inside.txt ? tree/lnk-ans.txt ? tree/o1-file.txt -> ../outside1/outside1-file.txt ? tree/o1-folder -> ../outside1 ? tree/o2-file.txt -> ../outside2-file.txt ? sent 440 bytes? received 93 bytes? 1,066.00 bytes/sec ? total size is 147? speedup is 0.28 As we can see from the output rsync makes a copy of tree/lnk-ans.txt According to the documentation this is correct. --copy-unsafe-links instructs rsync to make copies of the files outside the copied tree. But the same should happen for ??? tree/o1-file.txt ??? tree/o1-folder ??? tree/o2-file.txt because all these symlinks point outside tree. am I missing something? Is this the intended behavior? According to the documentation (man rsync) I think it is not. Thank you very much. Cristian -------- BEGIN ENVIRONMNENT --------- $ rsync --version rsync? version 3.1.3? protocol version 31 Copyright (C) 1996-2018 by Andrew Tridgell, Wayne Davison, and others. Web site: http://rsync.samba.org/ Capabilities: ??? 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints, ??? socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace, ??? append, ACLs, xattrs, iconv, symtimes, prealloc Operating System: Debian 10 -------- END ENVIRONMNENT ---------
Wayne Davison
2021-Dec-31 20:39 UTC
--copy-unsafe-links unexpected behavior with unsafe symlinks
On Sun, Nov 28, 2021 at 12:53 PM Cristian via rsync <rsync at lists.samba.org> wrote:> $ rsync --copy-unsafe-links -avz --delete tree XXX >In this case, the "tree" directory is a part of the transfer inside the top-of-transfer dir (the current directory). Thus any symlinks that don't try to escape the current directory are considered to be OK. You should instead suffix "tree" with a slash and add "tree" to your destination path: $ rsync --copy-unsafe-links -aivz --delete tree/ host:/old/path/tree/ This is discussed in the man page <https://download.samba.org/pub/rsync/rsync.1> (search for "unsafe"). ..wayne.. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20211231/9ed7078b/attachment.htm>