Installer: Setup Mode und Drittanbieter-CA erfassen, Abbruch wenn Vorlage Secure Boot verlangt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-26 18:47:06 +01:00
1 parent 3f841f0801
commit eaa6bce003
2 files changed
+74 -1

No files matched your search

+50 -1
View File
@@ -227,6 +227,47 @@ get_secure_boot_state() {
esac
}
# Prüfroutine Secure Boot (26.10.2026, platform-docs roadmap/secure-boot-
# verschluesselung.md Schritt 3): ob Secure Boot auf dem Gerät einschaltbar
# wäre. Setup Mode = keine Plattformschlüssel eingetragen. Linux startet mit
# Secure Boot nur, wenn db die Microsoft-CA für Drittanbieter enthält (2011
# oder 2023; "Windows UEFI CA 2023" startet nur Windows). Ausgabe jeweils
# "true", "false" oder "null" (kein UEFI bzw. Variable nicht lesbar). Der
# Agent erfasst dasselbe bei jedem Check-in (provisioning-agent).
get_secure_boot_setup_mode() {
local file value
file="$(find "${EFI_VARS_DIR}" -maxdepth 1 -type f -name 'SetupMode-*' -print -quit 2>/dev/null || true)"
if [[ -z "${file}" || ! -r "${file}" ]]; then
printf 'null'
return 0
fi
value="$(od --address-radix=n --format=u1 --skip-bytes=4 --read-bytes=1 "${file}" 2>/dev/null | tr -d '[:space:]')"
case "${value}" in
1) printf 'true' ;;
0) printf 'false' ;;
*) printf 'null' ;;
esac
}
get_secure_boot_third_party_ca() {
local file
file="$(find "${EFI_VARS_DIR}" -maxdepth 1 -type f -name 'db-*' -print -quit 2>/dev/null || true)"
if [[ -z "${file}" || ! -r "${file}" ]]; then
# Ohne UEFI unbekannt; mit UEFI fehlt db z.B. im Setup Mode ganz.
[[ -d /sys/firmware/efi ]] && printf 'false' || printf 'null'
return 0
fi
if grep -a -q -E 'Microsoft Corporation UEFI CA 2011|Microsoft UEFI CA 2023' "${file}"; then
printf 'true'
else
printf 'false'
fi
}
get_tpm_version() {
if [[ ! -e /dev/tpm0 && ! -e /dev/tpmrm0 ]]; then
printf 'none'
@@ -375,6 +416,8 @@ build_hardware_json() {
local architecture
local boot_mode
local secure_boot
local setup_mode
local third_party_ca
local tpm_version
local interfaces_json
local device_fingerprint
@@ -401,6 +444,8 @@ build_hardware_json() {
architecture="$(get_architecture)"
boot_mode="$(get_boot_mode)"
secure_boot="$(get_secure_boot_state)"
setup_mode="$(get_secure_boot_setup_mode)"
third_party_ca="$(get_secure_boot_third_party_ca)"
tpm_version="$(get_tpm_version)"
cpu_model="$(get_cpu_model)"
cpu_count="$(get_cpu_count)"
@@ -434,6 +479,8 @@ build_hardware_json() {
--arg architecture "${architecture}" \
--arg boot_mode "${boot_mode}" \
--arg secure_boot "${secure_boot}" \
--argjson setup_mode "${setup_mode}" \
--argjson third_party_ca "${third_party_ca}" \
--arg tpm_version "${tpm_version}" \
--arg cpu_model "${cpu_model}" \
--argjson cpu_count "${cpu_count}" \
@@ -496,7 +543,9 @@ build_hardware_json() {
if $bios_version == "" then null else $bios_version end
),
boot_mode: $boot_mode,
secure_boot: $secure_boot
secure_boot: $secure_boot,
setup_mode: $setup_mode,
third_party_ca: $third_party_ca
},
security: {
+24
View File
@@ -100,12 +100,36 @@ check_power() {
fi
}
# Prüfroutine Secure Boot (26.10.2026, platform-docs roadmap/secure-boot-
# verschluesselung.md Schritt 3): Verlangt die Bereitstellungsvorlage Secure
# Boot, wird ohne eingeschaltetes Secure Boot nicht installiert. Sonst nur
# ein Logeintrag - die Installation läuft meist unbeaufsichtigt, der Hinweis
# steht im Portal beim Gerät (Hardware-Informationen).
check_secure_boot() {
local verlangt file wert=""
verlangt="$(jq -r '.template.secure_boot_required // false' "${TEMPLATE_FILE}" 2>/dev/null || echo false)"
if [[ -d /sys/firmware/efi ]]; then
file="$(find /sys/firmware/efi/efivars -maxdepth 1 -name 'SecureBoot-*' -print -quit 2>/dev/null || true)"
[[ -n "${file}" ]] && wert="$(od -An -tu1 -j4 -N1 "${file}" 2>/dev/null | tr -d '[:space:]')"
fi
log "Secure Boot: $([[ "${wert}" == 1 ]] && echo an || echo aus), von der Vorlage verlangt: ${verlangt}."
[[ "${verlangt}" == "true" && "${wert}" != "1" ]] || return 0
if [[ ! -d /sys/firmware/efi ]]; then
problems+=("Die Vorlage verlangt Secure Boot, das Gerät startet aber im alten BIOS-Modus (Legacy/CSM). Im Firmware-Setup auf UEFI umstellen und Secure Boot einschalten, falls die Firmware das anbietet.")
else
problems+=("Die Vorlage verlangt Secure Boot, es ist im Firmware-Setup aber ausgeschaltet. Secure Boot einschalten (falls nötig vorher die Werksschlüssel wiederherstellen und die „Microsoft 3rd Party UEFI CA“ erlauben).")
fi
}
main() {
[[ -r "${TEMPLATE_FILE}" ]] || { log "FEHLER: ${TEMPLATE_FILE} fehlt."; exit 1; }
check_disk
check_ram
check_power
check_secure_boot
if (( ${#problems[@]} > 0 )); then
{