| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
import os |
| 17 |
|
| 18 |
from rsyncfns import ( |
| 19 |
SCRATCHDIR, get_rootgid, get_rootuid, get_testuid, makepath, rmtree, |
| 20 |
run_rsync, start_test_daemon, test_fail, |
| 21 |
) |
| 22 |
|
| 23 |
DAEMON_PORT = 12948 |
| 24 |
CONTENT = "in-module sibling\n" |
| 25 |
|
| 26 |
base = SCRATCHDIR / 'daemon-subdir-climb' |
| 27 |
rmtree(base) |
| 28 |
mod = base / 'mod' |
| 29 |
dest = base / 'dest' |
| 30 |
makepath(mod / 'sub', mod / 'sibling', dest) |
| 31 |
(mod / 'sibling' / 's.txt').write_text(CONTENT) |
| 32 |
|
| 33 |
|
| 34 |
os.symlink('../sibling', mod / 'sub' / 'climb') |
| 35 |
|
| 36 |
root = get_testuid() == get_rootuid() |
| 37 |
ids = f"uid = {get_rootuid()}\ngid = {get_rootgid()}" if root else "" |
| 38 |
|
| 39 |
conf = base / 'd.conf' |
| 40 |
conf.write_text(f"""\ |
| 41 |
pid file = {base}/rsyncd.pid |
| 42 |
use chroot = no |
| 43 |
{ids} |
| 44 |
log file = {base}/rsyncd.log |
| 45 |
|
| 46 |
[m] |
| 47 |
path = {mod} |
| 48 |
read only = yes |
| 49 |
hosts allow = 127.0.0.1 |
| 50 |
""") |
| 51 |
url = start_test_daemon(conf, DAEMON_PORT) |
| 52 |
|
| 53 |
|
| 54 |
run_rsync('-a', '--copy-dirlinks', f'{url}m/sub/', f'{dest}/', check=False) |
| 55 |
|
| 56 |
got = dest / 'climb' / 's.txt' |
| 57 |
if not got.is_file() or got.read_text() != CONTENT: |
| 58 |
test_fail( |
| 59 |
"daemon subdir pull with --copy-dirlinks failed to follow an in-module " |
| 60 |
"symlink that climbs '..' to a sibling inside the module " |
| 61 |
"(dest/climb/s.txt missing/wrong): the enumeration must anchor at " |
| 62 |
"module_dir, not the scan cwd.") |
| 63 |
print("daemon-subdir-climb-symlink: in-module ..-climbing symlink followed under --copy-dirlinks") |