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