Debian Codegraph @

testsuite/relative-symlinked-parent_test.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 # rsync -aR of a source file whose path goes through an IN-TREE symlinked parent
3 # directory must transfer the file -- the symlink is part of the operator's own
4 # source tree, which 3.4.x follows.
5 #
6 # A/B-discovered 3.5 regression (abdiff: 3.5 vs 3.4.4): an early per-component
7 # O_NOFOLLOW resolver refused to traverse the in-tree symlinked parent that -R
8 # keeps in the path, so the content open failed (exit 23, the file lost; a
9 # near-silent partial copy). The secure resolver now follows in-tree directory
10 # symlinks on every platform -- it readlinks the symlink and walks its target off
11 # held dirfds -- so this transfers uniformly. 3.4.x is unaffected everywhere.
12 #
13 # Related to the fixed `rsync -aR /abs` bug (sender content-open confinement),
14 # but a distinct trigger: an in-tree symlinked *parent component* under -R.
15 # Plain transfer, no root.
16
17 import os
18
19 from rsyncfns import SCRATCHDIR, assert_same, makepath, rmtree, run_rsync, test_fail
20
21 base = SCRATCHDIR / 'rsymparent'
22 rmtree(base)
23 makepath(base / 'src' / 'real' / 'sub', base / 'dest')
24 (base / 'src' / 'real' / 'sub' / 'file').write_text('payload data\n')
25 os.symlink('real', base / 'src' / 'link') # in-tree dir-symlink: link -> real
26
27 os.chdir(base) # -R mirrors the path as given
28 run_rsync('-aR', 'src/link/sub/file', 'dest/') # check=True: resolver follows the in-tree symlink
29
30 landed = base / 'dest' / 'src' / 'link' / 'sub' / 'file'
31 if not landed.is_file():
32 test_fail(f"-aR through an in-tree symlinked parent dropped the file: {landed} missing")
33 assert_same(base / 'src' / 'real' / 'sub' / 'file', landed, label='content')
34
35 print("relative-symlinked-parent: -aR transfers a file under an in-tree symlinked parent dir")