| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
import os |
| 12 |
import shlex |
| 13 |
import subprocess |
| 14 |
|
| 15 |
from rsyncfns import RSYNC, TMPDIR, test_fail, split_rsync_cmd |
| 16 |
|
| 17 |
|
| 18 |
workdir = TMPDIR / 'workdir' |
| 19 |
(workdir / 'mod').mkdir(parents=True, exist_ok=True) |
| 20 |
os.chdir(workdir) |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
rsync_bin = split_rsync_cmd(RSYNC)[0] |
| 25 |
|
| 26 |
proc = subprocess.run( |
| 27 |
[rsync_bin, '--server', '--sender', '-vlr', |
| 28 |
'--filter=merge a/../test', '.', 'mod/'], |
| 29 |
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, |
| 30 |
) |
| 31 |
|
| 32 |
if proc.returncode >= 128: |
| 33 |
test_fail(f"rsync exited due to a signal (status={proc.returncode})") |
| 34 |
if proc.returncode == 0: |
| 35 |
test_fail("rsync accepted the bogus 'a/../test' merge filter (expected a " |
| 36 |
"non-zero rejection); clean_fname() may have mis-collapsed it") |
| 37 |
|
| 38 |
print("OK: clean_fname() handled 'a/../test' without crashing, and rejected it") |