fix(guanghu-os): trust versioned subcontrol backend link

This commit is contained in:
冰朔 2026-08-15 22:34:27 +08:00
commit d2b15299a5
2 changed files with 9 additions and 3 deletions

View file

@ -60,7 +60,12 @@ else
[[ "${current_root}" =~ ^/guanghu/versions/[A-Za-z0-9._-]+$ ]] || die "current root is invalid"
fi
[[ "${code_unit}" == "hlcc-jd-candidate.service" ]] || die "code unit binding mismatch"
[[ -x "${backend_command}" && ! -L "${backend_command}" ]] || die "subcontrol backend is unavailable"
[[ -x "${backend_command}" ]] || die "subcontrol backend is unavailable"
if [[ "${test_mode}" != 1 ]]; then
resolved_backend=$(readlink -f "${backend_command}")
[[ "${resolved_backend}" =~ ^/guanghu/versions/[A-Za-z0-9._-]+/bin/guanghu-linux-subcontrol-backend$ ]] ||
die "subcontrol backend target is outside the versioned Guanghu root"
fi
[[ -x "${systemctl_bin}" ]] || die "systemctl is unavailable"
verify_machine() {

View file

@ -11,12 +11,13 @@ ln -sfn "${fixture}/versions/test-supervisor-world" "${fixture}/current"
printf '%s\n' 'f3d4b730-7f02-452f-975b-7091a4800431' >"${fixture}/dmi"
printf '%s\n' "menuentry 'Ubuntu' --id 'rescue-slot' {" >"${fixture}/grub.cfg"
cat >"${fixture}/backend" <<'EOF'
cat >"${fixture}/backend-real" <<'EOF'
#!/usr/bin/env bash
[[ "${1:-}" == preflight || "${1:-}" == observe ]] || exit 1
if [[ "${1:-}" == observe ]]; then echo dormant; fi
EOF
chmod +x "${fixture}/backend"
chmod +x "${fixture}/backend-real"
ln -s "${fixture}/backend-real" "${fixture}/backend"
cat >"${fixture}/systemctl" <<'EOF'
#!/usr/bin/env bash