From af5b3db6c0abe7cb3091b9e7448db4485079de8d Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 06 2019 10:59:47 +0000 Subject: import grubby-8.28-26.el7 --- diff --git a/SOURCES/0077-Fix-incorrect-test-case-and-remove-args-with-a-value.patch b/SOURCES/0077-Fix-incorrect-test-case-and-remove-args-with-a-value.patch new file mode 100644 index 0000000..2b55585 --- /dev/null +++ b/SOURCES/0077-Fix-incorrect-test-case-and-remove-args-with-a-value.patch @@ -0,0 +1,168 @@ +From 605367b51d425df0bbbcca830e6fe0c50895c83f Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 27 Sep 2017 11:28:00 -0400 +Subject: [PATCH] Fix incorrect test case and --remove-args with a value. + +Currently we have this test case: + + grubTest grub.3 updargs/g3.4 --update-kernel=ALL --remove-args="hdd=foobar" + +This fails to notice that the actual argument in grub.3 is hdd=ide-scsi, +and removes it anyway, and the data in g3.4 supports that behavior. +This is clearly wrong, and so this patch introduces updargs/g3.5, which +leaves hdd=ide-scsi intact, and fixes the code so that it won't modify +the command line in that case. + +Resolves: rhbz#1476273 + +Signed-off-by: Peter Jones +--- + grubby.c | 71 ++++++++++++++++++++++++++++++++------- + test.sh | 2 +- + test/results/updargs/g3.5 | 16 +++++++++ + 3 files changed, 76 insertions(+), 13 deletions(-) + create mode 100644 test/results/updargs/g3.5 + +diff --git a/grubby.c b/grubby.c +index 5202485a5411..863ec4e7ef0b 100644 +--- a/grubby.c ++++ b/grubby.c +@@ -3536,23 +3536,67 @@ static void removeElement(struct singleLine *line, int removeHere) + line->numElements--; + } + +-int argMatch(const char *one, const char *two) ++static int argNameMatch(const char *one, const char *two) + { + char *first, *second; +- char *chptr; ++ char *chptra, *chptrb; ++ int rc; + + first = strcpy(alloca(strlen(one) + 1), one); + second = strcpy(alloca(strlen(two) + 1), two); + +- chptr = strchr(first, '='); +- if (chptr) +- *chptr = '\0'; ++ chptra = strchr(first, '='); ++ if (chptra) ++ *chptra = '\0'; + +- chptr = strchr(second, '='); ++ chptrb = strchr(second, '='); ++ if (chptrb) ++ *chptrb = '\0'; ++ ++ rc = strcmp(first, second); ++ ++ if (chptra) ++ *chptra = '='; ++ if (chptrb) ++ *chptrb = '='; ++ ++ return rc; ++} ++ ++static int argHasValue(const char *arg) ++{ ++ char *chptr; ++ ++ chptr = strchr(arg, '='); + if (chptr) +- *chptr = '\0'; ++ return 1; ++ return 0; ++} ++ ++static int argValueMatch(const char *one, const char *two) ++{ ++ char *first, *second; ++ char *chptra, *chptrb; ++ ++ first = strcpy(alloca(strlen(one) + 1), one); ++ second = strcpy(alloca(strlen(two) + 1), two); + +- return strcmp(first, second); ++ chptra = strchr(first, '='); ++ if (chptra) ++ chptra += 1; ++ ++ chptrb = strchr(second, '='); ++ if (chptrb) ++ chptrb += 1; ++ ++ if (!chptra && !chptrb) ++ return 0; ++ else if (!chptra) ++ return *chptrb - 0; ++ else if (!chptrb) ++ return 0 - *chptra; ++ else ++ return strcmp(chptra, chptrb); + } + + int updateActualImage(struct grubConfig *cfg, const char *image, +@@ -3696,7 +3740,7 @@ int updateActualImage(struct grubConfig *cfg, const char *image, + } + if (usedElements[i]) + continue; +- if (!argMatch(line->elements[i].item, *arg)) { ++ if (!argNameMatch(line->elements[i].item, *arg)) { + usedElements[i] = 1; + break; + } +@@ -3755,9 +3799,12 @@ int updateActualImage(struct grubConfig *cfg, const char *image, + !strcmp(line->elements[i].item, "--")) + /* reached the end of hyper args, stop here */ + break; +- if (!argMatch(line->elements[i].item, *arg)) { +- removeElement(line, i); +- break; ++ if (!argNameMatch(line->elements[i].item, *arg)) { ++ if (!argHasValue(*arg) || ++ !argValueMatch(line->elements[i].item, *arg)) { ++ removeElement(line, i); ++ break; ++ } + } + } + /* handle removing LT_ROOT line too */ +diff --git a/test.sh b/test.sh +index 533bda0acbf5..b5fe21ca5850 100755 +--- a/test.sh ++++ b/test.sh +@@ -386,7 +386,7 @@ grubTest grub.3 updargs/g3.2 --update-kernel=DEFAULT \ + --args "root=/dev/hdd1 hdd=notide-scsi" + grubTest grub.3 updargs/g3.4 --update-kernel=ALL --remove-args="hdd" + grubTest grub.3 updargs/g3.4 --update-kernel=ALL --remove-args="hdd=ide-scsi" +-grubTest grub.3 updargs/g3.4 --update-kernel=ALL --remove-args="hdd=foobar" ++grubTest grub.3 updargs/g3.5 --update-kernel=ALL --remove-args="hdd=foobar" + grubTest grub.3 updargs/g3.7 --update-kernel=ALL \ + --remove-args="hdd root ro" + grubTest grub.7 updargs/g7.2 --boot-filesystem=/ \ +diff --git a/test/results/updargs/g3.5 b/test/results/updargs/g3.5 +new file mode 100644 +index 000000000000..7d50bb87d845 +--- /dev/null ++++ b/test/results/updargs/g3.5 +@@ -0,0 +1,16 @@ ++#boot=/dev/hda ++timeout=10 ++splashimage=(hd0,1)/grub/splash.xpm.gz ++title Red Hat Linux (2.4.7-2smp) ++ root (hd0,1) ++ kernel /vmlinuz-2.4.7-2smp ro root=/dev/hda5 hdd=ide-scsi ++ initrd /initrd-2.4.7-2smp.img ++title Red Hat Linux-up (2.4.7-2) ++ root (hd0,1) ++ kernel /vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi ++ initrd /initrd-2.4.7-2.img ++title DOS ++ rootnoverify (hd0,0) ++ chainloader +1 ++ ++ +-- +2.17.1 + diff --git a/SOURCES/0078-Check-that-pointers-are-not-NULL-before-dereferencin.patch b/SOURCES/0078-Check-that-pointers-are-not-NULL-before-dereferencin.patch new file mode 100644 index 0000000..ba3523d --- /dev/null +++ b/SOURCES/0078-Check-that-pointers-are-not-NULL-before-dereferencin.patch @@ -0,0 +1,37 @@ +From c3d6d7dd1feb5a7f02778304a5233cf882c651c4 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Fri, 15 Mar 2019 10:14:42 +0100 +Subject: [PATCH] Check that pointers are not NULL before dereferencing them + +The coverity scan complains that the argValueMatch() function derefences +the chptra and chptrb pointers when these may be NULL. That's not really +true since the function first checks if both aren't NULL and then only +dereferences one when the other is NULL. + +But still this confuses coverity, so to make it happy let's just check +if the pointer isn't NULL before derefencing them. + +Signed-off-by: Javier Martinez Canillas +--- + grubby.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grubby.c b/grubby.c +index 947b45895fc..9c506aeb438 100644 +--- a/grubby.c ++++ b/grubby.c +@@ -3761,9 +3761,9 @@ static int argValueMatch(const char *one, const char *two) + + if (!chptra && !chptrb) + return 0; +- else if (!chptra) ++ else if (!chptra && chptrb) + return *chptrb - 0; +- else if (!chptrb) ++ else if (!chptrb && chptra) + return 0 - *chptra; + else + return strcmp(chptra, chptrb); +-- +2.20.1 + diff --git a/SOURCES/0079-Improve-man-page-for-info-option.patch b/SOURCES/0079-Improve-man-page-for-info-option.patch new file mode 100644 index 0000000..f8d0c72 --- /dev/null +++ b/SOURCES/0079-Improve-man-page-for-info-option.patch @@ -0,0 +1,30 @@ +From e15806969cbae83a94068d99e4f1d295dab95eac Mon Sep 17 00:00:00 2001 +From: Jan Stodola +Date: Tue, 20 Nov 2018 15:02:19 +0100 +Subject: [PATCH] Improve man page for --info option + +1) commit 941d4a0b removed description of --info DEFAULT +2) Add description of --info ALL +--- + grubby.8 | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/grubby.8 b/grubby.8 +index 1e8f140c4df..8b98433960c 100644 +--- a/grubby.8 ++++ b/grubby.8 +@@ -185,7 +185,10 @@ Display the title of the current default boot entry and exit. + + .TP + \fB-\-info\fR=\fIkernel-path\fR +-Display information on all boot entries which match \fIkernel-path\fR. I ++Display information on all boot entries which match \fIkernel-path\fR. If ++\fIkernel-path\fR is \fBDEFAULT\fR, then information on the default kernel ++is displayed. If \fIkernel-path\fR is \fBALL\fR, then information on all boot ++entries are displayed. + + .TP + \fB-\-bootloader-probe\fR +-- +2.20.1 + diff --git a/SOURCES/0080-Print-default-image-even-if-isn-t-a-suitable-one.patch b/SOURCES/0080-Print-default-image-even-if-isn-t-a-suitable-one.patch new file mode 100644 index 0000000..a9e1db0 --- /dev/null +++ b/SOURCES/0080-Print-default-image-even-if-isn-t-a-suitable-one.patch @@ -0,0 +1,50 @@ +From ee49b7b71d017097be5b4a0f32bff83379b0a86e Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Mon, 18 Mar 2019 12:53:23 +0100 +Subject: [PATCH] Print default image even if isn't a suitable one + +The grubby --default-kernel option only prints the default kernel if this +is a suitable one. That is if its associated kernel cmdline root param is +the same than the partition currently mounted as the filesystem root. + +But the grubby --set-default option doesn't have that restriction, it is +able to set a kernel as the default even if its root is for a different +partition. So make the --default-kernel option to also print the kernel +in this case. Still check if is a suitable image so --debug can tell it. + +Resolves: rhbz#1323842 + +Signed-off-by: Javier Martinez Canillas +--- + grubby.c | 5 +++-- + test/results/debug/g2.1 | 1 + + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/grubby.c b/grubby.c +index 9c506aeb438..a7f823cb58c 100644 +--- a/grubby.c ++++ b/grubby.c +@@ -5531,8 +5531,9 @@ int main(int argc, const char **argv) + entry = findEntryByIndex(config, config->defaultImage); + if (!entry) + return 0; +- if (!suitableImage(entry, bootPrefix, 0, flags)) +- return 0; ++ ++ /* check if is a suitable image but still print it */ ++ suitableImage(entry, bootPrefix, 0, flags); + + line = + getLineByType(LT_KERNEL | LT_HYPER | LT_KERNEL_EFI | +diff --git a/test/results/debug/g2.1 b/test/results/debug/g2.1 +index f5187f5f4b5..d579b59e59f 100644 +--- a/test/results/debug/g2.1 ++++ b/test/results/debug/g2.1 +@@ -12,3 +12,4 @@ DBG: linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root + DBG: echo 'Loading initial ramdisk ...' + DBG: initrd /initramfs-2.6.38.8-32.fc15.x86_64.img + DBG: } ++/boot/vmlinuz-2.6.38.8-32.fc15.x86_64 +-- +2.20.1 + diff --git a/SPECS/grubby.spec b/SPECS/grubby.spec index 6690aa5..edbe503 100644 --- a/SPECS/grubby.spec +++ b/SPECS/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.28 -Release: 25%{?dist} +Release: 26%{?dist} Summary: Command line tool for updating bootloader configs Group: System Environment/Base License: GPLv2+ @@ -83,13 +83,17 @@ Patch0073: 0073-Fix-info-for-s390x-s390-1285601.patch Patch0074: 0074-Add-s390-s390x-set-default-index-test-1285601.patch Patch0075: 0075-Fix-setDefaultImage-for-s390-s390x-1285601.patch Patch0076: 0076-grubby-Make-sure-configure-BOOTLOADER-variables-are-.patch +Patch0077: 0077-Fix-incorrect-test-case-and-remove-args-with-a-value.patch +Patch0078: 0078-Check-that-pointers-are-not-NULL-before-dereferencin.patch +Patch0079: 0079-Improve-man-page-for-info-option.patch +Patch0080: 0080-Print-default-image-even-if-isn-t-a-suitable-one.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: pkgconfig glib2-devel popt-devel BuildRequires: libblkid-devel git # for make test / getopt: BuildRequires: util-linux-ng -%ifarch aarch64 i686 x86_64 ppc ppc64 +%ifarch aarch64 x86_64 ppc ppc64 BuildRequires: grub2-tools-minimal %endif %ifarch s390 s390x @@ -100,6 +104,8 @@ Requires: uboot-tools %endif Requires: system-release +ExcludeArch: %{?ix86} + %description grubby is a command line tool for updating and displaying information about the configuration files for the grub, lilo, elilo (ia64), yaboot (powerpc) @@ -160,6 +166,16 @@ rm -rf $RPM_BUILD_ROOT %endif %changelog +* Mon Mar 18 2019 Javier Martinez Canillas - 8.28-26 +- Exclude building on i686 + Related: rhbz#1476273 +- Fix grubby removing wrong kernel command line parameter + Resolves: rhbz#1476273 +- Improve man page for --info option (jstodola) + Resolves: rhbz#1651673 +- Print default image even if isn't a suitable one + Resolves: rhbz#1323842 + * Tue Aug 14 2018 Peter Jones - 8.28-25 - Ensure /etc/sysconfig/kernel has a stable mode, now that rpm handles ghost files differently.