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

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