grubby-bls: fix logic to check if the kernelopts var is defined in a BLS

The logic to check if a kernelopts variable is defined in a BLS entry was
wrong and caused grubby to expand the variables even when it was defined.

Resolves: rhbz#1726514

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2019-11-27 17:08:03 +01:00
parent 5dafc374ee
commit 08153fc1d6
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
1 changed files with 4 additions and 4 deletions

View File

@ -224,10 +224,10 @@ has_kernelopts()
local opts=(${args})
for opt in ${opts[*]}; do
[[ $opt = "\$kernelopts" ]] && return 0
[[ $opt = "\$kernelopts" ]] && echo "true"
done
return 1
echo "false"
}
get_bls_args() {
@ -504,11 +504,11 @@ update_bls_fragment() {
local old_args="$(get_bls_args "$i")"
local new_args="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
if [[ $param != "ALL" || ! "$(has_kernelopts "$i")" ]]; then
if [[ $param != "ALL" || "$(has_kernelopts "$i")" = "false" ]]; then
set_bls_value "${bls_file[$i]}" "options" "${new_args}"
fi
if [[ $bootloader = grub2 && ! "$(has_kernelopts "$i")" && $opts = $new_args ]]; then
if [[ $bootloader = grub2 && "$(has_kernelopts "$i")" = "false" && $opts = $new_args ]]; then
set_bls_value "${bls_file[$i]}" "options" "\$kernelopts"
fi
fi