Blob Blame History Raw
From f88808a37044c323e35eda49dbc326dcf260439b Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 24 Jun 2016 16:05:45 -0400
Subject: [PATCH 23/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 54625e7da0a..d889399449b 100644
--- a/grubby.c
+++ b/grubby.c
@@ -4212,11 +4212,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 */
@@ -4715,7 +4721,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.17.1