Blame SOURCES/0010-extlinux-Understand-default-properly.patch

903092
From b0b7669740fd8cb9ee465d0f978ed30d5e28af6e Mon Sep 17 00:00:00 2001
903092
From: Lubomir Rintel <lkundrak@v3.sk>
903092
Date: Wed, 27 Nov 2013 16:59:50 +0100
903092
Subject: [PATCH 10/41] extlinux: Understand "default" properly
903092
903092
The configuration looks like the following:
903092
903092
  default Fedora (3.11.6-301.fc20.i686+PAE) 20 (Heisenbug)
903092
903092
  title Fedora (3.11.6-301.fc20.i686+PAE) 20 (Heisenbug)
903092
  ...
903092
903092
Grubby skips over the default clause as it has more than one element. And even
903092
if it did not, it would not match it against the title, since it handles titles
903092
specially, concatenating the title, but not the default clause.
903092
903092
This commit adds special handling for extlinux, which causes it to parse
903092
default and title in the same way.
903092
903092
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
903092
---
903092
 grubby.c | 15 ++++++++++-----
903092
 1 file changed, 10 insertions(+), 5 deletions(-)
903092
903092
diff --git a/grubby.c b/grubby.c
903092
index 895ed06..21c5044 100644
903092
--- a/grubby.c
903092
+++ b/grubby.c
903092
@@ -159,6 +159,7 @@ struct configFileInfo {
903092
     int defaultIsVariable;
903092
     int defaultSupportSaved;
903092
     int defaultIsSaved;
903092
+    int defaultIsUnquoted;
903092
     enum lineType_e entryStart;
903092
     enum lineType_e entryEnd;
903092
     int needsBootPrefix;
903092
@@ -630,6 +631,7 @@ struct configFileInfo extlinuxConfigType = {
903092
     .needsBootPrefix = 1,
903092
     .maxTitleLength = 255,
903092
     .mbAllowExtraInitRds = 1,
903092
+    .defaultIsUnquoted = 1,
903092
 };
903092
 
903092
 struct grubConfig {
903092
@@ -1185,9 +1187,6 @@ static struct grubConfig * readConfig(const char * inName,
903092
 		cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT;
903092
 		defaultLine = line;
903092
 	    }
903092
-	} else if (line->type == LT_DEFAULT && line->numElements == 2) {
903092
-	    cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT;
903092
-	    defaultLine = line;
903092
 
903092
         } else if (iskernel(line->type)) {
903092
 	    /* if by some freak chance this is multiboot and the "module"
903092
@@ -1220,8 +1219,9 @@ static struct grubConfig * readConfig(const char * inName,
903092
 	    cfg->fallbackImage = strtol(line->elements[1].item, &end, 10);
903092
 	    if (*end) cfg->fallbackImage = -1;
903092
 
903092
-	} else if (line->type == LT_TITLE && line->numElements > 1) {
903092
-	    /* make the title a single argument (undoing our parsing) */
903092
+	} else if ((line->type == LT_DEFAULT && cfi->defaultIsUnquoted) ||
903092
+                (line->type == LT_TITLE && line->numElements > 1)) {
903092
+	    /* make the title/default a single argument (undoing our parsing) */
903092
 	    len = 0;
903092
 	    for (int i = 1; i < line->numElements; i++) {
903092
 		len += strlen(line->elements[i].item);
903092
@@ -1328,6 +1328,11 @@ static struct grubConfig * readConfig(const char * inName,
903092
 	    }
903092
 	}
903092
 
903092
+	if (line->type == LT_DEFAULT && line->numElements == 2) {
903092
+	    cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT;
903092
+	    defaultLine = line;
903092
+	}
903092
+
903092
 	/* If we find a generic config option which should live at the
903092
 	   top of the file, move it there. Old versions of grubby were
903092
 	   probably responsible for putting new images in the wrong 
903092
-- 
903092
2.4.3
903092