Skip to content

Commit

Permalink
bootloader/grub2: Handle empty static configs
Browse files Browse the repository at this point in the history
In ostreedev#3205, we introduced a check to skip re-generating the GRUB config if
we detect that static configs are in used by looking at bootupd's state.

Unfortunately this check is incomplete and does not account for present
but null entries in the JSON state file.

A proper fix would be to parse the JSON but this requires a larger code
change.

Fixes: ostreedev#3295
Fixes: ostreedev#3205
  • Loading branch information
travier committed Sep 13, 2024
1 parent 81867f0 commit 725e5c0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/libostree/ostree-bootloader-grub2.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define BOOTUPD_CONFIG "boot/bootupd-state.json"
// Horrible hack, to avoid including a JSON parser we just grep for this
#define BOOTUPD_CONFIG_STATIC_JSON_FRAGMENT "\"static-configs\""
#define BOOTUPD_CONFIG_STATIC_JSON_FRAGMENT_NULL "\"static-configs\":null"

/* Maintain backwards compatibility with legacy GRUB
* installations that might rely on the -16 suffix
Expand Down Expand Up @@ -90,9 +91,12 @@ _ostree_bootloader_grub2_query (OstreeBootloader *bootloader, gboolean *out_is_a
return glnx_prefix_error (error, "Failed to read bootupd config");
if (strstr (bootupd_config_contents, BOOTUPD_CONFIG_STATIC_JSON_FRAGMENT) != NULL)
{
g_debug ("Found static bootupd config");
*out_is_active = FALSE;
return TRUE;
if (strstr (bootupd_config_contents, BOOTUPD_CONFIG_STATIC_JSON_FRAGMENT_NULL) == NULL)
{
g_debug ("Found static bootupd config");
*out_is_active = FALSE;
return TRUE;
}
}
}

Expand Down

0 comments on commit 725e5c0

Please sign in to comment.