Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the fallback mechanism when menu entries fail to boot #195

Open
wants to merge 2 commits into
base: fedora-42
Choose a base branch
from

Commits on Oct 24, 2024

  1. script/execute: Don't let trailing blank lines determine the return code

    grub_script_execute_sourcecode() parses and executes code one line at a
    time, updating the return code each time because only the last line
    determines the final status. However, trailing new lines were also
    executed, masking any failure on the previous line. Fix this by only
    trying to execute the command when there is actually one present.
    
    This has presumably never been noticed because this code is not used by
    regular functions, only in special cases like eval and menu entries. The
    latter generally don't return at all, having booted an OS. When failing
    to boot, upstream GRUB triggers the fallback mechanism regardless of the
    return code.
    
    We noticed the problem while using Red Hat's patches, which change this
    behaviour to take account of the return code. In that case, a failure
    takes you back to the menu rather than triggering a fallback.
    
    Signed-off-by: James Le Cuirot <[email protected]>
    chewi committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    442b676 View commit details
    Browse the repository at this point in the history
  2. 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]>
    chewi committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    93eedb6 View commit details
    Browse the repository at this point in the history