Commit graph

563 commits

Author SHA1 Message Date
Javier Martinez Canillas
2724adb931
Make blscfg to support the GRUB_{SAVEDEFAULT,CMDLINE_LINUX_DEFAULT} options
These two options were not supported on a BLS configuration.

Resolves: rhbz#1704926

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-01-13 17:55:18 +01:00
Javier Martinez Canillas
0539c2ea03
Drop patch fixing a corner case in BLS variable expansion
There is a bug reported about a system failing to boot with the latest pkg
and the only relevant change was this patch. Drop it just to be sure since
it is fixing a corner case in variable expansion so is not worth the risk.

Related: rhbz#1779611

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-12-05 10:39:12 +01:00
Javier Martinez Canillas
23822b2470
Fix a grub hidden-menu regression and a bug in blscfg variable expansion
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-11-27 16:52:41 +01:00
Javier Martinez Canillas
2878d37def
grub-set-bootflag: Write new env to tmpfile and then rename
Resolves: CVE-2019-14865
Resolves: rhbz#1776580

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-11-26 10:57:00 +01:00
Javier Martinez Canillas
d1ac398c52
A couple of BLS fixes
99-grub-mkconfig: Also disable BLS usage for Xen Dom0 hosts
  Resolves: rhbz#1761799
blscfg: Fix typo for gfxpayload variable name
  Resolves: rhbz#1706489

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-10-16 12:25:29 +02:00
Javier Martinez Canillas
2e8e92930e
99-grub-mkconfig: Also disable BLS usage for Xen Dom0 hosts
A previous patch disabled BLS usage for Xen Dom0 guests but it turns out
that Xen Dom0 hosts also need to regenerate a GRUB config file since the
menuentries used aren't the generated by 10_linux but by 20_linux_xen.

Resolves: rhbz#1761799

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Tested-by: Steven Haigh <netwiz@crc.id.au>
2019-10-16 11:55:32 +02:00
Javier Martinez Canillas
ac6bc3ed8d
99-grub-mkconfig: Fix script condition to exit and remove ppc64 BE check
The ppc64 big endian support ended in F29 and only ppc64le is supported so
there's no need to check for this architecture.

Also the script wasn't properly tested and the check for Xen DomU machines
isn't correct. Fix the test condition to exit the script.

Related: rhbz#1703700

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-10-10 09:29:05 +02:00
Javier Martinez Canillas
3561ca9ef6
99-grub-mkconfig: Disable BLS usage for Xen DomU guests
GRUB is used to boot Xen Dom0 hosts so BLS is supported there, but PV and
PVH Xen DomU guests are booted with pygrub that doesn't have BLS support.

This means that only HVM Xen DomU guests can support BLS and others need
a traditional GRUB configuration file that contains menuentry commands.

So to make the GRUB config compatible with all Xen DomU guests, don't use
the BLS snippets and instead call grub2-mkconfig to regenerate the config
on each kernel install and removal.

Even when HVM Xen DomU guests can support BLS, just disable for all DomU
so the configuration is consistent across all Xen DomU guests variants.

And also because even when an installation is made with HVM, this can be
later changed to a DomU variant that uses pygrub and doesn't support BLS.

Resolves: rhbz#1703700

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Tested-by: Steven Haigh <netwiz@crc.id.au>
2019-10-09 16:52:50 +02:00
Javier Martinez Canillas
53711828a3
Don't try to switch to a BLS config if GRUB_ENABLE_BLSCFG is already set
There's no point on executing the script if GRUB_ENABLE_BLSCFG has already
been set. Currently was checking if an user explicitly set it to false to
avoid enabling the BLS configuration, but it should also be avoided if was
already set to true by a previous package update or during installation.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-05-20 19:08:11 +02:00
Javier Martinez Canillas
4c3c0c390f
Fix error messages wrongly being printed when executing blscfg command
Resolves: rhbz#1699761

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-05-15 11:50:23 +02:00
Javier Martinez Canillas
f52f8fe0ab
Make blscfg module compatible at least up to the Fedora 19 GRUB core
The blscfg module isn't compatible with the GRUB core.img installed by any
release older than Fedora 21.

This is because the blscfg module calls to the grub_file_size() function to
check if the BLS file size is correct, but the struct grub_file used as the
parameter for this function changed in the GRUB version used in Fedora 21.

So the function returns a wrong file size due the .size field offset being
different in the older GRUB from Fedora 20 and earlier.

This is causing all the BLS files to be ignored due having a wrong size and
leading to GRUB menu not being populated on boot.

Related: rhbz#1652806

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-05-08 14:47:56 +02:00
Javier Martinez Canillas
e95ccc7ba6
Add 10_reset_boot_success to Makefile
This was missed when the script got added.

Related: rhbz#1701003

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-04-18 19:25:57 +02:00
Javier Martinez Canillas
fded58021e
Fix fallback not working when output is serial and a HTTP boot bug
Resolves: rhbz#1701003

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-04-18 12:47:43 +02:00
Javier Martinez Canillas
50f79d8617
Execute grub2-switch-to-blscfg script in %posttrans instead of %post
The GRUB configuration is switched to BLS using the grub2-switch-to-blscfg
script, which is installed by the grub2-tools package. Among other things,
the script copies the blscfg module from the /usr/lib/grub/$arch directory
to /boot/grub2/$arch.

This is done because for non-UEFI installs (i386-pc and powerpc-ieee1275)
the GRUB core and modules aren't updated on package upgrade, so the blscfg
module won't be the latest that contains the current BLS support.

But the grub2-switch-to-blscfg script is currently executed in grub2-tools
%post scritplet, which means that if the grub2-tools package is installed
before the grub2-pc-modules package (that installs the blscfg module), the
grub2-switch-to-blscfg script won't copy the latest version of the module.

This will make systems to fail to populate the GRUB menu, since its config
will already be migrated to BLS but the blscfg module won't be the latest.

So to make sure that the latest blscfg module is copied regardless of the
grub2-tools and grub2-pc-modules packages install order, run the switch
script in a grub2-tools %posttrans so it's executed at the end of the RPM
transaction once all the packages have been installed.

Resolves: rhbz#1652806

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-04-15 17:49:07 +02:00
Javier Martinez Canillas
115e0f60fa
10_linux_bls: don't add --users option to generated menu entries
The generated menu entries have a --users $grub_users option but this will
fail on old versions of GRUB, since it expects the --users option argument
to either be a constant or a variable that has been set.

The latest GRUB version fix this but the GRUB core isn't updated on a GRUB
package update, so this will cause the entries to not be shown in the menu
after a system upgrade.

Since can cause issues and because the entries that weren't generated from
the BLS snippets didn't have the --users option either, just don't add it.

Resolves: rhbz#1693515

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-03-28 17:24:52 +01:00
Javier Martinez Canillas
89b65757a9
Two more BLS fixes
Only set blsdir if /boot/loader/entries is in a btrfs or zfs partition
  Related: rhbz#1688453
Fix some BLS snippets not being displayed in the GRUB menu
  Resolves: rhbz#1691232

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-03-22 16:02:15 +01:00
bbe7d2e505
Do not remove boot loader configuration for other boot loaders 2019-03-12 11:25:59 +01:00
Javier Martinez Canillas
c916dad5b6
Two more fixes
Avoid grub2-efi package to overwrite existing /boot/grub2/grubenv file
  Resolves: rhbz#1687323
Switch to BLS in tools package %%post scriptlet
  Resolves: rhbz#1652806

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-03-11 13:26:39 +01:00
Javier Martinez Canillas
c31e801897
Switch to BLS in tools package %post scriptlet
The switch to a BLS configuration was made before in the grubby package
%post scriptlet, but this is wrong since it means that a not up-do-date
grub2-switch-to-blscfg script could be used to do the switch.

Resolves: rhbz#1652806

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-03-11 13:26:39 +01:00
Javier Martinez Canillas
b9750a4853
Avoid grub2-efi package to overwrite existing /boot/grub2/grubenv file
The grub2-efi package create a /boot/grub2/grubenv symlink that points to
/boot/efi/EFI/fedora/grubenv that's where the real grubenv file is looked
up by GRUB on an EFI installation.

But currently if the grub2-efi is installed on a legacy BIOS install, it
will overwrite an existing /boot/grub2/grubenv file with a broken symlink.

So mark it as %config(noreplace) to avoid loosing an existing grubenv.

Resolves: rhbz#1687323

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-03-11 13:26:39 +01:00
Javier Martinez Canillas
388b8a4e20
Some BLS fixes
20-grub-install: Replace, rather than overwrite, the existing kernel (pjones)
  Resolves: rhbz#1642402
99-grub-mkconfig: Don't update grubenv generating entries on ppc64le
  Related: rhbz#1637875
blscfg: fallback to default_kernelopts if BLS option field isn't set
  Related: rhbz#1625124
grub-switch-to-blscfg: copy increment.mod for legacy BIOS and ppc64
  Resolves: rhbz#1652806

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-02-27 19:12:53 +01:00
Javier Martinez Canillas
6882a13215
99-grub-mkconfig: Don't update grubenv generating entries on ppc64le
The grubenv file is updated when grub-mkconfig is executed but on ppc64le
is used on each kernel install to re-generate the grub2.cfg file with the
updated entries. So in this case the grubenv file should not be updated.

Related: rhbz#1637875

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-02-26 16:15:34 +01:00
Peter Jones
ca870c05c4
20-grub-install: Replace, rather than overwrite, the existing kernel.
In rhbz#1638405, we worked around the issue of an existing initramfs
being in the way by removing it if it's older than the kernel we're in
the process of installing.

But it was buggy and only worked with some filesystem layouts and paths, and
also possibly had some issues with file creation times causing the shell -ot
comparison to fail in some cases.

This patch changes it to remove the existing kernel (as well as other
related files) in the case that it's going to do the copy, and also fixes the
path issues.

Resolves: rhbz#1642402
Related: rhbz#1638405

Signed-off-by: Peter Jones <pjones@redhat.com>
Tested-by: Prarit Bhargava <prarit@redhat.com>
2019-02-26 16:15:33 +01:00
Javier Martinez Canillas
f6d4ab8f83
Check if blsdir exists before attempting to get it's real path
Resolves: rhbz#1677415

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-02-15 18:22:18 +01:00
Javier Martinez Canillas
e3a408a521
A couple of fixes
Don't make grub_strtoull() print an error if no conversion is performed
  Resolves: rhbz#1674512
Set blsdir if the BLS directory path isn't one of the looked up by default
  Resolves: rhbz#1657240

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-02-13 13:41:46 +01:00
Javier Martinez Canillas
11b49b804e
BLS support enhancements and some fixes
- Don't build the grub2-efi-ia32-* packages on i686 (pjones)
- Add efi-export-env and efi-load-env commands (pjones)
- Make it possible to subtract conditions from debug= (pjones)
- Try to set -fPIE and friends on libgnu.a (pjones)
- Add more options to blscfg command to make it more flexible
- Add support for prepend early initrds to the BLS entries
- Fix grub.cfg-XXX look up when booting over TFTP

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-02-04 19:28:49 +01:00
Fedora Release Engineering
5699af497f - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-02-01 01:37:54 +00:00
Igor Gnatenko
3463a4b800 Remove obsolete Group tag
References: https://fedoraproject.org/wiki/Changes/Remove_Group_Tag
2019-01-28 20:24:06 +01:00
Igor Gnatenko
23b6ae2b79
Remove obsolete scriptlets
References: https://fedoraproject.org/wiki/Changes/RemoveObsoleteScriptlets
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2019-01-27 19:01:54 +01:00
Javier Martinez Canillas
bb036b8233
Don't exclude /etc/grub.d/01_fallback_counting anymore
This was causing issues but it should be fixed now.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-12-17 12:58:43 +01:00
Javier Martinez Canillas
4ff5f8dcef
Another set of BLS fixes
BLS files should only be copied by grub-switch-to-blscfg if BLS isn't set
  Related: rhbz#1638117
Fix get_entry_number() wrongly dereferencing the tail pointer
  Resolves: rhbz#1654936
Make grub2-mkconfig to honour GRUB_CMDLINE_LINUX in /etc/default/grub
  Resolves: rhbz#1637875

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-12-11 20:23:51 +01:00
Javier Martinez Canillas
1f092caba7
Drop two efinet patches that were causing issues and a bunch of other fixes
Add comments and revert logic changes in 01_fallback_counting
Remove quotes when reading ID value from /etc/os-release
  Related: rhbz#1650706
blscfg: expand grub_users before passing to grub_normal_add_menu_entry()
  Resolves: rhbz#1650706
Drop buggy downstream patch "efinet: retransmit if our device is busy"
  Resolves: rhbz#1649048
Make the menu entry users option argument to be optional
  Related: rhbz#1652434
10_linux_bls: add missing menu entries options
  Resolves: rhbz#1652434
Drop "Be more aggro about actually using the *configured* network device."
  Resolves: rhbz#1654388
Fix menu entry selection based on title
  Resolves: rhbz#1654936

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-12-01 03:28:36 +01:00
Javier Martinez Canillas
f92a00c4b3
Remove installkernel-bls script
The installkernel-bls script is present in both the grub2-common and
grubby packages. But there's no need for this duplication and it can
just be installed by the grubby package.

Related: rhbz#1647721

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-11-21 10:06:17 +01:00
Javier Martinez Canillas
ff9dc1ed7d
Don't unconditionally set default entry when installing debug kernels
If a debug kernel package is installed, the default entry should only
be set when DEFAULTDEBUG=yes is set in /etc/sysconfig/kernel.

Resolves: rhbz#1636346

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-26 14:25:04 +02:00
Javier Martinez Canillas
420527a50b
A bunch of fixes for BLS
- add 10_linux_bls grub.d snippet to generate menu entries from BLS files
  Resolves: rhbz#1636013
- Only set kernelopts in grubenv if it wasn't set before
  Resolves: rhbz#1636466
- kernel-install: Remove existing initramfs if it's older than the kernel (pjones)
  Resolves: rhbz#1638405
- Update the saved entry correctly after a kernel install (pjones)
  Resolves: rhbz#1638117
- blscfg: sort everything with rpm *package* comparison (pjones)
  Related: rhbz#1638103
- blscfg: Make 10_linux_bls sort the same way as well
  Related: rhbz#1638103
- don't set saved_entry on grub2-mkconfig
  Resolves: rhbz#1636466
- Fix menu entry selection based on ID and title (pjones)
  Resolves: rhbz#1640979

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-23 15:57:56 +02:00
Javier Martinez Canillas
efb46dff18
20-grub.install: use ~debug instead of -debug as suffix to sort correctly
For the debug BLS entries a -debug suffix was added so they are sorted after
the kernel entries, but that only works with version sort and not rpm sort.

So instead use ~debug prefix so rpm sort algorithm could sort it correctly.

Related: rhbz#1638103

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-23 12:23:25 +02:00
Peter Jones
67aea4f8a5
kernel-install: Remove existing initramfs if it's older than the kernel
Currently we fail to install a new kernel with "make install" on the second
try, because dracut won't over-write the initramfs without --force.  In this
patch, 20-grub.install will remove an existing initramfs if it's newer than the
kernel we're installing.

Resolves: rhbz#1638405
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-10-23 12:23:25 +02:00
Peter Jones
66078fcba2
Update the saved entry correctly after a kernel install.
Resolves: rhbz#1638117

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-10-23 12:23:25 +02:00
Javier Martinez Canillas
682540cbf5
do-rebase: add more options to not depend on the user git configuration
The patches generated by do-rebase depend on the user having core.abbrv=11
in their .gitconfig and also a diff.orderFile set.

These assumptions were removed for the git format-patch command by passing
all the configuration as options, but it was still present for git diff.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2018-10-23 12:23:21 +02:00
Peter Jones
db4a99687c Exclude /etc/grub.d/01_fallback_counting until we work through some design
questions.
  Resolves: rhbz#1614637

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-10-04 17:11:21 -04:00
Peter Jones
7531222057 Fix the fallback counting script even harder. Apparently, this wasn't
tested well enough.
  Resolves: rhbz#1614637

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-10-03 15:57:52 -04:00
Peter Jones
a3bfe35d12 Various bug fixes
- Fix grub.cfg boot counting snippet generation (lorbus)
  Resolves: rhbz#1614637
- Fix spurrious allocation error reporting on EFI boot
  Resolves: rhbz#1635319
- Stop doing TPM on BIOS *again*.  It just doesn't work.
  Related: rhbz#1579835
- Make blscfg module loadable on older grub2 i386-pc and powerpc-ieee1275
  builds
- Fix execstack cropping up in grub2-tools
- Ban stack trampolines with compiler flags.

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-10-02 13:40:52 -04:00
Hans de Goede
ace3c257a6 Stop using pkexec for grub2-set-bootflag
Stop using pkexec for grub2-set-bootflag, it does not work under gdm instead
make it suid root (it was written with this in mind)

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-09-25 14:11:00 -04:00
Peter Jones
e30274adfa More EFI memory allocator work.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-09-25 14:10:22 -04:00
Peter Jones
c4e6bf30f6 Some more bug fixes and just some general hygiene.
Add 2 conditions to boot-success timer and service:
  Don't run it for system users
  Resolves: rhbz#1592201
  Don't run it when pkexec isn't available
  Resolves: rhbz#1619445
Use -Wsign-compare -Wconversion -Wextra in the build.
  Related: rhbz#1624532
  Related: rhbz#1626844

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-09-12 10:36:43 -04:00
Peter Jones
98536ecf37 Once more into the breach, dear friends.
- Limit grub_malloc() on x86_64 to < 31bit addresses, as some devices seem to
  have a colossally broken storage controller (or UEFI driver) that can't do
  DMA to higher memory addresses, but fails silently.
  Resolves: rhbz#1626844 (possibly really resolving it this time.)
- Also integrate Hans's attempt to fix the related error from -54, but do it
  the other way around: try the low addresses first and *then* the high one if
  the allocation fails.  This way we'll get low regions by default, and if
  kernel/initramfs don't fit anywhere, it'll try the higher addresses.
  Related: rhbz#1624532
- Coalesce all the intermediate debugging junk from -54/-55/-56.

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-09-11 18:08:44 -04:00
Peter Jones
371309b06e More bug "fixes"...
Don't mangle fw_path even harder.
  Resolves: rhbz#1626844
Fix reboot being missing on some platforms, and make it alias to
  "reset" as well.
More dprintf().

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-09-11 11:07:08 -04:00
Peter Jones
5376ad0c95 Fix 'reboot' command
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-09-11 10:44:46 -04:00
Peter Jones
543f7e2717 Fix a typo...
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-09-10 17:39:02 -04:00
Peter Jones
76df8270f6 Several fixes.
Fix UEFI memory problem in a different way.
  Related: rhbz#1624532
Don't mangle fw_path with a / unless we're on http
  Resolves: rhbz#1626844

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-09-10 17:32:30 -04:00