diff options
author | Anssi Hannula <anssi.hannula@bitwise.fi> | 2021-09-23 12:08:05 +0300 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-10-12 18:00:09 +0200 |
commit | 9ade10a6cdf159283d27a83bb690d7264fe96586 (patch) | |
tree | 46d189633bc63c3bf5a5095b1ae38f4145af19b5 | |
parent | b1caaefe041a12ab939d69dafd56d9a9918ad770 (diff) | |
download | systemd-9ade10a6cdf159283d27a83bb690d7264fe96586.tar.gz |
bootctl: Fix update not adding EFI entry if Boot IDs are non-consecutive
"bootctl update" tries to add sd-boot to the EFI boot loader list if it
is not already there. To do so, it uses find_slot() which finds the
proper BootXXXX slot ID to use and also returns 1 if an existing sd-boot
entry was found at this ID or 0 if it is a new unused ID. In "update"
case install_variables() only writes the entry in case 0 (no existing
entry).
However, find_slot() erroneously returns 1 if it finds a gap in the Boot
IDs (i.e. when not resorting to max(ids) + 1). This causes
"bootctl update" to not add a missing systemd-boot boot entry if the
existing BootXXXX entry IDs are not consecutive.
Fix that by returning 0 in find_slot() when an empty gap ID is selected
to make it match the behavior when selecting an empty non-gap ID.
(cherry picked from commit 26d54e1263dcb58daa6578595cc6ab1037315593)
(cherry picked from commit 0028a3eb976dfa7209433dfa3a24b785f05fd352)
-rw-r--r-- | src/boot/bootctl.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 7450f2a97d..fa4c30d843 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -698,7 +698,7 @@ static int find_slot(sd_id128_t uuid, const char *path, uint16_t *id) { for (i = 0; i < n; i++) if (i != options[i]) { *id = i; - return 1; + return 0; } /* use the next one */ |