From 08153fc1d69f8766bfccd46134969b4f2fecc541 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Nov 28 2019 09:52:53 +0000 Subject: 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 --- diff --git a/grubby-bls b/grubby-bls index 24790a8..06a021b 100755 --- a/grubby-bls +++ b/grubby-bls @@ -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