| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
import subprocess |
| 24 |
|
| 25 |
from rsyncfns import ( |
| 26 |
SCRATCHDIR, makepath, rmtree, rsync_argv, start_test_daemon, test_fail, |
| 27 |
write_daemon_conf, |
| 28 |
) |
| 29 |
|
| 30 |
DAEMON_PORT = 12897 |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
served = SCRATCHDIR / 'served' |
| 35 |
dst = SCRATCHDIR / 'pulldst' |
| 36 |
rmtree(served) |
| 37 |
rmtree(dst) |
| 38 |
makepath(served / 'sub') |
| 39 |
makepath(dst) |
| 40 |
(served / 'README').write_text("readme-contents\n") |
| 41 |
(served / 'sub' / 'deep.txt').write_text("deep-contents\n") |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
conf = write_daemon_conf([ |
| 47 |
('root', {'path': '/', 'read only': 'yes'}), |
| 48 |
]) |
| 49 |
url = start_test_daemon(conf, DAEMON_PORT) |
| 50 |
|
| 51 |
served_rel = str(served).lstrip('/') |
| 52 |
proc = subprocess.run( |
| 53 |
rsync_argv('-a', f'{url}root/{served_rel}/', f'{dst}/'), |
| 54 |
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, |
| 55 |
) |
| 56 |
out = proc.stdout or '' |
| 57 |
print(out) |
| 58 |
|
| 59 |
|
| 60 |
if 'Invalid argument (22)' in out or ('failed to open' in out and proc.returncode != 0): |
| 61 |
from rsyncfns import test_xfail |
| 62 |
test_xfail( |
| 63 |
"#897: daemon module `path = /` (use chroot = no) cannot send files -- " |
| 64 |
"`send_files failed to open ...: Invalid argument (22)`. The sender's " |
| 65 |
"secure_relative_open(module_dir, secure_path) gets an ABSOLUTE " |
| 66 |
"secure_path (F_PATHNAME is absolute when path=/) and the front door " |
| 67 |
"rejects absolute relpaths with EINVAL before any openat2. To be closed " |
| 68 |
"by letting the sender open succeed for an absolute module-root path.") |
| 69 |
|
| 70 |
|
| 71 |
if proc.returncode != 0: |
| 72 |
test_fail(f"daemon pull failed unexpectedly (rc={proc.returncode}); " |
| 73 |
f"not the #897 EINVAL symptom:\n{out}") |
| 74 |
for rel in ('README', 'sub/deep.txt'): |
| 75 |
got = dst / rel |
| 76 |
if not got.is_file(): |
| 77 |
test_fail(f"daemon pull did not deliver {rel} (dst={dst})") |
| 78 |
if got.read_text() != (served / rel).read_text(): |
| 79 |
test_fail(f"delivered {rel} content differs from source") |