| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
import subprocess |
| 13 |
|
| 14 |
from rsyncfns import ( |
| 15 |
SCRATCHDIR, rmtree, rsync_argv, start_test_daemon, test_fail, |
| 16 |
write_daemon_conf, |
| 17 |
) |
| 18 |
|
| 19 |
DAEMON_PORT = 12906 |
| 20 |
|
| 21 |
base = SCRATCHDIR / 'daemon-path-var' |
| 22 |
rmtree(base) |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
root = base / 'root' |
| 28 |
served = root / 'served' |
| 29 |
served.mkdir(parents=True) |
| 30 |
(served / 'hello.txt').write_text('EXPANDED\n') |
| 31 |
|
| 32 |
conf = write_daemon_conf([ |
| 33 |
('served', {'path': f'{root}/%RSYNC_MODULE_NAME%', |
| 34 |
'use chroot': 'no', 'read only': 'yes'}), |
| 35 |
]) |
| 36 |
url = start_test_daemon(conf, DAEMON_PORT).rstrip('/') |
| 37 |
|
| 38 |
dest = base / 'dest' |
| 39 |
dest.mkdir(parents=True) |
| 40 |
proc = subprocess.run( |
| 41 |
rsync_argv('-a', f'{url}/served/hello.txt', str(dest) + '/'), |
| 42 |
capture_output=True, text=True) |
| 43 |
|
| 44 |
got = dest / 'hello.txt' |
| 45 |
if proc.returncode != 0 or not got.is_file(): |
| 46 |
test_fail("%RSYNC_MODULE_NAME% in `path` did not expand to the raw value " |
| 47 |
"(the daemon could not chdir -- the path was shell-quoted); " |
| 48 |
f"rc={proc.returncode}\nstderr: {proc.stderr.strip()}") |
| 49 |
if got.read_text() != 'EXPANDED\n': |
| 50 |
test_fail(f"unexpected content from the expanded-path module: {got.read_text()!r}") |
| 51 |
|
| 52 |
print("daemon-path-rsync-var: %RSYNC_*% in a string param expands unquoted") |