| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
import os |
| 13 |
import subprocess |
| 14 |
import time |
| 15 |
|
| 16 |
from rsyncfns import ( |
| 17 |
SCRATCHDIR, rmtree, rsync_argv, start_test_daemon, test_fail, write_daemon_conf, |
| 18 |
) |
| 19 |
|
| 20 |
DAEMON_PORT = 12989 |
| 21 |
|
| 22 |
base = SCRATCHDIR / 'symlink-exclude-meta' |
| 23 |
rmtree(base) |
| 24 |
base.mkdir() |
| 25 |
|
| 26 |
mod = base / 'mod' |
| 27 |
mod.mkdir() |
| 28 |
pub = mod / 'pub' |
| 29 |
pub.mkdir() |
| 30 |
victim = pub / 'blocked' |
| 31 |
victim.write_text("PROTECTED\n") |
| 32 |
old = 1_000_000_000 |
| 33 |
os.utime(victim, (old, old)) |
| 34 |
os.symlink('pub/', mod / 'blink2') |
| 35 |
|
| 36 |
src = base / 'src' |
| 37 |
(src / 'blink2').mkdir(parents=True) |
| 38 |
(src / 'blink2' / 'blocked').write_text("PROTECTED\n") |
| 39 |
new = old + 999_999 |
| 40 |
os.utime(src / 'blink2' / 'blocked', (new, new)) |
| 41 |
|
| 42 |
conf = write_daemon_conf( |
| 43 |
[('mod', {'path': str(mod), 'read only': 'no', 'exclude': '/pub/blocked'})]) |
| 44 |
url = start_test_daemon(conf, DAEMON_PORT) |
| 45 |
|
| 46 |
subprocess.run( |
| 47 |
rsync_argv('-a', '--keep-dirlinks', f'{src}/', f'{url}mod/'), |
| 48 |
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
| 49 |
|
| 50 |
if int(victim.stat().st_mtime) == old: |
| 51 |
test_fail( |
| 52 |
"the daemon refused a metadata write onto an excluded leaf that stock " |
| 53 |
f"rsync (3.2.7) performs: {victim} mtime is still {old} (expected it to " |
| 54 |
f"advance to {new}). The exclude is name-based ('blink2/blocked', not the " |
| 55 |
"physical 'pub/blocked'); it must not block this.") |
| 56 |
print("daemon exclude is name-based: metadata on an excluded leaf via an in-tree " |
| 57 |
"symlink is written (3.2.7-equivalent)") |