Pulls the 5 privileged helpers out of deploy/files/usr/local/{libexec,sbin}/
into top-level scripts/{libexec,sbin}/. They are application-inherent code
(invoked at runtime via sudo from l4d2host/l4d2web), not deploy artifacts —
the previous nesting under deploy/files/ confused source-of-truth with
install-target FHS layout.
deploy/ now means "reference exemplar": README explaining the target
layout, plus example sudoers / sysctl / sandbox-resolv.conf / env
templates / curated systemd units (the ones ckn-bw's reactor emits).
Anyone building a fresh deployment (other than ckn-bw) reads this tree.
Dead static artifacts deleted: left4me-apply-cake helper, left4me-cake
+ left4me-nft-mark service units, cake.env, left4me-mark.nft, and the
superseded deploy-test-server.sh installer.
Tests split to match the new shape:
- scripts/tests/{test_overlay,test_script_sandbox,test_systemctl_helper,
test_journalctl_helper,test_helpers_use_fixed_paths,test_sudoers_grants}.py
with shared fixtures in conftest.py
- deploy/tests/test_example_units.py (renamed from test_deploy_artifacts.py)
— slimmed to lock down the curated example units, sysctl, env templates
l4d2host/tests/test_overlay_helper.py: helper-source path updated to
scripts/libexec/left4me-overlay (was building the path segment-by-segment
under deploy/files/, missed by the path-prefix grep during pre-flight).
Runtime install-target paths (/usr/local/{libexec,sbin}/) unchanged, so
l4d2host/service_control.py, l4d2web/services/overlay_builders.py, the
sudoers grants, and the systemd units all keep their existing path
references.
Requires the matching ckn-bw change to bundles/left4me/items.py
(install_left4me_scripts repointed from /opt/left4me/src/deploy/files/...
to /opt/left4me/src/scripts/...). Left4me lands first so a fresh
git_deploy exposes the new source path before the bundle apply runs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
from conftest import LIBEXEC
|
|
|
|
|
|
OVERLAY_HELPER = LIBEXEC / "left4me-overlay"
|
|
|
|
|
|
def test_overlay_helper_is_python_with_strict_validation():
|
|
text = OVERLAY_HELPER.read_text()
|
|
assert text.startswith("#!/usr/bin/python3")
|
|
# Validation surface
|
|
assert "NAME_RE = re.compile" in text
|
|
assert "LOWERDIR_ALLOWLIST" in text
|
|
assert "user.fuseoverlayfs." in text
|
|
assert "MAX_LOWERDIRS = 500" in text
|
|
# Mounts via PID 1's mount namespace
|
|
assert "/proc/1/ns/mnt" in text
|
|
assert "nsenter" in text
|
|
# Verbs are mount and umount (not unmount)
|
|
assert '"mount"' in text and '"umount"' in text
|
|
assert '"unmount"' not in text
|
|
|
|
|
|
def test_overlay_helper_mount_is_idempotent_when_already_mounted():
|
|
"""ExecStartPre runs on every Restart=on-failure cycle. If a previous
|
|
start mounted successfully but ExecStart failed afterwards, the next
|
|
ExecStartPre would re-mount on top -- which fails. The helper must
|
|
short-circuit when merged is already a mount point.
|
|
"""
|
|
text = OVERLAY_HELPER.read_text()
|
|
# Two ismount checks now: one in cmd_mount (skip if mounted),
|
|
# one in cmd_umount (skip if not mounted).
|
|
assert text.count("os.path.ismount") >= 2
|