Mask runtime-only systemctl hooks during extension composition

This commit is contained in:
Archipelago 2026-11-18 11:20:54 +00:00
parent 593629f031
commit 194f97e508
2 changed files with 27 additions and 0 deletions

View file

@ -165,6 +165,15 @@ the image's `/etc/pacman.conf` is never changed. Without this, an unsigned local
archive was rejected as "package missing required signature" even though its exact
bytes and `.PKGINFO` identity had already been checked.
A second composition-only failure appeared once the signature policy was fixed:
`36-systemd-modules-load.hook` calls `/usr/bin/systemctl --system restart` directly,
and the isolated root has no target systemd bus. The adapter now masks every base
hook whose `Exec` calls `systemctl` directly (currently modules-load and the sshd
restart marker); hooks routed through `systemd-hook` already detect a chroot and
skip. The target boot still loads modules and starts services from the installed
configuration. An unrelated existing hook is never overwritten: a real file is a
composition error.
Retry operation `6245b28b175df563140d6087779d3dff` succeeded and staged
`a8b738f3fcb904ad763a2420631db7f4f007b502c649e460c4518e3dcb8b5c66`.
Verified `broadcom-wl-dkms 6.30.223.271-50`, `dkms 3.4.4-1`, matching

View file

@ -131,6 +131,24 @@ if $dkms_enabled; then
fi
(cd "$generation/inputs"; find . -maxdepth 1 -type f ! -name SHA256SUMS -print0 | sort -z | xargs -0 sha256sum) > "$generation/inputs/SHA256SUMS"
# Runtime-only base hooks call the target systemd bus, which does not exist in
# the isolated composition. Mask direct systemctl actions (module loading, sshd
# restart markers); the target boot applies runtime state. Hooks routed through
# systemd-hook already detect a chroot and skip themselves. Do not overwrite an
# unrelated existing hook: that would hide an image or admin override.
mkdir -p "$root/etc/pacman.d/hooks"
for hook in "$root"/usr/share/libalpm/hooks/*.hook; do
[[ -f $hook ]] || continue
grep -Eq '^[[:space:]]*Exec[[:space:]]*=.*systemctl' "$hook" || continue
name=$(basename "$hook")
existing="$root/etc/pacman.d/hooks/$name"
if [[ -e $existing && ! -L $existing ]]; then
echo "Runtime hook conflict: $name" >&2
exit 1
fi
ln -sfn /dev/null "$existing"
done
service_args=()
if [[ $service_packages == 1 ]]; then
service_args+=(--setenv=ARCHIPELAGO_SERVICE_PACKAGE=1