fix(installer): allow root execution in archiso by shimming sudo

When running as root (archiso chroot context), all three TUI installers
previously died immediately. Replace the hard die with a sudo passthrough
shim ($TMP_D/bin/sudo → exec "$@") prepended to PATH, so every module's
`sudo pacman`, `sudo systemctl` etc. just executes directly as root.
The shim lives in TMP_D and is cleaned up by the existing EXIT trap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main
Amir Alexander Abdelbaki 2026-05-22 05:04:55 +02:00
parent f358cb6d2c
commit 3e78c7cb2a
3 changed files with 21 additions and 3 deletions

View File

@ -149,7 +149,13 @@ count_steps() {
[[ "$sel" == *"kate"* ]] && TOTAL=$(( TOTAL + 1 ))
}
[[ $EUID -eq 0 ]] && die "Run as your normal user (not root)."
if [[ $EUID -eq 0 ]]; then
# Root context (e.g. archiso chroot): shim sudo as a passthrough
mkdir -p "$TMP_D/bin"
printf '#!/bin/bash\nexec "$@"\n' > "$TMP_D/bin/sudo"
chmod +x "$TMP_D/bin/sudo"
export PATH="$TMP_D/bin:$PATH"
fi
command -v pacman &>/dev/null || die "pacman not found — Arch Linux required."
require_dialog

View File

@ -395,7 +395,13 @@ get_mac_suffix() {
}
# ── Preflight ─────────────────────────────────────────────────────────────────
[[ $EUID -eq 0 ]] && die "Run as your normal user (not root)."
if [[ $EUID -eq 0 ]]; then
# Root context (e.g. archiso chroot): shim sudo as a passthrough
mkdir -p "$TMP_D/bin"
printf '#!/bin/bash\nexec "$@"\n' > "$TMP_D/bin/sudo"
chmod +x "$TMP_D/bin/sudo"
export PATH="$TMP_D/bin:$PATH"
fi
command -v pacman &>/dev/null || die "pacman not found — Arch Linux required."
if $ANSWERFILE_MODE; then

View File

@ -220,7 +220,13 @@ get_mac_suffix() {
}
# ── Preflight ─────────────────────────────────────────────────────────────────
[[ $EUID -eq 0 ]] && die "Run as your normal user (not root)."
if [[ $EUID -eq 0 ]]; then
# Root context (e.g. archiso chroot): shim sudo as a passthrough
mkdir -p "$TMP_D/bin"
printf '#!/bin/bash\nexec "$@"\n' > "$TMP_D/bin/sudo"
chmod +x "$TMP_D/bin/sudo"
export PATH="$TMP_D/bin:$PATH"
fi
command -v pacman &>/dev/null || die "pacman not found — Arch Linux required."
require_dialog