| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
import subprocess |
| 10 |
|
| 11 |
from rsyncfns import ( |
| 12 |
SCRATCHDIR, rmtree, rsync_argv, start_test_daemon, test_fail, write_daemon_conf, |
| 13 |
) |
| 14 |
|
| 15 |
base = SCRATCHDIR / 'inmodule' |
| 16 |
rmtree(base) |
| 17 |
base.mkdir() |
| 18 |
mod = base / 'mod' |
| 19 |
mod.mkdir() |
| 20 |
(mod / 'pdir').mkdir() |
| 21 |
(mod / 'f0').write_text("OLD\n") |
| 22 |
src = base / 'src' |
| 23 |
src.mkdir() |
| 24 |
(src / 'f0').write_text("NEW-LONGER-CONTENT-SO-IT-TRANSFERS\n") |
| 25 |
|
| 26 |
conf = write_daemon_conf([('mod', {'path': str(mod), 'read only': 'no'})]) |
| 27 |
url = start_test_daemon(conf, 12908) |
| 28 |
|
| 29 |
|
| 30 |
proc = subprocess.run( |
| 31 |
rsync_argv('-a', f'--partial-dir={mod}/pdir', f'{src}/', f'{url}mod/'), |
| 32 |
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) |
| 33 |
got = (mod / 'f0').read_text() if (mod / 'f0').exists() else None |
| 34 |
if got != "NEW-LONGER-CONTENT-SO-IT-TRANSFERS\n": |
| 35 |
test_fail( |
| 36 |
"a legitimate absolute in-module --partial-dir was over-blocked: " |
| 37 |
f"dest f0 is {got!r} (rc={proc.returncode}, err={proc.stderr.strip()[:200]}). " |
| 38 |
"The module-confine/exclude refusal must allow the module root's ancestors.") |
| 39 |
print("legitimate absolute in-module --partial-dir is accepted") |