Skip to content

Commit 93eedb6

Browse files
committed
normal/menu: Check return code of the script when executing a menu entry
Don't rely on grub_errno here because grub_script_execute_new_scope() calls grub_print_error(), which always resets grub_errno back to GRUB_ERR_NONE. It may also get reset by grub_wait_after_message(). This problem was observed when a "bad signature" error resulted in the menu being redisplayed rather than the fallback mechanism being triggered, although another change was also needed to fix it. This only happens with Red Hat's patches because upstream GRUB triggers the fallback mechanism regardless of the return code. Signed-off-by: James Le Cuirot <[email protected]>
1 parent 442b676 commit 93eedb6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

grub-core/normal/menu.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,14 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot)
376376
if (ptr && ptr[0] && ptr[1])
377377
grub_env_set ("default", ptr + 1);
378378

379-
grub_script_execute_new_scope (entry->sourcecode, entry->argc, entry->args);
379+
err = grub_script_execute_new_scope (entry->sourcecode, entry->argc, entry->args);
380380

381381
if (errs_before != grub_err_printed_errors)
382382
grub_wait_after_message ();
383383

384384
errs_before = grub_err_printed_errors;
385385

386-
if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ())
386+
if (err == GRUB_ERR_NONE && grub_loader_is_loaded ())
387387
/* Implicit execution of boot, only if something is loaded. */
388388
err = grub_command_execute ("boot", 0, 0);
389389

0 commit comments

Comments
 (0)