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

2022-01-11 Thread Cristian via rsync




On Sun, Nov 28, 2021 at 12:53 PM Cristian via rsync 
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
 (search for "unsafe").


Hello Wayne

The first time when I read your answer above it when I saw "in the man page" I 
looked
in the manual page on my local computer but the explanations for the 
|--copy-unsafe-links|
option do not contain the section regarding the "cut-off point"

Now it happened to me to repoen this email and to check the link above and I
had the pleasant surprise to find the part about the "cut-off point" that 
explains
what is going on.

Thank you Wayne for your answer.

Cristian.


..wayne..



--
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


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

2022-01-04 Thread Wayne Davison via rsync
To be extra clear (since I was overly terse in my hasty answer), here's
your last example fixed for you:

$ cd ~/dev
$ rsync --copy-unsafe-links -aivz --delete ~/tmp/TST/tree/
~/tmp/XXX/tree/

This is how rsync knows where the safe restriction lies -- at the top of
the transfer (the final slash). Thus, your statement about your desired
restriction not being possible is false.

..wayne..
-- 
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


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

2022-01-03 Thread Wayne Davison via rsync
Read the section on --copy-unsafe-symlinks and make the change I
recommended.  That's all there is to it. When a dir name is in the
transfer, it is not the top of the transfer tree. It's parent is. This is
pretty standard rsync stuff, where trailing slashes are very important to
rsync.

..wayne..
-- 
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


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

2022-01-03 Thread Cristian via rsync

Hello Wayne

Thank you very much for trying to help,

I have the following three observations:


1) As recommended, I have searched the manual of rsync in order to try
   to find your interpretation about what is going on but the only relevant
   fact that I was able to find was how rsync defines unsafe links:

 Symbolic links are considered unsafe if  they  are  absolute
 symlinks (start with /), empty, or if they contain enough ".."
 components to ascend from the directory being copied.

   In my case  (I copy and paste below my original example for commodity)

   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

   when I run the commands

   $ cd TST
   $ rsync --copy-unsafe-links -avz --delete tree XXX

   In my opinion

   tree/o1-file.txt
   tree/o1-folder
   tree/o2-file.txt

   contain enough .. to ascend from the directory being copied (which
   is "tree")


2) I've also taken into account your observation that

    In this case, the "tree" directory is a part of the transfer
    inside the top-of-transfer dir (the current directory)

   which seems unusual to me (because in my case the directory being
   copied is "tree" and not the current directory (am I missing something?))
   and started the command rsync command from a another folder:

   $ cd ~/dev
   $ rsync --copy-unsafe-links -avz --delete ~/tmp/TST/tree ~/tmp/XXX

   The result is the same

    ~/tmp/TST/tree/lnk-ans.txt

   is copied as a file


   And

    ~/tmp/TST/tree/o1-file.txt
    ~/tmp/TST/tree/o1-folder
    ~/tmp/TST/tree/o2-file.txt

   are copied as broken symblinks.

3) I don't think that the intended behavior of rsync is to consider safe
   the symlinks that point to files and folders that are located just above
   the directory being copied ("tree" in this case).

   If this would be the intended behavior, then there will not be possibile
   to specify that you want and entire directory to be copied (with copies
   of the files pointed by unsafe links), because independently of what you
   specify in the command line as the source tree to be copied there will
   always be the posibility that the tree contains some symlink that points
   to a file that is outside the subtree but located under the parent that
   contains the tree and this file will not be copied.

Best regards
Cristian



On Sun, Nov 28, 2021 at 12:53 PM Cristian via rsync 
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
 (search for "unsafe").

..wayne..




--
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


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

2021-12-31 Thread Wayne Davison via rsync
On Sun, Nov 28, 2021 at 12:53 PM Cristian via rsync 
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
 (search for "unsafe").

..wayne..
-- 
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


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

2021-11-28 Thread Cristian via rsync



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