grubby/0038-Write-correct-default-to-environment-1285601.patch

44 lines
1.3 KiB
Diff

From d3c64808b6fc4794e2c58b1812315914966afea9 Mon Sep 17 00:00:00 2001
From: Robert Marshall <rmarshall@redhat.com>
Date: Thu, 22 Dec 2016 17:56:44 -0500
Subject: [PATCH 38/55] Write correct default to environment (#1285601)
grubby writes the title of the default boot entry to the bootloader
environment. The title lookup did not correctly account for the offset
required if some boot entries were marked for removal.
Related: rhbz#1285601
---
grubby.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/grubby.c b/grubby.c
index 692c351ccb6..9edb26d0ded 100644
--- a/grubby.c
+++ b/grubby.c
@@ -1709,7 +1709,20 @@ static void writeDefault(FILE * out, char *indent,
fprintf(out, "%sset default=\"${saved_entry}\"\n", indent);
if (cfg->defaultImage >= FIRST_ENTRY_INDEX && cfg->cfi->setEnv) {
char *title;
- entry = findEntryByIndex(cfg, cfg->defaultImage);
+ int trueIndex, currentIndex;
+
+ trueIndex = 0;
+ currentIndex = 0;
+
+ while ((entry = findEntryByIndex(cfg, currentIndex))) {
+ if (!entry->skip) {
+ if (trueIndex == cfg->defaultImage) {
+ break;
+ }
+ trueIndex++;
+ }
+ currentIndex++;
+ }
line = getLineByType(LT_MENUENTRY, entry->lines);
if (!line)
line = getLineByType(LT_TITLE, entry->lines);
--
2.17.1