|
|
56d25d |
From 916d5770b5c8fb87503a99f98c13a5232a7dafbf Mon Sep 17 00:00:00 2001
|
|
|
56d25d |
From: Peter Jones <pjones@redhat.com>
|
|
|
56d25d |
Date: Thu, 10 Sep 2015 10:13:15 -0400
|
|
|
56d25d |
Subject: [PATCH] Fix some coverity concerns...
|
|
|
56d25d |
|
|
|
56d25d |
While checking on coverity's concern with kwcmp() having a loop it
|
|
|
56d25d |
really didn't need, I discovered another problem with the fix here that
|
|
|
56d25d |
made spaces not work right in grub2 variable assignment. So here's a
|
|
|
56d25d |
new version of the fix, and yet another test case.
|
|
|
56d25d |
|
|
|
56d25d |
Resolves: rhbz#1152550
|
|
|
56d25d |
|
|
|
56d25d |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
56d25d |
---
|
|
|
56d25d |
grubby.c | 204 ++++++++++++++++++++++++++++++++++++-----------
|
|
|
56d25d |
test.sh | 6 ++
|
|
|
56d25d |
test/grub2.17 | 156 ++++++++++++++++++++++++++++++++++++
|
|
|
56d25d |
test/results/add/g2-1.17 | 170 +++++++++++++++++++++++++++++++++++++++
|
|
|
56d25d |
4 files changed, 490 insertions(+), 46 deletions(-)
|
|
|
56d25d |
create mode 100644 test/grub2.17
|
|
|
56d25d |
create mode 100644 test/results/add/g2-1.17
|
|
|
56d25d |
|
|
|
56d25d |
diff --git a/grubby.c b/grubby.c
|
|
|
56d25d |
index d66c1c5..2a6eedb 100644
|
|
|
56d25d |
--- a/grubby.c
|
|
|
56d25d |
+++ b/grubby.c
|
|
|
56d25d |
@@ -751,28 +751,30 @@ static char *sdupprintf(const char *format, ...)
|
|
|
56d25d |
static inline int
|
|
|
56d25d |
kwcmp(struct keywordTypes *kw, const char * label, int case_insensitive)
|
|
|
56d25d |
{
|
|
|
56d25d |
- int kwl = strlen(kw->key);
|
|
|
56d25d |
- int ll = strlen(label);
|
|
|
56d25d |
- int rc;
|
|
|
56d25d |
- int (*snc)(const char *s1, const char *s2, size_t n) =
|
|
|
56d25d |
- case_insensitive ? strncasecmp : strncmp;
|
|
|
56d25d |
- int (*sc)(const char *s1, const char *s2) =
|
|
|
56d25d |
- case_insensitive ? strcasecmp : strcmp;
|
|
|
56d25d |
-
|
|
|
56d25d |
- rc = snc(kw->key, label, kwl);
|
|
|
56d25d |
- if (rc)
|
|
|
56d25d |
- return rc;
|
|
|
56d25d |
-
|
|
|
56d25d |
- for (int i = kwl; i < ll; i++) {
|
|
|
56d25d |
- if (isspace(label[i]))
|
|
|
56d25d |
- return 0;
|
|
|
56d25d |
- if (kw->separatorChar && label[i] == kw->separatorChar)
|
|
|
56d25d |
- return 0;
|
|
|
56d25d |
- else if (kw->nextChar && label[i] == kw->nextChar)
|
|
|
56d25d |
- return 0;
|
|
|
56d25d |
- return sc(kw->key+kwl, label+kwl);
|
|
|
56d25d |
- }
|
|
|
56d25d |
- return 0;
|
|
|
56d25d |
+ int kwl = strlen(kw->key);
|
|
|
56d25d |
+ int ll = strlen(label);
|
|
|
56d25d |
+ int rc;
|
|
|
56d25d |
+ int (*snc)(const char *s1, const char *s2, size_t n) =
|
|
|
56d25d |
+ case_insensitive ? strncasecmp : strncmp;
|
|
|
56d25d |
+ int (*sc)(const char *s1, const char *s2) =
|
|
|
56d25d |
+ case_insensitive ? strcasecmp : strcmp;
|
|
|
56d25d |
+
|
|
|
56d25d |
+ if (kwl > ll)
|
|
|
56d25d |
+ return ll - kwl;
|
|
|
56d25d |
+
|
|
|
56d25d |
+ rc = snc(kw->key, label, kwl);
|
|
|
56d25d |
+ if (rc)
|
|
|
56d25d |
+ return rc;
|
|
|
56d25d |
+
|
|
|
56d25d |
+ if (!label[kwl])
|
|
|
56d25d |
+ return 0;
|
|
|
56d25d |
+ if (isspace(label[kwl]))
|
|
|
56d25d |
+ return 0;
|
|
|
56d25d |
+ if (kw->separatorChar && label[kwl] == kw->separatorChar)
|
|
|
56d25d |
+ return 0;
|
|
|
56d25d |
+ if (kw->nextChar && label[kwl] == kw->nextChar)
|
|
|
56d25d |
+ return 0;
|
|
|
56d25d |
+ return sc(kw->key+kwl, label+kwl);
|
|
|
56d25d |
}
|
|
|
56d25d |
|
|
|
56d25d |
static enum lineType_e preferredLineType(enum lineType_e type,
|
|
|
56d25d |
@@ -1034,6 +1036,123 @@ static int lineWrite(FILE * out, struct singleLine *line,
|
|
|
56d25d |
return 0;
|
|
|
56d25d |
}
|
|
|
56d25d |
|
|
|
56d25d |
+static int mergeElements(struct singleLine *line, int left, int right)
|
|
|
56d25d |
+{
|
|
|
56d25d |
+ struct lineElement *elements = alloca(sizeof (line->elements[0]) *
|
|
|
56d25d |
+ line->numElements);
|
|
|
56d25d |
+ int i, j;
|
|
|
56d25d |
+ size_t itemsize = 0;
|
|
|
56d25d |
+ size_t newNumElements = 0;
|
|
|
56d25d |
+ char *newitem;
|
|
|
56d25d |
+ char *newindent = NULL;
|
|
|
56d25d |
+
|
|
|
56d25d |
+ if (right >= line->numElements)
|
|
|
56d25d |
+ right = line->numElements - 1;
|
|
|
56d25d |
+
|
|
|
56d25d |
+ if (!elements)
|
|
|
56d25d |
+ return -1;
|
|
|
56d25d |
+ for (i = 0; i < left; i++) {
|
|
|
56d25d |
+ elements[i] = line->elements[i];
|
|
|
56d25d |
+ newNumElements++;
|
|
|
56d25d |
+ }
|
|
|
56d25d |
+ for (; i <= right; i++) {
|
|
|
56d25d |
+ itemsize += strlen(line->elements[i].item);
|
|
|
56d25d |
+ if (line->elements[i].indent && line->elements[i].indent[0]) {
|
|
|
56d25d |
+ if (i != right)
|
|
|
56d25d |
+ itemsize += strlen(line->elements[i].indent);
|
|
|
56d25d |
+ }
|
|
|
56d25d |
+ }
|
|
|
56d25d |
+ newitem = calloc (itemsize+1, 1);
|
|
|
56d25d |
+ if (!newitem)
|
|
|
56d25d |
+ return -1;
|
|
|
56d25d |
+ for (i = left; i <= right; i++) {
|
|
|
56d25d |
+ strcat(newitem, line->elements[i].item);
|
|
|
56d25d |
+ if (line->elements[i].indent) {
|
|
|
56d25d |
+ if (i != right) {
|
|
|
56d25d |
+ strcat(newitem, line->elements[i].indent);
|
|
|
56d25d |
+ free(line->elements[i].indent);
|
|
|
56d25d |
+ } else {
|
|
|
56d25d |
+ newindent = line->elements[i].indent;
|
|
|
56d25d |
+ }
|
|
|
56d25d |
+ } else {
|
|
|
56d25d |
+ newindent = strdup("");
|
|
|
56d25d |
+ }
|
|
|
56d25d |
+ }
|
|
|
56d25d |
+ newNumElements++;
|
|
|
56d25d |
+ elements[left].item = newitem;
|
|
|
56d25d |
+ elements[left].indent = newindent;
|
|
|
56d25d |
+ if (left+1 < line->numElements && right+1 < line->numElements) {
|
|
|
56d25d |
+ for (j = left+1, i = right+1; i < line->numElements; i++) {
|
|
|
56d25d |
+ elements[j++] = line->elements[i];
|
|
|
56d25d |
+ newNumElements++;
|
|
|
56d25d |
+ }
|
|
|
56d25d |
+ }
|
|
|
56d25d |
+ memcpy(line->elements, elements,
|
|
|
56d25d |
+ sizeof (line->elements[i]) * newNumElements);
|
|
|
56d25d |
+ line->numElements = newNumElements;
|
|
|
56d25d |
+ return 0;
|
|
|
56d25d |
+}
|
|
|
56d25d |
+
|
|
|
56d25d |
+static int emptyElement(struct lineElement *element)
|
|
|
56d25d |
+{
|
|
|
56d25d |
+ if (element->item && strlen(element->item) > 0)
|
|
|
56d25d |
+ return 0;
|
|
|
56d25d |
+ if (element->indent && strlen(element->indent) > 0)
|
|
|
56d25d |
+ return 0;
|
|
|
56d25d |
+ return 1;
|
|
|
56d25d |
+}
|
|
|
56d25d |
+
|
|
|
56d25d |
+static int splitElement(struct singleLine *line, int element, int splitchar)
|
|
|
56d25d |
+{
|
|
|
56d25d |
+ struct lineElement split[2] = {{0,0},{0,0}};
|
|
|
56d25d |
+ struct lineElement *elements = NULL;
|
|
|
56d25d |
+ int saved_errno;
|
|
|
56d25d |
+ int i, j;
|
|
|
56d25d |
+
|
|
|
56d25d |
+ elements = calloc(line->numElements + 1, sizeof (line->elements[0]));
|
|
|
56d25d |
+ if (!elements)
|
|
|
56d25d |
+ return -1;
|
|
|
56d25d |
+
|
|
|
56d25d |
+ split[0].item = strndup(line->elements[element].item, splitchar);
|
|
|
56d25d |
+ if (!split[0].item)
|
|
|
56d25d |
+ goto err;
|
|
|
56d25d |
+ split[0].indent = strndup(&line->elements[element].item[splitchar], 1);
|
|
|
56d25d |
+ if (!split[0].indent)
|
|
|
56d25d |
+ goto err;
|
|
|
56d25d |
+ split[1].item = strdup(&line->elements[element].item[splitchar+1]);
|
|
|
56d25d |
+ if (!split[1].item)
|
|
|
56d25d |
+ goto err;
|
|
|
56d25d |
+ split[1].indent = line->elements[element].indent;
|
|
|
56d25d |
+
|
|
|
56d25d |
+ for (i = j = 0; i < line->numElements; i++) {
|
|
|
56d25d |
+ if (i != element) {
|
|
|
56d25d |
+ memcpy(&elements[j++], &line->elements[i],
|
|
|
56d25d |
+ sizeof(line->elements[i]));
|
|
|
56d25d |
+ } else {
|
|
|
56d25d |
+ memcpy(&elements[j++], &split[0], sizeof(split[0]));
|
|
|
56d25d |
+ memcpy(&elements[j++], &split[1], sizeof(split[1]));
|
|
|
56d25d |
+ free(line->elements[i].item);
|
|
|
56d25d |
+ }
|
|
|
56d25d |
+ }
|
|
|
56d25d |
+ free(line->elements);
|
|
|
56d25d |
+ line->elements = elements;
|
|
|
56d25d |
+ line->numElements++;
|
|
|
56d25d |
+
|
|
|
56d25d |
+ return 0;
|
|
|
56d25d |
+err:
|
|
|
56d25d |
+ saved_errno = errno;
|
|
|
56d25d |
+ if (split[0].item)
|
|
|
56d25d |
+ free(split[0].item);
|
|
|
56d25d |
+ if (split[0].indent)
|
|
|
56d25d |
+ free(split[0].indent);
|
|
|
56d25d |
+ if (split[1].item)
|
|
|
56d25d |
+ free(split[1].item);
|
|
|
56d25d |
+ if (elements)
|
|
|
56d25d |
+ free(elements);
|
|
|
56d25d |
+ errno = saved_errno;
|
|
|
56d25d |
+ return -1;
|
|
|
56d25d |
+}
|
|
|
56d25d |
+
|
|
|
56d25d |
/* we've guaranteed that the buffer ends w/ \n\0 */
|
|
|
56d25d |
static int getNextLine(char **bufPtr, struct singleLine *line,
|
|
|
56d25d |
struct configFileInfo *cfi)
|
|
|
56d25d |
@@ -1208,34 +1327,27 @@ static int getNextLine(char **bufPtr, struct singleLine *line,
|
|
|
56d25d |
* yet a third way to avoid rhbz# XXX FIXME :/
|
|
|
56d25d |
*/
|
|
|
56d25d |
char *eq;
|
|
|
56d25d |
- int l;
|
|
|
56d25d |
- int numElements = line->numElements;
|
|
|
56d25d |
- struct lineElement *newElements;
|
|
|
56d25d |
+ int rc;
|
|
|
56d25d |
+ rc = mergeElements(line, 2, line->numElements);
|
|
|
56d25d |
+ if (rc < 0)
|
|
|
56d25d |
+ return rc;
|
|
|
56d25d |
eq = strchr(line->elements[1].item, '=');
|
|
|
56d25d |
if (!eq)
|
|
|
56d25d |
return 0;
|
|
|
56d25d |
- l = eq - line->elements[1].item;
|
|
|
56d25d |
- if (eq[1] != 0)
|
|
|
56d25d |
- numElements++;
|
|
|
56d25d |
- newElements = calloc(numElements,sizeof (*newElements));
|
|
|
56d25d |
- memcpy(&newElements[0], &line->elements[0],
|
|
|
56d25d |
- sizeof (newElements[0]));
|
|
|
56d25d |
- newElements[1].item =
|
|
|
56d25d |
- strndup(line->elements[1].item, l);
|
|
|
56d25d |
- newElements[1].indent = "=";
|
|
|
56d25d |
- *(eq++) = '\0';
|
|
|
56d25d |
- newElements[2].item = strdup(eq);
|
|
|
56d25d |
- free(line->elements[1].item);
|
|
|
56d25d |
- if (line->elements[1].indent)
|
|
|
56d25d |
- newElements[2].indent = line->elements[1].indent;
|
|
|
56d25d |
- for (int i = 2; i < line->numElements; i++) {
|
|
|
56d25d |
- newElements[i+1].item = line->elements[i].item;
|
|
|
56d25d |
- newElements[i+1].indent =
|
|
|
56d25d |
- line->elements[i].indent;
|
|
|
56d25d |
+ rc = splitElement(line, 1, eq-line->elements[1].item);
|
|
|
56d25d |
+ if (rc < 0)
|
|
|
56d25d |
+ return rc;
|
|
|
56d25d |
+ /* now make sure we haven't got any bogus elements at
|
|
|
56d25d |
+ * the end that don't mean anything.
|
|
|
56d25d |
+ */
|
|
|
56d25d |
+ while (line->numElements > 1 &&
|
|
|
56d25d |
+ emptyElement(
|
|
|
56d25d |
+ &line->elements[line->numElements-1])) {
|
|
|
56d25d |
+ rc = mergeElements(line, line->numElements-2,
|
|
|
56d25d |
+ line->numElements-1);
|
|
|
56d25d |
+ if (rc < 0)
|
|
|
56d25d |
+ return rc;
|
|
|
56d25d |
}
|
|
|
56d25d |
- free(line->elements);
|
|
|
56d25d |
- line->elements = newElements;
|
|
|
56d25d |
- line->numElements = numElements;
|
|
|
56d25d |
}
|
|
|
56d25d |
}
|
|
|
56d25d |
|
|
|
56d25d |
diff --git a/test.sh b/test.sh
|
|
|
56d25d |
index ba466a5..d488333 100755
|
|
|
56d25d |
--- a/test.sh
|
|
|
56d25d |
+++ b/test.sh
|
|
|
56d25d |
@@ -551,6 +551,12 @@ if [ "$testgrub2" == "y" ]; then
|
|
|
56d25d |
--copy-default --title 'Red Hat Enterprise Linux Server' \
|
|
|
56d25d |
--args=root=/dev/mapper/foo--
|
|
|
56d25d |
|
|
|
56d25d |
+ # the same, but for: set foo = " bar=1,2 "
|
|
|
56d25d |
+ grub2Test grub2.17 add/g2-1.17 \
|
|
|
56d25d |
+ --boot-filesystem=/boot --add-kernel=/boot/vmlinuz-foo \
|
|
|
56d25d |
+ --copy-default --title 'Red Hat Enterprise Linux Server' \
|
|
|
56d25d |
+ --args=root=/dev/mapper/foo--
|
|
|
56d25d |
+
|
|
|
56d25d |
testing="GRUB2 add initrd"
|
|
|
56d25d |
grub2Test grub2.2 add/g2-1.4 --update-kernel=/boot/new-kernel.img \
|
|
|
56d25d |
--initrd=/boot/new-initrd --boot-filesystem=/boot/
|
|
|
56d25d |
diff --git a/test/grub2.17 b/test/grub2.17
|
|
|
56d25d |
new file mode 100644
|
|
|
56d25d |
index 0000000..bd8c9c5
|
|
|
56d25d |
--- /dev/null
|
|
|
56d25d |
+++ b/test/grub2.17
|
|
|
56d25d |
@@ -0,0 +1,156 @@
|
|
|
56d25d |
+#
|
|
|
56d25d |
+# DO NOT EDIT THIS FILE
|
|
|
56d25d |
+#
|
|
|
56d25d |
+# It is automatically generated by grub2-mkconfig using templates
|
|
|
56d25d |
+# from /etc/grub.d and settings from /etc/default/grub
|
|
|
56d25d |
+#
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/00_header ###
|
|
|
56d25d |
+set pager=1
|
|
|
56d25d |
+
|
|
|
56d25d |
+if [ -s $prefix/grubenv ]; then
|
|
|
56d25d |
+ load_env
|
|
|
56d25d |
+fi
|
|
|
56d25d |
+if [ "${next_entry}" ] ; then
|
|
|
56d25d |
+ set default="${next_entry}"
|
|
|
56d25d |
+ set next_entry=
|
|
|
56d25d |
+ save_env next_entry
|
|
|
56d25d |
+ set boot_once=true
|
|
|
56d25d |
+else
|
|
|
56d25d |
+ set default="${saved_entry}"
|
|
|
56d25d |
+fi
|
|
|
56d25d |
+
|
|
|
56d25d |
+if [ x"${feature_menuentry_id}" = xy ]; then
|
|
|
56d25d |
+ menuentry_id_option="--id"
|
|
|
56d25d |
+else
|
|
|
56d25d |
+ menuentry_id_option=""
|
|
|
56d25d |
+fi
|
|
|
56d25d |
+
|
|
|
56d25d |
+export menuentry_id_option
|
|
|
56d25d |
+
|
|
|
56d25d |
+if [ "${prev_saved_entry}" ]; then
|
|
|
56d25d |
+ set saved_entry="${prev_saved_entry}"
|
|
|
56d25d |
+ save_env saved_entry
|
|
|
56d25d |
+ set prev_saved_entry=
|
|
|
56d25d |
+ save_env prev_saved_entry
|
|
|
56d25d |
+ set boot_once=true
|
|
|
56d25d |
+fi
|
|
|
56d25d |
+
|
|
|
56d25d |
+function savedefault {
|
|
|
56d25d |
+ if [ -z "${boot_once}" ]; then
|
|
|
56d25d |
+ saved_entry="${chosen}"
|
|
|
56d25d |
+ save_env saved_entry
|
|
|
56d25d |
+ fi
|
|
|
56d25d |
+}
|
|
|
56d25d |
+
|
|
|
56d25d |
+function load_video {
|
|
|
56d25d |
+ if [ x$feature_all_video_module = xy ]; then
|
|
|
56d25d |
+ insmod all_video
|
|
|
56d25d |
+ else
|
|
|
56d25d |
+ insmod efi_gop
|
|
|
56d25d |
+ insmod efi_uga
|
|
|
56d25d |
+ insmod ieee1275_fb
|
|
|
56d25d |
+ insmod vbe
|
|
|
56d25d |
+ insmod vga
|
|
|
56d25d |
+ insmod video_bochs
|
|
|
56d25d |
+ insmod video_cirrus
|
|
|
56d25d |
+ fi
|
|
|
56d25d |
+}
|
|
|
56d25d |
+
|
|
|
56d25d |
+serial --speed=115200
|
|
|
56d25d |
+terminal_input serial console
|
|
|
56d25d |
+terminal_output serial console
|
|
|
56d25d |
+if [ x$feature_timeout_style = xy ] ; then
|
|
|
56d25d |
+ set timeout_style=menu
|
|
|
56d25d |
+ set timeout=5
|
|
|
56d25d |
+# Fallback normal timeout code in case the timeout_style feature is
|
|
|
56d25d |
+# unavailable.
|
|
|
56d25d |
+else
|
|
|
56d25d |
+ set timeout=5
|
|
|
56d25d |
+fi
|
|
|
56d25d |
+### END /etc/grub.d/00_header ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/00_tuned ###
|
|
|
56d25d |
+set tuned_params= " isolcpus=1,3 "
|
|
|
56d25d |
+### END /etc/grub.d/00_tuned ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/01_users ###
|
|
|
56d25d |
+if [ -f ${prefix}/user.cfg ]; then
|
|
|
56d25d |
+ source ${prefix}/user.cfg
|
|
|
56d25d |
+ if [ -n ${GRUB2_PASSWORD} ]; then
|
|
|
56d25d |
+ set superusers="root"
|
|
|
56d25d |
+ export superusers
|
|
|
56d25d |
+ password_pbkdf2 root ${GRUB2_PASSWORD}
|
|
|
56d25d |
+ fi
|
|
|
56d25d |
+fi
|
|
|
56d25d |
+### END /etc/grub.d/01_users ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/10_linux ###
|
|
|
56d25d |
+menuentry 'Red Hat Enterprise Linux Server (3.10.0-297.el7.x86_64) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-296.el7.x86_64-advanced-ae7b3742-9092-4432-9f7f-8abdbf0dc3db' {
|
|
|
56d25d |
+ load_video
|
|
|
56d25d |
+ set gfxpayload=keep
|
|
|
56d25d |
+ insmod gzio
|
|
|
56d25d |
+ insmod part_msdos
|
|
|
56d25d |
+ insmod xfs
|
|
|
56d25d |
+ set root='hd0,msdos1'
|
|
|
56d25d |
+ if [ x$feature_platform_search_hint = xy ]; then
|
|
|
56d25d |
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' cae02b39-f239-4d26-9032-674d261c93d8
|
|
|
56d25d |
+ else
|
|
|
56d25d |
+ search --no-floppy --fs-uuid --set=root cae02b39-f239-4d26-9032-674d261c93d8
|
|
|
56d25d |
+ fi
|
|
|
56d25d |
+ linux16 /vmlinuz-3.10.0-297.el7.x86_64 root=/dev/mapper/rhel_hp--dl380pgen8--02--vm--10-root ro crashkernel=auto rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/root rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/swap console=ttyS0,115200n81 $tuned_params LANG=en_US.UTF-8
|
|
|
56d25d |
+}
|
|
|
56d25d |
+menuentry 'Red Hat Enterprise Linux Server (3.10.0-296.el7.x86_64) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-296.el7.x86_64-advanced-ae7b3742-9092-4432-9f7f-8abdbf0dc3db' {
|
|
|
56d25d |
+ load_video
|
|
|
56d25d |
+ set gfxpayload=keep
|
|
|
56d25d |
+ insmod gzio
|
|
|
56d25d |
+ insmod part_msdos
|
|
|
56d25d |
+ insmod xfs
|
|
|
56d25d |
+ set root='hd0,msdos1'
|
|
|
56d25d |
+ if [ x$feature_platform_search_hint = xy ]; then
|
|
|
56d25d |
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' cae02b39-f239-4d26-9032-674d261c93d8
|
|
|
56d25d |
+ else
|
|
|
56d25d |
+ search --no-floppy --fs-uuid --set=root cae02b39-f239-4d26-9032-674d261c93d8
|
|
|
56d25d |
+ fi
|
|
|
56d25d |
+ linux16 /vmlinuz-3.10.0-296.el7.x86_64 root=/dev/mapper/rhel_hp--dl380pgen8--02--vm--10-root ro crashkernel=auto rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/root rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/swap console=ttyS0,115200n81 $tuned_params
|
|
|
56d25d |
+ initrd16 /initramfs-3.10.0-296.el7.x86_64.img
|
|
|
56d25d |
+}
|
|
|
56d25d |
+menuentry 'Red Hat Enterprise Linux Server (0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7-advanced-ae7b3742-9092-4432-9f7f-8abdbf0dc3db' {
|
|
|
56d25d |
+ load_video
|
|
|
56d25d |
+ insmod gzio
|
|
|
56d25d |
+ insmod part_msdos
|
|
|
56d25d |
+ insmod xfs
|
|
|
56d25d |
+ set root='hd0,msdos1'
|
|
|
56d25d |
+ if [ x$feature_platform_search_hint = xy ]; then
|
|
|
56d25d |
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' cae02b39-f239-4d26-9032-674d261c93d8
|
|
|
56d25d |
+ else
|
|
|
56d25d |
+ search --no-floppy --fs-uuid --set=root cae02b39-f239-4d26-9032-674d261c93d8
|
|
|
56d25d |
+ fi
|
|
|
56d25d |
+ linux16 /vmlinuz-0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7 root=/dev/mapper/rhel_hp--dl380pgen8--02--vm--10-root ro crashkernel=auto rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/root rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/swap console=ttyS0,115200n81 $tuned_params
|
|
|
56d25d |
+ initrd16 /initramfs-0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7.img
|
|
|
56d25d |
+}
|
|
|
56d25d |
+if [ "x$default" = 'Red Hat Enterprise Linux Server (3.10.0-296.el7.x86_64) 7.2 (Maipo)' ]; then default='Advanced options for Red Hat Enterprise Linux Server>Red Hat Enterprise Linux Server (3.10.0-296.el7.x86_64) 7.2 (Maipo)'; fi;
|
|
|
56d25d |
+### END /etc/grub.d/10_linux ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/20_linux_xen ###
|
|
|
56d25d |
+### END /etc/grub.d/20_linux_xen ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/20_ppc_terminfo ###
|
|
|
56d25d |
+### END /etc/grub.d/20_ppc_terminfo ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/30_os-prober ###
|
|
|
56d25d |
+### END /etc/grub.d/30_os-prober ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/40_custom ###
|
|
|
56d25d |
+# This file provides an easy way to add custom menu entries. Simply type the
|
|
|
56d25d |
+# menu entries you want to add after this comment. Be careful not to change
|
|
|
56d25d |
+# the 'exec tail' line above.
|
|
|
56d25d |
+### END /etc/grub.d/40_custom ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/41_custom ###
|
|
|
56d25d |
+if [ -f ${config_directory}/custom.cfg ]; then
|
|
|
56d25d |
+ source ${config_directory}/custom.cfg
|
|
|
56d25d |
+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
|
|
|
56d25d |
+ source $prefix/custom.cfg;
|
|
|
56d25d |
+fi
|
|
|
56d25d |
+### END /etc/grub.d/41_custom ###
|
|
|
56d25d |
diff --git a/test/results/add/g2-1.17 b/test/results/add/g2-1.17
|
|
|
56d25d |
new file mode 100644
|
|
|
56d25d |
index 0000000..afb151d
|
|
|
56d25d |
--- /dev/null
|
|
|
56d25d |
+++ b/test/results/add/g2-1.17
|
|
|
56d25d |
@@ -0,0 +1,170 @@
|
|
|
56d25d |
+#
|
|
|
56d25d |
+# DO NOT EDIT THIS FILE
|
|
|
56d25d |
+#
|
|
|
56d25d |
+# It is automatically generated by grub2-mkconfig using templates
|
|
|
56d25d |
+# from /etc/grub.d and settings from /etc/default/grub
|
|
|
56d25d |
+#
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/00_header ###
|
|
|
56d25d |
+set pager=1
|
|
|
56d25d |
+
|
|
|
56d25d |
+if [ -s $prefix/grubenv ]; then
|
|
|
56d25d |
+ load_env
|
|
|
56d25d |
+fi
|
|
|
56d25d |
+if [ "${next_entry}" ] ; then
|
|
|
56d25d |
+ set default="${next_entry}"
|
|
|
56d25d |
+ set next_entry=
|
|
|
56d25d |
+ save_env next_entry
|
|
|
56d25d |
+ set boot_once=true
|
|
|
56d25d |
+else
|
|
|
56d25d |
+ set default="${saved_entry}"
|
|
|
56d25d |
+fi
|
|
|
56d25d |
+
|
|
|
56d25d |
+if [ x"${feature_menuentry_id}" = xy ]; then
|
|
|
56d25d |
+ menuentry_id_option="--id"
|
|
|
56d25d |
+else
|
|
|
56d25d |
+ menuentry_id_option=""
|
|
|
56d25d |
+fi
|
|
|
56d25d |
+
|
|
|
56d25d |
+export menuentry_id_option
|
|
|
56d25d |
+
|
|
|
56d25d |
+if [ "${prev_saved_entry}" ]; then
|
|
|
56d25d |
+ set saved_entry="${prev_saved_entry}"
|
|
|
56d25d |
+ save_env saved_entry
|
|
|
56d25d |
+ set prev_saved_entry=
|
|
|
56d25d |
+ save_env prev_saved_entry
|
|
|
56d25d |
+ set boot_once=true
|
|
|
56d25d |
+fi
|
|
|
56d25d |
+
|
|
|
56d25d |
+function savedefault {
|
|
|
56d25d |
+ if [ -z "${boot_once}" ]; then
|
|
|
56d25d |
+ saved_entry="${chosen}"
|
|
|
56d25d |
+ save_env saved_entry
|
|
|
56d25d |
+ fi
|
|
|
56d25d |
+}
|
|
|
56d25d |
+
|
|
|
56d25d |
+function load_video {
|
|
|
56d25d |
+ if [ x$feature_all_video_module = xy ]; then
|
|
|
56d25d |
+ insmod all_video
|
|
|
56d25d |
+ else
|
|
|
56d25d |
+ insmod efi_gop
|
|
|
56d25d |
+ insmod efi_uga
|
|
|
56d25d |
+ insmod ieee1275_fb
|
|
|
56d25d |
+ insmod vbe
|
|
|
56d25d |
+ insmod vga
|
|
|
56d25d |
+ insmod video_bochs
|
|
|
56d25d |
+ insmod video_cirrus
|
|
|
56d25d |
+ fi
|
|
|
56d25d |
+}
|
|
|
56d25d |
+
|
|
|
56d25d |
+serial --speed=115200
|
|
|
56d25d |
+terminal_input serial console
|
|
|
56d25d |
+terminal_output serial console
|
|
|
56d25d |
+if [ x$feature_timeout_style = xy ] ; then
|
|
|
56d25d |
+ set timeout_style=menu
|
|
|
56d25d |
+ set timeout=5
|
|
|
56d25d |
+# Fallback normal timeout code in case the timeout_style feature is
|
|
|
56d25d |
+# unavailable.
|
|
|
56d25d |
+else
|
|
|
56d25d |
+ set timeout=5
|
|
|
56d25d |
+fi
|
|
|
56d25d |
+### END /etc/grub.d/00_header ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/00_tuned ###
|
|
|
56d25d |
+set tuned_params= " isolcpus=1,3 "
|
|
|
56d25d |
+### END /etc/grub.d/00_tuned ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/01_users ###
|
|
|
56d25d |
+if [ -f ${prefix}/user.cfg ]; then
|
|
|
56d25d |
+ source ${prefix}/user.cfg
|
|
|
56d25d |
+ if [ -n ${GRUB2_PASSWORD} ]; then
|
|
|
56d25d |
+ set superusers="root"
|
|
|
56d25d |
+ export superusers
|
|
|
56d25d |
+ password_pbkdf2 root ${GRUB2_PASSWORD}
|
|
|
56d25d |
+ fi
|
|
|
56d25d |
+fi
|
|
|
56d25d |
+### END /etc/grub.d/01_users ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/10_linux ###
|
|
|
56d25d |
+menuentry 'Red Hat Enterprise Linux Server' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-296.el7.x86_64-advanced-ae7b3742-9092-4432-9f7f-8abdbf0dc3db' {
|
|
|
56d25d |
+ load_video
|
|
|
56d25d |
+ set gfxpayload=keep
|
|
|
56d25d |
+ insmod gzio
|
|
|
56d25d |
+ insmod part_msdos
|
|
|
56d25d |
+ insmod xfs
|
|
|
56d25d |
+ set root='hd0,msdos1'
|
|
|
56d25d |
+ if [ x$feature_platform_search_hint = xy ]; then
|
|
|
56d25d |
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' cae02b39-f239-4d26-9032-674d261c93d8
|
|
|
56d25d |
+ else
|
|
|
56d25d |
+ search --no-floppy --fs-uuid --set=root cae02b39-f239-4d26-9032-674d261c93d8
|
|
|
56d25d |
+ fi
|
|
|
56d25d |
+ linux16 /vmlinuz-foo root=/dev/mapper/foo-- ro crashkernel=auto rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/root rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/swap console=ttyS0,115200n81 $tuned_params LANG=en_US.UTF-8
|
|
|
56d25d |
+}
|
|
|
56d25d |
+menuentry 'Red Hat Enterprise Linux Server (3.10.0-297.el7.x86_64) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-296.el7.x86_64-advanced-ae7b3742-9092-4432-9f7f-8abdbf0dc3db' {
|
|
|
56d25d |
+ load_video
|
|
|
56d25d |
+ set gfxpayload=keep
|
|
|
56d25d |
+ insmod gzio
|
|
|
56d25d |
+ insmod part_msdos
|
|
|
56d25d |
+ insmod xfs
|
|
|
56d25d |
+ set root='hd0,msdos1'
|
|
|
56d25d |
+ if [ x$feature_platform_search_hint = xy ]; then
|
|
|
56d25d |
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' cae02b39-f239-4d26-9032-674d261c93d8
|
|
|
56d25d |
+ else
|
|
|
56d25d |
+ search --no-floppy --fs-uuid --set=root cae02b39-f239-4d26-9032-674d261c93d8
|
|
|
56d25d |
+ fi
|
|
|
56d25d |
+ linux16 /vmlinuz-3.10.0-297.el7.x86_64 root=/dev/mapper/rhel_hp--dl380pgen8--02--vm--10-root ro crashkernel=auto rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/root rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/swap console=ttyS0,115200n81 $tuned_params LANG=en_US.UTF-8
|
|
|
56d25d |
+}
|
|
|
56d25d |
+menuentry 'Red Hat Enterprise Linux Server (3.10.0-296.el7.x86_64) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-296.el7.x86_64-advanced-ae7b3742-9092-4432-9f7f-8abdbf0dc3db' {
|
|
|
56d25d |
+ load_video
|
|
|
56d25d |
+ set gfxpayload=keep
|
|
|
56d25d |
+ insmod gzio
|
|
|
56d25d |
+ insmod part_msdos
|
|
|
56d25d |
+ insmod xfs
|
|
|
56d25d |
+ set root='hd0,msdos1'
|
|
|
56d25d |
+ if [ x$feature_platform_search_hint = xy ]; then
|
|
|
56d25d |
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' cae02b39-f239-4d26-9032-674d261c93d8
|
|
|
56d25d |
+ else
|
|
|
56d25d |
+ search --no-floppy --fs-uuid --set=root cae02b39-f239-4d26-9032-674d261c93d8
|
|
|
56d25d |
+ fi
|
|
|
56d25d |
+ linux16 /vmlinuz-3.10.0-296.el7.x86_64 root=/dev/mapper/rhel_hp--dl380pgen8--02--vm--10-root ro crashkernel=auto rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/root rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/swap console=ttyS0,115200n81 $tuned_params
|
|
|
56d25d |
+ initrd16 /initramfs-3.10.0-296.el7.x86_64.img
|
|
|
56d25d |
+}
|
|
|
56d25d |
+menuentry 'Red Hat Enterprise Linux Server (0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7-advanced-ae7b3742-9092-4432-9f7f-8abdbf0dc3db' {
|
|
|
56d25d |
+ load_video
|
|
|
56d25d |
+ insmod gzio
|
|
|
56d25d |
+ insmod part_msdos
|
|
|
56d25d |
+ insmod xfs
|
|
|
56d25d |
+ set root='hd0,msdos1'
|
|
|
56d25d |
+ if [ x$feature_platform_search_hint = xy ]; then
|
|
|
56d25d |
+ search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' cae02b39-f239-4d26-9032-674d261c93d8
|
|
|
56d25d |
+ else
|
|
|
56d25d |
+ search --no-floppy --fs-uuid --set=root cae02b39-f239-4d26-9032-674d261c93d8
|
|
|
56d25d |
+ fi
|
|
|
56d25d |
+ linux16 /vmlinuz-0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7 root=/dev/mapper/rhel_hp--dl380pgen8--02--vm--10-root ro crashkernel=auto rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/root rd.lvm.lv=rhel_hp-dl380pgen8-02-vm-10/swap console=ttyS0,115200n81 $tuned_params
|
|
|
56d25d |
+ initrd16 /initramfs-0-rescue-cc21b92886f9ebbd3ed5a494639b7fd7.img
|
|
|
56d25d |
+}
|
|
|
56d25d |
+if [ "x$default" = 'Red Hat Enterprise Linux Server (3.10.0-296.el7.x86_64) 7.2 (Maipo)' ]; then default='Advanced options for Red Hat Enterprise Linux Server>Red Hat Enterprise Linux Server (3.10.0-296.el7.x86_64) 7.2 (Maipo)'; fi;
|
|
|
56d25d |
+### END /etc/grub.d/10_linux ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/20_linux_xen ###
|
|
|
56d25d |
+### END /etc/grub.d/20_linux_xen ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/20_ppc_terminfo ###
|
|
|
56d25d |
+### END /etc/grub.d/20_ppc_terminfo ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/30_os-prober ###
|
|
|
56d25d |
+### END /etc/grub.d/30_os-prober ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/40_custom ###
|
|
|
56d25d |
+# This file provides an easy way to add custom menu entries. Simply type the
|
|
|
56d25d |
+# menu entries you want to add after this comment. Be careful not to change
|
|
|
56d25d |
+# the 'exec tail' line above.
|
|
|
56d25d |
+### END /etc/grub.d/40_custom ###
|
|
|
56d25d |
+
|
|
|
56d25d |
+### BEGIN /etc/grub.d/41_custom ###
|
|
|
56d25d |
+if [ -f ${config_directory}/custom.cfg ]; then
|
|
|
56d25d |
+ source ${config_directory}/custom.cfg
|
|
|
56d25d |
+elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
|
|
|
56d25d |
+ source $prefix/custom.cfg;
|
|
|
56d25d |
+fi
|
|
|
56d25d |
+### END /etc/grub.d/41_custom ###
|
|
|
56d25d |
--
|
|
|
56d25d |
2.4.3
|
|
|
56d25d |
|