#!/bin/bash # SPDX-Version: 3.0 # SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; # SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.installer.git # SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency # SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; # SPDX-FileType: SOURCE # SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0 # SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework. # SPDX-PackageName: CISS.debian.installer # SPDX-Security-Contact: security@coresecret.eu ### Options in "GRUB_CMDLINE_LINUX" are always effective. ### Options in "GRUB_CMDLINE_LINUX_DEFAULT" are effective ONLY during normal boot (NOT during recovery mode). guard_sourcing ####################################### # Hardening Grub boot parameter. # Globals: # ARY_BOOTPARAM # TARGET # VAR_GRUB_CMDLINE_LINUX_DEFAULT # Arguments: # None # Returns: # 0: on success ####################################### setup_grub_bootparameter() { declare var_nuke_string="" var_param="" grub_extract_current_string for var_param in "${ARY_BOOTPARAM[@]}"; do if [[ -z "${var_param}" ]]; then do_log "warn" "true" "Empty GRUB parameter detected and skipped." continue fi if grep -q --word-regexp "${var_param%%=*}" <<< "${VAR_GRUB_CMDLINE_LINUX_DEFAULT}"; then do_log "info" "true" "Skipping duplicate kernel parameter: '${var_param}'." continue fi VAR_GRUB_CMDLINE_LINUX_DEFAULT+=" ${var_param}" done if [[ "${VAR_NUKE}" == "true" ]]; then var_nuke_string="nuke=${VAR_NUKE_HASH}" VAR_GRUB_CMDLINE_LINUX+=" ${var_nuke_string}" fi grub_finalize_string do_in_target "${TARGET}" update-grub do_log "info" "true" "Setting GRUB kernel parameters: ${VAR_GRUB_CMDLINE_LINUX_DEFAULT}" return 0 } # vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh