Blob Blame History Raw
From d4d7954a983f9cf68cd49c181e8deb1493e76e9e Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 24 Jun 2016 16:05:45 -0400
Subject: [PATCH 54/55] Ensure command line updates also honor --set-index

Related: rhbz#1285601

Signed-off-by: Peter Jones <pjones@redhat.com>
---
 grubby.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/grubby.c b/grubby.c
index 2402116..c379388 100644
--- a/grubby.c
+++ b/grubby.c
@@ -4292,11 +4292,17 @@ int addNewKernel(struct grubConfig *config, struct singleEntry *template,
 	struct singleEntry *new, *entry, *prev = NULL;
 	struct singleLine *newLine = NULL, *tmplLine = NULL, *masterLine = NULL;
 	int needs;
+	char *indexs;
 	char *chptr;
+	int rc;
 
 	if (!newKernelPath)
 		return 0;
 
+	rc = asprintf(&indexs, "%d", newIndex);
+	if (rc < 0)
+		return 1;
+
 	/* if the newKernelTitle is too long silently munge it into something
 	 * we can live with. truncating is first check, then we'll just mess with
 	 * it until it looks better */
@@ -4753,7 +4759,7 @@ int addNewKernel(struct grubConfig *config, struct singleEntry *template,
 		abort();
 	}
 
-	if (updateImage(config, "0", prefix, newKernelArgs, NULL,
+	if (updateImage(config, indexs, prefix, newKernelArgs, NULL,
 			newMBKernelArgs, NULL))
 		return 1;
 
-- 
2.5.5