From b0e18855dde4ae5aa71a3773f4014733d71e26de Mon Sep 17 00:00:00 2001 From: Miha Purg Date: Wed, 21 Feb 2024 16:14:43 +0100 Subject: [PATCH] Fix grub2_bootloader_argument to check /etc/default/grub.d on Ubuntu --- ...ootloader_disable_recovery_set_to_true.xml | 4 ++++ .../grub2_bootloader_argument/oval.template | 8 ++++++++ .../tests/correct_value_configdir.pass.sh | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 shared/templates/grub2_bootloader_argument/tests/correct_value_configdir.pass.sh diff --git a/shared/checks/oval/bootloader_disable_recovery_set_to_true.xml b/shared/checks/oval/bootloader_disable_recovery_set_to_true.xml index ff64177d6df..e58cc95c228 100644 --- a/shared/checks/oval/bootloader_disable_recovery_set_to_true.xml +++ b/shared/checks/oval/bootloader_disable_recovery_set_to_true.xml @@ -24,7 +24,11 @@ + {{%- if 'ubuntu' in product %}} + ^/etc/default/grub(\.d/[^/]+\.cfg)?$ + {{%- else %}} /etc/default/grub + {{%- endif %}} ^\s*GRUB_DISABLE_RECOVERY=(.*)$ 1 diff --git a/shared/templates/grub2_bootloader_argument/oval.template b/shared/templates/grub2_bootloader_argument/oval.template index b8ef28297a8..63478873a01 100644 --- a/shared/templates/grub2_bootloader_argument/oval.template +++ b/shared/templates/grub2_bootloader_argument/oval.template @@ -88,7 +88,11 @@ + {{%- if 'ubuntu' in product %}} + ^/etc/default/grub(\.d/[^/]+\.cfg)?$ + {{%- else %}} /etc/default/grub + {{%- endif %}} ^\s*GRUB_CMDLINE_LINUX="(.*)"$ 1 @@ -102,7 +106,11 @@ + {{%- if 'ubuntu' in product %}} + ^/etc/default/grub(\.d/[^/]+\.cfg)?$ + {{%- else %}} /etc/default/grub + {{%- endif %}} ^\s*GRUB_CMDLINE_LINUX_DEFAULT="(.*)"$ 1 diff --git a/shared/templates/grub2_bootloader_argument/tests/correct_value_configdir.pass.sh b/shared/templates/grub2_bootloader_argument/tests/correct_value_configdir.pass.sh new file mode 100644 index 00000000000..734142a4e3a --- /dev/null +++ b/shared/templates/grub2_bootloader_argument/tests/correct_value_configdir.pass.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# platform = multi_platform_ubuntu +# packages = grub2 + +{{%- if ARG_VARIABLE %}} +# variables = {{{ ARG_VARIABLE }}}=correct_value +{{%- set ARG_NAME_VALUE= ARG_NAME ~ "=correct_value" %}} +{{%- endif %}} + +source common.sh + +echo > /etc/default/grub +rm -f /etc/default/grub.d/* + +echo "GRUB_CMDLINE_LINUX=\"\$GRUB_CMDLINE_LINUX {{{ ARG_NAME_VALUE }}}\"" > /etc/default/grub.d/custom.cfg + +{{{ grub_command("update") }}} +