--copy-unsafe-links unexpected behavior with unsafe symlinks

Cristian via rsync <[email protected]>
Newsgroups gmane.network.rsync.general
Message-ID <[email protected]>
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 ---------


-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.