-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revise other test scenarios of grub2_argument template
- Loading branch information
1 parent
19c63ae
commit f6e1fa3
Showing
8 changed files
with
75 additions
and
18 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
shared/templates/grub2_bootloader_argument/tests/arg_not_in_entries.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# platform = multi_platform_fedora,multi_platform_rhel | ||
# packages = grub2,grubby | ||
|
||
source common.sh | ||
|
||
# Removes argument from kernel command line in /boot/loader/entries/*.conf | ||
|
||
for file in /boot/loader/entries/*.conf ; do | ||
if grep -q '^.*{{{ ESCAPED_ARG_NAME }}}=.*' "$file" ; then | ||
sed -i 's/\(^.*\){{{ARG_NAME}}}=[^[:space:]]*\(.*\)/\1 \2/' "$file" | ||
fi | ||
done |
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
...lates/grub2_bootloader_argument/tests/arg_not_in_etcdefaultgrub_recovery_disabled.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# platform = Oracle Linux 7 | ||
# Removes the argument from kernel command line in /etc/default/grub | ||
if grep -q '^GRUB_CMDLINE_LINUX_DEFAULT=.*{{{ARG_NAME}}}=.*"' '/etc/default/grub' ; then | ||
sed -i 's/\(^GRUB_CMDLINE_LINUX_DEFAULT=".*\){{{ARG_NAME}}}=[^[:space:]]*\(.*"\)/\1 \2/' '/etc/default/grub' | ||
fi | ||
|
||
# removing the parameter from the no recovery kernel parameters as well | ||
sed -i 's/\(^GRUB_CMDLINE_LINUX=".*\){{{ARG_NAME}}}=[^[:space:]]*\(.*"\)/\1 \2/' '/etc/default/grub' | ||
|
||
# disabling recovery | ||
sed -i 's/\(^.*GRUB_DISABLE_RECOVERY=\).*/\1true/' '/etc/default/grub' | ||
|
||
#if the line is not present at all, add it | ||
if ! grep -q '^GRUB_CMDLINE_LINUX_DEFAULT=.*$' '/etc/default/grub'; then | ||
echo 'GRUB_CMDLINE_LINUX_DEFAULT=""' >> /etc/default/grub | ||
fi |
28 changes: 28 additions & 0 deletions
28
...d/templates/grub2_bootloader_argument/tests/arg_not_in_grubenv_and_not_referenced.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# platform = Oracle Linux 8,Red Hat Enterprise Linux 8 | ||
# packages = grub2,grubby | ||
|
||
{{%- if ARG_VARIABLE %}} | ||
# variables = {{{ ARG_VARIABLE }}}=correct_value | ||
{{%- set ARG_NAME_VALUE= ARG_NAME ~ "=correct_value" %}} | ||
{{%- endif %}} | ||
|
||
|
||
source common.sh | ||
|
||
# Removes audit argument from kernel command line in /boot/grub2/grubenv | ||
file="/boot/grub2/grubenv" | ||
if grep -q '^.*{{{ARG_NAME}}}=.*' "$file" ; then | ||
sed -i 's/\(^.*\){{{ARG_NAME}}}=[^[:space:]]*\(.*\)/\1 \2/' "$file" | ||
fi | ||
|
||
# ensure that the grubenv entry is not referenced | ||
for entry in /boot/loader/entries/*.conf; do | ||
if ! grep -q '\$kernelopts' "$entry"; then | ||
sed -i 's/^(options.*)$/\1 \$kernelopts/' "$entry" | ||
fi | ||
done | ||
|
||
# remediate with grubby, this ill ensure expanded options are in /boot/loader/entries/*.conf | ||
{{{ grub2_bootloader_argument_remediation(ARG_NAME, ARG_NAME_VALUE) }}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
shared/templates/grub2_bootloader_argument/tests/correct_value.pass.sh
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
shared/templates/grub2_bootloader_argument/tests/wrong_value_entries.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters