Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix grub2_argument bash remediation #4891

Merged
merged 2 commits into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# profiles = xccdf_org.ssgproject.content_profile_ospp
# platform = Red Hat Enterprise Linux 8

# Removes pti argument from kernel command line in /boot/grub2/grubenv
file="/boot/grub2/grubenv"
if grep -q '^.*pti=.*' "$file" ; then
sed -i 's/\(^.*\)pti=[^[:space:]]*\(.*\)/\1 \2/' "$file"
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# profiles = xccdf_org.ssgproject.content_profile_ospp
# platform = Red Hat Enterprise Linux 8

grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) pti=on"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# profiles = xccdf_org.ssgproject.content_profile_ospp
# platform = Red Hat Enterprise Linux 8

# Break the pti argument in kernel command line in /boot/grub2/grubenv
file="/boot/grub2/grubenv"
if grep -q '^.*pti=.*' "$file" ; then
# modify the GRUB command-line if an pti= arg already exists
sed -i 's/\(^.*\)pti=[^[:space:]]*\(.*\)/\1 pti=off \2/' "$file"
else
# no pti=arg is present, append it
sed -i 's/\(^.*\(vmlinuz\|kernelopts\).*\)/\1 pti=off/' "$file"
fi
2 changes: 1 addition & 1 deletion shared/templates/template_BASH_grub2_bootloader_argument
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ fi
grubby --update-kernel=ALL --args="{{{ ARG_NAME_VALUE }}}"
{{% else %}}
#in later versions of rhel grub2-editenv is used
grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) audit=1"
grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) {{{ ARG_NAME_VALUE }}}"
{{% endif %}}