grubby-bls: check if entry exists before attempting to print its info

The grubby --info option didn't check if an entry existed for a kernel and
printed wrong information about it. Fix this and also for --update-kernel
and --set-default options that have the same issue.

Resolves: rhbz#1634712

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2018-10-15 15:25:43 +02:00
parent cf425061aa
commit b40ea5be18
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
1 changed files with 12 additions and 0 deletions

View File

@ -188,6 +188,10 @@ param_to_indexes() {
display_info_values() {
local indexes=($(param_to_indexes "$1"))
if [[ $indexes = "-1" ]]; then
print_error "The param $1 is incorrect"
fi
for i in ${indexes[*]}; do
echo "index=$i"
echo "kernel=${bls_linux[$i]}"
@ -358,6 +362,10 @@ update_bls_fragment() {
local add_args=$1 && shift
local initrd=$1 && shift
if [[ $indexes = "-1" ]]; then
print_error "The param $1 is incorrect"
fi
for i in ${indexes[*]}; do
if [[ -n $remove_args || -n $add_args ]]; then
local new_args="$(update_args "${bls_options[$i]}" "${remove_args}" "${add_args}")"
@ -375,6 +383,10 @@ update_bls_fragment() {
set_default_bls() {
local index=($(param_to_indexes "$1"))
if [[ $index = "-1" ]]; then
print_error "The param $1 is incorrect"
fi
if [[ $bootloader = grub2 ]]; then
grub2-editenv "${env}" set saved_entry="${bls_id[$index]}"
else