| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
import subprocess |
| 9 |
|
| 10 |
from rsyncfns import ( |
| 11 |
SCRATCHDIR, rmtree, rsync_argv, start_test_daemon, test_fail, |
| 12 |
write_daemon_conf, |
| 13 |
) |
| 14 |
|
| 15 |
DAEMON_PORT = 12902 |
| 16 |
|
| 17 |
base = SCRATCHDIR / 'insecure-refused' |
| 18 |
rmtree(base) |
| 19 |
base.mkdir() |
| 20 |
mod = base / 'mod' |
| 21 |
mod.mkdir() |
| 22 |
(mod / 'f').write_text("data\n") |
| 23 |
|
| 24 |
conf = write_daemon_conf([('mod', {'path': mod, 'read only': 'yes'})]) |
| 25 |
url = start_test_daemon(conf, DAEMON_PORT) |
| 26 |
|
| 27 |
|
| 28 |
ok = subprocess.run(rsync_argv(f'{url}mod/'), |
| 29 |
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) |
| 30 |
if ok.returncode != 0: |
| 31 |
test_fail(f"control listing failed (daemon broken?): {ok.stderr}") |
| 32 |
|
| 33 |
|
| 34 |
proc = subprocess.run(rsync_argv('-M--insecure-links', f'{url}mod/'), |
| 35 |
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) |
| 36 |
out = (proc.stdout or '') + (proc.stderr or '') |
| 37 |
if proc.returncode == 0: |
| 38 |
test_fail("the daemon accepted a client-sent --insecure-links instead of " |
| 39 |
f"dropping the connection: {out!r}") |
| 40 |
if 'insecure-links' not in out and 'not allowed' not in out: |
| 41 |
test_fail("the connection ended but without the expected refusal message " |
| 42 |
f"(@ERROR: --insecure-links is not allowed from a client): {out!r}") |
| 43 |
print("daemon drops the connection on a client-sent --insecure-links") |