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