fix(guanghu-os): trust versioned subcontrol backend link
This commit is contained in:
parent
da610ed7e5
commit
d2b15299a5
2 changed files with 9 additions and 3 deletions
|
|
@ -60,7 +60,12 @@ else
|
||||||
[[ "${current_root}" =~ ^/guanghu/versions/[A-Za-z0-9._-]+$ ]] || die "current root is invalid"
|
[[ "${current_root}" =~ ^/guanghu/versions/[A-Za-z0-9._-]+$ ]] || die "current root is invalid"
|
||||||
fi
|
fi
|
||||||
[[ "${code_unit}" == "hlcc-jd-candidate.service" ]] || die "code unit binding mismatch"
|
[[ "${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"
|
[[ -x "${systemctl_bin}" ]] || die "systemctl is unavailable"
|
||||||
|
|
||||||
verify_machine() {
|
verify_machine() {
|
||||||
|
|
|
||||||
|
|
@ -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' 'f3d4b730-7f02-452f-975b-7091a4800431' >"${fixture}/dmi"
|
||||||
printf '%s\n' "menuentry 'Ubuntu' --id 'rescue-slot' {" >"${fixture}/grub.cfg"
|
printf '%s\n' "menuentry 'Ubuntu' --id 'rescue-slot' {" >"${fixture}/grub.cfg"
|
||||||
|
|
||||||
cat >"${fixture}/backend" <<'EOF'
|
cat >"${fixture}/backend-real" <<'EOF'
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
[[ "${1:-}" == preflight || "${1:-}" == observe ]] || exit 1
|
[[ "${1:-}" == preflight || "${1:-}" == observe ]] || exit 1
|
||||||
if [[ "${1:-}" == observe ]]; then echo dormant; fi
|
if [[ "${1:-}" == observe ]]; then echo dormant; fi
|
||||||
EOF
|
EOF
|
||||||
chmod +x "${fixture}/backend"
|
chmod +x "${fixture}/backend-real"
|
||||||
|
ln -s "${fixture}/backend-real" "${fixture}/backend"
|
||||||
|
|
||||||
cat >"${fixture}/systemctl" <<'EOF'
|
cat >"${fixture}/systemctl" <<'EOF'
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue