Debian Codegraph @

testsuite/operator-path-dir-daemon-mkdir_test.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 # A DIRECTORY-only module exclude (exclude = /public/pdir/) must not be
3 # bypassable by creating that dir through a peer --partial-dir symlink.
4 # (Codex-review follow-up.) The partial dir does not exist yet, so the leaf is
5 # created by handle_partial_dir(); the resolver must filter-check the absent
6 # leaf against dir-only rules, not just as a file. Runs unprivileged.
7
8 import os
9 import subprocess
10
11 from rsyncfns import (
12 SCRATCHDIR, rmtree, rsync_argv, start_test_daemon, test_fail, write_daemon_conf,
13 )
14
15 base = SCRATCHDIR / 'mkdirx'
16 rmtree(base)
17 base.mkdir()
18 mod = base / 'mod'
19 pub = mod / 'public' # served dir; only /public/pdir/ excluded
20 pub.mkdir(parents=True)
21 (pub / 'served.txt').write_text("served\n")
22 os.symlink('public', mod / 'blink')
23 src = base / 'src'
24 src.mkdir()
25 (src / 'f0').write_text("NEW\n")
26
27 conf = write_daemon_conf(
28 [('mod', {'path': str(mod), 'read only': 'no', 'exclude': '/public/pdir/'})])
29 url = start_test_daemon(conf, 12913)
30
31 # --partial-dir resolves (via blink) to the excluded dir public/pdir, which does
32 # not exist yet -> handle_partial_dir() would mkdir it.
33 subprocess.run(
34 rsync_argv('-a', '--delay-updates', '--partial-dir=/blink/pdir', f'{src}/', f'{url}mod/'),
35 stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
36
37 if not (pub / 'pdir').exists():
38 test_fail(
39 "the daemon refused to create public/pdir via a --partial-dir symlink that "
40 "stock rsync (3.2.7) creates. The daemon exclude filter is name-based "
41 "('blink' is not excluded), not a symlink boundary; it must not block this.")
42 print("daemon exclude is name-based: an operator-path symlink creates a "
43 "dir-excluded leaf in a served dir (3.2.7-equivalent)")