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