grubby-bls: expand only the kernelopts variable

The BLS snippets have the options field set to a kernelopts variable by
default, which is set in GRUB's environemnt block to the kernel cmdline.

When the kernel command line parameters are modified for all the entries,
the value of this kernelopts variable is modified. But if the cmdline is
modified for a single entry, then the kernelopts variable is expanded and
the resulted modified value stored in the BLS snippet.

The grubby tool expanded all the variables in the options field, but it's
possible that some of these variables are managed by another tool. For
example the tuned program adds a tuned variable that shouldn't be changed
by the grubby tool. Otherwise it will mangle the tuned configuration set.

To prevent this, let's make grubby to only expand the kernelopts variable.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2021-06-09 23:38:54 +02:00
parent 5d3963841d
commit 2b59d1355d
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
2 changed files with 5 additions and 2 deletions

View File

@ -235,7 +235,7 @@ get_bls_args() {
local opts=(${args}) local opts=(${args})
for opt in ${opts[*]}; do for opt in ${opts[*]}; do
if [[ $opt =~ ^\$ ]]; then if [[ $opt = "\$kernelopts" ]]; then
value="$(expand_var $opt)" value="$(expand_var $opt)"
args="$(echo ${args} | sed -e "s/${opt}/${value}/")" args="$(echo ${args} | sed -e "s/${opt}/${value}/")"
fi fi

View File

@ -1,6 +1,6 @@
Name: grubby Name: grubby
Version: 8.40 Version: 8.40
Release: 52%{?dist} Release: 53%{?dist}
Summary: Command line tool for updating bootloader configs Summary: Command line tool for updating bootloader configs
License: GPLv2+ License: GPLv2+
URL: https://github.com/rhinstaller/grubby URL: https://github.com/rhinstaller/grubby
@ -131,6 +131,9 @@ current boot environment.
%{_mandir}/man8/*.8* %{_mandir}/man8/*.8*
%changelog %changelog
* Wed Jun 09 2021 Javier Martinez Canillas <javierm@redhat.com> - 8.40-53
- grubby-bls: expand only the kernelopts variable
* Mon Apr 26 2021 Javier Martinez Canillas <javierm@redhat.com> - 8.40-52 * Mon Apr 26 2021 Javier Martinez Canillas <javierm@redhat.com> - 8.40-52
- grubby-bs: Fix changing kernel cmdline params not working on ppc64le - grubby-bs: Fix changing kernel cmdline params not working on ppc64le