Blame SOURCES/0069-Write-correct-default-to-environment-1285601.patch

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