| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
import os |
| 13 |
import subprocess |
| 14 |
|
| 15 |
from rsyncfns import ( |
| 16 |
SCRATCHDIR, rmtree, rsync_argv, start_test_daemon, test_fail, write_daemon_conf, |
| 17 |
) |
| 18 |
|
| 19 |
DAEMON_PORT = 12987 |
| 20 |
|
| 21 |
base = SCRATCHDIR / 'symlink-exclude-leaf' |
| 22 |
rmtree(base) |
| 23 |
base.mkdir() |
| 24 |
|
| 25 |
mod = base / 'mod' |
| 26 |
mod.mkdir() |
| 27 |
pub = mod / 'pub' |
| 28 |
pub.mkdir() |
| 29 |
os.symlink('pub/', mod / 'blink2') |
| 30 |
|
| 31 |
src = base / 'src' |
| 32 |
(src / 'blink2').mkdir(parents=True) |
| 33 |
(src / 'blink2' / 'blocked').write_text("SHOULD-NOT-LAND\n") |
| 34 |
|
| 35 |
conf = write_daemon_conf( |
| 36 |
[('mod', {'path': str(mod), 'read only': 'no', 'exclude': '/pub/blocked'})]) |
| 37 |
url = start_test_daemon(conf, DAEMON_PORT) |
| 38 |
|
| 39 |
subprocess.run( |
| 40 |
rsync_argv('-a', '--keep-dirlinks', f'{src}/', f'{url}mod/'), |
| 41 |
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
| 42 |
|
| 43 |
blocked = pub / 'blocked' |
| 44 |
if not blocked.exists(): |
| 45 |
test_fail( |
| 46 |
"the daemon refused an excluded leaf that stock rsync (3.2.7) writes: " |
| 47 |
f"{blocked} was not created through the in-tree symlink. The exclude is " |
| 48 |
"name-based (it sees 'blink2/blocked', not the physical 'pub/blocked'); it " |
| 49 |
"must not block this.") |
| 50 |
print("daemon exclude is name-based: an excluded leaf reached through an in-tree " |
| 51 |
"dir symlink is written (3.2.7-equivalent)") |