| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
import subprocess |
| 17 |
|
| 18 |
from rsyncfns import ( |
| 19 |
SCRATCHDIR, rmtree, rsync_argv, start_test_daemon, test_fail, write_daemon_conf, |
| 20 |
) |
| 21 |
|
| 22 |
DAEMON_PORT = 13010 |
| 23 |
|
| 24 |
|
| 25 |
CASES = [ |
| 26 |
('bare', '/excluded', True), |
| 27 |
('dir', '/excluded/', False), |
| 28 |
('triple', '/excluded/***', False), |
| 29 |
] |
| 30 |
|
| 31 |
base = SCRATCHDIR / 'daemon-exclude-namebased' |
| 32 |
rmtree(base) |
| 33 |
base.mkdir() |
| 34 |
src = base / 'hosts' |
| 35 |
src.write_text("127.0.0.1 localhost\n") |
| 36 |
|
| 37 |
modules = [] |
| 38 |
for name, pattern, _ in CASES: |
| 39 |
mod = base / name |
| 40 |
(mod / 'excluded').mkdir(parents=True) |
| 41 |
modules.append((name, {'path': str(mod), 'read only': 'no', 'exclude': pattern})) |
| 42 |
|
| 43 |
url = start_test_daemon(write_daemon_conf(modules), DAEMON_PORT) |
| 44 |
|
| 45 |
for name, pattern, expect_landed in CASES: |
| 46 |
subprocess.run( |
| 47 |
rsync_argv('-a', str(src), f'{url}{name}/excluded/x2.tx'), |
| 48 |
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
| 49 |
landed = (base / name / 'excluded' / 'x2.tx').exists() |
| 50 |
if landed != expect_landed: |
| 51 |
verb = "did not land" if expect_landed else "landed" |
| 52 |
test_fail( |
| 53 |
f"exclude={pattern!r}: a file push to excluded/x2.tx {verb} " |
| 54 |
f"(landed={landed}, expected {expect_landed}). A bare anchored name " |
| 55 |
"protects only an entry of that exact name; a subtree needs a " |
| 56 |
"trailing-slash or /*** pattern (rsyncd.conf(5)).") |
| 57 |
|
| 58 |
print("daemon exclude is name-based: a bare-name pattern does not protect the " |
| 59 |
"subtree; a /dir/ or /dir/*** pattern does (3.2.7-equivalent)") |