| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
import os |
| 8 |
import subprocess |
| 9 |
from rsyncfns import ( |
| 10 |
FROMDIR, RSYNC_PEER, SRCDIR, SCRATCHDIR, makepath, rmtree, rsync_argv, test_fail, rsync_path_arg, rsh_cmd, |
| 11 |
) |
| 12 |
|
| 13 |
LSH = rsh_cmd() |
| 14 |
os.environ['RSYNC_RSH'] = LSH |
| 15 |
|
| 16 |
src = FROMDIR |
| 17 |
rmtree(src) |
| 18 |
makepath(src) |
| 19 |
(src / 'f').write_text('payload\n') |
| 20 |
|
| 21 |
|
| 22 |
def run(label, extra, local=False): |
| 23 |
dest = SCRATCHDIR / ('dest-' + label) |
| 24 |
rmtree(dest) |
| 25 |
makepath(dest) |
| 26 |
if local: |
| 27 |
argv = rsync_argv('-a', *extra, f'{src}/', f'{dest}/') |
| 28 |
else: |
| 29 |
argv = rsync_argv('-a', *extra, '-e', LSH, |
| 30 |
f'--rsync-path={rsync_path_arg()}', f'{src}/', f'localhost:{dest}/') |
| 31 |
r = subprocess.run(argv, capture_output=True, text=True) |
| 32 |
if r.returncode < 0 or r.returncode >= 128: |
| 33 |
test_fail(f'{label}: rsync crashed (rc={r.returncode}): {r.stderr.strip()[:200]}') |
| 34 |
if not (dest / 'f').exists() or (dest / 'f').read_text() != 'payload\n': |
| 35 |
test_fail(f'{label}: transfer did not complete (rc={r.returncode}): {r.stderr.strip()[:200]}') |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
run('verbose-flood', ['-v'] * 60) |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
run('info-overflow', ['--info=BACKUP99999999999999999999']) |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
run('skip-compress-long', ['-z', '--skip-compress=' + 'a' * 5000], local=True) |
| 49 |
|
| 50 |
print("scanner-argv-bounds: -v flood, --info overflow, --skip-compress long token all clean") |