Compare commits

...

No commits in common. "c8" and "c10s" have entirely different histories.
c8 ... c10s

730 changed files with 18832 additions and 80429 deletions

15
.git.diff.order Normal file
View File

@ -0,0 +1,15 @@
*.dec
*.dsc.inc
*.dsc
*.fdf
*.inf
*.vfr
*.ac
*.def
*.c
*.h
*.S
*.mk
Makefile.*
Make.*
Makefile

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
po/exclude.pot binary

22
.gitignore vendored
View File

@ -1,9 +1,13 @@
SOURCES/grub-2.02.tar.xz
SOURCES/redhatsecureboot301.cer
SOURCES/redhatsecureboot502.cer
SOURCES/redhatsecureboot601.cer
SOURCES/redhatsecureboot701.cer
SOURCES/redhatsecurebootca3.cer
SOURCES/redhatsecurebootca5.cer
SOURCES/theme.tar.bz2
SOURCES/unifont-5.1.20080820.pcf.gz
grub-*.tar.?z
*.rpm
clog
/unifont-*.pcf.?z
/theme.tar.bz2
kojilogs
/grub-*/
.build*.log
.*.git/
tmp/
.*.sw?
results_grub2/
/gnulib-*.tar.?z

View File

@ -1,9 +0,0 @@
3d7eb6eaab28b88cb969ba9ab24af959f4d1b178 SOURCES/grub-2.02.tar.xz
4a07b56e28741884b86da6ac91f8f9929541a1e4 SOURCES/redhatsecureboot301.cer
3f94c47f1d08bacc7cb29bdd912e286b8d2f6fcf SOURCES/redhatsecureboot502.cer
039357ef97aab3e484d1119edd4528156f5859e6 SOURCES/redhatsecureboot601.cer
e89890ca0ded2f9058651cc5fa838b78db2e6cc2 SOURCES/redhatsecureboot701.cer
cf9230e69000076727e5b784ec871d22716dc5da SOURCES/redhatsecurebootca3.cer
e6f506462069aa17d2e8610503635c20f3a995c3 SOURCES/redhatsecurebootca5.cer
cf0b7763c528902da7e8b05cfa248f20c8825ce5 SOURCES/theme.tar.bz2
87f8600ba24e521b5d20bdf6c4b71af8ae861e3a SOURCES/unifont-5.1.20080820.pcf.gz

View File

@ -0,0 +1,24 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Fri, 11 Jun 2021 12:10:45 +0200
Subject: [PATCH] Revert "templates: Fix user-facing typo with an incorrect use
of "it's""
This reverts commit 722737630889607c3b5761f1f5a48f1674cd2821.
---
util/grub.d/30_os-prober.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
index 656301eaf22..376ca47efe4 100644
--- a/util/grub.d/30_os-prober.in
+++ b/util/grub.d/30_os-prober.in
@@ -36,7 +36,7 @@ if ! command -v os-prober > /dev/null || ! command -v linux-boot-prober > /dev/n
exit 0
fi
-grub_warn "$(gettext_printf "os-prober will be executed to detect other bootable partitions.\nIts output will be used to detect bootable binaries on them and create new boot entries.")"
+grub_warn "$(gettext_printf "os-prober will be executed to detect other bootable partitions.\nIt's output will be used to detect bootable binaries on them and create new boot entries.")"
OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"
if [ -z "${OSPROBED}" ] ; then

View File

@ -0,0 +1,71 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Fri, 11 Jun 2021 12:10:54 +0200
Subject: [PATCH] Revert "templates: Properly disable the os-prober by default"
This reverts commit 54e0a1bbf1e9106901a557195bb35e5e20fb3925.
---
util/grub-mkconfig.in | 5 +----
util/grub.d/30_os-prober.in | 8 ++++----
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index 32c480daeb2..7516a015be0 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -140,9 +140,6 @@ GRUB_DEVICE_PARTUUID="`${grub_probe} --device ${GRUB_DEVICE} --target=partuuid 2
GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
-# Disable os-prober by default due to security reasons.
-GRUB_DISABLE_OS_PROBER="true"
-
# Filesystem for the device containing our userland. Used for stuff like
# choosing Hurd filesystem module.
GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`"
@@ -204,7 +201,6 @@ export GRUB_DEVICE \
GRUB_DEVICE_PARTUUID \
GRUB_DEVICE_BOOT \
GRUB_DEVICE_BOOT_UUID \
- GRUB_DISABLE_OS_PROBER \
GRUB_FS \
GRUB_FONT \
GRUB_PRELOAD_MODULES \
@@ -250,6 +246,7 @@ export GRUB_DEFAULT \
GRUB_BACKGROUND \
GRUB_THEME \
GRUB_GFXPAYLOAD_LINUX \
+ GRUB_DISABLE_OS_PROBER \
GRUB_INIT_TUNE \
GRUB_SAVEDEFAULT \
GRUB_ENABLE_CRYPTODISK \
diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
index 376ca47efe4..30f27f15b83 100644
--- a/util/grub.d/30_os-prober.in
+++ b/util/grub.d/30_os-prober.in
@@ -26,8 +26,8 @@ export TEXTDOMAINDIR="@localedir@"
. "$pkgdatadir/grub-mkconfig_lib"
-if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
- grub_warn "$(gettext_printf "os-prober will not be executed to detect other bootable partitions.\nSystems on them will not be added to the GRUB boot configuration.\nCheck GRUB_DISABLE_OS_PROBER documentation entry.")"
+if [ "x${GRUB_DISABLE_OS_PROBER}" = "xfalse" ]; then
+ gettext_printf "os-prober will not be executed to detect other bootable partitions.\nSystems on them will not be added to the GRUB boot configuration.\nCheck GRUB_DISABLE_OS_PROBER documentation entry.\n"
exit 0
fi
@@ -36,12 +36,12 @@ if ! command -v os-prober > /dev/null || ! command -v linux-boot-prober > /dev/n
exit 0
fi
-grub_warn "$(gettext_printf "os-prober will be executed to detect other bootable partitions.\nIt's output will be used to detect bootable binaries on them and create new boot entries.")"
-
OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"
if [ -z "${OSPROBED}" ] ; then
# empty os-prober output, nothing doing
exit 0
+else
+ grub_warn "$(gettext_printf "os-prober was executed to detect other bootable partitions.\nIt's output will be used to detect bootable binaries on them and create new boot entries.")"
fi
osx_entry() {

View File

@ -0,0 +1,70 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Fri, 11 Jun 2021 12:10:58 +0200
Subject: [PATCH] Revert "templates: Disable the os-prober by default"
This reverts commit e346414725a70e5c74ee87ca14e580c66f517666.
---
docs/grub.texi | 18 ++++++++----------
util/grub.d/30_os-prober.in | 5 +----
2 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/docs/grub.texi b/docs/grub.texi
index a225f9a88d2..974bc0ddb07 100644
--- a/docs/grub.texi
+++ b/docs/grub.texi
@@ -1552,13 +1552,10 @@ boot sequence. If you have problems, set this option to @samp{text} and
GRUB will tell Linux to boot in normal text mode.
@item GRUB_DISABLE_OS_PROBER
-The @command{grub-mkconfig} has a feature to use the external
-@command{os-prober} program to discover other operating systems installed on
-the same machine and generate appropriate menu entries for them. It is disabled
-by default since automatic and silent execution of @command{os-prober}, and
-creating boot entries based on that data, is a potential attack vector. Set
-this option to @samp{false} to enable this feature in the
-@command{grub-mkconfig} command.
+Normally, @command{grub-mkconfig} will try to use the external
+@command{os-prober} program, if installed, to discover other operating
+systems installed on the same system and generate appropriate menu entries
+for them. Set this option to @samp{true} to disable this.
@item GRUB_OS_PROBER_SKIP_LIST
List of space-separated FS UUIDs of filesystems to be ignored from os-prober
@@ -1889,9 +1886,10 @@ than zero; otherwise 0.
@section Multi-boot manual config
Currently autogenerating config files for multi-boot environments depends on
-os-prober and has several shortcomings. Due to that it is disabled by default.
-It is advised to use the power of GRUB syntax and do it yourself. A possible
-configuration is detailed here, feel free to adjust to your needs.
+os-prober and has several shortcomings. While fixing it is scheduled for the
+next release, meanwhile you can make use of the power of GRUB syntax and do it
+yourself. A possible configuration is detailed here, feel free to adjust to your
+needs.
First create a separate GRUB partition, big enough to hold GRUB. Some of the
following entries show how to load OS installer images from this same partition,
diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
index 30f27f15b83..f300e46fc6a 100644
--- a/util/grub.d/30_os-prober.in
+++ b/util/grub.d/30_os-prober.in
@@ -26,8 +26,7 @@ export TEXTDOMAINDIR="@localedir@"
. "$pkgdatadir/grub-mkconfig_lib"
-if [ "x${GRUB_DISABLE_OS_PROBER}" = "xfalse" ]; then
- gettext_printf "os-prober will not be executed to detect other bootable partitions.\nSystems on them will not be added to the GRUB boot configuration.\nCheck GRUB_DISABLE_OS_PROBER documentation entry.\n"
+if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
exit 0
fi
@@ -40,8 +39,6 @@ OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"
if [ -z "${OSPROBED}" ] ; then
# empty os-prober output, nothing doing
exit 0
-else
- grub_warn "$(gettext_printf "os-prober was executed to detect other bootable partitions.\nIt's output will be used to detect bootable binaries on them and create new boot entries.")"
fi
osx_entry() {

View File

@ -6,15 +6,17 @@ Subject: [PATCH] Rework linux command
We want a single buffer that contains the entire kernel image in order to
perform a TPM measurement. Allocate one and copy the entire kernel into it
before pulling out the individual blocks later on.
Signed-off-by: Matthew Garrett <mjg59@coreos.com>
---
grub-core/loader/i386/linux.c | 37 ++++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)
grub-core/loader/i386/linux.c | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
index 9b53d3168..f7186be40 100644
index 977757f2cc9..10f967f2563 100644
--- a/grub-core/loader/i386/linux.c
+++ b/grub-core/loader/i386/linux.c
@@ -685,13 +685,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
@@ -661,13 +661,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
{
grub_file_t file = 0;
struct linux_i386_kernel_header lh;
@ -31,7 +33,7 @@ index 9b53d3168..f7186be40 100644
grub_dl_ref (my_mod);
@@ -705,7 +707,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
@@ -681,7 +683,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
if (! file)
goto fail;
@ -48,7 +50,7 @@ index 9b53d3168..f7186be40 100644
{
if (!grub_errno)
grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
@@ -713,6 +723,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
@@ -689,6 +699,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
goto fail;
}
@ -58,33 +60,25 @@ index 9b53d3168..f7186be40 100644
if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55))
{
grub_error (GRUB_ERR_BAD_OS, "invalid magic number");
@@ -804,6 +817,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
preferred_address))
goto fail;
@@ -796,13 +809,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
/* We've already read lh so there is no need to read it second time. */
len -= sizeof(lh);
+
grub_memset (&linux_params, 0, sizeof (linux_params));
grub_memcpy (&linux_params.setup_sects, &lh.setup_sects, sizeof (lh) - 0x1F1);
@@ -812,13 +826,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
linux_params.ps_mouse = linux_params.padding10 = 0;
len = sizeof (linux_params) - sizeof (lh);
- if (grub_file_read (file, (char *) &linux_params + sizeof (lh), len) != len)
- {
- if ((len > 0) &&
- (grub_file_read (file, (char *) &linux_params + sizeof (lh), len) != len))
+ linux_params_ptr = (void *)&linux_params;
+ if (len > 0)
{
- if (!grub_errno)
- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
- argv[0]);
- goto fail;
- }
+
+ linux_params_ptr = (void *)&linux_params;
+ grub_memcpy (linux_params_ptr + sizeof (lh), kernel + kernel_offset, len);
+ kernel_offset += len;
+ grub_memcpy (linux_params_ptr + sizeof (lh), kernel + kernel_offset, len);
+ kernel_offset += len;
}
linux_params.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE;
@@ -877,7 +888,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
linux_params.code32_start = prot_mode_target + lh.code32_start - GRUB_LINUX_BZIMAGE_ADDR;
@@ -865,7 +876,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
/* The other parameters are filled when booting. */
@ -93,8 +87,8 @@ index 9b53d3168..f7186be40 100644
grub_dprintf ("linux", "bzImage, setup=0x%x, size=0x%x\n",
(unsigned) real_size, (unsigned) prot_size);
@@ -1025,9 +1036,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
- (sizeof (LINUX_IMAGE) - 1));
@@ -1019,9 +1030,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
}
len = prot_file_size;
- if (grub_file_read (file, prot_mode_mem, len) != len && !grub_errno)
@ -104,7 +98,7 @@ index 9b53d3168..f7186be40 100644
if (grub_errno == GRUB_ERR_NONE)
{
@@ -1038,6 +1047,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
@@ -1032,6 +1041,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
fail:

View File

@ -6,15 +6,17 @@ Subject: [PATCH] Rework linux16 command
We want a single buffer that contains the entire kernel image in order to
perform a TPM measurement. Allocate one and copy the entire kernel int it
before pulling out the individual blocks later on.
Signed-off-by: Matthew Garrett <mjg59@coreos.com>
---
grub-core/loader/i386/pc/linux.c | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
grub-core/loader/i386/pc/linux.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c
index a3c87cf2f..caa76bee8 100644
index 4adeee9ae00..600530a742b 100644
--- a/grub-core/loader/i386/pc/linux.c
+++ b/grub-core/loader/i386/pc/linux.c
@@ -123,13 +123,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
@@ -124,13 +124,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
grub_file_t file = 0;
struct linux_i386_kernel_header lh;
grub_uint8_t setup_sects;
@ -30,7 +32,7 @@ index a3c87cf2f..caa76bee8 100644
grub_dl_ref (my_mod);
@@ -143,7 +144,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
@@ -144,7 +145,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
if (! file)
goto fail;
@ -47,7 +49,7 @@ index a3c87cf2f..caa76bee8 100644
{
if (!grub_errno)
grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
@@ -151,6 +160,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
@@ -152,6 +161,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
goto fail;
}
@ -57,7 +59,7 @@ index a3c87cf2f..caa76bee8 100644
if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55))
{
grub_error (GRUB_ERR_BAD_OS, "invalid magic number");
@@ -314,13 +326,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
@@ -320,13 +332,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
grub_memmove (grub_linux_real_chunk, &lh, sizeof (lh));
len = real_size + GRUB_DISK_SECTOR_SIZE - sizeof (lh);
@ -74,12 +76,11 @@ index a3c87cf2f..caa76bee8 100644
if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
|| grub_le_to_cpu16 (lh.version) < 0x0200)
@@ -355,10 +363,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
@@ -364,9 +372,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
}
len = grub_linux16_prot_size;
- if (grub_file_read (file, grub_linux_prot_chunk, grub_linux16_prot_size)
- != (grub_ssize_t) grub_linux16_prot_size && !grub_errno)
- if (grub_file_read (file, grub_linux_prot_chunk, len) != len && !grub_errno)
- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
- argv[0]);
+ grub_memcpy (grub_linux_prot_chunk, kernel + kernel_offset, len);
@ -87,7 +88,7 @@ index a3c87cf2f..caa76bee8 100644
if (grub_errno == GRUB_ERR_NONE)
{
@@ -368,6 +374,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
@@ -376,6 +383,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
fail:

View File

@ -0,0 +1,246 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 8 Jul 2019 12:55:29 +0200
Subject: [PATCH] re-write .gitignore
---
.gitignore | 150 ++++++++++++++++++++++++++++++++++++++
docs/.gitignore | 5 ++
grub-core/.gitignore | 16 ++++
grub-core/lib/.gitignore | 1 +
include/grub/gcrypt/.gitignore | 2 +
po/.gitignore | 5 ++
util/bash-completion.d/.gitignore | 2 +
7 files changed, 181 insertions(+)
create mode 100644 docs/.gitignore
create mode 100644 grub-core/.gitignore
create mode 100644 grub-core/lib/.gitignore
create mode 100644 include/grub/gcrypt/.gitignore
create mode 100644 po/.gitignore
create mode 100644 util/bash-completion.d/.gitignore
diff --git a/.gitignore b/.gitignore
index 4d0dfb700e4..a18787dcfe6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -279,3 +279,153 @@ widthspec.bin
/xfs_test
/xzcompress_test
/zfs_test
+=======
+# things ./autogen.sh will create
+/Makefile.utilgcry.def
+/ABOUT-NLS
+/aclocal.m4
+/autom4te.cache
+/build-aux
+/configure
+/gnulib
+/grub-core/lib/gnulib/
+/Makefile
+
+# things very common editors create that we never want
+*~
+.*.sw?
+*.patch
+
+# stuff you're likely to make while building test trees
+grub.cfg
+/build*/
+
+# built objects across the whole tree
+Makefile.in
+*.a
+*.am
+*.efi
+*.exec
+*.image
+*.img
+*.info
+*.lst
+*.marker
+/m4
+*.mod
+*.module
+*.o
+*.pf2
+*.yy.[ch]
+.deps/
+.deps-core/
+.deps-util/
+.dirstamp
+
+# next are things you get if you do ./configure in the topdir (for e.g.
+# "make dist" invocation.
+/config-util.h
+/config.h
+/include/grub/cpu
+/include/grub/machine
+/INSTALL
+/INSTALL.grub
+/po/Makefile.in.in
+/po/Makevars
+/po/Makevars.template
+/po/POTFILES
+/po/Rules-quot
+/stamp-h
+/stamp-h1
+bootstrap.log
+config.log
+config.status
+
+# stuff "make dist" creates
+ChangeLog
+grub-*.tar
+grub-*.tar.*
+
+# stuff "make" creates
+/[[:digit:]][[:digit:]]_?*
+/ascii.h
+/build-grub-gen-asciih
+/build-grub-gen-widthspec
+/build-grub-mkfont
+/config-util.h.in
+/garbage-gen
+/grub*-bios-setup
+/grub*-bios-setup.8
+/grub*-editenv
+/grub*-editenv.1
+/grub*-file
+/grub*-file.1
+/grub*-fs-tester
+/grub*-fstest
+/grub*-fstest.1
+/grub*-get-kernel-settings
+/grub*-get-kernel-settings.3
+/grub*-glue-efi
+/grub*-glue-efi.1
+/grub*-install
+/grub*-install.8
+/grub*-kbdcomp
+/grub*-kbdcomp.1
+/grub*-macbless
+/grub*-macbless.8
+/grub*-menulst2cfg
+/grub*-menulst2cfg.1
+/grub*-mount
+/grub*-mount.1
+/grub*-mkconfig
+/grub*-mkconfig.8
+/grub*-mkconfig_lib
+/grub*-mkfont
+/grub*-mkfont.1
+/grub*-mkimage
+/grub*-mkimage.1
+/grub*-mklayout
+/grub*-mklayout.1
+/grub*-mknetdir
+/grub*-mknetdir.1
+/grub*-mkpasswd-pbkdf2
+/grub*-mkpasswd-pbkdf2.1
+/grub*-mkrelpath
+/grub*-mkrelpath.1
+/grub*-mkrescue
+/grub*-mkrescue.1
+/grub*-mkstandalone
+/grub*-mkstandalone.1
+/grub*-ofpathname
+/grub*-ofpathname.8
+/grub*-probe
+/grub*-probe.8
+/grub*-reboot
+/grub*-reboot.8
+/grub*-render-label
+/grub*-render-label.1
+/grub*-script-check
+/grub*-script-check.1
+/grub*-set-bootflag
+/grub*-set-bootflag.1
+/grub*-set-default
+/grub*-set-default.8
+/grub*-set-password
+/grub*-set-password.8
+/grub*-shell
+/grub*-shell-tester
+/grub*-sparc64-setup
+/grub*-sparc64-setup.8
+/grub*-syslinux2cfg
+/grub*-syslinux2cfg.1
+/grub*-switch-to-blscfg
+/grub*-switch-to-blscfg.8
+/grub_fstest.pp
+/grub_fstest_init.c
+/grub_fstest_init.lst
+/grub_script.tab.[ch]
+/libgrub.pp
+/libgrub_a_init.c
+/libgrub_a_init.lst
+/stamp-h.in
+/widthspec.h
diff --git a/docs/.gitignore b/docs/.gitignore
new file mode 100644
index 00000000000..e1d849ef95b
--- /dev/null
+++ b/docs/.gitignore
@@ -0,0 +1,5 @@
+/*.in
+/Makefile
+/stamp-1
+/stamp-vti
+/version*.texi
diff --git a/grub-core/.gitignore b/grub-core/.gitignore
new file mode 100644
index 00000000000..2acce281159
--- /dev/null
+++ b/grub-core/.gitignore
@@ -0,0 +1,16 @@
+/*.lst
+/Makefile
+/Makefile.gcry.def
+/unidata.c
+/build-grub-module-verifier
+/gdb_grub
+/genmod.sh
+/gensyminfo.sh
+/gentrigtables
+/gmodule.pl
+/grub_script.tab.[ch]
+/modinfo.sh
+/rs_decoder.h
+/symlist.c
+/symlist.h
+/trigtables.c
diff --git a/grub-core/lib/.gitignore b/grub-core/lib/.gitignore
new file mode 100644
index 00000000000..68154591404
--- /dev/null
+++ b/grub-core/lib/.gitignore
@@ -0,0 +1 @@
+/libgcrypt-grub/
diff --git a/include/grub/gcrypt/.gitignore b/include/grub/gcrypt/.gitignore
new file mode 100644
index 00000000000..8fbf5646246
--- /dev/null
+++ b/include/grub/gcrypt/.gitignore
@@ -0,0 +1,2 @@
+g10lib.h
+gcrypt.h
diff --git a/po/.gitignore b/po/.gitignore
new file mode 100644
index 00000000000..f507e7741e3
--- /dev/null
+++ b/po/.gitignore
@@ -0,0 +1,5 @@
+/Makefile
+/POTFILES*.in
+/grub.pot
+/remove-potcdate.sed
+/stamp-po
diff --git a/util/bash-completion.d/.gitignore b/util/bash-completion.d/.gitignore
new file mode 100644
index 00000000000..6813a527ad3
--- /dev/null
+++ b/util/bash-completion.d/.gitignore
@@ -0,0 +1,2 @@
+Makefile
+grub

View File

@ -7,16 +7,20 @@ This is an implementation of IBM client architecture (CAS) reboot for GRUB.
There are cases where the POWER firmware must reboot in order to support
specific features requested by a kernel. The kernel calls
ibm,client-architecture-support and it may either return or reboot with the new
feature set. eg:
ibm,client-architecture-support and it may either return or reboot with
the new feature set. eg:
Calling ibm,client-architecture-support.../
Elapsed time since release of system processors: 70959 mins 50 secs
Welcome to GRUB!
Instead of return to the GRUB menu, it will check if the flag for CAS reboot is
set. If so, grub will automatically boot the last booted kernel using the same
parameters
Instead of return to the GRUB menu, it will check if the flag for CAS
reboot is set. If so, grub will automatically boot the last booted
kernel using the same parameters
Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
[rharwood@redhat.com: commit message rewrap]
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/kern/ieee1275/openfw.c | 63 ++++++++++++++++++++++++++++++++++++++++
grub-core/normal/main.c | 19 ++++++++++++
@ -25,10 +29,10 @@ parameters
4 files changed, 91 insertions(+)
diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c
index 62929d983..2d53c0e86 100644
index 11b2beb2ff2..e2ecc65d2d8 100644
--- a/grub-core/kern/ieee1275/openfw.c
+++ b/grub-core/kern/ieee1275/openfw.c
@@ -588,3 +588,66 @@ grub_ieee1275_get_boot_dev (void)
@@ -591,3 +591,66 @@ grub_ieee1275_get_boot_dev (void)
return bootpath;
}
@ -96,10 +100,10 @@ index 62929d983..2d53c0e86 100644
+ return 0;
+}
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index 78a70a8bf..249e19bc7 100644
index bd44310005d..d3f53d93d87 100644
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -33,6 +33,9 @@
@@ -34,6 +34,9 @@
#include <grub/charset.h>
#include <grub/script_sh.h>
#include <grub/bufio.h>
@ -109,7 +113,7 @@ index 78a70a8bf..249e19bc7 100644
GRUB_MOD_LICENSE ("GPLv3+");
@@ -275,6 +278,22 @@ grub_normal_execute (const char *config, int nested, int batch)
@@ -276,6 +279,22 @@ grub_normal_execute (const char *config, int nested, int batch)
{
menu = read_config_file (config);
@ -133,20 +137,20 @@ index 78a70a8bf..249e19bc7 100644
grub_errno = GRUB_ERR_NONE;
}
diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c
index a8502d907..ab78ca87f 100644
index 14ff09094f0..dab8fd2aeb0 100644
--- a/grub-core/script/execute.c
+++ b/grub-core/script/execute.c
@@ -27,6 +27,9 @@
#include <grub/normal.h>
@@ -28,6 +28,9 @@
#include <grub/extcmd.h>
#include <grub/i18n.h>
#include <grub/verify.h>
+#ifdef GRUB_MACHINE_IEEE1275
+#include <grub/ieee1275/ieee1275.h>
+#endif
/* Max digits for a char is 3 (0xFF is 255), similarly for an int it
is sizeof (int) * 3, and one extra for a possible -ve sign. */
@@ -877,6 +880,10 @@ grub_script_execute_sourcecode (const char *source)
@@ -883,6 +886,10 @@ grub_script_execute_sourcecode (const char *source)
grub_err_t ret = 0;
struct grub_script *parsed_script;
@ -158,10 +162,10 @@ index a8502d907..ab78ca87f 100644
{
char *line;
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
index 8868f3a75..2310f33db 100644
index dddb385149e..4f6e6aaa098 100644
--- a/include/grub/ieee1275/ieee1275.h
+++ b/include/grub/ieee1275/ieee1275.h
@@ -252,6 +252,8 @@ int EXPORT_FUNC(grub_ieee1275_devalias_next) (struct grub_ieee1275_devalias *ali
@@ -251,6 +251,8 @@ int EXPORT_FUNC(grub_ieee1275_devalias_next) (struct grub_ieee1275_devalias *ali
void EXPORT_FUNC(grub_ieee1275_children_peer) (struct grub_ieee1275_devalias *alias);
void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath,
struct grub_ieee1275_devalias *alias);

View File

@ -10,12 +10,14 @@ This should fix this bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=908519
Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/term/terminfo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c
index d317efa36..29df35e6d 100644
index 4e534c683eb..3dbe88e8933 100644
--- a/grub-core/term/terminfo.c
+++ b/grub-core/term/terminfo.c
@@ -151,7 +151,7 @@ grub_terminfo_set_current (struct grub_term_output *term,

View File

@ -5,6 +5,9 @@ Subject: [PATCH] Disable GRUB video support for IBM power machines
Should fix the problem in bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=973205
Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/kern/ieee1275/cmain.c | 5 ++++-
grub-core/video/ieee1275.c | 9 ++++++---
@ -12,10 +15,10 @@ https://bugzilla.redhat.com/show_bug.cgi?id=973205
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c
index 3e12e6b24..3e14f5393 100644
index e74de32483f..810a089a934 100644
--- a/grub-core/kern/ieee1275/cmain.c
+++ b/grub-core/kern/ieee1275/cmain.c
@@ -90,7 +90,10 @@ grub_ieee1275_find_options (void)
@@ -89,7 +89,10 @@ grub_ieee1275_find_options (void)
}
if (rc >= 0 && grub_strncmp (tmp, "IBM", 3) == 0)
@ -28,10 +31,10 @@ index 3e12e6b24..3e14f5393 100644
/* Old Macs have no key repeat, newer ones have fully working one.
The ones inbetween when repeated key generates an escaoe sequence
diff --git a/grub-core/video/ieee1275.c b/grub-core/video/ieee1275.c
index 17a3dbbb5..b8e4b3feb 100644
index ca3d3c3b2c8..5592e4bb7c9 100644
--- a/grub-core/video/ieee1275.c
+++ b/grub-core/video/ieee1275.c
@@ -352,9 +352,12 @@ static struct grub_video_adapter grub_video_ieee1275_adapter =
@@ -351,9 +351,12 @@ static struct grub_video_adapter grub_video_ieee1275_adapter =
GRUB_MOD_INIT(ieee1275_fb)
{
@ -48,13 +51,13 @@ index 17a3dbbb5..b8e4b3feb 100644
GRUB_MOD_FINI(ieee1275_fb)
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
index 2310f33db..ca08bd966 100644
index 4f6e6aaa098..db0ec5f4c68 100644
--- a/include/grub/ieee1275/ieee1275.h
+++ b/include/grub/ieee1275/ieee1275.h
@@ -146,6 +146,8 @@ enum grub_ieee1275_flag
GRUB_IEEE1275_FLAG_BROKEN_REPEAT,
@@ -145,6 +145,8 @@ enum grub_ieee1275_flag
GRUB_IEEE1275_FLAG_POWER_VM,
GRUB_IEEE1275_FLAG_CURSORONOFF_ANSI_BROKEN,
GRUB_IEEE1275_FLAG_POWER_KVM,
+
+ GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT
};

View File

@ -10,10 +10,10 @@ Apparently these go in a new place now.
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index c7888e40f..783118ccd 100644
index cd667a2eb75..ae3a49321ad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -289,6 +289,14 @@ AC_SUBST(grubdirname)
@@ -319,6 +319,14 @@ AC_SUBST(grubdirname)
AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
[Default grub directory name])
@ -28,7 +28,7 @@ index c7888e40f..783118ccd 100644
#
# Checks for build programs.
#
@@ -498,6 +506,9 @@ HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags"
@@ -534,6 +542,9 @@ HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags"
# Check for target programs.
#
@ -39,7 +39,7 @@ index c7888e40f..783118ccd 100644
if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
tmp_ac_tool_prefix="$ac_tool_prefix"
diff --git a/util/bash-completion.d/Makefile.am b/util/bash-completion.d/Makefile.am
index 136287cf1..61108f054 100644
index 136287cf1bf..61108f05429 100644
--- a/util/bash-completion.d/Makefile.am
+++ b/util/bash-completion.d/Makefile.am
@@ -6,7 +6,6 @@ EXTRA_DIST = $(bash_completion_source)

View File

@ -12,10 +12,10 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
1 file changed, 58 insertions(+), 27 deletions(-)
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
index e7a83c2d6..d2f64b05e 100644
index 6a90e091f22..6444ee6f969 100644
--- a/grub-core/normal/menu.c
+++ b/grub-core/normal/menu.c
@@ -163,16 +163,41 @@ grub_menu_set_timeout (int timeout)
@@ -163,15 +163,40 @@ grub_menu_set_timeout (int timeout)
}
}
@ -51,14 +51,13 @@ index e7a83c2d6..d2f64b05e 100644
-get_and_remove_first_entry_number (const char *name)
+get_and_remove_first_entry_number (grub_menu_t menu, const char *name)
{
const char *val;
char *tail;
const char *val, *tail;
int entry;
+ int sz = 0;
val = grub_env_get (name);
if (! val)
@@ -182,9 +207,39 @@ get_and_remove_first_entry_number (const char *name)
@@ -181,9 +206,39 @@ get_and_remove_first_entry_number (const char *name)
entry = (int) grub_strtoul (val, &tail, 0);
@ -99,7 +98,7 @@ index e7a83c2d6..d2f64b05e 100644
while (*tail && grub_isspace (*tail))
tail++;
grub_env_set (name, tail);
@@ -347,7 +402,7 @@ grub_menu_execute_with_fallback (grub_menu_t menu,
@@ -346,7 +401,7 @@ grub_menu_execute_with_fallback (grub_menu_t menu,
grub_menu_execute_entry (entry, 1);
/* Deal with fallback entries. */
@ -108,7 +107,7 @@ index e7a83c2d6..d2f64b05e 100644
>= 0)
{
grub_print_error ();
@@ -465,30 +520,6 @@ grub_menu_register_viewer (struct grub_menu_viewer *viewer)
@@ -464,30 +519,6 @@ grub_menu_register_viewer (struct grub_menu_viewer *viewer)
viewers = viewer;
}

View File

@ -13,24 +13,24 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
grub-core/commands/minicmd.c | 20 ++++++++++++++++----
grub-core/kern/efi/efi.c | 9 +++++++--
grub-core/kern/emu/main.c | 2 +-
grub-core/kern/emu/misc.c | 5 +++--
grub-core/kern/emu/misc.c | 9 +++++----
grub-core/kern/i386/coreboot/init.c | 2 +-
grub-core/kern/i386/qemu/init.c | 2 +-
grub-core/kern/ieee1275/init.c | 2 +-
grub-core/kern/mips/arc/init.c | 2 +-
grub-core/kern/mips/loongson/init.c | 2 +-
grub-core/kern/mips/qemu_mips/init.c | 2 +-
grub-core/kern/misc.c | 2 +-
grub-core/kern/misc.c | 11 ++++++++++-
grub-core/kern/uboot/init.c | 6 +++---
grub-core/kern/xen/init.c | 2 +-
include/grub/misc.h | 2 +-
14 files changed, 39 insertions(+), 21 deletions(-)
14 files changed, 50 insertions(+), 23 deletions(-)
diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c
index a3a118241..b25ca4b9f 100644
index fa498931ed2..2bd3ac76f2d 100644
--- a/grub-core/commands/minicmd.c
+++ b/grub-core/commands/minicmd.c
@@ -176,12 +176,24 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)),
@@ -182,12 +182,24 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)),
}
/* exit */
@ -60,10 +60,10 @@ index a3a118241..b25ca4b9f 100644
}
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
index 708581fcb..e339f264b 100644
index b93ae3aba12..885d7c6420e 100644
--- a/grub-core/kern/efi/efi.c
+++ b/grub-core/kern/efi/efi.c
@@ -164,11 +164,16 @@ grub_reboot (void)
@@ -175,11 +175,16 @@ grub_reboot (void)
}
void
@ -76,14 +76,14 @@ index 708581fcb..e339f264b 100644
+ rc = GRUB_EFI_SUCCESS;
+
grub_machine_fini (GRUB_LOADER_FLAG_NORETURN);
efi_call_4 (grub_efi_system_table->boot_services->exit,
- grub_efi_image_handle, GRUB_EFI_SUCCESS, 0, 0);
+ grub_efi_image_handle, rc, 0, 0);
grub_efi_system_table->boot_services->exit (grub_efi_image_handle,
- GRUB_EFI_SUCCESS, 0, 0);
+ rc, 0, 0);
for (;;) ;
}
diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c
index 425bb9603..55ea5a11c 100644
index 855b11c3dec..38c1576a2ef 100644
--- a/grub-core/kern/emu/main.c
+++ b/grub-core/kern/emu/main.c
@@ -67,7 +67,7 @@ grub_reboot (void)
@ -96,10 +96,19 @@ index 425bb9603..55ea5a11c 100644
grub_reboot ();
}
diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c
index 76661337f..82012a72f 100644
index 521220b49d2..16c79bc9488 100644
--- a/grub-core/kern/emu/misc.c
+++ b/grub-core/kern/emu/misc.c
@@ -137,9 +137,10 @@ xasprintf (const char *fmt, ...)
@@ -83,7 +83,7 @@ grub_util_error (const char *fmt, ...)
vfprintf (stderr, fmt, ap);
va_end (ap);
fprintf (stderr, ".\n");
- grub_exit ();
+ grub_exit (1);
}
void *
@@ -152,12 +152,13 @@ xasprintf (const char *fmt, ...)
#if !defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL)
void
@ -107,13 +116,17 @@ index 76661337f..82012a72f 100644
+__attribute__ ((noreturn))
+grub_exit (int rc)
{
-#if defined (GRUB_KERNEL)
+#if defined (GRUB_KERNEL) && !defined (GRUB_MACHINE_EFI)
grub_reboot ();
#endif
- exit (1);
+ exit (rc < 0 ? 1 : rc);
}
#endif
diff --git a/grub-core/kern/i386/coreboot/init.c b/grub-core/kern/i386/coreboot/init.c
index 3314f027f..36f9134b7 100644
index 4fae8b571f1..feaf9295e30 100644
--- a/grub-core/kern/i386/coreboot/init.c
+++ b/grub-core/kern/i386/coreboot/init.c
@@ -41,7 +41,7 @@ extern grub_uint8_t _end[];
@ -126,7 +139,7 @@ index 3314f027f..36f9134b7 100644
/* We can't use grub_fatal() in this function. This would create an infinite
loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */
diff --git a/grub-core/kern/i386/qemu/init.c b/grub-core/kern/i386/qemu/init.c
index 271b6fbfa..9fafe98f0 100644
index 08f81d25e68..604fc94b5a0 100644
--- a/grub-core/kern/i386/qemu/init.c
+++ b/grub-core/kern/i386/qemu/init.c
@@ -42,7 +42,7 @@ extern grub_uint8_t _end[];
@ -139,11 +152,11 @@ index 271b6fbfa..9fafe98f0 100644
/* We can't use grub_fatal() in this function. This would create an infinite
loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
index 0d8ebf58b..f5423ce27 100644
index fb7d1a3bacf..50c65b2f6e5 100644
--- a/grub-core/kern/ieee1275/init.c
+++ b/grub-core/kern/ieee1275/init.c
@@ -68,7 +68,7 @@ grub_addr_t grub_ieee1275_original_stack;
#endif
@@ -114,7 +114,7 @@ grub_addr_t grub_ieee1275_original_stack;
#define BYTE22 (DY_MEM_V2 | DRC_INFO)
void
-grub_exit (void)
@ -152,7 +165,7 @@ index 0d8ebf58b..f5423ce27 100644
grub_ieee1275_exit ();
}
diff --git a/grub-core/kern/mips/arc/init.c b/grub-core/kern/mips/arc/init.c
index 3834a1490..86b3a25ec 100644
index 2ed3ff3191e..5c40c34078d 100644
--- a/grub-core/kern/mips/arc/init.c
+++ b/grub-core/kern/mips/arc/init.c
@@ -276,7 +276,7 @@ grub_halt (void)
@ -165,7 +178,7 @@ index 3834a1490..86b3a25ec 100644
GRUB_ARC_FIRMWARE_VECTOR->exit ();
diff --git a/grub-core/kern/mips/loongson/init.c b/grub-core/kern/mips/loongson/init.c
index 7b96531b9..dff598ca7 100644
index 5bd721260f6..97b09b0eeea 100644
--- a/grub-core/kern/mips/loongson/init.c
+++ b/grub-core/kern/mips/loongson/init.c
@@ -304,7 +304,7 @@ grub_halt (void)
@ -178,7 +191,7 @@ index 7b96531b9..dff598ca7 100644
grub_halt ();
}
diff --git a/grub-core/kern/mips/qemu_mips/init.c b/grub-core/kern/mips/qemu_mips/init.c
index be88b77d2..8b6c55ffc 100644
index b5477b87ffa..69488a34e7c 100644
--- a/grub-core/kern/mips/qemu_mips/init.c
+++ b/grub-core/kern/mips/qemu_mips/init.c
@@ -75,7 +75,7 @@ grub_machine_fini (int flags __attribute__ ((unused)))
@ -191,10 +204,10 @@ index be88b77d2..8b6c55ffc 100644
grub_halt ();
}
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index 3b633d51f..952411d5d 100644
index 7cee5d75c3c..11037dc0227 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -1095,7 +1095,7 @@ grub_abort (void)
@@ -1311,9 +1311,18 @@ grub_abort (void)
grub_getkey ();
}
@ -202,9 +215,20 @@ index 3b633d51f..952411d5d 100644
+ grub_exit (1);
}
+#if defined (__clang__) && !defined (GRUB_UTIL)
+/* clang emits references to abort(). */
+void __attribute__ ((noreturn))
+abort (void)
+{
+ grub_abort ();
+}
+#endif
+
void
grub_fatal (const char *fmt, ...)
{
diff --git a/grub-core/kern/uboot/init.c b/grub-core/kern/uboot/init.c
index 3e338645c..be2a5be1d 100644
index 3e338645c57..be2a5be1d07 100644
--- a/grub-core/kern/uboot/init.c
+++ b/grub-core/kern/uboot/init.c
@@ -39,9 +39,9 @@ extern grub_size_t grub_total_module_size;
@ -229,10 +253,10 @@ index 3e338645c..be2a5be1d 100644
else if (ver > API_SIG_VERSION)
{
diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c
index 0559c033c..fce526d41 100644
index 782ca72952a..708b060f324 100644
--- a/grub-core/kern/xen/init.c
+++ b/grub-core/kern/xen/init.c
@@ -549,7 +549,7 @@ grub_machine_init (void)
@@ -584,7 +584,7 @@ grub_machine_init (void)
}
void
@ -242,15 +266,15 @@ index 0559c033c..fce526d41 100644
struct sched_shutdown arg;
diff --git a/include/grub/misc.h b/include/grub/misc.h
index 372f009e8..83fd69f4a 100644
index 1b35a167fde..72aff15750d 100644
--- a/include/grub/misc.h
+++ b/include/grub/misc.h
@@ -334,7 +334,7 @@ int EXPORT_FUNC(grub_vsnprintf) (char *str, grub_size_t n, const char *fmt,
char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...)
@@ -385,7 +385,7 @@ char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...)
__attribute__ ((format (GNU_PRINTF, 1, 2))) WARN_UNUSED_RESULT;
char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args) WARN_UNUSED_RESULT;
-void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn));
+void EXPORT_FUNC(grub_exit) (int rc) __attribute__ ((noreturn));
void EXPORT_FUNC(grub_abort) (void) __attribute__ ((noreturn));
grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n,
grub_uint64_t d,
grub_uint64_t *r);

View File

@ -6,30 +6,38 @@ Subject: [PATCH] Make efi machines load an env block from a variable
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/Makefile.core.def | 1 +
grub-core/kern/efi/init.c | 34 +++++++++++++++++++++++++++++++++-
2 files changed, 34 insertions(+), 1 deletion(-)
grub-core/kern/efi/init.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index e92a7ef32..f80653882 100644
index 1571421d7e8..0bffbfea917 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -191,6 +191,7 @@ kernel = {
efi = term/efi/console.c;
efi = kern/acpi.c;
@@ -219,6 +219,7 @@ kernel = {
efi = kern/efi/acpi.c;
efi = kern/efi/sb.c;
efi = kern/lockdown.c;
+ efi = lib/envblk.c;
i386_coreboot = kern/i386/pc/acpi.c;
i386_multiboot = kern/i386/pc/acpi.c;
i386_coreboot = kern/acpi.c;
diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c
index 3dfdf2d22..71d2279a0 100644
index 6c54af6e79e..b5201974a76 100644
--- a/grub-core/kern/efi/init.c
+++ b/grub-core/kern/efi/init.c
@@ -25,9 +25,40 @@
@@ -28,8 +28,11 @@
#include <grub/env.h>
#include <grub/mm.h>
#include <grub/kernel.h>
+
#include <grub/stack_protector.h>
+#include <grub/lib/envblk.h>
+
#ifdef GRUB_STACK_PROTECTOR
static grub_efi_char16_t stack_chk_fail_msg[] =
@@ -103,6 +106,36 @@ stack_protector_init (void)
grub_addr_t grub_modbase;
@ -50,12 +58,12 @@ index 3dfdf2d22..71d2279a0 100644
+static void
+grub_efi_env_init (void)
+{
+ grub_efi_guid_t efi_grub_guid = GRUB_EFI_GRUB_VARIABLE_GUID;
+ grub_guid_t efi_grub_guid = GRUB_EFI_GRUB_VARIABLE_GUID;
+ struct grub_envblk envblk_s = { NULL, 0 };
+ grub_envblk_t envblk = &envblk_s;
+
+ envblk_s.buf = grub_efi_get_variable ("GRUB_ENV", &efi_grub_guid,
+ &envblk_s.size);
+ grub_efi_get_variable ("GRUB_ENV", &efi_grub_guid, &envblk_s.size,
+ (void **) &envblk_s.buf);
+ if (!envblk_s.buf || envblk_s.size < 1)
+ return;
+
@ -63,19 +71,14 @@ index 3dfdf2d22..71d2279a0 100644
+ grub_free (envblk_s.buf);
+}
+
void
__attribute__ ((__optimize__ ("-fno-stack-protector"))) void
grub_efi_init (void)
{
@@ -42,10 +73,11 @@ grub_efi_init (void)
efi_call_4 (grub_efi_system_table->boot_services->set_watchdog_timer,
0, 0, 0, NULL);
@@ -128,6 +161,7 @@ grub_efi_init (void)
grub_efi_system_table->boot_services->set_watchdog_timer (0, 0, 0, NULL);
+ grub_efi_env_init ();
grub_efidisk_init ();
}
-void (*grub_efi_net_config) (grub_efi_handle_t hnd,
+void (*grub_efi_net_config) (grub_efi_handle_t hnd,
char **device,
char **path);
grub_efi_register_debug_commands ();

View File

@ -3,8 +3,11 @@ From: Mark Hamzy <hamzy@us.ibm.com>
Date: Wed, 28 Mar 2012 14:46:41 -0500
Subject: [PATCH] Migrate PPC from Yaboot to Grub2
Add configuration support for serial terminal consoles. This will set the
maximum screen size so that text is not overwritten.
Add configuration support for serial terminal consoles. This will set
the maximum screen size so that text is not overwritten.
Signed-off-by: Mark Hamzy <hamzy@us.ibm.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
Makefile.util.def | 7 +++
util/grub.d/20_ppc_terminfo.in | 114 +++++++++++++++++++++++++++++++++++++++++
@ -12,11 +15,11 @@ maximum screen size so that text is not overwritten.
create mode 100644 util/grub.d/20_ppc_terminfo.in
diff --git a/Makefile.util.def b/Makefile.util.def
index 3180ac880..c7b775bce 100644
index 9432365a9df..09bfcadd976 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -487,6 +487,13 @@ script = {
condition = COND_HOST_LINUX;
@@ -517,6 +517,13 @@ script = {
installdir = grubconf;
};
+script = {
@ -31,7 +34,7 @@ index 3180ac880..c7b775bce 100644
common = util/grub.d/30_os-prober.in;
diff --git a/util/grub.d/20_ppc_terminfo.in b/util/grub.d/20_ppc_terminfo.in
new file mode 100644
index 000000000..10d665868
index 00000000000..10d66586820
--- /dev/null
+++ b/util/grub.d/20_ppc_terminfo.in
@@ -0,0 +1,114 @@

View File

@ -8,16 +8,19 @@ found. It was originally written by Matthew Garrett, and adapted to fix the
"No modules are loaded on grub2 network boot" issue:
https://bugzilla.redhat.com/show_bug.cgi?id=857936
Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/kern/main.c | 13 ++++++-------
grub-core/normal/main.c | 25 ++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
index 9cad0c448..8ab7794c4 100644
index 731c07c2901..463dafdba02 100644
--- a/grub-core/kern/main.c
+++ b/grub-core/kern/main.c
@@ -127,16 +127,15 @@ grub_set_prefix_and_root (void)
@@ -128,16 +128,15 @@ grub_set_prefix_and_root (void)
grub_machine_get_bootlocation (&fwdevice, &fwpath);
@ -41,10 +44,10 @@ index 9cad0c448..8ab7794c4 100644
}
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index 249e19bc7..759c475c4 100644
index d3f53d93d87..08f48c71df1 100644
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -338,7 +338,30 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
@@ -339,7 +339,30 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
/* Guess the config filename. It is necessary to make CONFIG static,
so that it won't get broken by longjmp. */
char *config;
@ -59,7 +62,7 @@ index 249e19bc7..759c475c4 100644
+ {
+ grub_file_t file;
+
+ file = grub_file_open (config);
+ file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
+ if (file)
+ {
+ grub_file_close (file);

View File

@ -3,17 +3,20 @@ From: Peter Jones <pjones@redhat.com>
Date: Mon, 1 Oct 2012 13:24:37 -0400
Subject: [PATCH] Pass "\x[[:hex:]][[:hex:]]" straight through unmolested.
Don't munge raw spaces when we're doing our cmdline escaping (#923374)
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/commands/wildcard.c | 16 +++++++++++++++-
grub-core/lib/cmdline.c | 34 ++++++++++++++++++++++++++++++++--
grub-core/lib/cmdline.c | 25 +++++++++++++++++++++++--
grub-core/script/execute.c | 43 +++++++++++++++++++++++++++++++++++++------
3 files changed, 84 insertions(+), 9 deletions(-)
3 files changed, 75 insertions(+), 9 deletions(-)
diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c
index 9b4e72766..02c46f9fd 100644
index ed65865050a..5455242c352 100644
--- a/grub-core/commands/wildcard.c
+++ b/grub-core/commands/wildcard.c
@@ -462,6 +462,12 @@ check_file (const char *dir, const char *basename)
@@ -488,6 +488,12 @@ check_file (const char *dir, const char *basename)
return ctx.found;
}
@ -26,7 +29,7 @@ index 9b4e72766..02c46f9fd 100644
static void
unescape (char *out, const char *in, const char *end)
{
@@ -470,7 +476,15 @@ unescape (char *out, const char *in, const char *end)
@@ -496,7 +502,15 @@ unescape (char *out, const char *in, const char *end)
for (optr = out, iptr = in; iptr < end;)
{
@ -44,7 +47,7 @@ index 9b4e72766..02c46f9fd 100644
*optr++ = iptr[1];
iptr += 2;
diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c
index d5e10ee87..0a5b2afb9 100644
index ed0b149dca5..8e2294d8ff6 100644
--- a/grub-core/lib/cmdline.c
+++ b/grub-core/lib/cmdline.c
@@ -20,6 +20,12 @@
@ -75,21 +78,12 @@ index d5e10ee87..0a5b2afb9 100644
size++;
else if (*c == ' ')
space = 1;
@@ -85,7 +97,25 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf,
@@ -86,7 +98,16 @@ grub_create_loader_cmdline (int argc, char *argv[], char *buf,
while (*c)
{
- if (*c == '\\' || *c == '\'' || *c == '"')
+ if (*c == ' ')
+ {
+ *buf++ = '\\';
+ *buf++ = 'x';
+ *buf++ = '2';
+ *buf++ = '0';
+ c++;
+ continue;
+ }
+ else if (*c == '\\' && *(c+1) == 'x' &&
+ if (*c == '\\' && *(c+1) == 'x' &&
+ is_hex(*(c+2)) && is_hex(*(c+3)))
+ {
+ *buf++ = *c++;
@ -103,10 +97,10 @@ index d5e10ee87..0a5b2afb9 100644
*buf++ = *c;
diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c
index ab78ca87f..cf6cd6601 100644
index dab8fd2aeb0..c19b4bf700e 100644
--- a/grub-core/script/execute.c
+++ b/grub-core/script/execute.c
@@ -55,6 +55,12 @@ static struct grub_script_scope *scope = 0;
@@ -56,6 +56,12 @@ static struct grub_script_scope *scope = 0;
/* Wildcard translator for GRUB script. */
struct grub_script_wildcard_translator *grub_wildcard_translator;
@ -119,7 +113,7 @@ index ab78ca87f..cf6cd6601 100644
static char*
wildcard_escape (const char *s)
{
@@ -71,7 +77,15 @@ wildcard_escape (const char *s)
@@ -72,7 +78,15 @@ wildcard_escape (const char *s)
i = 0;
while ((ch = *s++))
{
@ -136,7 +130,7 @@ index ab78ca87f..cf6cd6601 100644
p[i++] = '\\';
p[i++] = ch;
}
@@ -95,7 +109,14 @@ wildcard_unescape (const char *s)
@@ -96,7 +110,14 @@ wildcard_unescape (const char *s)
i = 0;
while ((ch = *s++))
{
@ -152,7 +146,7 @@ index ab78ca87f..cf6cd6601 100644
p[i++] = *s++;
else
p[i++] = ch;
@@ -397,10 +418,20 @@ parse_string (const char *str,
@@ -398,10 +419,20 @@ parse_string (const char *str,
switch (*ptr)
{
case '\\':

File diff suppressed because it is too large Load Diff

View File

@ -20,10 +20,10 @@ Signed-off-by: David A. Marlin <dmarlin@redhat.com>
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index b0a8626dd..f68d4925e 100644
index 7516a015be0..7b355115dd4 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -254,7 +254,8 @@ export GRUB_DEFAULT \
@@ -252,7 +252,8 @@ export GRUB_DEFAULT \
GRUB_ENABLE_CRYPTODISK \
GRUB_BADRAM \
GRUB_OS_PROBER_SKIP_LIST \
@ -34,10 +34,10 @@ index b0a8626dd..f68d4925e 100644
if test "x${grub_cfg}" != "x"; then
rm -f "${grub_cfg}.new"
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 87a7da349..233754ff2 100644
index cc393be7eda..00d4b220ccb 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -153,6 +153,13 @@ EOF
@@ -155,6 +155,13 @@ EOF
sed "s/^/$submenu_indentation/" << EOF
echo '$(echo "$message" | grub_quote)'
initrd $(echo $initrd_path)
@ -51,7 +51,7 @@ index 87a7da349..233754ff2 100644
EOF
fi
sed "s/^/$submenu_indentation/" << EOF
@@ -236,6 +243,14 @@ while [ "x$list" != "x" ] ; do
@@ -250,6 +257,14 @@ for linux in ${reverse_sorted_list}; do
gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2
fi

View File

@ -9,7 +9,7 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
1 file changed, 2 insertions(+)
diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in
index 93a90233e..858b526c9 100644
index 6a316a5ba77..c2d8b093762 100644
--- a/util/grub.d/00_header.in
+++ b/util/grub.d/00_header.in
@@ -43,6 +43,8 @@ if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_

View File

@ -0,0 +1,85 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 14 Mar 2011 14:27:42 -0400
Subject: [PATCH] Don't say "GNU/Linux" in generated menus.
[rharwood: say it even less]
---
grub-core/normal/main.c | 2 +-
tests/util/grub-shell-tester.in | 2 +-
tests/util/grub-shell.in | 2 +-
util/grub.d/10_linux.in | 4 ++--
util/grub.d/20_linux_xen.in | 4 ++--
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index 1317279c081..568c2adfa16 100644
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -218,7 +218,7 @@ grub_normal_init_page (struct grub_term_output *term,
grub_term_cls (term);
- msg_formatted = grub_xasprintf (_("GNU GRUB version %s"), PACKAGE_VERSION);
+ msg_formatted = grub_xasprintf (_("GRUB version %s"), PACKAGE_VERSION);
if (!msg_formatted)
return;
diff --git a/tests/util/grub-shell-tester.in b/tests/util/grub-shell-tester.in
index 8a87109b152..9a4319d4f4f 100644
--- a/tests/util/grub-shell-tester.in
+++ b/tests/util/grub-shell-tester.in
@@ -56,7 +56,7 @@ for option in "$@"; do
usage
exit 0 ;;
-v | --version)
- echo "$0 (GNU GRUB ${PACKAGE_VERSION})"
+ echo "$0 (GRUB ${PACKAGE_VERSION})"
exit 0 ;;
--modules=*)
ms=`echo "$option" | sed -e 's/--modules=//'`
diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in
index 496e1bab33c..e0570c88e15 100644
--- a/tests/util/grub-shell.in
+++ b/tests/util/grub-shell.in
@@ -243,7 +243,7 @@ for option in "$@"; do
usage
exit 0 ;;
-v | --version)
- echo "$0 (GNU GRUB ${PACKAGE_VERSION})"
+ echo "$0 (GRUB ${PACKAGE_VERSION})"
exit 0 ;;
--trim)
trim=1 ;;
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 00d4b220ccb..901745707f1 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -29,9 +29,9 @@ export TEXTDOMAINDIR="@localedir@"
CLASS="--class gnu-linux --class gnu --class os"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
- OS=GNU/Linux
+ OS="$(sed 's, release .*$,,g' /etc/system-release)"
else
- OS="${GRUB_DISTRIBUTOR} GNU/Linux"
+ OS="${GRUB_DISTRIBUTOR}"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
fi
diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
index 94dd8be1342..98ee5bc58dc 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -29,9 +29,9 @@ export TEXTDOMAINDIR="@localedir@"
CLASS="--class gnu-linux --class gnu --class os --class xen"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
- OS=GNU/Linux
+ OS="$(sed 's, release .*$,,g' /etc/system-release)"
else
- OS="${GRUB_DISTRIBUTOR} GNU/Linux"
+ OS="${GRUB_DISTRIBUTOR}"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
fi

View File

@ -3,20 +3,21 @@ From: Fedora Ninjas <grub2-owner@fedoraproject.org>
Date: Mon, 13 Jan 2014 21:50:59 -0500
Subject: [PATCH] Add .eh_frame to list of relocations stripped
Signed-off-by: Peter Jones <pjones@redhat.com>
---
conf/Makefile.common | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/conf/Makefile.common b/conf/Makefile.common
index 311da61c6..044ab3abe 100644
index b8f216f6cd3..ece9ed8a1bf 100644
--- a/conf/Makefile.common
+++ b/conf/Makefile.common
@@ -38,7 +38,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding
@@ -41,7 +41,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC)
CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1
CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
-STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx
+STRIPFLAGS_KERNEL = -R .eh_frame -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx
CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
if !COND_emu
if COND_HAVE_ASM_USCORE
LDFLAGS_KERNEL += -Wl,--defsym=_malloc=_grub_malloc -Wl,--defsym=_free=_grub_free

View File

@ -14,7 +14,7 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 6299836b5..b744438e0 100644
index 901745707f1..9c31a94decb 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -26,7 +26,7 @@ datarootdir="@datarootdir@"

View File

@ -17,10 +17,10 @@ Signed-off-by: Mark Salter <msalter@redhat.com>
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index 0ce59fdc3..a3713efcd 100644
index 568c2adfa16..0b2bbee19c3 100644
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -343,7 +343,7 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
@@ -347,7 +347,7 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
char *config;
const char *prefix, *fw_path;
@ -29,7 +29,7 @@ index 0ce59fdc3..a3713efcd 100644
if (fw_path)
{
config = grub_xasprintf ("%s/grub.cfg", fw_path);
@@ -366,7 +366,8 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
@@ -370,7 +370,8 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
}
}

View File

@ -0,0 +1,127 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 8 Jul 2019 17:33:22 +0200
Subject: [PATCH] Try mac/guid/etc before grub.cfg on tftp config files.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/normal/main.c | 97 ++++++++++++++++++++++++++-----------------------
1 file changed, 51 insertions(+), 46 deletions(-)
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index 0b2bbee19c3..4c89892fa70 100644
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -345,61 +345,66 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
/* Guess the config filename. It is necessary to make CONFIG static,
so that it won't get broken by longjmp. */
char *config;
- const char *prefix, *fw_path;
-
- prefix = fw_path = grub_env_get ("fw_path");
- if (fw_path)
- {
- config = grub_xasprintf ("%s/grub.cfg", fw_path);
- if (config)
- {
- grub_file_t file;
-
- file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
- if (file)
- {
- grub_file_close (file);
- grub_enter_normal_mode (config);
- }
- else
- {
- /* Ignore all errors. */
- grub_errno = 0;
- }
- grub_free (config);
- }
- }
+ const char *prefix;
+ const char *net_search_cfg;
+ int disable_net_search = 0;
+ prefix = grub_env_get ("fw_path");
if (! prefix)
prefix = grub_env_get ("prefix");
+
+ net_search_cfg = grub_env_get ("feature_net_search_cfg");
+ if (net_search_cfg && net_search_cfg[0] == 'n')
+ disable_net_search = 1;
+
if (prefix)
{
- grub_size_t config_len;
- int disable_net_search = 0;
- const char *net_search_cfg;
-
- config_len = grub_strlen (prefix) +
- sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
- config = grub_malloc (config_len);
-
- if (!config)
- goto quit;
-
- grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
-
- net_search_cfg = grub_env_get ("feature_net_search_cfg");
- if (net_search_cfg && net_search_cfg[0] == 'n')
- disable_net_search = 1;
-
if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0 &&
!disable_net_search)
- grub_net_search_config_file (config);
+ {
+ grub_size_t config_len;
+ config_len = grub_strlen (prefix) +
+ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
+ config = grub_malloc (config_len);
- grub_enter_normal_mode (config);
- grub_free (config);
- }
+ if (! config)
+ goto quit;
+
+ grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
+
+ grub_net_search_configfile (config);
+
+ grub_enter_normal_mode (config);
+ grub_free (config);
+ config = NULL;
+ }
+
+ if (!config)
+ {
+ config = grub_xasprintf ("%s/grub.cfg", prefix);
+ if (config)
+ {
+ grub_file_t file;
+
+ file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
+ if (file)
+ {
+ grub_file_close (file);
+ grub_enter_normal_mode (config);
+ }
+ else
+ {
+ /* Ignore all errors. */
+ grub_errno = 0;
+ }
+ grub_free (config);
+ }
+ }
+ }
else
- grub_enter_normal_mode (0);
+ {
+ grub_enter_normal_mode (0);
+ }
}
else
grub_enter_normal_mode (argv[0]);

View File

@ -14,7 +14,7 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index b744438e0..43d98476b 100644
index 9c31a94decb..b7809091b36 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -29,7 +29,8 @@ export TEXTDOMAINDIR="@localedir@"

View File

@ -1,44 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 3 Oct 2014 11:08:03 -0400
Date: Tue, 9 Jul 2019 10:35:16 +0200
Subject: [PATCH] Try $prefix if $fw_path doesn't work.
Related: rhbz#1148652
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/kern/ieee1275/init.c | 28 +++++-----
grub-core/kern/ieee1275/init.c | 34 ++++++-----
grub-core/net/net.c | 2 +-
grub-core/normal/main.c | 120 ++++++++++++++++++++---------------------
3 files changed, 75 insertions(+), 75 deletions(-)
grub-core/normal/main.c | 134 ++++++++++++++++++++---------------------
3 files changed, 85 insertions(+), 85 deletions(-)
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
index f5423ce27..e01bc6eab 100644
index 50c65b2f6e5..51c1e1c9d9f 100644
--- a/grub-core/kern/ieee1275/init.c
+++ b/grub-core/kern/ieee1275/init.c
@@ -124,23 +124,25 @@ grub_machine_get_bootlocation (char **device, char **path)
@@ -170,23 +170,25 @@ grub_machine_get_bootlocation (char **device, char **path)
grub_free (canon);
}
else
- *device = grub_ieee1275_encode_devname (bootpath);
- grub_free (type);
-
- filename = grub_ieee1275_get_filename (bootpath);
- if (filename)
{
- char *lastslash = grub_strrchr (filename, '\\');
-
- /* Truncate at last directory. */
- if (lastslash)
+ {
+ filename = grub_ieee1275_get_filename (bootpath);
+ if (filename)
{
- *lastslash = '\0';
- grub_translate_ieee1275_path (filename);
+ {
+ char *lastslash = grub_strrchr (filename, '\\');
- *path = filename;
- }
+
+ /* Truncate at last directory. */
+ if (lastslash)
+ {
@ -49,17 +37,32 @@ index f5423ce27..e01bc6eab 100644
+ }
+ }
+ *device = grub_ieee1275_encode_devname (bootpath);
}
+ }
+
+ grub_free (type);
grub_free (type);
-
- filename = grub_ieee1275_get_filename (bootpath);
- if (filename)
- {
- char *lastslash = grub_strrchr (filename, '\\');
-
- /* Truncate at last directory. */
- if (lastslash)
- {
- *lastslash = '\0';
- grub_translate_ieee1275_path (filename);
-
- *path = filename;
- }
- }
grub_free (bootpath);
}
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
index 0769bf850..16d2ce06d 100644
index 8cad4fb6d4d..54451cea2a7 100644
--- a/grub-core/net/net.c
+++ b/grub-core/net/net.c
@@ -1850,7 +1850,7 @@ grub_net_search_configfile (char *config)
@@ -2005,7 +2005,7 @@ grub_net_search_config_file (char *config)
/* Remove the remaining minus sign at the end. */
config[config_len] = '\0';
@ -69,10 +72,10 @@ index 0769bf850..16d2ce06d 100644
static struct grub_preboot *fini_hnd;
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index 7d9c4f09b..b69f9e738 100644
index 4c89892fa70..3463f444f74 100644
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -331,74 +331,72 @@ grub_enter_normal_mode (const char *config)
@@ -335,81 +335,79 @@ grub_enter_normal_mode (const char *config)
grub_boot_time ("Exiting normal mode");
}
@ -82,38 +85,45 @@ index 7d9c4f09b..b69f9e738 100644
+ char *config;
+ const char *prefix;
+ grub_err_t err = GRUB_ERR_FILE_NOT_FOUND;
+ const char *net_search_cfg;
+ int disable_net_search = 0;
+
+ prefix = grub_env_get (variable);
+ if (!prefix)
+ return GRUB_ERR_FILE_NOT_FOUND;
+
+ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0)
+ net_search_cfg = grub_env_get ("feature_net_search_cfg");
+ if (net_search_cfg && net_search_cfg[0] == 'n')
+ disable_net_search = 1;
+
+ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0 &&
+ !disable_net_search)
+ {
+ grub_size_t config_len;
+ config_len = grub_strlen (prefix) +
+ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
+ config = grub_malloc (config_len);
+ grub_size_t config_len;
+ config_len = grub_strlen (prefix) +
+ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
+ config = grub_malloc (config_len);
+
+ if (! config)
+ return GRUB_ERR_FILE_NOT_FOUND;
+ if (! config)
+ return GRUB_ERR_FILE_NOT_FOUND;
+
+ grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
+ err = grub_net_search_configfile (config);
+ grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
+ err = grub_net_search_config_file (config);
+ }
+
+ if (err != GRUB_ERR_NONE)
+ {
+ config = grub_xasprintf ("%s/grub.cfg", prefix);
+ if (config)
+ {
+ grub_file_t file;
+ file = grub_file_open (config);
+ if (file)
+ {
+ grub_file_close (file);
+ err = GRUB_ERR_NONE;
+ }
+ }
+ config = grub_xasprintf ("%s/grub.cfg", prefix);
+ if (config)
+ {
+ grub_file_t file;
+ file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
+ if (file)
+ {
+ grub_file_close (file);
+ err = GRUB_ERR_NONE;
+ }
+ }
+ }
+
+ if (err == GRUB_ERR_NONE)
@ -135,58 +145,65 @@ index 7d9c4f09b..b69f9e738 100644
- so that it won't get broken by longjmp. */
- char *config;
- const char *prefix;
- const char *net_search_cfg;
- int disable_net_search = 0;
-
- prefix = grub_env_get ("fw_path");
- if (! prefix)
- prefix = grub_env_get ("prefix");
-
- net_search_cfg = grub_env_get ("feature_net_search_cfg");
- if (net_search_cfg && net_search_cfg[0] == 'n')
- disable_net_search = 1;
-
- if (prefix)
- {
- if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0)
- {
- grub_size_t config_len;
- config_len = grub_strlen (prefix) +
- sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
- config = grub_malloc (config_len);
- {
- if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0 &&
- !disable_net_search)
- {
- grub_size_t config_len;
- config_len = grub_strlen (prefix) +
- sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
- config = grub_malloc (config_len);
-
- if (! config)
- goto quit;
- if (! config)
- goto quit;
-
- grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
- grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
-
- grub_net_search_configfile (config);
- grub_net_search_configfile (config);
-
- grub_enter_normal_mode (config);
- grub_free (config);
- config = NULL;
- }
- grub_enter_normal_mode (config);
- grub_free (config);
- config = NULL;
- }
-
- if (!config)
- {
- config = grub_xasprintf ("%s/grub.cfg", prefix);
- if (config)
- {
- grub_file_t file;
- if (!config)
- {
- config = grub_xasprintf ("%s/grub.cfg", prefix);
- if (config)
- {
- grub_file_t file;
-
- file = grub_file_open (config);
- if (file)
- {
- grub_file_close (file);
- grub_enter_normal_mode (config);
- }
- else
- {
- /* Ignore all errors. */
- grub_errno = 0;
- }
- grub_free (config);
- }
- }
- }
- file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
- if (file)
- {
- grub_file_close (file);
- grub_enter_normal_mode (config);
- }
- else
- {
- /* Ignore all errors. */
- grub_errno = 0;
- }
- grub_free (config);
- }
- }
- }
- else
- {
- grub_enter_normal_mode (0);
- }
- {
- grub_enter_normal_mode (0);
- }
- }
- else
+ if (argc)

View File

@ -12,10 +12,10 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 43d98476b..a8a8e2cf3 100644
index b7809091b36..993c53ad92e 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -78,6 +78,32 @@ case x"$GRUB_FS" in
@@ -80,6 +80,32 @@ case x"$GRUB_FS" in
;;
esac
@ -48,7 +48,7 @@ index 43d98476b..a8a8e2cf3 100644
title_correction_code=
linux_entry ()
@@ -91,17 +117,11 @@ linux_entry ()
@@ -93,17 +119,11 @@ linux_entry ()
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
fi
if [ x$type != xsimple ] ; then

View File

@ -8,36 +8,43 @@ without having to alter the grub.cfg. The hashed password now
lives in a root-only-readable configuration file.
Resolves: rhbz#985962
Signed-off-by: Robert Marshall <rmarshall@redhat.com>
[pjones: fix the efidir in grub-setpassword and rename tool]
Signed-off-by: Peter Jones <pjones@redhat.com>
[luto: fix grub-setpassword -o's output path]
Signed-off-by: Andy Lutomirski <luto@kernel.org>
[rharwood: migrate man page to h2m, context]
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
configure.ac | 1 +
Makefile.util.def | 13 +++++
.gitignore | 2 +
util/grub-mkconfig.in | 2 +
util/grub-setpassword.8 | 28 +++++++++++
util/grub-setpassword.in | 123 +++++++++++++++++++++++++++++++++++++++++++++++
util/grub.d/01_users.in | 11 +++++
7 files changed, 180 insertions(+)
create mode 100644 util/grub-setpassword.8
create mode 100644 util/grub-setpassword.in
configure.ac | 1 +
Makefile.util.def | 13 +++++
docs/man/grub-set-password.h2m | 2 +
util/grub-mkconfig.in | 2 +
util/grub-set-password.in | 128 +++++++++++++++++++++++++++++++++++++++++
util/grub.d/01_users.in | 11 ++++
6 files changed, 157 insertions(+)
create mode 100644 docs/man/grub-set-password.h2m
create mode 100644 util/grub-set-password.in
create mode 100644 util/grub.d/01_users.in
diff --git a/configure.ac b/configure.ac
index 056df1cba..679f634ce 100644
index ae3a49321ad..493e336ec6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,7 @@ grub_TRANSFORM([grub-mkrelpath])
@@ -77,6 +77,7 @@ grub_TRANSFORM([grub-mkrelpath])
grub_TRANSFORM([grub-mkrescue])
grub_TRANSFORM([grub-probe])
grub_TRANSFORM([grub-reboot])
+grub_TRANSFORM([grub-setpassword])
grub_TRANSFORM([grub-rpm-sort])
+grub_TRANSFORM([grub-set-password])
grub_TRANSFORM([grub-script-check])
grub_TRANSFORM([grub-set-default])
grub_TRANSFORM([grub-sparc64-setup])
diff --git a/Makefile.util.def b/Makefile.util.def
index 406d96861..fd91045bd 100644
index 09bfcadd976..95884956a68 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -440,6 +440,12 @@ script = {
@@ -455,6 +455,12 @@ script = {
installdir = grubconf;
};
@ -50,13 +57,13 @@ index 406d96861..fd91045bd 100644
script = {
name = '10_windows';
common = util/grub.d/10_windows.in;
@@ -722,6 +728,13 @@ script = {
@@ -733,6 +739,13 @@ script = {
installdir = sbin;
};
+script = {
+ name = grub-setpassword;
+ common = util/grub-setpassword.in;
+ name = grub-set-password;
+ common = util/grub-set-password.in;
+ mansection = 8;
+ installdir = sbin;
+};
@ -64,24 +71,19 @@ index 406d96861..fd91045bd 100644
script = {
name = grub-mkconfig_lib;
common = util/grub-mkconfig_lib.in;
diff --git a/.gitignore b/.gitignore
index fa2e5b609..5066689bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,8 @@ grub-*.tar.*
/grub*-script-check.1
/grub*-set-default
/grub*-set-default.8
+/grub*-setsetpassword
+/grub*-setsetpassword.8
/grub*-shell
/grub*-shell-tester
/grub*-sparc64-setup
diff --git a/docs/man/grub-set-password.h2m b/docs/man/grub-set-password.h2m
new file mode 100644
index 00000000000..10ee82f4d52
--- /dev/null
+++ b/docs/man/grub-set-password.h2m
@@ -0,0 +1,2 @@
+[NAME]
+grub-set-password \- generate the user.cfg file containing the hashed grub bootloader password
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index f68d4925e..bdb9982ae 100644
index 7b355115dd4..5f2824d4f58 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -282,6 +282,8 @@ for i in "${grub_mkconfig_dir}"/* ; do
@@ -280,6 +280,8 @@ for i in "${grub_mkconfig_dir}"/* ; do
*~) ;;
# emacsen autosave files. FIXME: support other editors
*/\#*\#) ;;
@ -90,50 +92,17 @@ index f68d4925e..bdb9982ae 100644
*)
if grub_file_is_not_garbage "$i" && test -x "$i" ; then
echo
diff --git a/util/grub-setpassword.8 b/util/grub-setpassword.8
diff --git a/util/grub-set-password.in b/util/grub-set-password.in
new file mode 100644
index 000000000..49200a848
index 00000000000..5ebf50576d6
--- /dev/null
+++ b/util/grub-setpassword.8
@@ -0,0 +1,28 @@
+.TH GRUB-SETPASSWORD 3 "Thu Jun 25 2015"
+.SH NAME
+\fBgrub-setpassword\fR \(em Generate the user.cfg file containing the hashed grub bootloader password.
+
+.SH SYNOPSIS
+\fBgrub-setpassword\fR [OPTION]
+
+.SH DESCRIPTION
+\fBgrub-setpassword\fR outputs the user.cfg file which contains the hashed GRUB bootloader password. This utility only supports configurations where there is a single root user.
+
+The file has the format:
+GRUB2_PASSWORD=<\fIhashed password\fR>.
+
+.SH OPTIONS
+.TP
+-h, --help
+Display program usage and exit.
+.TP
+-v, --version
+Display the current version.
+.TP
+-o, --output[=\fIDIRECTORY PATH\fR]
+Choose the file path to which user.cfg will be written.
+
+.SH SEE ALSO
+.BR "info grub"
+
+.BR "info grub2-mkpasswd-pbkdf2"
diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in
new file mode 100644
index 000000000..dd76f00fc
--- /dev/null
+++ b/util/grub-setpassword.in
@@ -0,0 +1,123 @@
+++ b/util/grub-set-password.in
@@ -0,0 +1,128 @@
+#!/bin/sh -e
+
+EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/')
+if [ -d /sys/firmware/efi/efivars/ ]; then
+ grubdir=`echo "/@bootdirname@/efi/EFI/redhat/" | sed 's,//*,/,g'`
+ grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'`
+else
+ grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
+fi
@ -148,15 +117,14 @@ index 000000000..dd76f00fc
+# Print the usage.
+usage () {
+ cat <<EOF
+Usage: $0 [OPTION] [SOURCE]
+Run GRUB script in a Qemu instance.
+
+ -h, --help print this message and exit
+ -v, --version print the version information and exit
+ -o, --output_path choose a custom output path for user.cfg
+
+Usage: $0 [OPTION]
+$0 prompts the user to set a password on the grub bootloader. The password
+is written to a file named user.cfg.
+is written to a file named user.cfg which lives in the GRUB directory
+located by default at ${grubdir}.
+
+ -h, --help print this message and exit
+ -v, --version print the version information and exit
+ -o, --output_path <DIRECTORY> put user.cfg in a user-selected directory
+
+Report bugs at https://bugzilla.redhat.com.
+EOF
@ -237,7 +205,7 @@ index 000000000..dd76f00fc
+ P1="$1" && shift
+
+ ( echo ${P0} ; echo ${P1} ) | \
+ ${grub_mkpasswd} | \
+ LC_ALL=C ${grub_mkpasswd} | \
+ grep -v '[eE]nter password:' | \
+ sed -e "s/PBKDF2 hash of your password is //"
+}
@ -250,12 +218,17 @@ index 000000000..dd76f00fc
+
+# on the ESP, these will fail to set the permissions, but it's okay because
+# the directory is protected.
+install -m 0600 /dev/null "${grubdir}/user.cfg" 2>/dev/null || :
+chmod 0600 "${grubdir}/user.cfg" 2>/dev/null || :
+echo "GRUB2_PASSWORD=${MYPASS}" > "${grubdir}/user.cfg"
+install -m 0600 /dev/null "${OUTPUT_PATH}/user.cfg" 2>/dev/null || :
+chmod 0600 "${OUTPUT_PATH}/user.cfg" 2>/dev/null || :
+echo "GRUB2_PASSWORD=${MYPASS}" > "${OUTPUT_PATH}/user.cfg"
+
+if ! grep -q "^### BEGIN /etc/grub.d/01_users ###$" "${OUTPUT_PATH}/grub.cfg"; then
+ echo "WARNING: The current configuration lacks password support!"
+ echo "Update your configuration with @grub_mkconfig@ to support this feature."
+fi
diff --git a/util/grub.d/01_users.in b/util/grub.d/01_users.in
new file mode 100644
index 000000000..db2f44bfb
index 00000000000..db2f44bfb78
--- /dev/null
+++ b/util/grub.d/01_users.in
@@ -0,0 +1,11 @@

View File

@ -17,7 +17,7 @@ Signed-off-by: Josef Bacik <jbacik@fb.com>
1 file changed, 29 insertions(+), 13 deletions(-)
diff --git a/grub-core/net/tcp.c b/grub-core/net/tcp.c
index e8ad34b84..7d4b82262 100644
index 93dee0caa1b..902ab7e8ae6 100644
--- a/grub-core/net/tcp.c
+++ b/grub-core/net/tcp.c
@@ -106,6 +106,18 @@ struct tcphdr
@ -39,7 +39,7 @@ index e8ad34b84..7d4b82262 100644
struct tcp_pseudohdr
{
grub_uint32_t src;
@@ -566,7 +578,7 @@ grub_net_tcp_open (char *server,
@@ -571,7 +583,7 @@ grub_net_tcp_open (char *server,
grub_net_tcp_socket_t socket;
static grub_uint16_t in_port = 21550;
struct grub_net_buff *nb;
@ -48,7 +48,7 @@ index e8ad34b84..7d4b82262 100644
int i;
grub_uint8_t *nbd;
grub_net_link_level_address_t ll_target_addr;
@@ -635,20 +647,24 @@ grub_net_tcp_open (char *server,
@@ -640,20 +652,24 @@ grub_net_tcp_open (char *server,
}
tcph = (void *) nb->data;

View File

@ -1,33 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 8 Jun 2016 21:03:37 -0400
Date: Tue, 9 Jul 2019 11:47:37 +0200
Subject: [PATCH] efinet and bootp: add support for dhcpv6
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/net/bootp.c | 174 +++++++++++++++++++++++++++++++++++++
grub-core/net/drivers/efi/efinet.c | 53 +++++++++--
grub-core/net/bootp.c | 173 +++++++++++++++++++++++++++++++++++++
grub-core/net/drivers/efi/efinet.c | 84 +++++++++++++-----
grub-core/net/net.c | 72 +++++++++++++++
grub-core/net/tftp.c | 4 +
grub-core/net/tftp.c | 3 +
include/grub/efi/api.h | 129 +++++++++++++++++++++++++--
include/grub/net.h | 60 +++++++++++++
6 files changed, 478 insertions(+), 14 deletions(-)
6 files changed, 491 insertions(+), 30 deletions(-)
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
index f03eeab2f..da3e45446 100644
index abe45ef7bf6..02d2c2614cb 100644
--- a/grub-core/net/bootp.c
+++ b/grub-core/net/bootp.c
@@ -23,6 +23,7 @@
#include <grub/net/ip.h>
#include <grub/net/netbuff.h>
#include <grub/net/udp.h>
+#include <grub/net/url.h>
#include <grub/datetime.h>
@@ -905,6 +905,179 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
static char *
@@ -349,6 +350,179 @@ grub_net_configure_by_dhcp_ack (const char *name,
return inter;
}
static grub_command_t cmd_getdhcp, cmd_bootp, cmd_dhcp;
+struct grub_net_network_level_interface *
+grub_net_configure_by_dhcpv6_ack (const char *name,
@ -203,19 +195,18 @@ index f03eeab2f..da3e45446 100644
+
+
void
grub_net_process_dhcp (struct grub_net_buff *nb,
struct grub_net_card *card)
grub_bootp_init (void)
{
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
index 5388f952b..a4daaa460 100644
index 3ea25cf9894..2af8742f904 100644
--- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -18,11 +18,15 @@
@@ -18,11 +18,14 @@
#include <grub/net/netbuff.h>
#include <grub/dl.h>
+#include <grub/env.h>
#include <grub/net.h>
+#include <grub/net/url.h>
#include <grub/time.h>
#include <grub/efi/api.h>
#include <grub/efi/efi.h>
@ -225,22 +216,23 @@ index 5388f952b..a4daaa460 100644
GRUB_MOD_LICENSE ("GPLv3+");
@@ -329,7 +333,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
@@ -346,7 +349,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
char **path)
{
struct grub_net_card *card;
- grub_efi_device_path_t *dp;
+ grub_efi_device_path_t *dp, *ldp = NULL;
dp = grub_efi_get_device_path (hnd);
if (! dp)
@@ -340,14 +344,18 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
struct grub_net_network_level_interface *inter;
grub_efi_device_path_t *vlan_dp;
grub_efi_uint16_t vlan_dp_len;
@@ -361,14 +364,19 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
grub_efi_device_path_t *cdp;
struct grub_efi_pxe *pxe;
struct grub_efi_pxe_mode *pxe_mode;
+
if (card->driver != &efidriver)
continue;
+
cdp = grub_efi_get_device_path (card->efi_handle);
if (! cdp)
continue;
@ -254,7 +246,7 @@ index 5388f952b..a4daaa460 100644
int match;
/* EDK2 UEFI PXE driver creates pseudo devices with type IPv4/IPv6
@@ -356,7 +364,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
@@ -377,7 +385,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
devices. We skip them when enumerating cards, so here we need to
find matching MAC device.
*/
@ -262,7 +254,7 @@ index 5388f952b..a4daaa460 100644
if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE
|| (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE
&& GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE))
@@ -373,16 +380,46 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
@@ -394,41 +401,70 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
if (!match)
continue;
}
@ -273,11 +265,6 @@ index 5388f952b..a4daaa460 100644
continue;
+
pxe_mode = pxe->mode;
- grub_net_configure_by_dhcp_ack (card->name, card, 0,
- (struct grub_net_bootp_packet *)
- &pxe_mode->dhcp_ack,
- sizeof (pxe_mode->dhcp_ack),
- 1, device, path);
+ if (pxe_mode->using_ipv6)
+ {
+ grub_net_link_level_address_t hwaddr;
@ -289,41 +276,86 @@ index 5388f952b..a4daaa460 100644
+ pxe_mode->dhcp_ack_received ? "" : " cannot continue");
+ if (!pxe_mode->dhcp_ack_received)
+ continue;
+
- inter = grub_net_configure_by_dhcp_ack (card->name, card, 0,
- (struct grub_net_bootp_packet *)
- &pxe_mode->dhcp_ack,
- sizeof (pxe_mode->dhcp_ack),
- 1, device, path);
+ hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+ grub_memcpy (hwaddr.mac,
+ card->efi_net->mode->current_address,
+ sizeof (hwaddr.mac));
+
+ intf = grub_net_configure_by_dhcpv6_ack (card->name, card, 0, &hwaddr,
- if (inter != NULL)
+ inter = grub_net_configure_by_dhcpv6_ack (card->name, card, 0, &hwaddr,
+ (const struct grub_net_dhcpv6_packet *)&pxe_mode->dhcp_ack.dhcpv6,
+ 1, device, path);
+ if (intf && device && path)
+ if (inter && device && path)
+ grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path);
+ }
+ else
+ {
{
- /*
- * Search the device path for any VLAN subtype and use it
- * to configure the interface.
- */
- vlan_dp = dp;
+ grub_dprintf ("efinet", "using ipv4 and dhcp\n");
+ grub_net_configure_by_dhcp_ack (card->name, card, 0,
+ (struct grub_net_bootp_packet *)
+ &pxe_mode->dhcp_ack,
+ sizeof (pxe_mode->dhcp_ack),
+ 1, device, path);
+ inter = grub_net_configure_by_dhcp_ack (card->name, card, 0,
+ (struct grub_net_bootp_packet *)
+ &pxe_mode->dhcp_ack,
+ sizeof (pxe_mode->dhcp_ack),
+ 1, device, path);
- while (!GRUB_EFI_END_ENTIRE_DEVICE_PATH (vlan_dp))
+ grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path);
+ }
return;
+ if (inter != NULL)
{
- if (GRUB_EFI_DEVICE_PATH_TYPE (vlan_dp) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE &&
- GRUB_EFI_DEVICE_PATH_SUBTYPE (vlan_dp) == GRUB_EFI_VLAN_DEVICE_PATH_SUBTYPE)
+ /*
+ * Search the device path for any VLAN subtype and use it
+ * to configure the interface.
+ */
+ vlan_dp = dp;
+
+ while (!GRUB_EFI_END_ENTIRE_DEVICE_PATH (vlan_dp))
{
- vlan = (grub_efi_vlan_device_path_t *) vlan_dp;
- inter->vlantag = vlan->vlan_id;
- break;
+ if (GRUB_EFI_DEVICE_PATH_TYPE (vlan_dp) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE &&
+ GRUB_EFI_DEVICE_PATH_SUBTYPE (vlan_dp) == GRUB_EFI_VLAN_DEVICE_PATH_SUBTYPE)
+ {
+ vlan = (grub_efi_vlan_device_path_t *) vlan_dp;
+ inter->vlantag = vlan->vlan_id;
+ break;
+ }
+
+ vlan_dp_len = GRUB_EFI_DEVICE_PATH_LENGTH (vlan_dp);
+ vlan_dp = (grub_efi_device_path_t *) ((grub_efi_uint8_t *) vlan_dp + vlan_dp_len);
}
-
- vlan_dp_len = GRUB_EFI_DEVICE_PATH_LENGTH (vlan_dp);
- vlan_dp = (grub_efi_device_path_t *) ((grub_efi_uint8_t *) vlan_dp + vlan_dp_len);
}
+ return;
}
- return;
}
}
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
index 16d2ce06d..4be228d95 100644
index 54451cea2a7..20c55257647 100644
--- a/grub-core/net/net.c
+++ b/grub-core/net/net.c
@@ -955,6 +955,78 @@ grub_net_network_level_interface_register (struct grub_net_network_level_interfa
@@ -984,6 +984,78 @@ grub_net_network_level_interface_register (struct grub_net_network_level_interfa
grub_net_network_level_interfaces = inter;
}
+int
+grub_ipv6_get_masksize (grub_uint16_t be_mask[8])
+grub_ipv6_get_masksize (grub_uint16_t *be_mask)
+{
+ grub_uint8_t *mask;
+ grub_uint16_t mask16[8];
@ -398,38 +430,36 @@ index 16d2ce06d..4be228d95 100644
grub_err_t
grub_net_add_ipv4_local (struct grub_net_network_level_interface *inter,
diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c
index 7d90bf66e..1157524fc 100644
index 409b1d09bcd..f300a9d4007 100644
--- a/grub-core/net/tftp.c
+++ b/grub-core/net/tftp.c
@@ -379,19 +379,23 @@ tftp_open (struct grub_file *file, const char *filename)
return grub_errno;
}
@@ -359,6 +359,7 @@ tftp_open (struct grub_file *file, const char *filename)
file->not_easily_seekable = 1;
file->data = data;
+ grub_dprintf("tftp", "resolving address for %s\n", file->device->net->server);
err = grub_net_resolve_address (file->device->net->server, &addr);
if (err)
{
+ grub_dprintf("tftp", "Address resolution failed: %d\n", err);
destroy_pq (data);
grub_free (data);
@@ -369,11 +370,13 @@ tftp_open (struct grub_file *file, const char *filename)
return err;
}
+ grub_dprintf("tftp", "opening connection\n");
data->sock = grub_net_udp_open (addr,
TFTP_SERVER_PORT, tftp_receive,
port ? port : TFTP_SERVER_PORT, tftp_receive,
file);
if (!data->sock)
{
+ grub_dprintf("tftp", "connection failed\n");
destroy_pq (data);
grub_free (data);
return grub_errno;
}
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
index c7c9f0e1d..28b6adf76 100644
index d44d00ad7d5..c6d702831f7 100644
--- a/include/grub/efi/api.h
+++ b/include/grub/efi/api.h
@@ -572,10 +572,16 @@ typedef void *grub_efi_handle_t;
@@ -637,10 +637,16 @@ typedef void *grub_efi_handle_t;
typedef void *grub_efi_event_t;
typedef grub_efi_uint64_t grub_efi_lba_t;
typedef grub_efi_uintn_t grub_efi_tpl_t;
@ -450,7 +480,7 @@ index c7c9f0e1d..28b6adf76 100644
typedef grub_efi_uint64_t grub_efi_physical_address_t;
typedef grub_efi_uint64_t grub_efi_virtual_address_t;
@@ -1450,16 +1456,127 @@ struct grub_efi_simple_text_output_interface
@@ -1521,16 +1527,127 @@ struct grub_efi_simple_text_output_interface
};
typedef struct grub_efi_simple_text_output_interface grub_efi_simple_text_output_interface_t;
@ -581,10 +611,10 @@ index c7c9f0e1d..28b6adf76 100644
typedef struct grub_efi_pxe
diff --git a/include/grub/net.h b/include/grub/net.h
index 50d62ab0c..f8f3ec13a 100644
index 844e501c128..bf8430a6364 100644
--- a/include/grub/net.h
+++ b/include/grub/net.h
@@ -442,6 +442,51 @@ struct grub_net_bootp_packet
@@ -450,6 +450,51 @@ struct grub_net_bootp_packet
grub_uint8_t vendor[0];
} GRUB_PACKED;
@ -636,7 +666,7 @@ index 50d62ab0c..f8f3ec13a 100644
#define GRUB_NET_BOOTP_RFC1048_MAGIC_0 0x63
#define GRUB_NET_BOOTP_RFC1048_MAGIC_1 0x82
#define GRUB_NET_BOOTP_RFC1048_MAGIC_2 0x53
@@ -470,6 +515,21 @@ grub_net_configure_by_dhcp_ack (const char *name,
@@ -485,6 +530,21 @@ grub_net_configure_by_dhcp_ack (const char *name,
grub_size_t size,
int is_def, char **device, char **path);

View File

@ -1,6 +1,6 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Michael Chang <mchang@suse.com>
Date: Sun, 10 Jul 2016 23:46:06 +0800
Date: Wed, 10 Jul 2019 15:42:36 +0200
Subject: [PATCH] bootp: New net_bootp6 command
Implement new net_bootp6 command for IPv6 network auto configuration via the
@ -8,21 +8,23 @@ DHCPv6 protocol (RFC3315).
Signed-off-by: Michael Chang <mchang@suse.com>
Signed-off-by: Ken Lin <ken.lin@hpe.com>
[pjones: Put back our code to add a local route]
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/net/bootp.c | 1048 ++++++++++++++++++++++++++++++------
grub-core/net/drivers/efi/efinet.c | 20 +-
grub-core/net/bootp.c | 1059 ++++++++++++++++++++++++++++++------
grub-core/net/drivers/efi/efinet.c | 18 +-
grub-core/net/ip.c | 39 ++
include/grub/efi/api.h | 2 +-
include/grub/net.h | 91 ++--
5 files changed, 994 insertions(+), 206 deletions(-)
5 files changed, 1001 insertions(+), 208 deletions(-)
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
index 4e55adc55..ff1d7776e 100644
index 02d2c2614cb..e0aec25233d 100644
--- a/grub-core/net/bootp.c
+++ b/grub-core/net/bootp.c
@@ -25,6 +25,98 @@
@@ -24,6 +24,98 @@
#include <grub/net/netbuff.h>
#include <grub/net/udp.h>
#include <grub/net/url.h>
#include <grub/datetime.h>
+#include <grub/time.h>
+#include <grub/list.h>
@ -117,26 +119,12 @@ index 4e55adc55..ff1d7776e 100644
+ return 1;
+}
static char *
grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)),
@@ -345,178 +437,578 @@ grub_net_configure_by_dhcp_ack (const char *name,
return inter;
struct grub_dhcp_discover_options
{
@@ -610,6 +702,584 @@ out:
return err;
}
-struct grub_net_network_level_interface *
-grub_net_configure_by_dhcpv6_ack (const char *name,
- struct grub_net_card *card,
- grub_net_interface_flags_t flags
- __attribute__((__unused__)),
- const grub_net_link_level_address_t *hwaddr,
- const struct grub_net_dhcpv6_packet *packet,
- int is_def, char **device, char **path)
-{
- struct grub_net_network_level_interface *inter = NULL;
- struct grub_net_network_level_address addr;
- int mask = -1;
-
- if (!device || !path)
+/* The default netbuff size for sending DHCPv6 packets which should be
+ large enough to hold the information */
+#define GRUB_DHCP6_DEFAULT_NETBUFF_ALLOC_SIZE 512
@ -354,19 +342,8 @@ index 4e55adc55..ff1d7776e 100644
+
+ options = grub_zalloc (sizeof(*options));
+ if (!options)
return NULL;
- *device = 0;
- *path = 0;
-
- grub_dprintf ("net", "mac address is %02x:%02x:%02x:%02x:%02x:%02x\n",
- hwaddr->mac[0], hwaddr->mac[1], hwaddr->mac[2],
- hwaddr->mac[3], hwaddr->mac[4], hwaddr->mac[5]);
-
- if (is_def)
- grub_net_default_server = 0;
-
- if (is_def && !grub_net_default_server && packet)
+ return NULL;
+
+ foreach_dhcp6_option ((const struct grub_net_dhcp6_option *)v6h->dhcp_options,
+ size - sizeof (*v6h), parse_dhcp6_option, options);
+
@ -410,165 +387,37 @@ index 4e55adc55..ff1d7776e 100644
+ struct grub_net_network_level_interface *inf;
+
+ if (dhcp6->ia_addr)
{
- const grub_uint8_t *options = packet->dhcp_options;
- unsigned int option_max = 1024 - OFFSET_OF (dhcp_options, packet);
- unsigned int i;
-
- for (i = 0; i < option_max - sizeof (grub_net_dhcpv6_option_t); )
- {
- grub_uint16_t num, len;
- grub_net_dhcpv6_option_t *opt =
- (grub_net_dhcpv6_option_t *)(options + i);
-
- num = grub_be_to_cpu16(opt->option_num);
- len = grub_be_to_cpu16(opt->option_len);
-
- grub_dprintf ("net", "got dhcpv6 option %d len %d\n", num, len);
-
- if (len == 0)
- break;
-
- if (len + i > 1024)
- break;
-
- if (num == GRUB_NET_DHCP6_BOOTFILE_URL)
- {
- char *scheme, *userinfo, *host, *file;
- char *tmp;
- int hostlen;
- int port;
- int rc = extract_url_info ((const char *)opt->option_data,
- (grub_size_t)len,
- &scheme, &userinfo, &host, &port,
- &file);
- if (rc < 0)
- continue;
-
- /* right now this only handles tftp. */
- if (grub_strcmp("tftp", scheme))
- {
- grub_free (scheme);
- grub_free (userinfo);
- grub_free (host);
- grub_free (file);
- continue;
- }
- grub_free (userinfo);
-
- hostlen = grub_strlen (host);
- if (hostlen > 2 && host[0] == '[' && host[hostlen-1] == ']')
- {
- tmp = host+1;
- host[hostlen-1] = '\0';
- }
- else
- tmp = host;
+ {
+ inf = grub_net_add_addr (name, card, dhcp6->ia_addr, &card->default_address, flags);
- *device = grub_xasprintf ("%s,%s", scheme, tmp);
- grub_free (scheme);
- grub_free (host);
+
+ netaddr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ netaddr.ipv6.base[0] = dhcp6->ia_addr->ipv6[0];
+ netaddr.ipv6.base[1] = 0;
+ netaddr.ipv6.masksize = 64;
+ grub_net_add_route (name, netaddr, inf);
- if (file && *file)
- {
- tmp = grub_strrchr (file, '/');
- if (tmp)
- *(tmp+1) = '\0';
- else
- file[0] = '\0';
- }
- else if (!file)
- file = grub_strdup ("");
-
- if (file[0] == '/')
- {
- *path = grub_strdup (file+1);
- grub_free (file);
- }
- else
- *path = file;
- }
- else if (num == GRUB_NET_DHCP6_IA_NA)
- {
- const grub_net_dhcpv6_option_t *ia_na_opt;
- const grub_net_dhcpv6_opt_ia_na_t *ia_na =
- (const grub_net_dhcpv6_opt_ia_na_t *)opt;
- unsigned int left = len - OFFSET_OF (options, ia_na);
- unsigned int j;
-
- if ((grub_uint8_t *)ia_na + left >
- (grub_uint8_t *)options + option_max)
- left -= ((grub_uint8_t *)ia_na + left)
- - ((grub_uint8_t *)options + option_max);
-
- if (len < OFFSET_OF (option_data, opt)
- + sizeof (grub_net_dhcpv6_option_t))
- {
- grub_dprintf ("net",
- "found dhcpv6 ia_na option with no address\n");
- continue;
- }
-
- for (j = 0; left > sizeof (grub_net_dhcpv6_option_t); )
- {
- ia_na_opt = (const grub_net_dhcpv6_option_t *)
- (ia_na->options + j);
- grub_uint16_t ia_na_opt_num, ia_na_opt_len;
-
- ia_na_opt_num = grub_be_to_cpu16 (ia_na_opt->option_num);
- ia_na_opt_len = grub_be_to_cpu16 (ia_na_opt->option_len);
- if (ia_na_opt_len == 0)
- break;
- if (j + ia_na_opt_len > left)
- break;
- if (ia_na_opt_num == GRUB_NET_DHCP6_IA_ADDRESS)
- {
- const grub_net_dhcpv6_opt_ia_address_t *ia_addr;
-
- ia_addr = (const grub_net_dhcpv6_opt_ia_address_t *)
- ia_na_opt;
- addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
- grub_memcpy(addr.ipv6, ia_addr->ipv6_address,
- sizeof (ia_addr->ipv6_address));
- inter = grub_net_add_addr (name, card, &addr, hwaddr, 0);
- }
-
- j += ia_na_opt_len;
- left -= ia_na_opt_len;
- }
- }
+
+ if (ret_inf)
+ *ret_inf = inf;
+ }
- i += len + 4;
- }
+
+ if (dhcp6->dns_server_addrs)
+ {
+ grub_uint16_t i;
- grub_print_error ();
+
+ for (i = 0; i < dhcp6->num_dns_server; ++i)
+ grub_net_add_dns_server (dhcp6->dns_server_addrs + i);
}
- if (is_def)
+ }
+
+ if (dhcp6->boot_file_path)
+ grub_env_set_net_property (name, "boot_file", dhcp6->boot_file_path,
+ grub_strlen (dhcp6->boot_file_path));
+
+ if (is_def && dhcp6->boot_file_server_ip)
{
+ {
+ grub_net_default_server = grub_strdup (dhcp6->boot_file_server_ip);
grub_env_set ("net_default_interface", name);
grub_env_export ("net_default_interface");
}
+ grub_env_set ("net_default_interface", name);
+ grub_env_export ("net_default_interface");
+ }
+}
+
+static void
@ -578,7 +427,7 @@ index 4e55adc55..ff1d7776e 100644
+ grub_dhcp6_session_t se;
+ struct grub_datetime date;
+ grub_err_t err;
+ grub_int32_t t = 0;
+ grub_int64_t t = 0;
+
+ se = grub_malloc (sizeof (*se));
+
@ -628,10 +477,7 @@ index 4e55adc55..ff1d7776e 100644
+grub_dhcp6_session_configure_network (grub_dhcp6_session_t se)
+{
+ char *name;
- if (inter)
- grub_net_add_ipv6_local (inter, mask);
- return inter;
+
+ name = grub_xasprintf ("%s:dhcp6", se->iface->card->name);
+ if (!name)
+ return grub_errno;
@ -640,8 +486,8 @@ index 4e55adc55..ff1d7776e 100644
+ grub_free (name);
+
+ return GRUB_ERR_NONE;
}
+}
+
+static grub_err_t
+grub_dhcp6_session_send_request (grub_dhcp6_session_t se)
+{
@ -818,6 +664,7 @@ index 4e55adc55..ff1d7776e 100644
+{
+ struct grub_net_network_level_interface *inf;
+ grub_dhcp6_options_t dhcp6;
+ int mask = -1;
+
+ dhcp6 = grub_dhcp6_options_get (v6h, size);
+ if (!dhcp6)
@ -849,18 +696,23 @@ index 4e55adc55..ff1d7776e 100644
+ }
+
+ grub_dhcp6_options_free (dhcp6);
+
+ if (inf)
+ grub_net_add_ipv6_local (inf, mask);
+
+ return inf;
+}
void
grub_net_process_dhcp (struct grub_net_buff *nb,
@@ -550,6 +1042,77 @@ grub_net_process_dhcp (struct grub_net_buff *nb,
+
/*
* This is called directly from net/ip.c:handle_dgram(), because those
* BOOTP/DHCP packets are a bit special due to their improper
@@ -678,6 +1348,77 @@ grub_net_process_dhcp (struct grub_net_buff *nb,
}
}
+grub_err_t
+grub_net_process_dhcp6 (struct grub_net_buff *nb,
+ struct grub_net_card *card __attribute__ ((unused)))
+ struct grub_net_card *card __attribute__ ((unused)))
+{
+ const struct grub_net_dhcp6_packet *v6h;
+ grub_dhcp6_session_t se;
@ -883,9 +735,9 @@ index 4e55adc55..ff1d7776e 100644
+ FOR_DHCP6_SESSIONS (se)
+ {
+ if (se->transaction_id == v6h->transaction_id &&
+ grub_memcmp (options->client_duid, &se->duid, sizeof (se->duid)) == 0 &&
+ se->iaid == options->iaid)
+ break;
+ grub_memcmp (options->client_duid, &se->duid, sizeof (se->duid)) == 0 &&
+ se->iaid == options->iaid)
+ break;
+ }
+
+ if (!se)
@ -898,11 +750,11 @@ index 4e55adc55..ff1d7776e 100644
+ if (v6h->message_type == GRUB_NET_DHCP6_ADVERTISE)
+ {
+ if (se->adv)
+ {
+ grub_dprintf ("bootp", "Skipped DHCPv6 Advertised .. \n");
+ grub_dhcp6_options_free (options);
+ return GRUB_ERR_NONE;
+ }
+ {
+ grub_dprintf ("bootp", "Skipped DHCPv6 Advertised .. \n");
+ grub_dhcp6_options_free (options);
+ return GRUB_ERR_NONE;
+ }
+
+ se->adv = options;
+ return grub_dhcp6_session_send_request (se);
@ -910,11 +762,11 @@ index 4e55adc55..ff1d7776e 100644
+ else if (v6h->message_type == GRUB_NET_DHCP6_REPLY)
+ {
+ if (!se->adv)
+ {
+ grub_dprintf ("bootp", "Skipped DHCPv6 Reply .. \n");
+ grub_dhcp6_options_free (options);
+ return GRUB_ERR_NONE;
+ }
+ {
+ grub_dprintf ("bootp", "Skipped DHCPv6 Reply .. \n");
+ grub_dhcp6_options_free (options);
+ return GRUB_ERR_NONE;
+ }
+
+ se->reply = options;
+ grub_dhcp6_session_configure_network (se);
@ -932,183 +784,342 @@ index 4e55adc55..ff1d7776e 100644
static grub_err_t
grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
int argc, char **args)
@@ -824,7 +1387,174 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
@@ -903,180 +1644,174 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
return err;
}
-static grub_command_t cmd_getdhcp, cmd_bootp;
-static grub_command_t cmd_getdhcp, cmd_bootp, cmd_dhcp;
-
-struct grub_net_network_level_interface *
-grub_net_configure_by_dhcpv6_ack (const char *name,
- struct grub_net_card *card,
- grub_net_interface_flags_t flags
- __attribute__((__unused__)),
- const grub_net_link_level_address_t *hwaddr,
- const struct grub_net_dhcpv6_packet *packet,
- int is_def, char **device, char **path)
+static grub_err_t
+grub_cmd_bootp6 (struct grub_command *cmd __attribute__ ((unused)),
+ int argc, char **args)
+{
+ int argc, char **args)
{
- struct grub_net_network_level_interface *inter = NULL;
- struct grub_net_network_level_address addr;
- int mask = -1;
+ struct grub_net_card *card;
+ grub_uint32_t iaid = 0;
+ int interval;
+ grub_err_t err;
+ grub_dhcp6_session_t se;
+
- if (!device || !path)
- return NULL;
+ err = GRUB_ERR_NONE;
+
- *device = 0;
- *path = 0;
+ FOR_NET_CARDS (card)
+ {
+ struct grub_net_network_level_interface *iface;
+
- grub_dprintf ("net", "mac address is %02x:%02x:%02x:%02x:%02x:%02x\n",
- hwaddr->mac[0], hwaddr->mac[1], hwaddr->mac[2],
- hwaddr->mac[3], hwaddr->mac[4], hwaddr->mac[5]);
+ if (argc > 0 && grub_strcmp (card->name, args[0]) != 0)
+ continue;
+
- if (is_def)
- grub_net_default_server = 0;
+ iface = grub_net_ipv6_get_link_local (card, &card->default_address);
+ if (!iface)
+ {
+ grub_dhcp6_session_remove_all ();
+ return grub_errno;
+ grub_dhcp6_session_remove_all ();
+ return grub_errno;
+ }
+
- if (is_def && !grub_net_default_server && packet)
+ grub_dhcp6_session_add (iface, iaid++);
+ }
+
+ for (interval = 200; interval < 10000; interval *= 2)
+ {
{
- const grub_uint8_t *options = packet->dhcp_options;
- unsigned int option_max = 1024 - OFFSET_OF (dhcp_options, packet);
- unsigned int i;
-
- for (i = 0; i < option_max - sizeof (grub_net_dhcpv6_option_t); )
- {
- grub_uint16_t num, len;
- grub_net_dhcpv6_option_t *opt =
- (grub_net_dhcpv6_option_t *)(options + i);
-
- num = grub_be_to_cpu16(opt->option_num);
- len = grub_be_to_cpu16(opt->option_len);
-
- grub_dprintf ("net", "got dhcpv6 option %d len %d\n", num, len);
-
- if (len == 0)
- break;
-
- if (len + i > 1024)
- break;
-
- if (num == GRUB_NET_DHCP6_BOOTFILE_URL)
- {
- char *scheme, *userinfo, *host, *file;
- char *tmp;
- int hostlen;
- int port;
- int rc = extract_url_info ((const char *)opt->option_data,
- (grub_size_t)len,
- &scheme, &userinfo, &host, &port,
- &file);
- if (rc < 0)
- continue;
-
- /* right now this only handles tftp. */
- if (grub_strcmp("tftp", scheme))
- {
- grub_free (scheme);
- grub_free (userinfo);
- grub_free (host);
- grub_free (file);
- continue;
- }
- grub_free (userinfo);
-
- hostlen = grub_strlen (host);
- if (hostlen > 2 && host[0] == '[' && host[hostlen-1] == ']')
- {
- tmp = host+1;
- host[hostlen-1] = '\0';
- }
- else
- tmp = host;
-
- *device = grub_xasprintf ("%s,%s", scheme, tmp);
- grub_free (scheme);
- grub_free (host);
-
- if (file && *file)
- {
- tmp = grub_strrchr (file, '/');
- if (tmp)
- *(tmp+1) = '\0';
- else
- file[0] = '\0';
- }
- else if (!file)
- file = grub_strdup ("");
-
- if (file[0] == '/')
- {
- *path = grub_strdup (file+1);
- grub_free (file);
- }
- else
- *path = file;
- }
- else if (num == GRUB_NET_DHCP6_IA_NA)
- {
- const grub_net_dhcpv6_option_t *ia_na_opt;
- const grub_net_dhcpv6_opt_ia_na_t *ia_na =
- (const grub_net_dhcpv6_opt_ia_na_t *)opt;
- unsigned int left = len - OFFSET_OF (options, ia_na);
- unsigned int j;
-
- if ((grub_uint8_t *)ia_na + left >
- (grub_uint8_t *)options + option_max)
- left -= ((grub_uint8_t *)ia_na + left)
- - ((grub_uint8_t *)options + option_max);
-
- if (len < OFFSET_OF (option_data, opt)
- + sizeof (grub_net_dhcpv6_option_t))
- {
- grub_dprintf ("net",
- "found dhcpv6 ia_na option with no address\n");
- continue;
- }
-
- for (j = 0; left > sizeof (grub_net_dhcpv6_option_t); )
- {
- ia_na_opt = (const grub_net_dhcpv6_option_t *)
- (ia_na->options + j);
- grub_uint16_t ia_na_opt_num, ia_na_opt_len;
-
- ia_na_opt_num = grub_be_to_cpu16 (ia_na_opt->option_num);
- ia_na_opt_len = grub_be_to_cpu16 (ia_na_opt->option_len);
- if (ia_na_opt_len == 0)
- break;
- if (j + ia_na_opt_len > left)
- break;
- if (ia_na_opt_num == GRUB_NET_DHCP6_IA_ADDRESS)
- {
- const grub_net_dhcpv6_opt_ia_address_t *ia_addr;
-
- ia_addr = (const grub_net_dhcpv6_opt_ia_address_t *)
- ia_na_opt;
- addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
- grub_memcpy(addr.ipv6, ia_addr->ipv6_address,
- sizeof (ia_addr->ipv6_address));
- inter = grub_net_add_addr (name, card, &addr, hwaddr, 0);
- }
-
- j += ia_na_opt_len;
- left -= ia_na_opt_len;
- }
- }
-
- i += len + 4;
- }
-
- grub_print_error ();
+ int done = 1;
+
+ FOR_DHCP6_SESSIONS (se)
+ {
+ struct grub_net_buff *nb;
+ struct grub_net_dhcp6_option *opt;
+ struct grub_net_dhcp6_packet *v6h;
+ struct grub_net_dhcp6_option_duid_ll *duid;
+ struct grub_net_dhcp6_option_iana *ia_na;
+ grub_net_network_level_address_t multicast;
+ grub_net_link_level_address_t ll_multicast;
+ struct udphdr *udph;
+ {
+ struct grub_net_buff *nb;
+ struct grub_net_dhcp6_option *opt;
+ struct grub_net_dhcp6_packet *v6h;
+ struct grub_net_dhcp6_option_duid_ll *duid;
+ struct grub_net_dhcp6_option_iana *ia_na;
+ grub_net_network_level_address_t multicast;
+ grub_net_link_level_address_t ll_multicast;
+ struct udphdr *udph;
+
+ multicast.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ multicast.ipv6[0] = grub_cpu_to_be64_compile_time (0xff02ULL << 48);
+ multicast.ipv6[1] = grub_cpu_to_be64_compile_time (0x10002ULL);
+ multicast.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ multicast.ipv6[0] = grub_cpu_to_be64_compile_time (0xff02ULL << 48);
+ multicast.ipv6[1] = grub_cpu_to_be64_compile_time (0x10002ULL);
+
+ err = grub_net_link_layer_resolve (se->iface,
+ &multicast, &ll_multicast);
+ if (err)
+ {
+ grub_dhcp6_session_remove_all ();
+ return err;
+ }
+ err = grub_net_link_layer_resolve (se->iface,
+ &multicast, &ll_multicast);
+ if (err)
+ {
+ grub_dhcp6_session_remove_all ();
+ return err;
+ }
+
+ nb = grub_netbuff_alloc (GRUB_DHCP6_DEFAULT_NETBUFF_ALLOC_SIZE);
+ nb = grub_netbuff_alloc (GRUB_DHCP6_DEFAULT_NETBUFF_ALLOC_SIZE);
+
+ if (!nb)
+ {
+ grub_dhcp6_session_remove_all ();
+ return grub_errno;
+ }
+ if (!nb)
+ {
+ grub_dhcp6_session_remove_all ();
+ return grub_errno;
+ }
+
+ err = grub_netbuff_reserve (nb, GRUB_DHCP6_DEFAULT_NETBUFF_ALLOC_SIZE);
+ if (err)
+ {
+ grub_dhcp6_session_remove_all ();
+ grub_netbuff_free (nb);
+ return err;
+ }
+ err = grub_netbuff_reserve (nb, GRUB_DHCP6_DEFAULT_NETBUFF_ALLOC_SIZE);
+ if (err)
+ {
+ grub_dhcp6_session_remove_all ();
+ grub_netbuff_free (nb);
+ return err;
+ }
+
+ err = grub_netbuff_push (nb, sizeof (*opt) + sizeof (grub_uint16_t));
+ if (err)
+ {
+ grub_dhcp6_session_remove_all ();
+ grub_netbuff_free (nb);
+ return err;
+ }
+ err = grub_netbuff_push (nb, sizeof (*opt) + sizeof (grub_uint16_t));
+ if (err)
+ {
+ grub_dhcp6_session_remove_all ();
+ grub_netbuff_free (nb);
+ return err;
+ }
+
+ opt = (struct grub_net_dhcp6_option *)nb->data;
+ opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_ELAPSED_TIME);
+ opt->len = grub_cpu_to_be16_compile_time (sizeof (grub_uint16_t));
+ grub_set_unaligned16 (opt->data, 0);
+ opt = (struct grub_net_dhcp6_option *)nb->data;
+ opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_ELAPSED_TIME);
+ opt->len = grub_cpu_to_be16_compile_time (sizeof (grub_uint16_t));
+ grub_set_unaligned16 (opt->data, 0);
+
+ err = grub_netbuff_push (nb, sizeof (*opt) + sizeof (*duid));
+ if (err)
+ {
+ grub_dhcp6_session_remove_all ();
+ grub_netbuff_free (nb);
+ return err;
+ }
+ err = grub_netbuff_push (nb, sizeof (*opt) + sizeof (*duid));
+ if (err)
+ {
+ grub_dhcp6_session_remove_all ();
+ grub_netbuff_free (nb);
+ return err;
+ }
+
+ opt = (struct grub_net_dhcp6_option *)nb->data;
+ opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_CLIENTID);
+ opt->len = grub_cpu_to_be16 (sizeof (*duid));
+ opt = (struct grub_net_dhcp6_option *)nb->data;
+ opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_CLIENTID);
+ opt->len = grub_cpu_to_be16 (sizeof (*duid));
+
+ duid = (struct grub_net_dhcp6_option_duid_ll *) opt->data;
+ grub_memcpy (duid, &se->duid, sizeof (*duid));
+ duid = (struct grub_net_dhcp6_option_duid_ll *) opt->data;
+ grub_memcpy (duid, &se->duid, sizeof (*duid));
+
+ err = grub_netbuff_push (nb, sizeof (*opt) + sizeof (*ia_na));
+ if (err)
+ {
+ grub_dhcp6_session_remove_all ();
+ grub_netbuff_free (nb);
+ return err;
+ }
+ err = grub_netbuff_push (nb, sizeof (*opt) + sizeof (*ia_na));
+ if (err)
+ {
+ grub_dhcp6_session_remove_all ();
+ grub_netbuff_free (nb);
+ return err;
+ }
+
+ opt = (struct grub_net_dhcp6_option *)nb->data;
+ opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_IA_NA);
+ opt->len = grub_cpu_to_be16 (sizeof (*ia_na));
+ ia_na = (struct grub_net_dhcp6_option_iana *)opt->data;
+ ia_na->iaid = grub_cpu_to_be32 (se->iaid);
+ ia_na->t1 = 0;
+ ia_na->t2 = 0;
+ opt = (struct grub_net_dhcp6_option *)nb->data;
+ opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_IA_NA);
+ opt->len = grub_cpu_to_be16 (sizeof (*ia_na));
+ ia_na = (struct grub_net_dhcp6_option_iana *)opt->data;
+ ia_na->iaid = grub_cpu_to_be32 (se->iaid);
+ ia_na->t1 = 0;
+ ia_na->t2 = 0;
+
+ err = grub_netbuff_push (nb, sizeof (*v6h));
+ if (err)
+ {
+ grub_dhcp6_session_remove_all ();
+ grub_netbuff_free (nb);
+ return err;
+ }
+ err = grub_netbuff_push (nb, sizeof (*v6h));
+ if (err)
+ {
+ grub_dhcp6_session_remove_all ();
+ grub_netbuff_free (nb);
+ return err;
+ }
+
+ v6h = (struct grub_net_dhcp6_packet *)nb->data;
+ v6h->message_type = GRUB_NET_DHCP6_SOLICIT;
+ v6h->transaction_id = se->transaction_id;
+ v6h = (struct grub_net_dhcp6_packet *)nb->data;
+ v6h->message_type = GRUB_NET_DHCP6_SOLICIT;
+ v6h->transaction_id = se->transaction_id;
+
+ grub_netbuff_push (nb, sizeof (*udph));
+ grub_netbuff_push (nb, sizeof (*udph));
+
+ udph = (struct udphdr *) nb->data;
+ udph->src = grub_cpu_to_be16_compile_time (DHCP6_CLIENT_PORT);
+ udph->dst = grub_cpu_to_be16_compile_time (DHCP6_SERVER_PORT);
+ udph->chksum = 0;
+ udph->len = grub_cpu_to_be16 (nb->tail - nb->data);
+ udph = (struct udphdr *) nb->data;
+ udph->src = grub_cpu_to_be16_compile_time (DHCP6_CLIENT_PORT);
+ udph->dst = grub_cpu_to_be16_compile_time (DHCP6_SERVER_PORT);
+ udph->chksum = 0;
+ udph->len = grub_cpu_to_be16 (nb->tail - nb->data);
+
+ udph->chksum = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_UDP,
+ &se->iface->address, &multicast);
+ udph->chksum = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_UDP,
+ &se->iface->address, &multicast);
+
+ err = grub_net_send_ip_packet (se->iface, &multicast,
+ &ll_multicast, nb, GRUB_NET_IP_UDP);
+ done = 0;
+ grub_netbuff_free (nb);
+ err = grub_net_send_ip_packet (se->iface, &multicast,
+ &ll_multicast, nb, GRUB_NET_IP_UDP);
+ done = 0;
+ grub_netbuff_free (nb);
+
+ if (err)
+ {
+ grub_dhcp6_session_remove_all ();
+ return err;
+ }
+ }
+ if (err)
+ {
+ grub_dhcp6_session_remove_all ();
+ return err;
+ }
+ }
+ if (!done)
+ grub_net_poll_cards (interval, 0);
+ }
+
+ grub_net_poll_cards (interval, 0);
}
- if (is_def)
+ FOR_DHCP6_SESSIONS (se)
+ {
{
- grub_env_set ("net_default_interface", name);
- grub_env_export ("net_default_interface");
+ grub_error_push ();
+ err = grub_error (GRUB_ERR_FILE_NOT_FOUND,
+ N_("couldn't autoconfigure %s"),
+ se->iface->card->name);
+ }
+
+ N_("couldn't autoconfigure %s"),
+ se->iface->card->name);
}
- if (inter)
- grub_net_add_ipv6_local (inter, mask);
- return inter;
+ grub_dhcp6_session_remove_all ();
+
+ return err;
+}
+
+static grub_command_t cmd_getdhcp, cmd_bootp, cmd_bootp6;
}
+static grub_command_t cmd_getdhcp, cmd_bootp, cmd_dhcp, cmd_bootp6;
void
grub_bootp_init (void)
@@ -835,6 +1565,9 @@ grub_bootp_init (void)
@@ -1090,11 +1825,15 @@ grub_bootp_init (void)
cmd_getdhcp = grub_register_command ("net_get_dhcp_option", grub_cmd_dhcpopt,
N_("VAR INTERFACE NUMBER DESCRIPTION"),
N_("retrieve DHCP option and save it into VAR. If VAR is - then print the value."));
@ -1118,17 +1129,17 @@ index 4e55adc55..ff1d7776e 100644
}
void
@@ -842,4 +1575,5 @@ grub_bootp_fini (void)
grub_bootp_fini (void)
{
+ grub_unregister_command (cmd_bootp6);
grub_unregister_command (cmd_getdhcp);
grub_unregister_command (cmd_bootp);
+ grub_unregister_command (cmd_bootp6);
}
grub_unregister_command (cmd_dhcp);
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
index cd6dba79f..6fd0a4f49 100644
index 2af8742f904..3e2432fb61c 100644
--- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -393,9 +393,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
@@ -410,9 +410,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
pxe_mode = pxe->mode;
if (pxe_mode->using_ipv6)
{
@ -1138,7 +1149,7 @@ index cd6dba79f..6fd0a4f49 100644
grub_dprintf ("efinet", "using ipv6 and dhcpv6\n");
grub_dprintf ("efinet", "dhcp_ack_received: %s%s\n",
pxe_mode->dhcp_ack_received ? "yes" : "no",
@@ -403,15 +400,14 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
@@ -420,14 +417,13 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
if (!pxe_mode->dhcp_ack_received)
continue;
@ -1147,26 +1158,24 @@ index cd6dba79f..6fd0a4f49 100644
- card->efi_net->mode->current_address,
- sizeof (hwaddr.mac));
-
- intf = grub_net_configure_by_dhcpv6_ack (card->name, card, 0, &hwaddr,
- inter = grub_net_configure_by_dhcpv6_ack (card->name, card, 0, &hwaddr,
- (const struct grub_net_dhcpv6_packet *)&pxe_mode->dhcp_ack.dhcpv6,
- 1, device, path);
- if (intf && device && path)
+ grub_net_configure_by_dhcpv6_reply (card->name, card, 0,
+ (struct grub_net_dhcp6_packet *)
+ &pxe_mode->dhcp_ack,
+ sizeof (pxe_mode->dhcp_ack),
+ 1, device, path);
+ inter = grub_net_configure_by_dhcpv6_reply (card->name, card, 0,
+ (struct grub_net_dhcp6_packet *)
+ &pxe_mode->dhcp_ack,
+ sizeof (pxe_mode->dhcp_ack),
+ 1, device, path);
+ if (grub_errno)
+ grub_print_error ();
+ if (device && path)
if (inter && device && path)
grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path);
}
else
diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c
index b2ca74b6e..9a4e589aa 100644
index 3c3d0be0e57..f967618e53f 100644
--- a/grub-core/net/ip.c
+++ b/grub-core/net/ip.c
@@ -239,6 +239,45 @@ handle_dgram (struct grub_net_buff *nb,
@@ -240,6 +240,45 @@ handle_dgram (struct grub_net_buff *nb,
{
struct udphdr *udph;
udph = (struct udphdr *) nb->data;
@ -1213,10 +1222,10 @@ index b2ca74b6e..9a4e589aa 100644
{
const struct grub_net_bootp_packet *bootp;
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
index e5b521bd9..1250d493e 100644
index c6d702831f7..c1b869db520 100644
--- a/include/grub/efi/api.h
+++ b/include/grub/efi/api.h
@@ -1507,7 +1507,7 @@ typedef struct grub_efi_pxe_ip_filter
@@ -1570,7 +1570,7 @@ typedef struct grub_efi_pxe_ip_filter
{
grub_efi_uint8_t filters;
grub_efi_uint8_t ip_count;
@ -1226,10 +1235,10 @@ index e5b521bd9..1250d493e 100644
} grub_efi_pxe_ip_filter_t;
diff --git a/include/grub/net.h b/include/grub/net.h
index f4cd86e58..5f78b22e1 100644
index bf8430a6364..ff901b96e22 100644
--- a/include/grub/net.h
+++ b/include/grub/net.h
@@ -447,50 +447,65 @@ struct grub_net_bootp_packet
@@ -450,50 +450,65 @@ struct grub_net_bootp_packet
grub_uint8_t vendor[0];
} GRUB_PACKED;
@ -1325,7 +1334,7 @@ index f4cd86e58..5f78b22e1 100644
#define GRUB_NET_BOOTP_RFC1048_MAGIC_0 0x63
#define GRUB_NET_BOOTP_RFC1048_MAGIC_1 0x82
@@ -521,12 +536,12 @@ grub_net_configure_by_dhcp_ack (const char *name,
@@ -531,12 +546,12 @@ grub_net_configure_by_dhcp_ack (const char *name,
int is_def, char **device, char **path);
struct grub_net_network_level_interface *
@ -1344,9 +1353,9 @@ index f4cd86e58..5f78b22e1 100644
int
grub_ipv6_get_masksize(grub_uint16_t *mask);
@@ -543,6 +558,10 @@ void
@@ -553,6 +568,10 @@ void
grub_net_process_dhcp (struct grub_net_buff *nb,
struct grub_net_card *card);
struct grub_net_network_level_interface *iface);
+grub_err_t
+grub_net_process_dhcp6 (struct grub_net_buff *nb,

View File

@ -10,24 +10,24 @@ variables are then used by 10_linux to choose whether or not to create
debug stanzas.
Resolves: rhbz#1226325
[rharwood: migrate man page to h2m]
---
configure.ac | 2 +
Makefile.util.def | 7 +++
.gitignore | 2 +
util/bash-completion.d/grub-completion.bash.in | 22 ++++++++
util/grub-get-kernel-settings.3 | 20 +++++++
util/grub-get-kernel-settings.in | 78 ++++++++++++++++++++++++++
configure.ac | 1 +
Makefile.util.def | 7 ++
docs/man/grub-get-kernel-settings.h2m | 2 +
util/bash-completion.d/grub-completion.bash.in | 22 +++++++
util/grub-get-kernel-settings.in | 88 ++++++++++++++++++++++++++
util/grub-mkconfig.in | 3 +
util/grub.d/10_linux.in | 23 ++++++--
8 files changed, 152 insertions(+), 5 deletions(-)
create mode 100644 util/grub-get-kernel-settings.3
util/grub.d/10_linux.in | 23 +++++--
7 files changed, 141 insertions(+), 5 deletions(-)
create mode 100644 docs/man/grub-get-kernel-settings.h2m
create mode 100644 util/grub-get-kernel-settings.in
diff --git a/configure.ac b/configure.ac
index 71d105696..aa06ed59c 100644
index 493e336ec6c..3602b4ab62b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,6 +58,7 @@ grub_TRANSFORM([grub-install])
@@ -70,6 +70,7 @@ grub_TRANSFORM([grub-install])
grub_TRANSFORM([grub-mkconfig])
grub_TRANSFORM([grub-mkfont])
grub_TRANSFORM([grub-mkimage])
@ -35,19 +35,11 @@ index 71d105696..aa06ed59c 100644
grub_TRANSFORM([grub-glue-efi])
grub_TRANSFORM([grub-mklayout])
grub_TRANSFORM([grub-mkpasswd-pbkdf2])
@@ -75,6 +76,7 @@ grub_TRANSFORM([grub-file])
grub_TRANSFORM([grub-bios-setup.3])
grub_TRANSFORM([grub-editenv.1])
grub_TRANSFORM([grub-fstest.3])
+grub_TRANSFORM([grub-get-kernel-settings.3])
grub_TRANSFORM([grub-glue-efi.3])
grub_TRANSFORM([grub-install.1])
grub_TRANSFORM([grub-kbdcomp.3])
diff --git a/Makefile.util.def b/Makefile.util.def
index fd91045bd..2d032643d 100644
index 95884956a68..84a17ef5cfa 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -714,6 +714,13 @@ script = {
@@ -725,6 +725,13 @@ script = {
installdir = sbin;
};
@ -61,24 +53,19 @@ index fd91045bd..2d032643d 100644
script = {
name = grub-set-default;
common = util/grub-set-default.in;
diff --git a/.gitignore b/.gitignore
index 5066689bc..54795fa60 100644
--- a/.gitignore
+++ b/.gitignore
@@ -68,6 +68,8 @@ grub-*.tar.*
/grub*-fs-tester
/grub*-fstest
/grub*-fstest.1
+/grub*-get-kernel-settings
+/grub*-get-kernel-settings.3
/grub*-glue-efi
/grub*-glue-efi.1
/grub*-install
diff --git a/docs/man/grub-get-kernel-settings.h2m b/docs/man/grub-get-kernel-settings.h2m
new file mode 100644
index 00000000000..b8051f01f3a
--- /dev/null
+++ b/docs/man/grub-get-kernel-settings.h2m
@@ -0,0 +1,2 @@
+[NAME]
+grub-get-kernel-settings \- Evaluate the system's kernel installation settings for use while making a grub configuration file
diff --git a/util/bash-completion.d/grub-completion.bash.in b/util/bash-completion.d/grub-completion.bash.in
index 44bf135b9..5c4acd496 100644
index 213ce1e57cf..da7fca5efac 100644
--- a/util/bash-completion.d/grub-completion.bash.in
+++ b/util/bash-completion.d/grub-completion.bash.in
@@ -264,6 +264,28 @@ have ${__grub_sparc64_setup_program} && \
@@ -275,6 +275,28 @@ have ${__grub_sparc64_setup_program} && \
unset __grub_sparc64_setup_program
@ -107,38 +94,12 @@ index 44bf135b9..5c4acd496 100644
#
# grub-install
#
diff --git a/util/grub-get-kernel-settings.3 b/util/grub-get-kernel-settings.3
new file mode 100644
index 000000000..ba33330e2
--- /dev/null
+++ b/util/grub-get-kernel-settings.3
@@ -0,0 +1,20 @@
+.TH GRUB-GET-KERNEL-SETTINGS 3 "Thu Jun 25 2015"
+.SH NAME
+\fBgrub-get-kernel-settings\fR \(em Evaluate the system's kernel installation settings for use while making a grub configuration file.
+
+.SH SYNOPSIS
+\fBgrub-get-kernel-settings\fR [OPTION]
+
+.SH DESCRIPTION
+\fBgrub-get-kernel-settings\fR reads the kernel installation settings on the host system, and emits a set of grub settings suitable for use when creating a grub configuration file.
+
+.SH OPTIONS
+.TP
+-h, --help
+Display program usage and exit.
+.TP
+-v, --version
+Display the current version.
+
+.SH SEE ALSO
+.BR "info grub"
diff --git a/util/grub-get-kernel-settings.in b/util/grub-get-kernel-settings.in
new file mode 100644
index 000000000..120462198
index 00000000000..7e87dfccc0e
--- /dev/null
+++ b/util/grub-get-kernel-settings.in
@@ -0,0 +1,78 @@
@@ -0,0 +1,88 @@
+#!/bin/sh
+set -e
+
@ -217,8 +178,18 @@ index 000000000..120462198
+ echo GRUB_LINUX_DEBUG_TITLE_POSTFIX=\" with debugging\"
+ echo export GRUB_LINUX_DEBUG_TITLE_POSTFIX
+fi
+if [ "$DEFAULTDEBUG" = "yes" ]; then
+ echo GRUB_DEFAULT_TO_DEBUG=true
+else
+ echo GRUB_DEFAULT_TO_DEBUG=false
+fi
+echo export GRUB_DEFAULT_TO_DEBUG
+if [ "$UPDATEDEFAULT" = "yes" ]; then
+ echo GRUB_UPDATE_DEFAULT_KERNEL=true
+ echo export GRUB_UPDATE_DEFAULT_KERNEL
+fi
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index bdb9982ae..8218f3d47 100644
index 5f2824d4f58..28e92515795 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -45,6 +45,7 @@ grub_probe="${sbindir}/@grub_probe@"
@ -235,14 +206,14 @@ index bdb9982ae..8218f3d47 100644
+eval "$("${grub_get_kernel_settings}")" || true
+
if [ "x$GRUB_DISABLE_UUID" != "xtrue" ]; then
if [ -z "$GRUB_DEVICE_UUID" ]; then
GRUB_DEVICE_UUID="$GRUB_DEVICE_UUID_GENERATED"
if [ "x${GRUB_DISABLE_UUID}" = "xtrue" ]; then
if [ -z "${GRUB_DISABLE_LINUX_UUID}" ]; then
GRUB_DISABLE_LINUX_UUID="true"
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index a8a8e2cf3..4e49ccdf7 100644
index 993c53ad92e..e8ab4082f87 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -111,7 +111,8 @@ linux_entry ()
@@ -113,7 +113,8 @@ linux_entry ()
os="$1"
version="$2"
type="$3"
@ -252,7 +223,7 @@ index a8a8e2cf3..4e49ccdf7 100644
if [ -z "$boot_device_id" ]; then
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
@@ -123,6 +124,9 @@ linux_entry ()
@@ -125,6 +126,9 @@ linux_entry ()
quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
fi
@ -262,7 +233,7 @@ index a8a8e2cf3..4e49ccdf7 100644
echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
else
echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
@@ -295,11 +299,15 @@ while [ "x$list" != "x" ] ; do
@@ -320,11 +324,15 @@ for linux in ${reverse_sorted_list}; do
fi
if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
@ -280,7 +251,7 @@ index a8a8e2cf3..4e49ccdf7 100644
if [ -z "$boot_device_id" ]; then
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
fi
@@ -308,10 +316,15 @@ while [ "x$list" != "x" ] ; do
@@ -333,10 +341,15 @@ for linux in ${reverse_sorted_list}; do
is_top_level=false
fi
@ -295,6 +266,6 @@ index a8a8e2cf3..4e49ccdf7 100644
if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
- linux_entry "${OS}" "${version}" recovery \
+ linux_entry "${OS}" "${version}" recovery standard \
"single ${GRUB_CMDLINE_LINUX}"
"${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}"
fi
done

View File

@ -5,18 +5,18 @@ Subject: [PATCH] Make grub_fatal() also backtrace.
---
grub-core/Makefile.core.def | 3 ++
grub-core/kern/misc.c | 8 +++++-
grub-core/kern/misc.c | 6 ++++
grub-core/lib/arm64/backtrace.c | 62 +++++++++++++++++++++++++++++++++++++++++
grub-core/lib/backtrace.c | 2 ++
grub-core/lib/i386/backtrace.c | 14 +++++++++-
5 files changed, 87 insertions(+), 2 deletions(-)
5 files changed, 86 insertions(+), 1 deletion(-)
create mode 100644 grub-core/lib/arm64/backtrace.c
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 991891a6e..27563743b 100644
index 47c0fc755a2..63f053b3add 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -175,6 +175,9 @@ kernel = {
@@ -199,6 +199,9 @@ kernel = {
softdiv = lib/division.c;
@ -25,21 +25,21 @@ index 991891a6e..27563743b 100644
+
i386 = kern/i386/dl.c;
i386_xen = kern/i386/dl.c;
i386_xen_pvh = kern/i386/dl.c;
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index f1fab7000..5ce89a40c 100644
index 11037dc0227..465a8e74ea7 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -24,6 +24,7 @@
#include <grub/term.h>
#include <grub/env.h>
@@ -26,6 +26,7 @@
#include <grub/i18n.h>
#include <grub/types.h>
#include <grub/charset.h>
+#include <grub/backtrace.h>
union printf_arg
{
@@ -1101,8 +1102,13 @@ grub_xasprintf (const char *fmt, ...)
static void __attribute__ ((noreturn))
@@ -1301,6 +1302,11 @@ grub_printf_fmt_check (const char *fmt, const char *fmt_expected)
void __attribute__ ((noreturn))
grub_abort (void)
{
+#ifndef GRUB_UTIL
@ -48,14 +48,11 @@ index f1fab7000..5ce89a40c 100644
+#endif
+#endif
grub_printf ("\nAborted.");
-
+
#ifndef GRUB_UTIL
if (grub_term_inputs)
#endif
diff --git a/grub-core/lib/arm64/backtrace.c b/grub-core/lib/arm64/backtrace.c
new file mode 100644
index 000000000..1079b5380
index 00000000000..1079b5380e1
--- /dev/null
+++ b/grub-core/lib/arm64/backtrace.c
@@ -0,0 +1,62 @@
@ -122,7 +119,7 @@ index 000000000..1079b5380
+}
+
diff --git a/grub-core/lib/backtrace.c b/grub-core/lib/backtrace.c
index 825a8800e..c0ad6ab8b 100644
index 825a8800e25..c0ad6ab8be1 100644
--- a/grub-core/lib/backtrace.c
+++ b/grub-core/lib/backtrace.c
@@ -29,6 +29,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
@ -142,7 +139,7 @@ index 825a8800e..c0ad6ab8b 100644
}
diff --git a/grub-core/lib/i386/backtrace.c b/grub-core/lib/i386/backtrace.c
index c3e03c727..c67273db3 100644
index c3e03c7275c..c67273db3ae 100644
--- a/grub-core/lib/i386/backtrace.c
+++ b/grub-core/lib/i386/backtrace.c
@@ -15,11 +15,23 @@

View File

@ -1,6 +1,6 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 6 May 2016 18:43:08 -0400
Date: Tue, 9 Jul 2019 12:59:58 +0200
Subject: [PATCH] Make our info pages say "grub2" where appropriate.
This needs to be hooked up to --program-transform=, but I haven't had
@ -9,11 +9,11 @@ time.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
docs/grub-dev.texi | 4 +-
docs/grub.texi | 318 ++++++++++++++++++++++++++---------------------------
2 files changed, 161 insertions(+), 161 deletions(-)
docs/grub.texi | 357 ++++++++++++++++++++++++++++-------------------------
2 files changed, 189 insertions(+), 172 deletions(-)
diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi
index a9f4de631..3ce827ab7 100644
index 1276c59302a..04c6678cb6b 100644
--- a/docs/grub-dev.texi
+++ b/docs/grub-dev.texi
@@ -1,7 +1,7 @@
@ -35,7 +35,7 @@ index a9f4de631..3ce827ab7 100644
@setchapternewpage odd
diff --git a/docs/grub.texi b/docs/grub.texi
index a7155c22f..2b7b7faf8 100644
index 974bc0ddb07..c30701b4e1f 100644
--- a/docs/grub.texi
+++ b/docs/grub.texi
@@ -1,7 +1,7 @@
@ -72,31 +72,7 @@ index a7155c22f..2b7b7faf8 100644
@end direntry
@setchapternewpage odd
@@ -103,15 +103,15 @@ This edition documents version @value{VERSION}.
* Platform-specific operations:: Platform-specific operations
* Supported kernels:: The list of supported kernels
* Troubleshooting:: Error messages produced by GRUB
-* Invoking grub-install:: How to use the GRUB installer
-* Invoking grub-mkconfig:: Generate a GRUB configuration file
-* Invoking grub-mkpasswd-pbkdf2::
+* Invoking grub2-install:: How to use the GRUB installer
+* Invoking grub2-mkconfig:: Generate a GRUB configuration file
+* Invoking grub2-mkpasswd-pbkdf2::
Generate GRUB password hashes
-* Invoking grub-mkrelpath:: Make system path relative to its root
-* Invoking grub-mkrescue:: Make a GRUB rescue image
-* Invoking grub-mount:: Mount a file system using GRUB
-* Invoking grub-probe:: Probe device information for GRUB
-* Invoking grub-script-check:: Check GRUB script file for syntax errors
+* Invoking grub2-mkrelpath:: Make system path relative to its root
+* Invoking grub2-mkrescue:: Make a GRUB rescue image
+* Invoking grub2-mount:: Mount a file system using GRUB
+* Invoking grub2-probe:: Probe device information for GRUB
+* Invoking grub2-script-check:: Check GRUB script file for syntax errors
* Obtaining and Building GRUB:: How to obtain and build GRUB
* Reporting bugs:: Where you should send a bug report
* Future:: Some future plans on GRUB
@@ -230,7 +230,7 @@ surprising.
@@ -223,7 +223,7 @@ surprising.
@item
@file{grub.cfg} is typically automatically generated by
@ -105,7 +81,7 @@ index a7155c22f..2b7b7faf8 100644
easier to handle versioned kernel upgrades.
@item
@@ -244,7 +244,7 @@ scripting language: variables, conditionals, and loops are available.
@@ -237,7 +237,7 @@ scripting language: variables, conditionals, and loops are available.
@item
A small amount of persistent storage is available across reboots, using the
@command{save_env} and @command{load_env} commands in GRUB and the
@ -114,7 +90,7 @@ index a7155c22f..2b7b7faf8 100644
(@pxref{Environment block}).
@item
@@ -549,7 +549,7 @@ On OS which have device nodes similar to Unix-like OS GRUB tools use the
@@ -542,7 +542,7 @@ On OS which have device nodes similar to Unix-like OS GRUB tools use the
OS name. E.g. for GNU/Linux:
@example
@ -123,7 +99,7 @@ index a7155c22f..2b7b7faf8 100644
@end example
On AROS we use another syntax. For volumes:
@@ -572,7 +572,7 @@ For disks we use syntax:
@@ -565,7 +565,7 @@ For disks we use syntax:
E.g.
@example
@ -132,7 +108,7 @@ index a7155c22f..2b7b7faf8 100644
@end example
On Windows we use UNC path. For volumes it's typically
@@ -599,7 +599,7 @@ For disks it's
@@ -592,7 +592,7 @@ For disks it's
E.g.
@example
@ -141,7 +117,7 @@ index a7155c22f..2b7b7faf8 100644
@end example
Beware that you may need to further escape the backslashes depending on your
@@ -609,7 +609,7 @@ When compiled with cygwin support then cygwin drive names are automatically
@@ -602,7 +602,7 @@ When compiled with cygwin support then cygwin drive names are automatically
when needed. E.g.
@example
@ -150,7 +126,7 @@ index a7155c22f..2b7b7faf8 100644
@end example
@node Installation
@@ -622,7 +622,7 @@ from the source tarball, or as a package for your OS.
@@ -615,7 +615,7 @@ from the source tarball, or as a package for your OS.
After you have done that, you need to install the boot loader on a
drive (floppy or hard disk) by using the utility
@ -159,7 +135,7 @@ index a7155c22f..2b7b7faf8 100644
GRUB comes with boot images, which are normally put in the directory
@file{/usr/lib/grub/<cpu>-<platform>} (for BIOS-based machines
@@ -633,22 +633,22 @@ loader needs to find them (usually @file{/boot}) will be called
@@ -626,22 +626,22 @@ loader needs to find them (usually @file{/boot}) will be called
the @dfn{boot directory}.
@menu
@ -187,7 +163,7 @@ index a7155c22f..2b7b7faf8 100644
The usage is basically very simple. You only need to specify one
argument to the program, namely, where to install the boot loader. The
@@ -657,13 +657,13 @@ For example, under Linux the following will install GRUB into the MBR
@@ -650,13 +650,13 @@ For example, under Linux the following will install GRUB into the MBR
of the first IDE disk:
@example
@ -203,7 +179,7 @@ index a7155c22f..2b7b7faf8 100644
@end example
But all the above examples assume that GRUB should put images under
@@ -677,7 +677,7 @@ boot floppy with a filesystem. Here is an example:
@@ -670,7 +670,7 @@ boot floppy with a filesystem. Here is an example:
# @kbd{mke2fs /dev/fd0}
# @kbd{mount -t ext2 /dev/fd0 /mnt}
# @kbd{mkdir /mnt/boot}
@ -212,7 +188,7 @@ index a7155c22f..2b7b7faf8 100644
# @kbd{umount /mnt}
@end group
@end example
@@ -689,16 +689,16 @@ floppy instead of exposing the USB drive as a hard disk (they call it
@@ -682,30 +682,37 @@ floppy instead of exposing the USB drive as a hard disk (they call it
@example
# @kbd{losetup /dev/loop0 /dev/sdb1}
# @kbd{mount /dev/loop0 /mnt/usb}
@ -223,17 +199,14 @@ index a7155c22f..2b7b7faf8 100644
This install doesn't conflict with standard install as long as they are in
separate directories.
-Note that @command{grub-install} is actually just a shell script and the
-real task is done by other tools such as @command{grub-mkimage}. Therefore,
+Note that @command{grub2-install} is actually just a shell script and the
+real task is done by other tools such as @command{grub2-mkimage}. Therefore,
you may run those commands directly to install GRUB, without using
-@command{grub-install}. Don't do that, however, unless you are very familiar
+you may run those commands directly to install GRUB, without using
+@command{grub2-install}. Don't do that, however, unless you are very familiar
with the internals of GRUB. Installing a boot loader on a running OS may be
extremely dangerous.
@@ -706,20 +706,20 @@ On EFI systems for fixed disk install you have to mount EFI System Partition.
+with the internals of GRUB. Installing a boot loader on a running OS may be
+extremely dangerous.
+
On EFI systems for fixed disk install you have to mount EFI System Partition.
If you mount it at @file{/boot/efi} then you don't need any special arguments:
@example
@ -257,7 +230,7 @@ index a7155c22f..2b7b7faf8 100644
@end example
@node Making a GRUB bootable CD-ROM
@@ -739,10 +739,10 @@ usually also need to include a configuration file @file{grub.cfg} and some
@@ -725,10 +732,10 @@ usually also need to include a configuration file @file{grub.cfg} and some
other GRUB modules.
To make a simple generic GRUB rescue CD, you can use the
@ -270,7 +243,7 @@ index a7155c22f..2b7b7faf8 100644
@end example
You will often need to include other files in your image. To do this, first
@@ -765,7 +765,7 @@ directory @file{iso/}.
@@ -751,7 +758,7 @@ directory @file{iso/}.
Finally, make the image:
@example
@ -279,7 +252,7 @@ index a7155c22f..2b7b7faf8 100644
@end example
This produces a file named @file{grub.iso}, which then can be burned
@@ -781,7 +781,7 @@ storage devices.
@@ -767,7 +774,7 @@ storage devices.
@node Device map
@section The map between BIOS drives and OS devices
@ -288,7 +261,7 @@ index a7155c22f..2b7b7faf8 100644
etc.) read it to map BIOS drives to OS devices. This file consists of lines
like this:
@@ -1225,23 +1225,23 @@ need to write the whole thing by hand.
@@ -1269,23 +1276,23 @@ need to write the whole thing by hand.
@node Simple configuration
@section Simple configuration handling
@ -317,7 +290,7 @@ index a7155c22f..2b7b7faf8 100644
valid POSIX shell input; normally, it will just be a sequence of
@samp{KEY=value} lines, but if the value contains spaces or other special
characters then it must be quoted. For example:
@@ -1279,7 +1279,7 @@ works it's not recommended since titles often contain unstable device names
@@ -1323,7 +1330,7 @@ works it's not recommended since titles often contain unstable device names
and may be translated
If you set this to @samp{saved}, then the default menu entry will be that
@ -326,7 +299,7 @@ index a7155c22f..2b7b7faf8 100644
the environment block, which may not be available in all situations
(@pxref{Environment block}).
@@ -1290,7 +1290,7 @@ If this option is set to @samp{true}, then, when an entry is selected, save
@@ -1334,7 +1341,7 @@ If this option is set to @samp{true}, then, when an entry is selected, save
it as a new default entry for use by future runs of GRUB. This is only
useful if @samp{GRUB_DEFAULT=saved}; it is a separate option because
@samp{GRUB_DEFAULT=saved} is useful without this option, in conjunction with
@ -335,7 +308,7 @@ index a7155c22f..2b7b7faf8 100644
This option relies on the environment block, which may not be available in
all situations (@pxref{Environment block}).
@@ -1420,7 +1420,7 @@ intel-uc.img intel-ucode.img amd-uc.img amd-ucode.img early_ucode.cpio microcode
@@ -1481,15 +1488,15 @@ intel-uc.img intel-ucode.img amd-uc.img amd-ucode.img early_ucode.cpio microcode
@end example
@item GRUB_DISABLE_LINUX_UUID
@ -344,7 +317,17 @@ index a7155c22f..2b7b7faf8 100644
universally-unique identifiers (UUIDs) to identify the root filesystem to
the Linux kernel, using a @samp{root=UUID=...} kernel parameter. This is
usually more reliable, but in some cases it may not be appropriate. To
@@ -1442,7 +1442,7 @@ If this option is set to @samp{true}, disable the generation of recovery
disable the use of UUIDs, set this option to @samp{true}.
@item GRUB_DISABLE_LINUX_PARTUUID
-If @command{grub-mkconfig} cannot identify the root filesystem via its
-universally-unique indentifier (UUID), @command{grub-mkconfig} can use the UUID
+If @command{grub2-mkconfig} cannot identify the root filesystem via its
+universally-unique indentifier (UUID), @command{grub2-mkconfig} can use the UUID
of the partition containing the filesystem to identify the root filesystem to
the Linux kernel via a @samp{root=PARTUUID=...} kernel parameter. This is not
as reliable as using the filesystem UUID, but is more reliable than using the
@@ -1503,7 +1510,7 @@ If this option is set to @samp{true}, disable the generation of recovery
mode menu entries.
@item GRUB_DISABLE_UUID
@ -353,7 +336,7 @@ index a7155c22f..2b7b7faf8 100644
universally-unique identifiers (UUIDs) to identify various filesystems to
search for files. This is usually more reliable, but in some cases it may
not be appropriate. To disable this use of UUIDs, set this option to
@@ -1451,12 +1451,12 @@ not be appropriate. To disable this use of UUIDs, set this option to
@@ -1514,12 +1521,12 @@ not be appropriate. To disable this use of UUIDs, set this option to
@item GRUB_VIDEO_BACKEND
If graphical video support is required, either because the @samp{gfxterm}
graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set,
@ -369,7 +352,7 @@ index a7155c22f..2b7b7faf8 100644
@item GRUB_GFXMODE
Set the resolution used on the @samp{gfxterm} graphical terminal. Note that
@@ -1488,7 +1488,7 @@ boot sequence. If you have problems, set this option to @samp{text} and
@@ -1552,7 +1559,7 @@ boot sequence. If you have problems, set this option to @samp{text} and
GRUB will tell Linux to boot in normal text mode.
@item GRUB_DISABLE_OS_PROBER
@ -378,7 +361,7 @@ index a7155c22f..2b7b7faf8 100644
@command{os-prober} program, if installed, to discover other operating
systems installed on the same system and generate appropriate menu entries
for them. Set this option to @samp{true} to disable this.
@@ -1498,7 +1498,7 @@ List of space-separated FS UUIDs of filesystems to be ignored from os-prober
@@ -1562,7 +1569,7 @@ List of space-separated FS UUIDs of filesystems to be ignored from os-prober
output. For efi chainloaders it's <UUID>@@<EFI FILE>
@item GRUB_DISABLE_SUBMENU
@ -387,7 +370,7 @@ index a7155c22f..2b7b7faf8 100644
the kernel with highest version number and put all other found kernels
or alternative menu entries for recovery mode in submenu. For entries returned
by @command{os-prober} first entry will be put on top level and all others
@@ -1506,11 +1506,11 @@ in submenu. If this option is set to @samp{y}, flat menu with all entries
@@ -1570,11 +1577,11 @@ in submenu. If this option is set to @samp{true}, flat menu with all entries
on top level will be generated instead. Changing this option will require
changing existing values of @samp{GRUB_DEFAULT}, @samp{fallback} (@pxref{fallback})
and @samp{default} (@pxref{default}) environment variables as well as saved
@ -402,7 +385,7 @@ index a7155c22f..2b7b7faf8 100644
check for encrypted disks and generate additional commands needed to access
them during boot. Note that in this case unattended boot is not possible
because GRUB will wait for passphrase to unlock encrypted container.
@@ -1569,7 +1569,7 @@ confusing @samp{GRUB_TIMEOUT_STYLE=countdown} or
@@ -1633,7 +1640,7 @@ confusing @samp{GRUB_TIMEOUT_STYLE=countdown} or
@end table
@ -411,7 +394,48 @@ index a7155c22f..2b7b7faf8 100644
edit the scripts in @file{/etc/grub.d} directly.
@file{/etc/grub.d/40_custom} is particularly useful for adding entire custom
menu entries; simply type the menu entries you want to add at the end of
@@ -1831,7 +1831,7 @@ images as well.
@@ -1641,14 +1648,14 @@ that file, making sure to leave at least the first two lines intact.
@node Root Identifcation Heuristics
@section Root Identifcation Heuristics
-If the target operating system uses the Linux kernel, @command{grub-mkconfig}
+If the target operating system uses the Linux kernel, @command{grub2-mkconfig}
attempts to identify the root file system via a heuristic algoirthm. This
algorithm selects the identification method of the root file system by
considering three factors. The first is if an initrd for the target operating
system is also present. The second is @samp{GRUB_DISABLE_LINUX_UUID} and if set
-to @samp{true}, prevents @command{grub-mkconfig} from identifying the root file
+to @samp{true}, prevents @command{grub2-mkconfig} from identifying the root file
system by its UUID. The third is @samp{GRUB_DISABLE_LINUX_PARTUUID} and if set
-to @samp{true}, prevents @command{grub-mkconfig} from identifying the root file
+to @samp{true}, prevents @command{grub2-mkconfig} from identifying the root file
system via the UUID of its enclosing partition. If the variables are assigned
any other value, that value is considered equivalent to @samp{false}. The
variables are also considered to be set to @samp{false} if they are not set.
@@ -1658,18 +1665,18 @@ filesystem to the initrd. Most initrd images determine the root file system by
checking the Linux kernel's command-line for the @samp{root} key and use its
value as the identification method of the root file system. To improve the
reliability of booting, most initrd images also allow the root file system to be
-identified by its UUID. Because of this behavior, the @command{grub-mkconfig}
+identified by its UUID. Because of this behavior, the @command{grub2-mkconfig}
command will set @samp{root} to @samp{root=UUID=...} to provide the initrd with
the filesystem UUID of the root file system.
If no initrd is detected or @samp{GRUB_DISABLE_LINUX_UUID} is set to @samp{true}
-then @command{grub-command} will identify the root filesystem by setting the
+then @command{grub2-command} will identify the root filesystem by setting the
kernel command-line variable @samp{root} to @samp{root=PARTUUID=...} unless
@samp{GRUB_DISABLE_LINUX_PARTUUID} is also set to @samp{true}. If
@samp{GRUB_DISABLE_LINUX_PARTUUID} is also set to @samp{true},
-@command{grub-command} will identify by its Linux device name.
+@command{grub2-command} will identify by its Linux device name.
-The following table summarizes the behavior of the @command{grub-mkconfig}
+The following table summarizes the behavior of the @command{grub2-mkconfig}
command.
@multitable {detected} {GRUB_DISABLE_LINUX_PARTUUID} {GRUB_DISABLE_LINUX_UUID} {Linux Root}
@@ -1898,7 +1905,7 @@ images as well.
Mount this partition on/mnt/boot and disable GRUB in all OSes and manually
install self-compiled latest GRUB with:
@ -420,7 +444,7 @@ index a7155c22f..2b7b7faf8 100644
In all the OSes install GRUB tools but disable installing GRUB in bootsector,
so you'll have menu.lst and grub.cfg available for use. Also disable os-prober
@@ -1841,20 +1841,20 @@ use by setting:
@@ -1908,20 +1915,20 @@ use by setting:
in /etc/default/grub
@ -444,7 +468,7 @@ index a7155c22f..2b7b7faf8 100644
@}
menuentry "Windows XP" @{
@@ -1917,15 +1917,15 @@ GRUB supports embedding a configuration file directly into the core image,
@@ -1984,15 +1991,15 @@ GRUB supports embedding a configuration file directly into the core image,
so that it is loaded before entering normal mode. This is useful, for
example, when it is not straightforward to find the real configuration file,
or when you need to debug problems with loading that file.
@ -463,7 +487,7 @@ index a7155c22f..2b7b7faf8 100644
After the embedded configuration file (if any) is executed, GRUB will load
the @samp{normal} module (@pxref{normal}), which will then read the real
@@ -1960,13 +1960,13 @@ included in the core image:
@@ -2027,13 +2034,13 @@ included in the core image:
@example
@group
search.fs_label grub root
@ -481,7 +505,7 @@ index a7155c22f..2b7b7faf8 100644
else
echo "Could not find an example configuration file!"
fi
@@ -2490,7 +2490,7 @@ grub-mknetdir --net-directory=/srv/tftp --subdir=/boot/grub -d /usr/lib/grub/i38
@@ -2557,7 +2564,7 @@ grub-mknetdir --net-directory=/srv/tftp --subdir=/boot/grub -d /usr/lib/grub/i38
@end group
@end example
@ -490,7 +514,7 @@ index a7155c22f..2b7b7faf8 100644
server.
The grub.cfg file is placed in the same directory as the path output by
@@ -2675,7 +2675,7 @@ team are:
@@ -2760,7 +2767,7 @@ team are:
@end table
To take full advantage of this function, install GRUB into the MBR
@ -499,7 +523,7 @@ index a7155c22f..2b7b7faf8 100644
If you have a laptop which has a similar feature and not in the above list
could you figure your address and contribute?
@@ -2736,7 +2736,7 @@ bytes.
@@ -2821,7 +2828,7 @@ bytes.
The sole function of @file{boot.img} is to read the first sector of the core
image from a local disk and jump to it. Because of the size restriction,
@file{boot.img} cannot understand any file system structure, so
@ -508,7 +532,7 @@ index a7155c22f..2b7b7faf8 100644
core image into @file{boot.img} when installing GRUB.
@item diskboot.img
@@ -2766,7 +2766,7 @@ images.
@@ -2851,7 +2858,7 @@ images.
@item core.img
This is the core image of GRUB. It is built dynamically from the kernel
@ -517,7 +541,7 @@ index a7155c22f..2b7b7faf8 100644
program. Usually, it contains enough modules to access @file{/boot/grub},
and loads everything else (including menu handling, the ability to load
target operating systems, and so on) from the file system at run-time. The
@@ -2818,7 +2818,7 @@ GRUB 2 has no single Stage 2 image. Instead, it loads modules from
@@ -2903,7 +2910,7 @@ GRUB 2 has no single Stage 2 image. Instead, it loads modules from
In GRUB 2, images for booting from CD-ROM drives are now constructed using
@file{cdboot.img} and @file{core.img}, making sure that the core image
contains the @samp{iso9660} module. It is usually best to use the
@ -526,7 +550,7 @@ index a7155c22f..2b7b7faf8 100644
@item nbgrub
There is as yet no equivalent for @file{nbgrub} in GRUB 2; it was used by
@@ -2974,8 +2974,8 @@ There are two ways to specify files, by @dfn{absolute file name} and by
@@ -3071,8 +3078,8 @@ There are two ways to specify files, by @dfn{absolute file name} and by
An absolute file name resembles a Unix absolute file name, using
@samp{/} for the directory separator (not @samp{\} as in DOS). One
@ -537,7 +561,7 @@ index a7155c22f..2b7b7faf8 100644
disk. If you omit the device name in an absolute file name, GRUB uses
GRUB's @dfn{root device} implicitly. So if you set the root device to,
say, @samp{(hd1,1)} by the command @samp{set root=(hd1,1)} (@pxref{set}),
@@ -2983,8 +2983,8 @@ then @code{/boot/kernel} is the same as @code{(hd1,1)/boot/kernel}.
@@ -3080,8 +3087,8 @@ then @code{/boot/kernel} is the same as @code{(hd1,1)/boot/kernel}.
On ZFS filesystem the first path component must be
@var{volume}@samp{@@}[@var{snapshot}].
@ -548,7 +572,7 @@ index a7155c22f..2b7b7faf8 100644
@samp{snap-129}. Trailing @samp{@@} after volume name is mandatory even if
snapshot name is omitted.
@@ -3387,7 +3387,7 @@ The more recent release of Minix would then be identified as
@@ -3500,7 +3507,7 @@ The more recent release of Minix would then be identified as
@samp{other>minix>minix-3.4.0}.
This variable is often set by @samp{GRUB_DEFAULT} (@pxref{Simple
@ -557,7 +581,7 @@ index a7155c22f..2b7b7faf8 100644
@node fallback
@@ -3477,7 +3477,7 @@ If this variable is set, it names the language code that the
@@ -3590,7 +3597,7 @@ If this variable is set, it names the language code that the
example, French would be named as @samp{fr}, and Simplified Chinese as
@samp{zh_CN}.
@ -566,7 +590,7 @@ index a7155c22f..2b7b7faf8 100644
reasonable default for this variable based on the system locale.
@@ -3485,10 +3485,10 @@ reasonable default for this variable based on the system locale.
@@ -3598,10 +3605,10 @@ reasonable default for this variable based on the system locale.
@subsection locale_dir
If this variable is set, it names the directory where translation files may
@ -579,7 +603,7 @@ index a7155c22f..2b7b7faf8 100644
default for this variable if internationalization is needed and any
translation files are available.
@@ -3606,7 +3606,7 @@ input. The default is not to pause output.
@@ -3738,7 +3745,7 @@ input. The default is not to pause output.
The location of the @samp{/boot/grub} directory as an absolute file name
(@pxref{File name syntax}). This is normally set by GRUB at startup based
@ -588,7 +612,7 @@ index a7155c22f..2b7b7faf8 100644
dynamically loaded from this directory, so it must be set correctly in order
for many parts of GRUB to work.
@@ -3697,17 +3697,17 @@ GRUB provides an ``environment block'' which can be used to save a small
@@ -3850,17 +3857,17 @@ GRUB provides an ``environment block'' which can be used to save a small
amount of state.
The environment block is a preallocated 1024-byte file, which normally lives
@ -608,8 +632,8 @@ index a7155c22f..2b7b7faf8 100644
+@command{grub2-mkconfig} uses this facility to implement
@samp{GRUB_SAVEDEFAULT} (@pxref{Simple configuration}).
@@ -4396,7 +4396,7 @@ Translate @var{string} into the current language.
@node Modules
@@ -4922,7 +4929,7 @@ Translate @var{string} into the current language.
The current language code is stored in the @samp{lang} variable in GRUB's
environment (@pxref{lang}). Translation files in MO format are read from
@ -618,7 +642,7 @@ index a7155c22f..2b7b7faf8 100644
@end deffn
@@ -4791,7 +4791,7 @@ Define a user named @var{user} with password @var{clear-password}.
@@ -5274,7 +5281,7 @@ Define a user named @var{user} with password @var{clear-password}.
@deffn Command password_pbkdf2 user hashed-password
Define a user named @var{user} with password hash @var{hashed-password}.
@ -627,7 +651,7 @@ index a7155c22f..2b7b7faf8 100644
to generate password hashes. @xref{Security}.
@end deffn
@@ -5614,8 +5614,8 @@ The @samp{password} (@pxref{password}) and @samp{password_pbkdf2}
@@ -6400,8 +6407,8 @@ The @samp{password} (@pxref{password}) and @samp{password_pbkdf2}
which has an associated password. @samp{password} sets the password in
plain text, requiring @file{grub.cfg} to be secure; @samp{password_pbkdf2}
sets the password hashed using the Password-Based Key Derivation Function
@ -638,7 +662,7 @@ index a7155c22f..2b7b7faf8 100644
In order to enable authentication support, the @samp{superusers} environment
variable must be set to a list of usernames, separated by any of spaces,
@@ -5659,7 +5659,7 @@ menuentry "May be run by user1 or a superuser" --users user1 @{
@@ -6446,7 +6453,7 @@ menuentry "May be run by user1 or a superuser" --users user1 @{
@end group
@end example
@ -647,28 +671,28 @@ index a7155c22f..2b7b7faf8 100644
generating configuration files with authentication. You can use
@file{/etc/grub.d/40_custom} to add simple superuser authentication, by
adding @kbd{set superusers=} and @kbd{password} or @kbd{password_pbkdf2}
@@ -5684,15 +5684,15 @@ verified with a public key currently trusted by GRUB
validation fails, then file @file{foo} cannot be opened. This failure
@@ -6472,8 +6479,18 @@ validation fails, then file @file{foo} cannot be opened. This failure
may halt or otherwise impact the boot process.
-@comment Unfortunately --pubkey is not yet supported by grub-install,
-@comment but we should not bring up internal detail grub-mkimage here
An initial trusted public key can be embedded within the GRUB @file{core.img}
-using the @code{--pubkey} option to @command{grub-install}
-(@pxref{Invoking grub-install}).
+using the @code{--pubkey} option to @command{grub2-install}
+(@pxref{Invoking grub2-install}).
+
+@comment Unfortunately --pubkey is not yet supported by grub2-install,
+@comment but we should not bring up internal detail grub2-mkimage here
@comment in the user guide (as opposed to developer's manual).
@comment An initial trusted public key can be embedded within the GRUB
@comment @file{core.img} using the @code{--pubkey} option to
-@comment @command{grub-mkimage} (@pxref{Invoking grub-install}). Presently it
-@comment is necessary to write a custom wrapper around @command{grub-mkimage}
-@comment using the @code{--grub-mkimage} flag to @command{grub-install}.
+@comment in the user guide (as opposed to developer's manual).
+
+@comment An initial trusted public key can be embedded within the GRUB
+@comment @file{core.img} using the @code{--pubkey} option to
+@comment @command{grub2-mkimage} (@pxref{Invoking grub2-install}). Presently it
+@comment is necessary to write a custom wrapper around @command{grub2-mkimage}
+@comment using the @code{--grub-mkimage} flag to @command{grub2-install}.
GRUB uses GPG-style detached signatures (meaning that a file
@file{foo.sig} will be produced when file @file{foo} is signed), and
@@ -5712,8 +5712,8 @@ gpg --detach-sign /path/to/file
@@ -6493,8 +6510,8 @@ gpg --detach-sign /path/to/file
For successful validation of all of GRUB's subcomponents and the
loaded OS kernel, they must all be signed. One way to accomplish this
is the following (after having already produced the desired
@ -679,7 +703,7 @@ index a7155c22f..2b7b7faf8 100644
@example
@group
@@ -5735,7 +5735,7 @@ See also: @ref{check_signatures}, @ref{verify_detached}, @ref{trust},
@@ -6516,7 +6533,7 @@ See also: @ref{check_signatures}, @ref{verify_detached}, @ref{trust},
Note that internally signature enforcement is controlled by setting
the environment variable @code{check_signatures} equal to
@code{enforce}. Passing one or more @code{--pubkey} options to
@ -688,7 +712,16 @@ index a7155c22f..2b7b7faf8 100644
equal to @code{enforce} in @file{core.img} prior to processing any
configuration files.
@@ -6092,10 +6092,10 @@ Required files are:
@@ -6564,7 +6581,7 @@ UTF-8 strings as comma-separated values (CSV). See
@uref{https://github.com/rhboot/shim/blob/main/SBAT.md} for more details.
To add a data section containing the SBAT information into the binary, the
-@option{--sbat} option of @command{grub-mkimage} command should be used. The content
+@option{--sbat} option of @command{grub2-mkimage} command should be used. The content
of a CSV file, encoded with UTF-8, is copied as is to the .sbat data section into
the generated EFI binary. The CSV file can be stored anywhere on the file system.
@@ -6975,10 +6992,10 @@ Required files are:
GRUB's normal start-up procedure involves setting the @samp{prefix}
environment variable to a value set in the core image by
@ -701,7 +734,7 @@ index a7155c22f..2b7b7faf8 100644
things GRUB is supposed to do.
If, instead, you only get a rescue shell, this usually means that GRUB
@@ -6121,8 +6121,8 @@ normal
@@ -7004,8 +7021,8 @@ normal
However, any problem that leaves you in the rescue shell probably means that
GRUB was not correctly installed. It may be more useful to try to reinstall
@ -712,7 +745,7 @@ index a7155c22f..2b7b7faf8 100644
@itemize @bullet{}
@item
@@ -6134,7 +6134,7 @@ is usually better to use UUIDs or file system labels and avoid depending on
@@ -7017,7 +7034,7 @@ is usually better to use UUIDs or file system labels and avoid depending on
drive ordering entirely.
@item
@ -721,14 +754,34 @@ index a7155c22f..2b7b7faf8 100644
to a partition but GRUB has already been installed in the master boot
record, then the GRUB installation in the partition will be ignored.
@@ -6154,21 +6154,21 @@ support has not yet been added to GRUB.
@end itemize
@@ -7052,33 +7069,33 @@ bootability on other machines.
@chapter User-space utilities
@menu
-* Invoking grub-install:: How to use the GRUB installer
-* Invoking grub-mkconfig:: Generate a GRUB configuration file
-* Invoking grub-mkpasswd-pbkdf2::
+* Invoking grub2-install:: How to use the GRUB installer
+* Invoking grub2-mkconfig:: Generate a GRUB configuration file
+* Invoking grub2-mkpasswd-pbkdf2::
Generate GRUB password hashes
-* Invoking grub-mkrelpath:: Make system path relative to its root
-* Invoking grub-mkrescue:: Make a GRUB rescue image
-* Invoking grub-mount:: Mount a file system using GRUB
-* Invoking grub-probe:: Probe device information for GRUB
-* Invoking grub-script-check:: Check GRUB script file for syntax errors
+* Invoking grub2-mkrelpath:: Make system path relative to its root
+* Invoking grub2-mkrescue:: Make a GRUB rescue image
+* Invoking grub2-mount:: Mount a file system using GRUB
+* Invoking grub2-probe:: Probe device information for GRUB
+* Invoking grub2-script-check:: Check GRUB script file for syntax errors
@end menu
-@node Invoking grub-install
-@chapter Invoking grub-install
-@section Invoking grub-install
+@node Invoking grub2-install
+@chapter Invoking grub2-install
+@section Invoking grub2-install
-The program @command{grub-install} generates a GRUB core image using
-@command{grub-mkimage} and installs it on your system. You must specify the
@ -749,7 +802,7 @@ index a7155c22f..2b7b7faf8 100644
@table @option
@item --help
@@ -6184,13 +6184,13 @@ separate partition or a removable disk.
@@ -7094,13 +7111,13 @@ separate partition or a removable disk.
If this option is not specified then it defaults to @file{/boot}, so
@example
@ -765,7 +818,7 @@ index a7155c22f..2b7b7faf8 100644
@end example
Here is an example in which you have a separate @dfn{boot} partition which is
@@ -6198,16 +6198,16 @@ mounted on
@@ -7108,16 +7125,16 @@ mounted on
@file{/mnt/boot}:
@example
@ -785,14 +838,14 @@ index a7155c22f..2b7b7faf8 100644
extra space in the bootloader embedding area for Reed-Solomon
error-correcting codes. This enables GRUB to still boot successfully
if some blocks are corrupted. The exact amount of protection offered
@@ -6220,17 +6220,17 @@ installation}) where GRUB does not reside in any unpartitioned space
@@ -7130,17 +7147,17 @@ installation}) where GRUB does not reside in any unpartitioned space
outside of the MBR. Disable the Reed-Solomon codes with this option.
@end table
-@node Invoking grub-mkconfig
-@chapter Invoking grub-mkconfig
-@section Invoking grub-mkconfig
+@node Invoking grub2-mkconfig
+@chapter Invoking grub2-mkconfig
+@section Invoking grub2-mkconfig
-The program @command{grub-mkconfig} generates a configuration file for GRUB
+The program @command{grub2-mkconfig} generates a configuration file for GRUB
@ -800,7 +853,7 @@ index a7155c22f..2b7b7faf8 100644
@example
-grub-mkconfig -o /boot/grub/grub.cfg
+grub-mkconfig -o /boot/grub2/grub.cfg
+grub2-mkconfig -o /boot/grub2/grub.cfg
@end example
-@command{grub-mkconfig} accepts the following options:
@ -808,21 +861,22 @@ index a7155c22f..2b7b7faf8 100644
@table @option
@item --help
@@ -6246,17 +6246,17 @@ it to standard output.
@@ -7156,17 +7173,17 @@ it to standard output.
@end table
-@node Invoking grub-mkpasswd-pbkdf2
-@chapter Invoking grub-mkpasswd-pbkdf2
-@section Invoking grub-mkpasswd-pbkdf2
+@node Invoking grub2-mkpasswd-pbkdf2
+@chapter Invoking grub2-mkpasswd-pbkdf2
+@section Invoking grub2-mkpasswd-pbkdf2
-The program @command{grub-mkpasswd-pbkdf2} generates password hashes for
+The program @command{grub2-mkpasswd-pbkdf2} generates password hashes for
GRUB (@pxref{Security}).
@example
grub-mkpasswd-pbkdf2
-grub-mkpasswd-pbkdf2
+grub2-mkpasswd-pbkdf2
@end example
-@command{grub-mkpasswd-pbkdf2} accepts the following options:
@ -830,14 +884,14 @@ index a7155c22f..2b7b7faf8 100644
@table @option
@item -c @var{number}
@@ -6274,23 +6274,23 @@ Length of the salt. Defaults to 64.
@@ -7184,23 +7201,23 @@ Length of the salt. Defaults to 64.
@end table
-@node Invoking grub-mkrelpath
-@chapter Invoking grub-mkrelpath
-@section Invoking grub-mkrelpath
+@node Invoking grub2-mkrelpath
+@chapter Invoking grub2-mkrelpath
+@section Invoking grub2-mkrelpath
-The program @command{grub-mkrelpath} makes a file system path relative to
+The program @command{grub2-mkrelpath} makes a file system path relative to
@ -860,21 +914,22 @@ index a7155c22f..2b7b7faf8 100644
@table @option
@item --help
@@ -6301,17 +6301,17 @@ Print the version number of GRUB and exit.
@@ -7211,17 +7228,17 @@ Print the version number of GRUB and exit.
@end table
-@node Invoking grub-mkrescue
-@chapter Invoking grub-mkrescue
-@section Invoking grub-mkrescue
+@node Invoking grub2-mkrescue
+@chapter Invoking grub2-mkrescue
+@section Invoking grub2-mkrescue
-The program @command{grub-mkrescue} generates a bootable GRUB rescue image
+The program @command{grub2-mkrescue} generates a bootable GRUB rescue image
(@pxref{Making a GRUB bootable CD-ROM}).
@example
grub-mkrescue -o grub.iso
-grub-mkrescue -o grub.iso
+grub2-mkrescue -o grub.iso
@end example
-All arguments not explicitly listed as @command{grub-mkrescue} options are
@ -882,8 +937,12 @@ index a7155c22f..2b7b7faf8 100644
passed on directly to @command{xorriso} in @command{mkisofs} emulation mode.
Options passed to @command{xorriso} will normally be interpreted as
@command{mkisofs} options; if the option @samp{--} is used, then anything
@@ -6326,7 +6326,7 @@ mkdir -p disk/boot/grub
grub-mkrescue -o grub.iso disk
@@ -7233,10 +7250,10 @@ commonly used to add extra files to the image:
@example
mkdir -p disk/boot/grub
@r{(add extra files to @file{disk/boot/grub})}
-grub-mkrescue -o grub.iso disk
+grub2-mkrescue -o grub.iso disk
@end example
-@command{grub-mkrescue} accepts the following options:
@ -891,7 +950,7 @@ index a7155c22f..2b7b7faf8 100644
@table @option
@item --help
@@ -6354,15 +6354,15 @@ Use @var{file} as the @command{xorriso} program, rather than the built-in
@@ -7264,15 +7281,15 @@ Use @var{file} as the @command{xorriso} program, rather than the built-in
default.
@item --grub-mkimage=@var{file}
@ -902,16 +961,16 @@ index a7155c22f..2b7b7faf8 100644
-@node Invoking grub-mount
-@chapter Invoking grub-mount
-@section Invoking grub-mount
+@node Invoking grub2-mount
+@chapter Invoking grub2-mount
+@section Invoking grub2-mount
-The program @command{grub-mount} performs a read-only mount of any file
+The program @command{grub2-mount} performs a read-only mount of any file
system or file system image that GRUB understands, using GRUB's file system
drivers via FUSE. (It is only available if FUSE development files were
present when GRUB was built.) This has a number of uses:
@@ -6394,13 +6394,13 @@ even if nobody has yet written a FUSE module specifically for that file
@@ -7304,13 +7321,13 @@ even if nobody has yet written a FUSE module specifically for that file
system type.
@end itemize
@ -919,7 +978,8 @@ index a7155c22f..2b7b7faf8 100644
+Using @command{grub2-mount} is normally as simple as:
@example
grub-mount /dev/sda1 /mnt
-grub-mount /dev/sda1 /mnt
+grub2-mount /dev/sda1 /mnt
@end example
-@command{grub-mount} must be given one or more images and a mount point as
@ -927,7 +987,7 @@ index a7155c22f..2b7b7faf8 100644
non-option arguments (if it is given more than one image, it will treat them
as a RAID set), and also accepts the following options:
@@ -6422,13 +6422,13 @@ Show debugging output for conditions matching @var{string}.
@@ -7332,13 +7349,13 @@ Show debugging output for conditions matching @var{string}.
@item -K prompt|@var{file}
@itemx --zfs-key=prompt|@var{file}
Load a ZFS encryption key. If you use @samp{prompt} as the argument,
@ -943,22 +1003,33 @@ index a7155c22f..2b7b7faf8 100644
root of the supplied file system.
If @var{device} is just a number, then it will be treated as a partition
@@ -6446,10 +6446,10 @@ Print verbose messages.
@@ -7347,7 +7364,7 @@ an entire disk in @file{disk.img}, then you can use this command to mount
its second partition:
@example
-grub-mount -r 2 disk.img mount-point
+grub2-mount -r 2 disk.img mount-point
@end example
@item -v
@@ -7356,18 +7373,18 @@ Print verbose messages.
@end table
-@node Invoking grub-probe
-@chapter Invoking grub-probe
-@section Invoking grub-probe
+@node Invoking grub2-probe
+@chapter Invoking grub2-probe
+@section Invoking grub2-probe
-The program @command{grub-probe} probes device information for a given path
+The program @command{grub2-probe} probes device information for a given path
or device.
@example
@@ -6457,7 +6457,7 @@ grub-probe --target=fs /boot/grub
grub-probe --target=drive --device /dev/sda1
-grub-probe --target=fs /boot/grub
-grub-probe --target=drive --device /dev/sda1
+grub2-probe --target=fs /boot/grub
+grub2-probe --target=drive --device /dev/sda1
@end example
-@command{grub-probe} must be given a path or device as a non-option
@ -966,7 +1037,7 @@ index a7155c22f..2b7b7faf8 100644
argument, and also accepts the following options:
@table @option
@@ -6470,16 +6470,16 @@ Print the version number of GRUB and exit.
@@ -7380,16 +7397,16 @@ Print the version number of GRUB and exit.
@item -d
@itemx --device
If this option is given, then the non-option argument is a system device
@ -986,14 +1057,14 @@ index a7155c22f..2b7b7faf8 100644
@item -t @var{target}
@itemx --target=@var{target}
@@ -6532,19 +6532,19 @@ Print verbose messages.
@@ -7442,19 +7459,19 @@ Print verbose messages.
@end table
-@node Invoking grub-script-check
-@chapter Invoking grub-script-check
-@section Invoking grub-script-check
+@node Invoking grub2-script-check
+@chapter Invoking grub2-script-check
+@section Invoking grub2-script-check
-The program @command{grub-script-check} takes a GRUB script file
+The program @command{grub2-script-check} takes a GRUB script file
@ -1003,7 +1074,7 @@ index a7155c22f..2b7b7faf8 100644
@example
-grub-script-check /boot/grub/grub.cfg
+grub-script-check /boot/grub2/grub.cfg
+grub2-script-check /boot/grub2/grub.cfg
@end example
-@command{grub-script-check} accepts the following options:

View File

@ -20,7 +20,7 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
1 file changed, 18 insertions(+), 60 deletions(-)
diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
index 9b8f5968e..13a3a6bc7 100644
index f300e46fc6a..d7d423b2eaf 100644
--- a/util/grub.d/30_os-prober.in
+++ b/util/grub.d/30_os-prober.in
@@ -42,68 +42,25 @@ if [ -z "${OSPROBED}" ] ; then
@ -104,7 +104,7 @@ index 9b8f5968e..13a3a6bc7 100644
}
EOF
}
@@ -284,11 +241,12 @@ EOF
@@ -296,11 +253,12 @@ EOF
echo "$title_correction_code"
;;
macosx)

View File

@ -1,6 +1,6 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeff Mahoney <jeffm@suse.com>
Date: Wed, 18 Dec 2013 09:57:04 +0000
Date: Tue, 9 Jul 2019 13:39:45 +0200
Subject: [PATCH] grub2/btrfs: Add ability to boot from subvolumes
This patch adds the ability to specify a different root on a btrfs
@ -19,25 +19,25 @@ variable and loading the config file from the subvolume.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
grub-core/fs/btrfs.c | 552 +++++++++++++++++++++++++++++++++++++++++++++++++--
grub-core/fs/btrfs.c | 558 ++++++++++++++++++++++++++++++++++++++++++++++++---
include/grub/btrfs.h | 1 +
2 files changed, 533 insertions(+), 20 deletions(-)
2 files changed, 536 insertions(+), 23 deletions(-)
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index be195448d..51ed63d42 100644
index ba0c583526d..f14fe9c1bda 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -29,6 +29,9 @@
#include <minilzo.h>
@@ -38,6 +38,9 @@
#include <zstd.h>
#include <grub/i18n.h>
#include <grub/btrfs.h>
+#include <grub/command.h>
+#include <grub/env.h>
+#include <grub/extcmd.h>
GRUB_MOD_LICENSE ("GPLv3+");
@@ -64,9 +67,11 @@ struct grub_btrfs_superblock
#include <grub/crypto.h>
#include <grub/diskfilter.h>
#include <grub/safemath.h>
@@ -79,9 +82,11 @@ struct grub_btrfs_superblock
grub_uint64_t generation;
grub_uint64_t root_tree;
grub_uint64_t chunk_tree;
@ -51,7 +51,7 @@ index be195448d..51ed63d42 100644
struct grub_btrfs_device this_device;
char label[0x100];
grub_uint8_t dummy4[0x100];
@@ -105,6 +110,7 @@ struct grub_btrfs_data
@@ -121,6 +126,7 @@ struct grub_btrfs_data
grub_uint64_t exttree;
grub_size_t extsize;
struct grub_btrfs_extent_data *extent;
@ -59,7 +59,7 @@ index be195448d..51ed63d42 100644
};
struct grub_btrfs_chunk_item
@@ -171,6 +177,14 @@ struct grub_btrfs_leaf_descriptor
@@ -191,6 +197,14 @@ struct grub_btrfs_leaf_descriptor
} *data;
};
@ -74,7 +74,7 @@ index be195448d..51ed63d42 100644
struct grub_btrfs_time
{
grub_int64_t sec;
@@ -215,6 +229,14 @@ struct grub_btrfs_extent_data
@@ -236,6 +250,14 @@ struct grub_btrfs_extent_data
#define GRUB_BTRFS_OBJECT_ID_CHUNK 0x100
@ -89,7 +89,7 @@ index be195448d..51ed63d42 100644
static grub_disk_addr_t superblock_sectors[] = { 64 * 2, 64 * 1024 * 2,
256 * 1048576 * 2, 1048576ULL * 1048576ULL * 2
};
@@ -837,6 +859,62 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
@@ -1252,6 +1274,62 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
return GRUB_ERR_NONE;
}
@ -152,7 +152,7 @@ index be195448d..51ed63d42 100644
static struct grub_btrfs_data *
grub_btrfs_mount (grub_device_t dev)
{
@@ -872,6 +950,13 @@ grub_btrfs_mount (grub_device_t dev)
@@ -1287,6 +1365,13 @@ grub_btrfs_mount (grub_device_t dev)
data->devices_attached[0].dev = dev;
data->devices_attached[0].id = data->sblock.this_device.device_id;
@ -166,7 +166,7 @@ index be195448d..51ed63d42 100644
return data;
}
@@ -1232,6 +1317,91 @@ get_root (struct grub_btrfs_data *data, struct grub_btrfs_key *key,
@@ -1784,6 +1869,91 @@ get_root (struct grub_btrfs_data *data, struct grub_btrfs_key *key,
return GRUB_ERR_NONE;
}
@ -258,7 +258,7 @@ index be195448d..51ed63d42 100644
static grub_err_t
find_path (struct grub_btrfs_data *data,
const char *path, struct grub_btrfs_key *key,
@@ -1250,14 +1420,26 @@ find_path (struct grub_btrfs_data *data,
@@ -1802,14 +1972,26 @@ find_path (struct grub_btrfs_data *data,
char *origpath = NULL;
unsigned symlinks_max = 32;
@ -289,15 +289,18 @@ index be195448d..51ed63d42 100644
while (1)
{
while (path[0] == '/')
@@ -1430,9 +1612,21 @@ find_path (struct grub_btrfs_data *data,
@@ -1982,13 +2164,25 @@ find_path (struct grub_btrfs_data *data,
path = path_alloc = tmp;
if (path[0] == '/')
{
- err = get_root (data, key, tree, type);
- if (err)
- return err;
+ if (data->fs_tree)
+ {
{
- grub_free (direl);
- grub_free (path_alloc);
- grub_free (origpath);
- return err;
+ *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
+ *tree = data->fs_tree;
+ /* This is a tree root, so everything starts at objectid 256 */
@ -309,12 +312,16 @@ index be195448d..51ed63d42 100644
+ {
+ err = get_root (data, key, tree, type);
+ if (err)
+ return err;
+ }
+ {
+ grub_free (direl);
+ grub_free (path_alloc);
+ grub_free (origpath);
+ return err;
+ }
}
}
continue;
}
@@ -1673,18 +1867,10 @@ grub_btrfs_read (grub_file_t file, char *buf, grub_size_t len)
@@ -2256,18 +2450,10 @@ grub_btrfs_read (grub_file_t file, char *buf, grub_size_t len)
data->tree, file->offset, buf, len);
}
@ -336,7 +343,7 @@ index be195448d..51ed63d42 100644
grub_be_to_cpu16 (data->sblock.uuid[0]),
grub_be_to_cpu16 (data->sblock.uuid[1]),
grub_be_to_cpu16 (data->sblock.uuid[2]),
@@ -1693,6 +1879,20 @@ grub_btrfs_uuid (grub_device_t device, char **uuid)
@@ -2276,6 +2462,20 @@ grub_btrfs_uuid (grub_device_t device, char **uuid)
grub_be_to_cpu16 (data->sblock.uuid[5]),
grub_be_to_cpu16 (data->sblock.uuid[6]),
grub_be_to_cpu16 (data->sblock.uuid[7]));
@ -357,7 +364,7 @@ index be195448d..51ed63d42 100644
grub_btrfs_unmount (data);
@@ -1749,6 +1949,242 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)),
@@ -2396,6 +2596,242 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)),
}
#endif
@ -599,8 +606,8 @@ index be195448d..51ed63d42 100644
+
static struct grub_fs grub_btrfs_fs = {
.name = "btrfs",
.dir = grub_btrfs_dir,
@@ -1764,12 +2200,88 @@ static struct grub_fs grub_btrfs_fs = {
.fs_dir = grub_btrfs_dir,
@@ -2411,12 +2847,88 @@ static struct grub_fs grub_btrfs_fs = {
#endif
};
@ -690,7 +697,7 @@ index be195448d..51ed63d42 100644
+
+// vim: si et sw=2:
diff --git a/include/grub/btrfs.h b/include/grub/btrfs.h
index 9d93fb6c1..234ad9767 100644
index 9d93fb6c182..234ad976771 100644
--- a/include/grub/btrfs.h
+++ b/include/grub/btrfs.h
@@ -29,6 +29,7 @@ enum

View File

@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 8 Jan 2024 15:41:52 -0500
Subject: [PATCH] btrfs: fix a bad null check
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
current gcc complains:
grub-core/fs/btrfs.c: In function grub_cmd_btrfs_info:
grub-core/fs/btrfs.c:2745:7: error: the comparison will always evaluate as true for the address of label will never be NULL [-Werror=address]
2745 | if (data->sblock.label)
| ^~~~
grub-core/fs/btrfs.c:92:8: note: label declared here
92 | char label[0x100];
| ^~~~~
cc1: all warnings being treated as errors
Obviously this check should be on the first data byte instead of the
symbol itself.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/fs/btrfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index f14fe9c1bda..8e2b1e9f7bc 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -2625,7 +2625,7 @@ grub_cmd_btrfs_info (grub_command_t cmd __attribute__ ((unused)), int argc,
return grub_error (GRUB_ERR_BAD_ARGUMENT, "failed to open fs");
}
- if (data->sblock.label)
+ if (data->sblock.label[0])
grub_printf("Label: '%s' ", data->sblock.label);
else
grub_printf("Label: none ");

View File

@ -12,10 +12,10 @@ Signed-off-by: Michael Chang <mchang@suse.com>
1 file changed, 2 insertions(+)
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index 51ed63d42..88d727d16 100644
index 8e2b1e9f7bc..14e38a4df02 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -2273,6 +2273,8 @@ GRUB_MOD_INIT (btrfs)
@@ -2920,6 +2920,8 @@ GRUB_MOD_INIT (btrfs)
subvol_set_env);
grub_register_variable_hook ("btrfs_subvolid", subvolid_get_env,
subvolid_set_env);

View File

@ -3,15 +3,17 @@ From: Michael Chang <mchang@suse.com>
Date: Thu, 21 Aug 2014 03:39:11 +0000
Subject: [PATCH] grub2-btrfs-03-follow_default
Signed-off-by: Michael Chang <mchang@suse.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/fs/btrfs.c | 107 ++++++++++++++++++++++++++++++++++++---------------
1 file changed, 76 insertions(+), 31 deletions(-)
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index 88d727d16..a47d29756 100644
index 14e38a4df02..d47f9ab0352 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -920,6 +920,7 @@ grub_btrfs_mount (grub_device_t dev)
@@ -1335,6 +1335,7 @@ grub_btrfs_mount (grub_device_t dev)
{
struct grub_btrfs_data *data;
grub_err_t err;
@ -19,7 +21,7 @@ index 88d727d16..a47d29756 100644
if (!dev->disk)
{
@@ -950,11 +951,14 @@ grub_btrfs_mount (grub_device_t dev)
@@ -1365,11 +1366,14 @@ grub_btrfs_mount (grub_device_t dev)
data->devices_attached[0].dev = dev;
data->devices_attached[0].id = data->sblock.this_device.device_id;
@ -38,7 +40,7 @@ index 88d727d16..a47d29756 100644
}
return data;
@@ -1414,24 +1418,39 @@ find_path (struct grub_btrfs_data *data,
@@ -1966,24 +1970,39 @@ find_path (struct grub_btrfs_data *data,
grub_size_t allocated = 0;
struct grub_btrfs_dir_item *direl = NULL;
struct grub_btrfs_key key_out;
@ -85,7 +87,7 @@ index 88d727d16..a47d29756 100644
}
else
{
@@ -1442,15 +1461,23 @@ find_path (struct grub_btrfs_data *data,
@@ -1994,15 +2013,23 @@ find_path (struct grub_btrfs_data *data,
while (1)
{
@ -118,7 +120,7 @@ index 88d727d16..a47d29756 100644
if (*type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY)
{
@@ -1461,7 +1488,9 @@ find_path (struct grub_btrfs_data *data,
@@ -2013,7 +2040,9 @@ find_path (struct grub_btrfs_data *data,
if (ctokenlen == 1 && ctoken[0] == '.')
{
@ -129,7 +131,7 @@ index 88d727d16..a47d29756 100644
continue;
}
if (ctokenlen == 2 && ctoken[0] == '.' && ctoken[1] == '.')
@@ -1492,8 +1521,9 @@ find_path (struct grub_btrfs_data *data,
@@ -2044,8 +2073,9 @@ find_path (struct grub_btrfs_data *data,
*type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY;
key->object_id = key_out.offset;
@ -141,7 +143,7 @@ index 88d727d16..a47d29756 100644
continue;
}
@@ -1562,7 +1592,9 @@ find_path (struct grub_btrfs_data *data,
@@ -2114,7 +2144,9 @@ find_path (struct grub_btrfs_data *data,
return err;
}
@ -152,7 +154,7 @@ index 88d727d16..a47d29756 100644
if (cdirel->type == GRUB_BTRFS_DIR_ITEM_TYPE_SYMLINK)
{
struct grub_btrfs_inode inode;
@@ -1612,14 +1644,26 @@ find_path (struct grub_btrfs_data *data,
@@ -2164,14 +2196,26 @@ find_path (struct grub_btrfs_data *data,
path = path_alloc = tmp;
if (path[0] == '/')
{
@ -186,7 +188,7 @@ index 88d727d16..a47d29756 100644
}
else
{
@@ -2275,6 +2319,7 @@ GRUB_MOD_INIT (btrfs)
@@ -2922,6 +2966,7 @@ GRUB_MOD_INIT (btrfs)
subvolid_set_env);
grub_env_export ("btrfs_subvol");
grub_env_export ("btrfs_subvolid");

View File

@ -3,20 +3,22 @@ From: Michael Chang <mchang@suse.com>
Date: Thu, 21 Aug 2014 03:39:11 +0000
Subject: [PATCH] grub2-btrfs-04-grub2-install
Signed-off-by: Michael Chang <mchang@suse.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/osdep/linux/getroot.c | 7 +++++++
grub-core/osdep/unix/config.c | 17 +++++++++++++++--
util/config.c | 10 ++++++++++
util/grub-install.c | 15 +++++++++++++++
util/grub-install.c | 14 ++++++++++++++
util/grub-mkrelpath.c | 6 ++++++
include/grub/emu/config.h | 1 +
6 files changed, 54 insertions(+), 2 deletions(-)
6 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c
index 6d9f4e5fa..5d50dd6f8 100644
index 7dd775d2ad9..7c29b3523b4 100644
--- a/grub-core/osdep/linux/getroot.c
+++ b/grub-core/osdep/linux/getroot.c
@@ -376,6 +376,7 @@ get_btrfs_fs_prefix (const char *mount_path)
@@ -373,6 +373,7 @@ get_btrfs_fs_prefix (const char *mount_path)
return NULL;
}
@ -24,7 +26,7 @@ index 6d9f4e5fa..5d50dd6f8 100644
char **
grub_find_root_devices_from_mountinfo (const char *dir, char **relroot)
@@ -519,6 +520,12 @@ again:
@@ -516,6 +517,12 @@ again:
{
ret = grub_find_root_devices_from_btrfs (dir);
fs_prefix = get_btrfs_fs_prefix (entries[i].enc_path);
@ -38,7 +40,7 @@ index 6d9f4e5fa..5d50dd6f8 100644
else if (!retry && grub_strcmp (entries[i].fstype, "autofs") == 0)
{
diff --git a/grub-core/osdep/unix/config.c b/grub-core/osdep/unix/config.c
index 65effa9f3..b637c58ef 100644
index 0b1f7618d21..0ce0e309ac0 100644
--- a/grub-core/osdep/unix/config.c
+++ b/grub-core/osdep/unix/config.c
@@ -82,6 +82,19 @@ grub_util_load_config (struct grub_util_config *cfg)
@ -73,7 +75,7 @@ index 65effa9f3..b637c58ef 100644
argv[2] = script;
argv[3] = '\0';
diff --git a/util/config.c b/util/config.c
index ebcdd8f5e..f044a880a 100644
index ebcdd8f5e22..f044a880a76 100644
--- a/util/config.c
+++ b/util/config.c
@@ -42,6 +42,16 @@ grub_util_parse_config (FILE *f, struct grub_util_config *cfg, int simple)
@ -94,19 +96,19 @@ index ebcdd8f5e..f044a880a 100644
sizeof ("GRUB_DISTRIBUTOR=") - 1) == 0)
{
diff --git a/util/grub-install.c b/util/grub-install.c
index 78d0138cb..4375c1619 100644
index 7dc5657bb67..ec3ed49674b 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -816,6 +816,8 @@ fill_core_services (const char *core_services)
free (sysv_plist);
@@ -843,6 +843,8 @@ try_open (const char *path)
}
#endif
+extern int use_relative_path_on_btrfs;
+
int
main (int argc, char *argv[])
{
@@ -849,6 +851,9 @@ main (int argc, char *argv[])
@@ -876,6 +878,9 @@ main (int argc, char *argv[])
grub_util_load_config (&config);
@ -116,11 +118,10 @@ index 78d0138cb..4375c1619 100644
if (!bootloader_id && config.grub_distributor)
{
char *ptr;
@@ -1321,6 +1326,16 @@ main (int argc, char *argv[])
fprintf (load_cfg_f, "set debug='%s'\n",
debug_image);
@@ -1366,6 +1371,15 @@ main (int argc, char *argv[])
relative_grubdir = xstrdup ("/");
}
+
+ if (config.is_suse_btrfs_snapshot_enabled
+ && grub_strncmp(grub_fs->name, "btrfs", sizeof ("btrfs") - 1) == 0)
+ {
@ -134,7 +135,7 @@ index 78d0138cb..4375c1619 100644
char *install_drive = NULL;
diff --git a/util/grub-mkrelpath.c b/util/grub-mkrelpath.c
index 47a241a39..5db7a9a7d 100644
index 47a241a391b..5db7a9a7d97 100644
--- a/util/grub-mkrelpath.c
+++ b/util/grub-mkrelpath.c
@@ -40,9 +40,12 @@ struct arguments
@ -161,7 +162,7 @@ index 47a241a39..5db7a9a7d 100644
if (state->arg_num == 0)
arguments->pathname = xstrdup (arg);
diff --git a/include/grub/emu/config.h b/include/grub/emu/config.h
index 875d5896c..c9a7e5f4a 100644
index 875d5896ce1..c9a7e5f4ade 100644
--- a/include/grub/emu/config.h
+++ b/include/grub/emu/config.h
@@ -37,6 +37,7 @@ struct grub_util_config

View File

@ -3,19 +3,20 @@ From: Michael Chang <mchang@suse.com>
Date: Thu, 21 Aug 2014 03:39:11 +0000
Subject: [PATCH] grub2-btrfs-05-grub2-mkconfig
Signed-off-by: Michael Chang <mchang@suse.com>
---
util/grub-mkconfig.in | 3 ++-
util/grub-mkconfig_lib.in | 4 ++++
util/grub.d/00_header.in | 24 +++++++++++++++++++++++-
util/grub.d/00_header.in | 25 ++++++++++++++++++++++++-
util/grub.d/10_linux.in | 4 ++++
util/grub.d/20_linux_xen.in | 4 ++++
5 files changed, 37 insertions(+), 2 deletions(-)
5 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index 8218f3d47..4248b9341 100644
index 28e92515795..884e4d363ca 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -258,7 +258,8 @@ export GRUB_DEFAULT \
@@ -256,7 +256,8 @@ export GRUB_DEFAULT \
GRUB_BADRAM \
GRUB_OS_PROBER_SKIP_LIST \
GRUB_DISABLE_SUBMENU \
@ -26,10 +27,10 @@ index 8218f3d47..4248b9341 100644
if test "x${grub_cfg}" != "x"; then
rm -f "${grub_cfg}.new"
diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
index 113a41f94..b3aae534d 100644
index 33e1750aebb..0ba0e0e1c65 100644
--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -52,7 +52,11 @@ grub_warn ()
@@ -49,7 +49,11 @@ grub_warn ()
make_system_path_relative_to_its_root ()
{
@ -42,7 +43,7 @@ index 113a41f94..b3aae534d 100644
is_path_readable_by_grub ()
diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in
index 858b526c9..e2a533001 100644
index c2d8b093762..3e1b77265db 100644
--- a/util/grub.d/00_header.in
+++ b/util/grub.d/00_header.in
@@ -27,6 +27,14 @@ export TEXTDOMAINDIR="@localedir@"
@ -71,12 +72,13 @@ index 858b526c9..e2a533001 100644
load_env
fi
EOF
@@ -356,3 +366,15 @@ fi
@@ -356,3 +366,16 @@ fi
if [ "x${GRUB_BADRAM}" != "x" ] ; then
echo "badram ${GRUB_BADRAM}"
fi
+
+if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] &&
+ [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ] &&
+ [ "x${GRUB_FS}" = "xbtrfs" ] ; then
+ # Note: No $snapshot_num on *read-only* rollback! (bsc#901487)
+ cat <<EOF
@ -88,10 +90,10 @@ index 858b526c9..e2a533001 100644
+EOF
+fi
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 4e49ccdf7..d9a05937e 100644
index e8ab4082f87..48ff32c1da4 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -66,10 +66,14 @@ fi
@@ -68,10 +68,14 @@ fi
case x"$GRUB_FS" in
xbtrfs)
@ -107,10 +109,10 @@ index 4e49ccdf7..d9a05937e 100644
xzfs)
rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
index 972a4b5a0..bcdc3ceac 100644
index 98ee5bc58dc..efcded0fbb4 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -73,10 +73,14 @@ fi
@@ -75,10 +75,14 @@ fi
case x"$GRUB_FS" in
xbtrfs)

View File

@ -1,8 +1,10 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Michael Chang <mchang@suse.com>
Date: Fri, 22 May 2015 11:45:25 +0000
Date: Tue, 9 Jul 2019 13:56:16 +0200
Subject: [PATCH] grub2-btrfs-06-subvol-mount
Signed-off-by: Michael Chang <mchang@suse.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/fs/btrfs.c | 195 +++++++++++++++++++++++++++++++++++++++-
grub-core/osdep/linux/getroot.c | 148 +++++++++++++++++++++++++++++-
@ -11,18 +13,18 @@ Subject: [PATCH] grub2-btrfs-06-subvol-mount
4 files changed, 392 insertions(+), 5 deletions(-)
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index a47d29756..2e36ac47e 100644
index d47f9ab0352..d44a1c73b8a 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -32,6 +32,7 @@
@@ -41,6 +41,7 @@
#include <grub/command.h>
#include <grub/env.h>
#include <grub/extcmd.h>
+#include <grub/list.h>
GRUB_MOD_LICENSE ("GPLv3+");
@@ -245,6 +246,12 @@ static grub_err_t
#include <grub/crypto.h>
#include <grub/diskfilter.h>
#include <grub/safemath.h>
@@ -266,6 +267,12 @@ static grub_err_t
grub_btrfs_read_logical (struct grub_btrfs_data *data,
grub_disk_addr_t addr, void *buf, grub_size_t size,
int recursion_depth);
@ -35,7 +37,7 @@ index a47d29756..2e36ac47e 100644
static grub_err_t
read_sblock (grub_disk_t disk, struct grub_btrfs_superblock *sb)
@@ -887,9 +894,26 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path)
@@ -1302,9 +1309,26 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path)
grub_err_t err;
grub_uint64_t tree = 0;
grub_uint8_t type;
@ -62,10 +64,10 @@ index a47d29756..2e36ac47e 100644
if (err)
return grub_error(GRUB_ERR_FILE_NOT_FOUND, "couldn't locate %s\n", path);
@@ -1758,11 +1782,20 @@ grub_btrfs_dir (grub_device_t device, const char *path,
int r = 0;
@@ -2316,11 +2340,20 @@ grub_btrfs_dir (grub_device_t device, const char *path,
grub_uint64_t tree;
grub_uint8_t type;
grub_size_t est_size = 0;
+ char *new_path = NULL;
if (!data)
@ -84,7 +86,7 @@ index a47d29756..2e36ac47e 100644
if (err)
{
grub_btrfs_unmount (data);
@@ -1864,11 +1897,21 @@ grub_btrfs_open (struct grub_file *file, const char *name)
@@ -2447,11 +2480,21 @@ grub_btrfs_open (struct grub_file *file, const char *name)
struct grub_btrfs_inode inode;
grub_uint8_t type;
struct grub_btrfs_key key_in;
@ -107,7 +109,7 @@ index a47d29756..2e36ac47e 100644
if (err)
{
grub_btrfs_unmount (data);
@@ -2039,6 +2082,150 @@ grub_cmd_btrfs_info (grub_command_t cmd __attribute__ ((unused)), int argc,
@@ -2686,6 +2729,150 @@ grub_cmd_btrfs_info (grub_command_t cmd __attribute__ ((unused)), int argc,
return 0;
}
@ -258,7 +260,7 @@ index a47d29756..2e36ac47e 100644
static grub_err_t
get_fs_root(struct grub_btrfs_data *data, grub_uint64_t tree,
grub_uint64_t objectid, grub_uint64_t offset,
@@ -2245,6 +2432,7 @@ static struct grub_fs grub_btrfs_fs = {
@@ -2892,6 +3079,7 @@ static struct grub_fs grub_btrfs_fs = {
};
static grub_command_t cmd_info;
@ -266,7 +268,7 @@ index a47d29756..2e36ac47e 100644
static grub_extcmd_t cmd_list_subvols;
static char *
@@ -2308,6 +2496,9 @@ GRUB_MOD_INIT (btrfs)
@@ -2955,6 +3143,9 @@ GRUB_MOD_INIT (btrfs)
cmd_info = grub_register_command("btrfs-info", grub_cmd_btrfs_info,
"DEVICE",
"Print BtrFS info about DEVICE.");
@ -277,10 +279,10 @@ index a47d29756..2e36ac47e 100644
grub_cmd_btrfs_list_subvols, 0,
"[-p|-n] [-o var] DEVICE",
diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c
index 5d50dd6f8..4c5a13022 100644
index 7c29b3523b4..74a48c03026 100644
--- a/grub-core/osdep/linux/getroot.c
+++ b/grub-core/osdep/linux/getroot.c
@@ -107,6 +107,14 @@ struct btrfs_ioctl_search_key
@@ -103,6 +103,14 @@ struct btrfs_ioctl_search_key
grub_uint32_t unused[9];
};
@ -295,7 +297,7 @@ index 5d50dd6f8..4c5a13022 100644
struct btrfs_ioctl_search_args {
struct btrfs_ioctl_search_key key;
grub_uint64_t buf[(4096 - sizeof(struct btrfs_ioctl_search_key))
@@ -378,6 +386,109 @@ get_btrfs_fs_prefix (const char *mount_path)
@@ -375,6 +383,109 @@ get_btrfs_fs_prefix (const char *mount_path)
int use_relative_path_on_btrfs = 0;
@ -405,7 +407,7 @@ index 5d50dd6f8..4c5a13022 100644
char **
grub_find_root_devices_from_mountinfo (const char *dir, char **relroot)
{
@@ -519,12 +630,15 @@ again:
@@ -516,12 +627,15 @@ again:
else if (grub_strcmp (entries[i].fstype, "btrfs") == 0)
{
ret = grub_find_root_devices_from_btrfs (dir);
@ -424,7 +426,7 @@ index 5d50dd6f8..4c5a13022 100644
}
}
else if (!retry && grub_strcmp (entries[i].fstype, "autofs") == 0)
@@ -1150,6 +1264,34 @@ grub_util_get_grub_dev_os (const char *os_dev)
@@ -1147,6 +1261,34 @@ grub_util_get_grub_dev_os (const char *os_dev)
return grub_dev;
}
@ -460,10 +462,10 @@ index 5d50dd6f8..4c5a13022 100644
grub_make_system_path_relative_to_its_root_os (const char *path)
{
diff --git a/util/grub-install.c b/util/grub-install.c
index 4375c1619..a0ad99729 100644
index ec3ed49674b..d3ec2570d1d 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -1535,6 +1535,55 @@ main (int argc, char *argv[])
@@ -1615,6 +1615,55 @@ main (int argc, char *argv[])
prefix_drive = xasprintf ("(%s)", grub_drives[0]);
}
@ -520,7 +522,7 @@ index 4375c1619..a0ad99729 100644
const char *core_name = NULL;
diff --git a/include/grub/emu/getroot.h b/include/grub/emu/getroot.h
index 73fa2d34a..9c642ae3f 100644
index 73fa2d34abb..9c642ae3fe3 100644
--- a/include/grub/emu/getroot.h
+++ b/include/grub/emu/getroot.h
@@ -53,6 +53,11 @@ char **

View File

@ -10,10 +10,10 @@ Ref: bsc#953538
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index 2e36ac47e..4a31d39ee 100644
index d44a1c73b8a..dba86d19b1a 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -924,11 +924,41 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path)
@@ -1339,11 +1339,41 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path)
return GRUB_ERR_NONE;
}

View File

@ -3,15 +3,17 @@ From: Michael Chang <mchang@suse.com>
Date: Thu, 11 May 2017 08:56:57 +0000
Subject: [PATCH] Grub not working correctly with btrfs snapshots (bsc#1026511)
Signed-off-by: Michael Chang <mchang@suse.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/fs/btrfs.c | 238 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 238 insertions(+)
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index 4a31d39ee..7002ad81b 100644
index dba86d19b1a..87e4dd1a07a 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -2446,6 +2446,238 @@ out:
@@ -3093,6 +3093,238 @@ out:
return 0;
}
@ -249,8 +251,8 @@ index 4a31d39ee..7002ad81b 100644
+
static struct grub_fs grub_btrfs_fs = {
.name = "btrfs",
.dir = grub_btrfs_dir,
@@ -2464,6 +2696,7 @@ static struct grub_fs grub_btrfs_fs = {
.fs_dir = grub_btrfs_dir,
@@ -3111,6 +3343,7 @@ static struct grub_fs grub_btrfs_fs = {
static grub_command_t cmd_info;
static grub_command_t cmd_mount_subvol;
static grub_extcmd_t cmd_list_subvols;
@ -258,7 +260,7 @@ index 4a31d39ee..7002ad81b 100644
static char *
subvolid_set_env (struct grub_env_var *var __attribute__ ((unused)),
@@ -2534,6 +2767,11 @@ GRUB_MOD_INIT (btrfs)
@@ -3181,6 +3414,11 @@ GRUB_MOD_INIT (btrfs)
"[-p|-n] [-o var] DEVICE",
"Print list of BtrFS subvolumes on "
"DEVICE.", options);

View File

@ -10,21 +10,21 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index 39480b386..09a18e563 100644
index a5cd99e5afa..8d98203a784 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -24,6 +24,10 @@
#include <grub/dl.h>
#include <grub/efi/api.h>
@@ -36,6 +36,10 @@ struct linux_arch_kernel_header {
struct grub_pe_image_header pe_image_header;
};
+/* Variables. */
+extern grub_efi_system_table_t *EXPORT_VAR(grub_efi_system_table);
+extern grub_efi_handle_t EXPORT_VAR(grub_efi_image_handle);
+
/* Functions. */
void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_efi_guid_t *protocol,
void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_guid_t *protocol,
void *registration);
@@ -60,6 +64,33 @@ EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size,
@@ -71,6 +75,33 @@ EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size,
grub_efi_uintn_t *descriptor_size,
grub_efi_uint32_t *descriptor_version);
void grub_efi_memory_fini (void);
@ -39,7 +39,7 @@ index 39480b386..09a18e563 100644
+ grub_efi_status_t status;
+
+ b = grub_efi_system_table->boot_services;
+ status = efi_call_3 (b->allocate_pool, pool_type, buffer_size, buffer);
+ status = b->allocate_pool(pool_type, buffer_size, buffer);
+ return status;
+}
+
@ -51,14 +51,14 @@ index 39480b386..09a18e563 100644
+ grub_efi_status_t status;
+
+ b = grub_efi_system_table->boot_services;
+ status = efi_call_1 (b->free_pool, buffer);
+ status = b->free_pool(buffer);
+ return status;
+}
+
grub_efi_loaded_image_t *EXPORT_FUNC(grub_efi_get_loaded_image) (grub_efi_handle_t image_handle);
void EXPORT_FUNC(grub_efi_print_device_path) (grub_efi_device_path_t *dp);
char *EXPORT_FUNC(grub_efi_get_filename) (grub_efi_device_path_t *dp);
@@ -109,10 +140,7 @@ void grub_efi_init (void);
@@ -140,10 +171,7 @@ void grub_efi_init (void);
void grub_efi_fini (void);
void grub_efi_set_prefix (void);

View File

@ -0,0 +1,36 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 1 Jun 2017 10:06:38 -0400
Subject: [PATCH] Use grub_efi_...() memory helpers where reasonable.
This uses grub_efi_allocate_pool(), grub_efi_free_pool(), and
grub_efi_free_pages() instead of open-coded efi_call_N() calls, so we
get more reasonable type checking.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/loader/efi/chainloader.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c
index 1de98f78313..2036924504b 100644
--- a/grub-core/loader/efi/chainloader.c
+++ b/grub-core/loader/efi/chainloader.c
@@ -95,7 +95,7 @@ grub_chainloader_boot (void *context)
}
if (exit_data)
- b->free_pool (exit_data);
+ grub_efi_free_pool (exit_data);
grub_loader_unset ();
@@ -419,7 +419,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
grub_free (file_path);
if (address)
- b->free_pages (address, pages);
+ grub_efi_free_pages (address, pages);
if (image_handle != NULL)
b->unload_image (image_handle);

View File

@ -0,0 +1,33 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 1 Jun 2017 10:07:50 -0400
Subject: [PATCH] Add PRIxGRUB_EFI_STATUS and use it.
This avoids syntax checkers getting confused about if it's llx or lx.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
include/grub/efi/api.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
index c1b869db520..daa9268fdaa 100644
--- a/include/grub/efi/api.h
+++ b/include/grub/efi/api.h
@@ -577,7 +577,16 @@ typedef grub_uint64_t grub_efi_uint64_t;
typedef grub_uint8_t grub_efi_char8_t;
typedef grub_uint16_t grub_efi_char16_t;
+
typedef grub_efi_uintn_t grub_efi_status_t;
+/* Make grub_efi_status_t reasonably printable. */
+#if GRUB_CPU_SIZEOF_VOID_P == 8
+#define PRIxGRUB_EFI_STATUS "lx"
+#define PRIdGRUB_EFI_STATUS "ld"
+#else
+#define PRIxGRUB_EFI_STATUS "llx"
+#define PRIdGRUB_EFI_STATUS "lld"
+#endif
/*
* On x86, the EFI calling convention may deviate from the local one, so

View File

@ -8,10 +8,10 @@ Subject: [PATCH] don't use int for efi status
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
index 562d6887e..bcae7f469 100644
index 885d7c6420e..2bb8a0e7a38 100644
--- a/grub-core/kern/efi/efi.c
+++ b/grub-core/kern/efi/efi.c
@@ -166,7 +166,7 @@ grub_reboot (void)
@@ -177,7 +177,7 @@ grub_reboot (void)
void
grub_exit (int retval)
{

View File

@ -8,7 +8,7 @@ Subject: [PATCH] make GRUB_MOD_INIT() declare its function prototypes.
1 file changed, 2 insertions(+)
diff --git a/include/grub/dl.h b/include/grub/dl.h
index 2bca56ce0..b1ed3c333 100644
index cd1f46c8bad..f2bf50eb98d 100644
--- a/include/grub/dl.h
+++ b/include/grub/dl.h
@@ -54,6 +54,7 @@ grub_mod_fini (void)

View File

@ -16,10 +16,10 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/util/grub-install.c b/util/grub-install.c
index a0ad99729..16f137ca8 100644
index d3ec2570d1d..66ef9494d9d 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -1159,18 +1159,8 @@ main (int argc, char *argv[])
@@ -1234,18 +1234,8 @@ main (int argc, char *argv[])
char *d;
is_guess = 1;

View File

@ -0,0 +1,47 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 9 Jul 2019 14:31:19 +0200
Subject: [PATCH] 20_linux_xen: load xen or multiboot{,2} modules as needed.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
util/grub.d/20_linux_xen.in | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
index efcded0fbb4..4ecf5deea17 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -156,6 +156,7 @@ linux_entry_xsm ()
else
xen_rm_opts="no-real-mode edd=off"
fi
+ insmod ${xen_module}
${xen_loader} ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts}
echo '$(echo "$lmessage" | grub_quote)'
${module_loader} ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
@@ -168,6 +169,7 @@ EOF
initrd_path="${rel_dirname}/${i}"
sed "s/^/$submenu_indentation/" << EOF
echo '$(echo "$message" | grub_quote)'
+ insmod ${xen_module}
${module_loader} --nounzip $(echo $initrd_path)
EOF
done
@@ -269,13 +271,16 @@ for current_xen in ${reverse_sorted_xen_list}; do
echo " submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_version}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {"
fi
if ($grub_file --is-arm64-efi $current_xen); then
+ xen_module="xen_boot"
xen_loader="xen_hypervisor"
module_loader="xen_module"
else
if ($grub_file --is-x86-multiboot2 $current_xen); then
+ xen_module="multiboot2"
xen_loader="multiboot2"
module_loader="module2"
else
+ xen_module="multiboot"
xen_loader="multiboot"
module_loader="module"
fi

View File

@ -9,7 +9,7 @@ Subject: [PATCH] align struct efi_variable better...
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/grub/efiemu/runtime.h b/include/grub/efiemu/runtime.h
index 36d2dedf4..9d93ba88b 100644
index 2ff42984545..6363fd522e1 100644
--- a/include/grub/efiemu/runtime.h
+++ b/include/grub/efiemu/runtime.h
@@ -33,5 +33,5 @@ struct efi_variable
@ -20,10 +20,10 @@ index 36d2dedf4..9d93ba88b 100644
+} GRUB_PACKED GRUB_ALIGNED(8);
#endif /* ! GRUB_EFI_EMU_RUNTIME_HEADER */
diff --git a/include/grub/types.h b/include/grub/types.h
index b93e48201..f6a972397 100644
index 064066e2e18..59e030268c2 100644
--- a/include/grub/types.h
+++ b/include/grub/types.h
@@ -29,6 +29,7 @@
@@ -30,6 +30,7 @@
#else
#define GRUB_PACKED __attribute__ ((packed))
#endif

View File

@ -0,0 +1,382 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 9 Dec 2016 15:40:29 -0500
Subject: [PATCH] Add BLS support to grub-mkconfig
GRUB now has BootLoaderSpec support, the user can choose to use this by
setting GRUB_ENABLE_BLSCFG to true in /etc/default/grub. On this setup,
the boot menu entries are not added to the grub.cfg, instead BLS config
files are parsed by blscfg command and the entries created dynamically.
A 10_linux_bls grub.d snippet to generate menu entries from BLS files
is also added that can be used on platforms where the bootloader doesn't
have BLS support and only can parse a normal grub configuration file.
Portions of the 10_linux_bls were taken from the ostree-grub-generator
script that's included in the OSTree project.
Fixes to support multi-devices and generate a BLS section even if no
kernels are found in the boot directory were proposed by Yclept Nemo
and Tom Gundersen respectively.
Signed-off-by: Peter Jones <pjones@redhat.com>
[javierm: remove outdated URL for BLS document]
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
[iwienand@redhat.com: skip machine ID check when updating entries]
Signed-off-by: Ian Wienand <iwienand@redhat.com>
[rharwood: use sort(1), commit message composits, drop man pages]
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
util/grub-mkconfig.in | 9 +-
util/grub-mkconfig_lib.in | 22 ++++-
util/grub.d/10_linux.in | 218 +++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 243 insertions(+), 6 deletions(-)
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index 884e4d363ca..bec52e052fc 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -50,6 +50,8 @@ grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@"
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
+export GRUB_GRUBENV_UPDATE="yes"
+
. "${pkgdatadir}/grub-mkconfig_lib"
# Usage: usage
@@ -59,6 +61,7 @@ usage () {
gettext "Generate a grub config file"; echo
echo
print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")"
+ print_option_help "--no-grubenv-update" "$(gettext "do not update variables in the grubenv file")"
print_option_help "-h, --help" "$(gettext "print this message and exit")"
print_option_help "-V, --version" "$(gettext "print the version information and exit")"
echo
@@ -94,6 +97,9 @@ do
--output=*)
grub_cfg=`echo "$option" | sed 's/--output=//'`
;;
+ --no-grubenv-update)
+ GRUB_GRUBENV_UPDATE="no"
+ ;;
-*)
gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2
usage
@@ -257,7 +263,8 @@ export GRUB_DEFAULT \
GRUB_OS_PROBER_SKIP_LIST \
GRUB_DISABLE_SUBMENU \
GRUB_DEFAULT_DTB \
- SUSE_BTRFS_SNAPSHOT_BOOTING
+ SUSE_BTRFS_SNAPSHOT_BOOTING \
+ GRUB_ENABLE_BLSCFG
if test "x${grub_cfg}" != "x"; then
rm -f "${grub_cfg}.new"
diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
index 0ba0e0e1c65..c2e107b41ab 100644
--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -30,6 +30,9 @@ fi
if test "x$grub_file" = x; then
grub_file="${bindir}/@grub_file@"
fi
+if test "x$grub_editenv" = x; then
+ grub_editenv="${bindir}/@grub_editenv@"
+fi
if test "x$grub_mkrelpath" = x; then
grub_mkrelpath="${bindir}/@grub_mkrelpath@"
fi
@@ -122,8 +125,19 @@ EOF
fi
}
+prepare_grub_to_access_device_with_variable ()
+{
+ device_variable="$1"
+ shift
+ prepare_grub_to_access_device "$@"
+ unset "device_variable"
+}
+
prepare_grub_to_access_device ()
{
+ if [ -z "$device_variable" ]; then
+ device_variable="root"
+ fi
old_ifs="$IFS"
IFS='
'
@@ -158,18 +172,18 @@ prepare_grub_to_access_device ()
# otherwise set root as per value in device.map.
fs_hint="`"${grub_probe}" --device $@ --target=compatibility_hint`"
if [ "x$fs_hint" != x ]; then
- echo "set root='$fs_hint'"
+ echo "set ${device_variable}='$fs_hint'"
fi
if [ "x${GRUB_DISABLE_UUID}" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then
hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints=
if [ "x$hints" != x ]; then
echo "if [ x\$feature_platform_search_hint = xy ]; then"
- echo " search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}"
+ echo " search --no-floppy --fs-uuid --set=${device_variable} ${hints} ${fs_uuid}"
echo "else"
- echo " search --no-floppy --fs-uuid --set=root ${fs_uuid}"
+ echo " search --no-floppy --fs-uuid --set=${device_variable} ${fs_uuid}"
echo "fi"
else
- echo "search --no-floppy --fs-uuid --set=root ${fs_uuid}"
+ echo "search --no-floppy --fs-uuid --set=${device_variable} ${fs_uuid}"
fi
fi
IFS="$old_ifs"
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 48ff32c1da4..cd9aea0cc01 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -84,6 +84,218 @@ case x"$GRUB_FS" in
;;
esac
+populate_header_warn()
+{
+if [ "x${BLS_POPULATE_MENU}" = "xtrue" ]; then
+ bls_parser="10_linux script"
+else
+ bls_parser="blscfg command"
+fi
+cat <<EOF
+
+# This section was generated by a script. Do not modify the generated file - all changes
+# will be lost the next time file is regenerated. Instead edit the BootLoaderSpec files.
+#
+# The $bls_parser parses the BootLoaderSpec files stored in /boot/loader/entries and
+# populates the boot menu. Please refer to the Boot Loader Specification documentation
+# for the files format: https://systemd.io/BOOT_LOADER_SPECIFICATION/.
+
+EOF
+}
+
+read_config()
+{
+ config_file=${1}
+ title=""
+ initrd=""
+ options=""
+ linux=""
+ grub_arg=""
+
+ while read -r line
+ do
+ record=$(echo ${line} | cut -f 1 -d ' ')
+ value=$(echo ${line} | cut -s -f2- -d ' ')
+ case "${record}" in
+ "title")
+ title=${value}
+ ;;
+ "initrd")
+ initrd=${value}
+ ;;
+ "linux")
+ linux=${value}
+ ;;
+ "options")
+ options=${value}
+ ;;
+ "grub_arg")
+ grub_arg=${value}
+ ;;
+ esac
+ done < ${config_file}
+}
+
+blsdir="/boot/loader/entries"
+
+get_sorted_bls()
+{
+ if ! [ -d "${blsdir}" ]; then
+ return
+ fi
+
+ local IFS=$'\n'
+
+ files=($(for bls in ${blsdir}/*.conf; do
+ if ! [[ -e "${bls}" ]] ; then
+ continue
+ fi
+ bls="${bls%.conf}"
+ bls="${bls##*/}"
+ echo "${bls}"
+ done | sort -Vr 2>/dev/null)) || :
+
+ echo "${files[@]}"
+}
+
+update_bls_cmdline()
+{
+ local cmdline="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+ local -a files=($(get_sorted_bls))
+
+ for bls in "${files[@]}"; do
+ local options="${cmdline}"
+ if [ -z "${bls##*debug*}" ]; then
+ options="${options} ${GRUB_CMDLINE_LINUX_DEBUG}"
+ fi
+ options="$(echo "${options}" | sed -e 's/\//\\\//g')"
+ sed -i -e "s/^options.*/options ${options}/" "${blsdir}/${bls}.conf"
+ done
+}
+
+populate_menu()
+{
+ local -a files=($(get_sorted_bls))
+
+ gettext_printf "Generating boot entries from BLS files...\n" >&2
+
+ for bls in "${files[@]}"; do
+ read_config "${blsdir}/${bls}.conf"
+
+ menu="${menu}menuentry '${title}' ${grub_arg} --id=${bls} {\n"
+ menu="${menu}\t linux ${linux} ${options}\n"
+ if [ -n "${initrd}" ] ; then
+ menu="${menu}\t initrd ${boot_prefix}${initrd}\n"
+ fi
+ menu="${menu}}\n\n"
+ done
+ # The printf command seems to be more reliable across shells for special character (\n, \t) evaluation
+ printf "$menu"
+}
+
+# Make BLS the default if GRUB_ENABLE_BLSCFG was not set and grubby is not installed.
+if [ -z "${GRUB_ENABLE_BLSCFG}" ] && ! command -v new-kernel-pkg >/dev/null; then
+ GRUB_ENABLE_BLSCFG="true"
+fi
+
+if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then
+ if [ x$dirname = x/ ]; then
+ if [ -z "${prepare_root_cache}" ]; then
+ prepare_grub_to_access_device ${GRUB_DEVICE}
+ fi
+ else
+ if [ -z "${prepare_boot_cache}" ]; then
+ prepare_grub_to_access_device ${GRUB_DEVICE_BOOT}
+ fi
+ fi
+
+ if [ -d /sys/firmware/efi ]; then
+ bootefi_device="`${grub_probe} --target=device /boot/efi/`"
+ prepare_grub_to_access_device_with_variable boot ${bootefi_device}
+ else
+ boot_device="`${grub_probe} --target=device /boot/`"
+ prepare_grub_to_access_device_with_variable boot ${boot_device}
+ fi
+
+ arch="$(uname -m)"
+ if [ "x${arch}" = "xppc64le" ] && [ -d /sys/firmware/opal ]; then
+
+ BLS_POPULATE_MENU="true"
+ petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot"
+
+ if test -e ${petitboot_path}; then
+ read -r -d '' petitboot_version < ${petitboot_path}
+ petitboot_version="$(echo ${petitboot_version//v})"
+
+ if test -n ${petitboot_version}; then
+ major_version="$(echo ${petitboot_version} | cut -d . -f1)"
+ minor_version="$(echo ${petitboot_version} | cut -d . -f2)"
+
+ re='^[0-9]+$'
+ if [[ $major_version =~ $re ]] && [[ $minor_version =~ $re ]] &&
+ ([[ ${major_version} -gt 1 ]] ||
+ [[ ${major_version} -eq 1 &&
+ ${minor_version} -ge 8 ]]); then
+ BLS_POPULATE_MENU="false"
+ fi
+ fi
+ fi
+ fi
+
+ populate_header_warn
+
+ cat << EOF
+# The kernelopts variable should be defined in the grubenv file. But to ensure that menu
+# entries populated from BootLoaderSpec files that use this variable work correctly even
+# without a grubenv file, define a fallback kernelopts variable if this has not been set.
+#
+# The kernelopts variable in the grubenv file can be modified using the grubby tool or by
+# executing the grub2-mkconfig tool. For the latter, the values of the GRUB_CMDLINE_LINUX
+# and GRUB_CMDLINE_LINUX_DEFAULT options from /etc/default/grub file are used to set both
+# the kernelopts variable in the grubenv file and the fallback kernelopts variable.
+if [ -z "\${kernelopts}" ]; then
+ set kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+fi
+EOF
+
+ update_bls_cmdline
+
+ if [ "x${BLS_POPULATE_MENU}" = "xtrue" ]; then
+ populate_menu
+ else
+ cat << EOF
+
+insmod blscfg
+blscfg
+EOF
+ fi
+
+ if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then
+ blsdir="/boot/loader/entries"
+ [ -d "${blsdir}" ] && GRUB_BLS_FS="$(${grub_probe} --target=fs ${blsdir})"
+ if [ "x${GRUB_BLS_FS}" = "xbtrfs" ] || [ "x${GRUB_BLS_FS}" = "xzfs" ]; then
+ blsdir=$(make_system_path_relative_to_its_root "${blsdir}")
+ if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then
+ ${grub_editenv} - set blsdir="${blsdir}"
+ fi
+ fi
+
+ if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then
+ ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}"
+ fi
+
+ if [ -n "${GRUB_DEFAULT_DTB}" ]; then
+ ${grub_editenv} - set devicetree="${GRUB_DEFAULT_DTB}"
+ fi
+
+ if [ -n "${GRUB_SAVEDEFAULT}" ]; then
+ ${grub_editenv} - set save_default="${GRUB_SAVEDEFAULT}"
+ fi
+ fi
+
+ exit 0
+fi
+
mktitle ()
{
local title_type
@@ -123,6 +335,7 @@ linux_entry ()
if [ -z "$boot_device_id" ]; then
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
fi
+
if [ x$type != xsimple ] ; then
title=$(mktitle "$type" "$version")
if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
@@ -243,6 +456,7 @@ fi
is_top_level=true
for linux in ${reverse_sorted_list}; do
gettext_printf "Found linux image: %s\n" "$linux" >&2
+
basename=`basename $linux`
dirname=`dirname $linux`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
@@ -283,7 +497,9 @@ for linux in ${reverse_sorted_list}; do
for i in ${initrd}; do
initrd_display="${initrd_display} ${dirname}/${i}"
done
- gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2
+ if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then
+ gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2
+ fi
fi
fdt=

View File

@ -12,10 +12,10 @@ Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index 04371ac49..636f97e1b 100644
index 465a8e74ea7..b1d399d37d7 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -1103,7 +1103,7 @@ static void __attribute__ ((noreturn))
@@ -1303,7 +1303,7 @@ void __attribute__ ((noreturn))
grub_abort (void)
{
#ifndef GRUB_UTIL

View File

@ -4,20 +4,26 @@ Date: Thu, 15 Mar 2018 14:12:40 -0400
Subject: [PATCH] Add grub2-switch-to-blscfg
Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
[jhlavac: Use ${etcdefaultgrub} instead of /etc/default/grub]
Signed-off-by: Jan Hlavac <jhlavac@redhat.com>
[rharwood: skip on ostree installations, migrate man to h2m]
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
Makefile.util.def | 7 ++
.gitignore | 2 +
util/grub-switch-to-blscfg.8 | 25 ++++
util/grub-switch-to-blscfg.in | 262 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 296 insertions(+)
create mode 100644 util/grub-switch-to-blscfg.8
Makefile.util.def | 7 +
docs/man/grub-switch-to-blscfg.h2m | 2 +
util/grub-set-password.in | 2 +-
util/grub-switch-to-blscfg.in | 317 +++++++++++++++++++++++++++++++++++++
util/grub.d/10_linux.in | 2 +-
5 files changed, 328 insertions(+), 2 deletions(-)
create mode 100644 docs/man/grub-switch-to-blscfg.h2m
create mode 100644 util/grub-switch-to-blscfg.in
diff --git a/Makefile.util.def b/Makefile.util.def
index 879e8eb98..f4fbd2506 100644
index 84a17ef5cfa..acbcc8c208c 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -1348,6 +1348,13 @@ program = {
@@ -1387,6 +1387,13 @@ program = {
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
};
@ -31,56 +37,32 @@ index 879e8eb98..f4fbd2506 100644
program = {
name = grub-glue-efi;
mansection = 1;
diff --git a/.gitignore b/.gitignore
index 54795fa60..424755921 100644
--- a/.gitignore
+++ b/.gitignore
@@ -121,6 +121,8 @@ grub-*.tar.*
/grub*-sparc64-setup.8
/grub*-syslinux2cfg
/grub*-syslinux2cfg.1
+/grub*-switch-to-blscfg
+/grub*-switch-to-blscfg.8
/grub_fstest.pp
/grub_fstest_init.c
/grub_fstest_init.lst
diff --git a/util/grub-switch-to-blscfg.8 b/util/grub-switch-to-blscfg.8
diff --git a/docs/man/grub-switch-to-blscfg.h2m b/docs/man/grub-switch-to-blscfg.h2m
new file mode 100644
index 000000000..134dfc62a
index 00000000000..fa341426a50
--- /dev/null
+++ b/util/grub-switch-to-blscfg.8
@@ -0,0 +1,25 @@
+.TH GRUB-SWITCH-TO-BLSCFG 1 "Wed Feb 26 2014"
+.SH NAME
+\fBgrub-switch-to-blscfg\fR \(em Switch to using BLS config files.
+
+.SH SYNOPSIS
+\fBgrub-switch-to-blscfg\fR [--grub-directory=\fIDIR\fR] [--config-file=\fIFILE\fR] [--grub-defaults=\fIFILE\fR]
+
+.SH DESCRIPTION
+\fBgrub-switch-to-blscfg\fR reconfigures grub-mkconfig to use BLS-style config files, and then regenerates the GRUB configuration.
+
+.SH OPTIONS
+.TP
+--grub-directory=\fIDIR\fR
+Search for grub.cfg under \fIDIR\fR. The default value is \fI/boot/efi/EFI/\fBVENDOR\fR on UEFI machines and \fI/boot/grub2\fR elsewhere.
+
+.TP
+--config-file=\fIFILE\fR
+The grub config file to use. The default value is \fI/etc/grub2-efi.cfg\fR on UEFI machines and \fI/etc/grub2.cfg\fR elsewhere. Symbolic links will be followed.
+
+.TP
+--grub-defaults=\fIFILE\fR
+The defaults file for grub-mkconfig. The default value is \fI/etc/default/grub\fR.
+
+.SH SEE ALSO
+.BR "info grub"
+++ b/docs/man/grub-switch-to-blscfg.h2m
@@ -0,0 +1,2 @@
+[NAME]
+grub-switch-to-blscfg \- switch to using BLS config files
diff --git a/util/grub-set-password.in b/util/grub-set-password.in
index 5ebf50576d6..c0b5ebbfdc5 100644
--- a/util/grub-set-password.in
+++ b/util/grub-set-password.in
@@ -1,6 +1,6 @@
#!/bin/sh -e
-EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/')
+EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/' -e 's/\"//g')
if [ -d /sys/firmware/efi/efivars/ ]; then
grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'`
else
diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in
new file mode 100644
index 000000000..3ae5e4ea8
index 00000000000..a851424beb2
--- /dev/null
+++ b/util/grub-switch-to-blscfg.in
@@ -0,0 +1,262 @@
@@ -0,0 +1,317 @@
+#! /bin/sh
+#
+# Set a default boot entry for GRUB.
@ -104,6 +86,7 @@ index 000000000..3ae5e4ea8
+# Initialize some variables.
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+sbindir=@sbindir@
+bindir=@bindir@
+sysconfdir="@sysconfdir@"
+PACKAGE_NAME=@PACKAGE_NAME@
@ -116,22 +99,27 @@ index 000000000..3ae5e4ea8
+
+self=`basename $0`
+
+grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@"
+grub_editenv=${bindir}/@grub_editenv@
+etcdefaultgrub=/etc/default/grub
+
+EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/')
+eval "$("${grub_get_kernel_settings}")" || true
+
+EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/' -e 's/\"//g')
+if [ -d /sys/firmware/efi/efivars/ ]; then
+ startlink=/etc/grub2-efi.cfg
+ grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'`
+ blsdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/loader/entries" | sed 's,//*,/,g'`
+else
+ startlink=/etc/grub2.cfg
+ grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
+ blsdir=`echo "/@bootdirname@" | sed 's,//*,/,g'`
+fi
+
+blsdir=`echo "/@bootdirname@/loader/entries" | sed 's,//*,/,g'`
+
+backupsuffix=.bak
+
+arch="$(uname -m)"
+
+export TEXTDOMAIN=@PACKAGE@
+export TEXTDOMAINDIR="@localedir@"
+
@ -230,18 +218,18 @@ index 000000000..3ae5e4ea8
+
+find_grub_cfg() {
+ local candidate=""
+ while [[ -e "${candidate}" || $# -gt 0 ]]
+ while [ -e "${candidate}" -o $# -gt 0 ]
+ do
+ if [[ ! -e "${candidate}" ]] ; then
+ if [ ! -e "${candidate}" ] ; then
+ candidate="$1"
+ shift
+ fi
+
+ if [[ -L "${candidate}" ]]; then
+ if [ -L "${candidate}" ]; then
+ candidate="$(realpath "${candidate}")"
+ fi
+
+ if [[ -f "${candidate}" ]]; then
+ if [ -f "${candidate}" ]; then
+ export GRUB_CONFIG_FILE="${candidate}"
+ return 0
+ fi
@ -254,11 +242,11 @@ index 000000000..3ae5e4ea8
+ exit 1
+fi
+
+if [[ ! -d "${blsdir}" ]]; then
+if [ ! -d "${blsdir}" ]; then
+ install -m 700 -d "${blsdir}"
+fi
+
+if [[ -f /etc/machine-id ]]; then
+if [ -f /etc/machine-id ]; then
+ MACHINE_ID=$(cat /etc/machine-id)
+else
+ MACHINE_ID=$(dmesg | sha256sum)
@ -267,14 +255,17 @@ index 000000000..3ae5e4ea8
+mkbls() {
+ local kernelver=$1 && shift
+ local datetime=$1 && shift
+ local kernelopts=$1 && shift
+
+ local debugname=""
+ local debugid=""
+ local flavor=""
+
+ if [[ "$kernelver" == *\+* ]] ; then
+ if [ "$kernelver" == *\+* ] ; then
+ local flavor=-"${kernelver##*+}"
+ if [[ "${flavor}" == "-debug" ]]; then
+ if [ "${flavor}" == "-debug" ]; then
+ local debugname=" with debugging"
+ local debugid="-debug"
+ fi
+ fi
+ (
@ -282,10 +273,10 @@ index 000000000..3ae5e4ea8
+
+ cat <<EOF
+title ${NAME} (${kernelver}) ${VERSION}${debugname}
+version ${kernelver}${debugid}
+linux /vmlinuz-${kernelver}
+initrd /initramfs-${kernelver}.img
+options \$kernelopts
+id ${ID}-${datetime}-${kernelver}
+options ${kernelopts}
+grub_users \$grub_users
+grub_arg --unrestricted
+grub_class kernel${flavor}
@ -293,23 +284,55 @@ index 000000000..3ae5e4ea8
+ ) | cat
+}
+
+for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
+ if [[ ! -d "/lib/modules/${kernelver}" ]] ; then
+ continue
+copy_bls() {
+ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
+ bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
+ linux="/vmlinuz-${kernelver}"
+ linux_path="/boot${linux}"
+ kernel_dir="/lib/modules/${kernelver}"
+
+ if [ ! -d "${kernel_dir}" ] ; then
+ continue
+ fi
+ if [ ! -f "${linux_path}" ]; then
+ continue
+ fi
+
+ linux_relpath="$("${grub_mkrelpath}" "${linux_path}")"
+ bootprefix="${linux_relpath%%"${linux}"}"
+ cmdline="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+
+ mkbls "${kernelver}" \
+ "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \
+ "${bootprefix}" "${cmdline}" >"${bls_target}"
+
+ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
+ bls_debug="$(echo ${bls_target} | sed -e "s/${kernelver}/${kernelver}~debug/")"
+ cp -aT "${bls_target}" "${bls_debug}"
+ title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')"
+ options="$(echo "${cmdline} ${GRUB_CMDLINE_LINUX_DEBUG}" | sed -e 's/\//\\\//g')"
+ sed -i -e "s/^title.*/title ${title}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${bls_debug}"
+ sed -i -e "s/^options.*/options ${options}/" "${bls_debug}"
+ fi
+ done
+
+ if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then
+ mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf"
+ fi
+ if [[ ! -f "/boot/vmlinuz-${kernelver}" ]]; then
+ continue
+ fi
+ bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
+ kernel_dir="/lib/modules/${kernelver}"
+ if [[ -f "${kernel_dir}/bls.conf" ]]; then
+ cp -af "${kernel_dir}/bls.conf" "${bls_target}"
+ else
+ mkbls "${kernelver}" \
+ "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \
+ >"${bls_target}"
+ fi
+done
+}
+
+# The grub2 EFI binary is not copied to the ESP as a part of an ostree
+# transaction. Make sure a grub2 version with BLS support is installed
+# but only do this if the blsdir is not set, to make sure that the BLS
+# parsing module will search for the BLS snippets in the default path.
+if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars && \
+ ! ${grub_editenv} - list | grep -q blsdir && \
+ mountpoint -q /boot; then
+ grub_binary="$(find /usr/lib/ostree-boot/efi/EFI/${EFIDIR}/ -name grub*.efi)"
+ install -m 700 ${grub_binary} ${grubdir} || exit 1
+ # Create a hidden file to indicate that grub2 now has BLS support.
+ touch /boot/grub2/.grub2-blscfg-supported
+fi
+
+GENERATE=0
+if grep '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" \
@ -329,13 +352,27 @@ index 000000000..3ae5e4ea8
+ GENERATE=1
+fi
+
+if [[ "${GENERATE}" -eq 1 ]] ; then
+if [ "${GENERATE}" -eq 1 ] ; then
+ copy_bls
+
+ if [ $arch = "x86_64" ] && [ ! -d /sys/firmware/efi ]; then
+ mod_dir="i386-pc"
+ elif [ $arch = "ppc64" -o $arch = "ppc64le" ] && [ ! -d /sys/firmware/opal ]; then
+ mod_dir="powerpc-ieee1275"
+ fi
+
+ if [ -n "${mod_dir}" ]; then
+ for mod in blscfg increment; do
+ install -m 700 ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1
+ done
+ fi
+
+ cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}"
+ if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then
+ cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}"
+ install -m 700 "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}"
+ sed -i"${backupsuffix}" \
+ -e 's,^GRUB_ENABLE_BLSCFG=.*,GRUB_ENABLE_BLSCFG=false,' \
+ /etc/default/grub
+ "${etcdefaultgrub}"
+ gettext_printf "Updating %s failed\n" "${GRUB_CONFIG_FILE}"
+ exit 1
+ fi
@ -343,3 +380,16 @@ index 000000000..3ae5e4ea8
+
+# Bye.
+exit 0
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index cd9aea0cc01..b8bc37e92aa 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -140,7 +140,7 @@ blsdir="/boot/loader/entries"
get_sorted_bls()
{
- if ! [ -d "${blsdir}" ]; then
+ if ! [ -d "${blsdir}" ] || [ -f /run/ostree-booted ] || [ -d /ostree/repo ]; then
return
fi

View File

@ -8,10 +8,10 @@ Subject: [PATCH] normal: don't draw our startup message if debug is set
1 file changed, 3 insertions(+)
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index b69f9e738..04ae9ed02 100644
index 3463f444f74..b5fa6156549 100644
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -419,6 +419,9 @@ grub_normal_reader_init (int nested)
@@ -430,6 +430,9 @@ grub_normal_reader_init (int nested)
const char *msg_esc = _("ESC at any time exits.");
char *msg_formatted;
@ -20,4 +20,4 @@ index b69f9e738..04ae9ed02 100644
+
msg_formatted = grub_xasprintf (_("Minimal BASH-like line editing is supported. For "
"the first word, TAB lists possible command completions. Anywhere "
"else TAB lists possible device or file completions. %s"),
"else TAB lists possible device or file completions. To enable "

View File

@ -17,7 +17,7 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
diff --git a/include/grub/arm/efi/console.h b/include/grub/arm/efi/console.h
new file mode 100644
index 000000000..1592f6f76
index 00000000000..1592f6f76b5
--- /dev/null
+++ b/include/grub/arm/efi/console.h
@@ -0,0 +1,24 @@
@ -47,7 +47,7 @@ index 000000000..1592f6f76
+#endif /* ! GRUB_ARM_EFI_CONSOLE_H */
diff --git a/include/grub/arm64/efi/console.h b/include/grub/arm64/efi/console.h
new file mode 100644
index 000000000..956893393
index 00000000000..95689339384
--- /dev/null
+++ b/include/grub/arm64/efi/console.h
@@ -0,0 +1,24 @@
@ -77,7 +77,7 @@ index 000000000..956893393
+#endif /* ! GRUB_ARM64_EFI_CONSOLE_H */
diff --git a/include/grub/i386/efi/console.h b/include/grub/i386/efi/console.h
new file mode 100644
index 000000000..9231375cb
index 00000000000..9231375cb07
--- /dev/null
+++ b/include/grub/i386/efi/console.h
@@ -0,0 +1,24 @@
@ -107,7 +107,7 @@ index 000000000..9231375cb
+#endif /* ! GRUB_I386_EFI_CONSOLE_H */
diff --git a/include/grub/x86_64/efi/console.h b/include/grub/x86_64/efi/console.h
new file mode 100644
index 000000000..dba9d8678
index 00000000000..dba9d8678d0
--- /dev/null
+++ b/include/grub/x86_64/efi/console.h
@@ -0,0 +1,24 @@

View File

@ -10,10 +10,10 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
2 files changed, 27 insertions(+)
diff --git a/configure.ac b/configure.ac
index f69f89867..359cac3c2 100644
index 3602b4ab62b..fcfbcbb664d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1386,7 +1386,15 @@ grub_PROG_TARGET_CC
@@ -1540,7 +1540,15 @@ grub_PROG_TARGET_CC
if test "x$TARGET_APPLE_LINKER" != x1 ; then
grub_PROG_OBJCOPY_ABSOLUTE
fi
@ -30,7 +30,7 @@ index f69f89867..359cac3c2 100644
if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
if test ! -z "$TARGET_IMG_LDSCRIPT"; then
diff --git a/acinclude.m4 b/acinclude.m4
index 78cdf6e1d..242e829ff 100644
index fa7840f09af..0231e64e337 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -136,6 +136,25 @@ if test "x$grub_cv_prog_ld_build_id_none" = xyes; then

View File

@ -1,12 +1,12 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 6 Nov 2017 18:31:56 -0500
Date: Tue, 9 Jul 2019 17:05:03 +0200
Subject: [PATCH] make better backtraces
Signed-off-by: Peter Jones <pjones@redhat.com>
---
Makefile.util.def | 6 ++
grub-core/Makefile.core.def | 15 ++--
grub-core/Makefile.core.def | 16 ++--
grub-core/{lib => commands}/backtrace.c | 2 +-
grub-core/gdb/cstub.c | 1 -
grub-core/kern/arm64/backtrace.c | 94 ++++++++++++++++++++++++
@ -15,7 +15,7 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
grub-core/kern/i386/backtrace.c | 125 ++++++++++++++++++++++++++++++++
grub-core/kern/i386/pc/init.c | 4 +-
grub-core/kern/ieee1275/init.c | 1 -
grub-core/kern/misc.c | 13 ++--
grub-core/kern/misc.c | 11 +--
grub-core/kern/mm.c | 6 +-
grub-core/lib/arm64/backtrace.c | 62 ----------------
grub-core/lib/i386/backtrace.c | 78 --------------------
@ -29,7 +29,7 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
grub-core/kern/ia64/efi/startup.S | 3 +-
grub-core/kern/sparc64/ieee1275/crt0.S | 3 +-
grub-core/Makefile.am | 1 +
24 files changed, 414 insertions(+), 166 deletions(-)
24 files changed, 413 insertions(+), 166 deletions(-)
rename grub-core/{lib => commands}/backtrace.c (98%)
create mode 100644 grub-core/kern/arm64/backtrace.c
create mode 100644 grub-core/kern/backtrace.c
@ -38,10 +38,10 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
delete mode 100644 grub-core/lib/i386/backtrace.c
diff --git a/Makefile.util.def b/Makefile.util.def
index f4fbd2506..cbd661d63 100644
index acbcc8c208c..1079add5bbe 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -49,6 +49,12 @@ library = {
@@ -51,6 +51,12 @@ library = {
common = grub-core/partmap/msdos.c;
common = grub-core/fs/proc.c;
common = grub-core/fs/archelp.c;
@ -55,13 +55,13 @@ index f4fbd2506..cbd661d63 100644
library = {
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 067b97a42..cb24f92a4 100644
index 63f053b3add..6645fbae34f 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -130,6 +130,12 @@ kernel = {
@@ -153,6 +153,12 @@ kernel = {
common = kern/rescue_reader.c;
common = kern/term.c;
common = kern/qsort.c;
common = kern/verifiers.c;
+ common = kern/backtrace.c;
+
+ x86 = kern/i386/backtrace.c;
@ -71,7 +71,7 @@ index 067b97a42..cb24f92a4 100644
noemu = kern/compiler-rt.c;
noemu = kern/mm.c;
@@ -176,9 +182,6 @@ kernel = {
@@ -199,9 +205,6 @@ kernel = {
softdiv = lib/division.c;
@ -80,17 +80,19 @@ index 067b97a42..cb24f92a4 100644
-
i386 = kern/i386/dl.c;
i386_xen = kern/i386/dl.c;
@@ -2277,13 +2280,11 @@ module = {
i386_xen_pvh = kern/i386/dl.c;
@@ -2455,15 +2458,12 @@ module = {
module = {
name = backtrace;
- x86 = lib/i386/backtrace.c;
- i386_xen_pvh = lib/i386/backtrace.c;
- i386_xen = lib/i386/backtrace.c;
- x86_64_xen = lib/i386/backtrace.c;
- common = lib/backtrace.c;
+ common = commands/backtrace.c;
enable = x86;
enable = i386_xen_pvh;
enable = i386_xen;
enable = x86_64_xen;
+ enable = arm64;
@ -101,7 +103,7 @@ diff --git a/grub-core/lib/backtrace.c b/grub-core/commands/backtrace.c
similarity index 98%
rename from grub-core/lib/backtrace.c
rename to grub-core/commands/backtrace.c
index c0ad6ab8b..8b5ec3913 100644
index c0ad6ab8be1..8b5ec3913b5 100644
--- a/grub-core/lib/backtrace.c
+++ b/grub-core/commands/backtrace.c
@@ -54,7 +54,7 @@ grub_cmd_backtrace (grub_command_t cmd __attribute__ ((unused)),
@ -114,7 +116,7 @@ index c0ad6ab8b..8b5ec3913 100644
}
diff --git a/grub-core/gdb/cstub.c b/grub-core/gdb/cstub.c
index b64acd70f..99281472d 100644
index b64acd70fee..99281472d36 100644
--- a/grub-core/gdb/cstub.c
+++ b/grub-core/gdb/cstub.c
@@ -215,7 +215,6 @@ grub_gdb_trap (int trap_no)
@ -127,7 +129,7 @@ index b64acd70f..99281472d 100644
diff --git a/grub-core/kern/arm64/backtrace.c b/grub-core/kern/arm64/backtrace.c
new file mode 100644
index 000000000..019c6fdfe
index 00000000000..019c6fdfef2
--- /dev/null
+++ b/grub-core/kern/arm64/backtrace.c
@@ -0,0 +1,94 @@
@ -227,7 +229,7 @@ index 000000000..019c6fdfe
+}
diff --git a/grub-core/kern/backtrace.c b/grub-core/kern/backtrace.c
new file mode 100644
index 000000000..4a82e865c
index 00000000000..4a82e865cc6
--- /dev/null
+++ b/grub-core/kern/backtrace.c
@@ -0,0 +1,97 @@
@ -329,10 +331,10 @@ index 000000000..4a82e865c
+ grub_backtrace (skip + 1);
+}
diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
index 621070918..5028d157c 100644
index 0bf40caa61a..931f6e41442 100644
--- a/grub-core/kern/dl.c
+++ b/grub-core/kern/dl.c
@@ -124,6 +124,50 @@ grub_dl_resolve_symbol (const char *name)
@@ -115,6 +115,50 @@ grub_dl_resolve_symbol (const char *name)
return 0;
}
@ -383,7 +385,7 @@ index 621070918..5028d157c 100644
/* Register a symbol with the name NAME and the address ADDR. */
grub_err_t
grub_dl_register_symbol (const char *name, void *addr, int isfunc,
@@ -336,6 +380,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
@@ -330,6 +374,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
const char *str;
Elf_Word size, entsize;
@ -393,7 +395,7 @@ index 621070918..5028d157c 100644
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
diff --git a/grub-core/kern/i386/backtrace.c b/grub-core/kern/i386/backtrace.c
new file mode 100644
index 000000000..2413f9a57
index 00000000000..2413f9a57db
--- /dev/null
+++ b/grub-core/kern/i386/backtrace.c
@@ -0,0 +1,125 @@
@ -523,7 +525,7 @@ index 000000000..2413f9a57
+#endif
+}
diff --git a/grub-core/kern/i386/pc/init.c b/grub-core/kern/i386/pc/init.c
index 27bc68b8a..b51d0abfa 100644
index 326d491c586..fe7ad14d45c 100644
--- a/grub-core/kern/i386/pc/init.c
+++ b/grub-core/kern/i386/pc/init.c
@@ -153,7 +153,7 @@ compact_mem_regions (void)
@ -535,7 +537,7 @@ index 27bc68b8a..b51d0abfa 100644
/* Helper for grub_machine_init. */
static int
@@ -217,7 +217,7 @@ grub_machine_init (void)
@@ -226,7 +226,7 @@ grub_machine_init (void)
/* This has to happen before any BIOS calls. */
grub_via_workaround_init ();
@ -545,27 +547,23 @@ index 27bc68b8a..b51d0abfa 100644
/* Initialize the console as early as possible. */
grub_console_init ();
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
index e01bc6eab..e731a57a4 100644
index 51c1e1c9d9f..c4d6962197b 100644
--- a/grub-core/kern/ieee1275/init.c
+++ b/grub-core/kern/ieee1275/init.c
@@ -60,7 +60,6 @@
#define HEAP_MAX_ADDR (unsigned long) (32 * 1024 * 1024)
#endif
@@ -70,7 +70,6 @@
*/
#define RUNTIME_MIN_SPACE (128UL * 1024 * 1024)
-extern char _start[];
extern char _end[];
#ifdef __sparc__
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index e758ab341..5c2d2039d 100644
index b1d399d37d7..779586658cb 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -1110,15 +1110,15 @@ grub_xasprintf (const char *fmt, ...)
}
/* Abort GRUB. This function does not return. */
-static void __attribute__ ((noreturn))
+static inline void __attribute__ ((noreturn))
@@ -1302,12 +1302,12 @@ grub_printf_fmt_check (const char *fmt, const char *fmt_expected)
void __attribute__ ((noreturn))
grub_abort (void)
{
-#ifndef GRUB_UTIL
@ -582,7 +580,7 @@ index e758ab341..5c2d2039d 100644
#ifndef GRUB_UTIL
if (grub_term_inputs)
@@ -1145,6 +1145,7 @@ grub_fatal (const char *fmt, ...)
@@ -1334,6 +1334,7 @@ grub_fatal (const char *fmt, ...)
{
va_list ap;
@ -591,10 +589,10 @@ index e758ab341..5c2d2039d 100644
grub_vprintf (_(fmt), ap);
va_end (ap);
diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c
index ee88ff611..002cbfa4f 100644
index 027a25cd1f0..1aeeba9e27e 100644
--- a/grub-core/kern/mm.c
+++ b/grub-core/kern/mm.c
@@ -95,13 +95,13 @@ get_header_from_pointer (void *ptr, grub_mm_header_t *p, grub_mm_region_t *r)
@@ -144,13 +144,13 @@ get_header_from_pointer (void *ptr, grub_mm_header_t *p, grub_mm_region_t *r)
break;
if (! *r)
@ -613,7 +611,7 @@ index ee88ff611..002cbfa4f 100644
diff --git a/grub-core/lib/arm64/backtrace.c b/grub-core/lib/arm64/backtrace.c
deleted file mode 100644
index 1079b5380..000000000
index 1079b5380e1..00000000000
--- a/grub-core/lib/arm64/backtrace.c
+++ /dev/null
@@ -1,62 +0,0 @@
@ -681,7 +679,7 @@ index 1079b5380..000000000
-
diff --git a/grub-core/lib/i386/backtrace.c b/grub-core/lib/i386/backtrace.c
deleted file mode 100644
index c67273db3..000000000
index c67273db3ae..00000000000
--- a/grub-core/lib/i386/backtrace.c
+++ /dev/null
@@ -1,78 +0,0 @@
@ -764,7 +762,7 @@ index c67273db3..000000000
-}
-
diff --git a/include/grub/backtrace.h b/include/grub/backtrace.h
index 395519762..275cf85e2 100644
index 395519762f0..275cf85e2d3 100644
--- a/include/grub/backtrace.h
+++ b/include/grub/backtrace.h
@@ -19,8 +19,14 @@
@ -785,10 +783,10 @@ index 395519762..275cf85e2 100644
#endif
diff --git a/include/grub/dl.h b/include/grub/dl.h
index b1ed3c333..7b5bfb07c 100644
index f2bf50eb98d..8a3d188d1d1 100644
--- a/include/grub/dl.h
+++ b/include/grub/dl.h
@@ -244,6 +244,8 @@ grub_dl_get (const char *name)
@@ -258,6 +258,8 @@ grub_dl_is_persistent (grub_dl_t mod)
#endif
@ -798,10 +796,10 @@ index b1ed3c333..7b5bfb07c 100644
int isfunc, grub_dl_t mod);
diff --git a/include/grub/kernel.h b/include/grub/kernel.h
index ecd88ca72..ae69218af 100644
index abbca5ea335..300a9766cda 100644
--- a/include/grub/kernel.h
+++ b/include/grub/kernel.h
@@ -108,6 +108,9 @@ grub_addr_t grub_modules_get_end (void);
@@ -111,6 +111,9 @@ grub_addr_t grub_modules_get_end (void);
#endif
@ -812,7 +810,7 @@ index ecd88ca72..ae69218af 100644
void grub_main (void) __attribute__ ((noreturn));
diff --git a/grub-core/kern/arm/efi/startup.S b/grub-core/kern/arm/efi/startup.S
index 9f8265315..f3bc41f9d 100644
index 9f8265315a9..f3bc41f9d0f 100644
--- a/grub-core/kern/arm/efi/startup.S
+++ b/grub-core/kern/arm/efi/startup.S
@@ -23,6 +23,8 @@
@ -825,7 +823,7 @@ index 9f8265315..f3bc41f9d 100644
/*
* EFI_SYSTEM_TABLE and EFI_HANDLE are passed in r1/r0.
diff --git a/grub-core/kern/arm/startup.S b/grub-core/kern/arm/startup.S
index 3946fe8e1..5679a1d00 100644
index 3946fe8e183..5679a1d00ad 100644
--- a/grub-core/kern/arm/startup.S
+++ b/grub-core/kern/arm/startup.S
@@ -48,6 +48,8 @@
@ -838,7 +836,7 @@ index 3946fe8e1..5679a1d00 100644
b codestart
diff --git a/grub-core/kern/arm64/efi/startup.S b/grub-core/kern/arm64/efi/startup.S
index 666a7ee3c..41676bdb2 100644
index 666a7ee3c92..41676bdb2b8 100644
--- a/grub-core/kern/arm64/efi/startup.S
+++ b/grub-core/kern/arm64/efi/startup.S
@@ -19,7 +19,9 @@
@ -852,7 +850,7 @@ index 666a7ee3c..41676bdb2 100644
/*
* EFI_SYSTEM_TABLE and EFI_HANDLE are passed in x1/x0.
diff --git a/grub-core/kern/i386/qemu/startup.S b/grub-core/kern/i386/qemu/startup.S
index 0d89858d9..939f182fc 100644
index 0d89858d9b3..939f182fc74 100644
--- a/grub-core/kern/i386/qemu/startup.S
+++ b/grub-core/kern/i386/qemu/startup.S
@@ -24,7 +24,8 @@
@ -866,7 +864,7 @@ index 0d89858d9..939f182fc 100644
jmp codestart
diff --git a/grub-core/kern/ia64/efi/startup.S b/grub-core/kern/ia64/efi/startup.S
index d75c6d7cc..8f2a593e5 100644
index d75c6d7cc74..8f2a593e529 100644
--- a/grub-core/kern/ia64/efi/startup.S
+++ b/grub-core/kern/ia64/efi/startup.S
@@ -24,8 +24,9 @@
@ -881,7 +879,7 @@ index d75c6d7cc..8f2a593e5 100644
alloc loc0=ar.pfs,2,4,0,0
mov loc1=rp
diff --git a/grub-core/kern/sparc64/ieee1275/crt0.S b/grub-core/kern/sparc64/ieee1275/crt0.S
index 03b916f05..701bf63ab 100644
index 03b916f0534..701bf63abcf 100644
--- a/grub-core/kern/sparc64/ieee1275/crt0.S
+++ b/grub-core/kern/sparc64/ieee1275/crt0.S
@@ -22,7 +22,8 @@
@ -895,7 +893,7 @@ index 03b916f05..701bf63ab 100644
ba codestart
mov %o4, %o0
diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
index 0108c0d42..f36200bd6 100644
index f18550c1c98..b7192a3da82 100644
--- a/grub-core/Makefile.am
+++ b/grub-core/Makefile.am
@@ -66,6 +66,7 @@ CLEANFILES += grub_script.yy.c grub_script.yy.h

View File

@ -0,0 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 10 May 2018 13:40:19 -0400
Subject: [PATCH] Fixup for newer compiler
---
grub-core/fs/btrfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index 87e4dd1a07a..ad35e75750b 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -218,7 +218,7 @@ struct grub_btrfs_inode
grub_uint64_t size;
grub_uint8_t dummy2[0x70];
struct grub_btrfs_time mtime;
-} GRUB_PACKED;
+} GRUB_PACKED __attribute__ ((aligned(8)));
struct grub_btrfs_extent_data
{

View File

@ -26,10 +26,10 @@ Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
1 file changed, 2 insertions(+)
diff --git a/include/grub/kernel.h b/include/grub/kernel.h
index ae69218af..9548d552a 100644
index 300a9766cda..55849777eaa 100644
--- a/include/grub/kernel.h
+++ b/include/grub/kernel.h
@@ -108,8 +108,10 @@ grub_addr_t grub_modules_get_end (void);
@@ -111,8 +111,10 @@ grub_addr_t grub_modules_get_end (void);
#endif

View File

@ -8,15 +8,15 @@ Subject: [PATCH] Fixup for newer compiler
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/conf/Makefile.common b/conf/Makefile.common
index 044ab3abe..c75848f5c 100644
index ece9ed8a1bf..6262f21a772 100644
--- a/conf/Makefile.common
+++ b/conf/Makefile.common
@@ -38,7 +38,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding
@@ -41,7 +41,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC)
CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1
CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
-STRIPFLAGS_KERNEL = -R .eh_frame -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx
+STRIPFLAGS_KERNEL = -R .eh_frame -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx -R .note.gnu.property -R .gnu.build.attributes
CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
if !COND_emu
if COND_HAVE_ASM_USCORE
LDFLAGS_KERNEL += -Wl,--defsym=_malloc=_grub_malloc -Wl,--defsym=_free=_grub_free

View File

@ -1,6 +1,6 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Andrzej Kacprowski <andrzej.kacprowski@intel.com>
Date: Fri, 21 Apr 2017 10:06:20 +0200
Date: Wed, 10 Jul 2019 15:22:29 +0200
Subject: [PATCH] Add support for non-Ethernet network cards
This patch replaces fixed 6-byte link layer address with
@ -20,26 +20,25 @@ then chaddr field in BOOTP it will be set to 0 as per rfc4390.
Resolves: rhbz#1370642
Signed-off-by: Andrzej Kacprowski <andrzej.kacprowski@intel.com>
Conflicts:
grub-core/net/ip.c
[msalter: Fix max string calculation in grub_net_hwaddr_to_str]
Signed-off-by: Mark Salter <msalter@redhat.com>
---
grub-core/net/arp.c | 155 ++++++++++++++++++++++-----------
grub-core/net/bootp.c | 14 ++-
grub-core/net/arp.c | 156 ++++++++++++++++++++++-----------
grub-core/net/bootp.c | 15 ++--
grub-core/net/drivers/efi/efinet.c | 8 +-
grub-core/net/drivers/emu/emunet.c | 1 +
grub-core/net/drivers/i386/pc/pxe.c | 13 +--
grub-core/net/drivers/ieee1275/ofnet.c | 2 +
grub-core/net/drivers/uboot/ubootnet.c | 1 +
grub-core/net/ethernet.c | 88 +++++++++----------
grub-core/net/ethernet.c | 89 +++++++++----------
grub-core/net/icmp6.c | 15 ++--
grub-core/net/ip.c | 4 +-
grub-core/net/net.c | 48 +++++-----
grub-core/net/net.c | 50 ++++++-----
include/grub/net.h | 19 ++--
12 files changed, 216 insertions(+), 152 deletions(-)
12 files changed, 220 insertions(+), 153 deletions(-)
diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c
index 54306e3b1..67b409a8a 100644
index 1d367436cfc..8bf0a06e193 100644
--- a/grub-core/net/arp.c
+++ b/grub-core/net/arp.c
@@ -31,22 +31,12 @@ enum
@ -138,7 +137,7 @@ index 54306e3b1..67b409a8a 100644
nbd = nb.data;
send_ethernet_packet (inf, &nb, target_mac_addr, GRUB_NET_ETHERTYPE_ARP);
@@ -114,28 +124,53 @@ grub_err_t
@@ -114,30 +124,56 @@ grub_err_t
grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card,
grub_uint16_t *vlantag)
{
@ -178,33 +177,36 @@ index 54306e3b1..67b409a8a 100644
+
+ /* The source protocol address. */
sender_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ grub_memcpy(&sender_addr.ipv4, tmp_ptr, pln);
+ tmp_ptr += pln;
+
+ grub_net_link_layer_add_address (card, &sender_addr, &sender_mac_addr, 1);
+
+ /* The target hardware address. */
+ tmp_ptr += hln;
+
+ /* The target protocol address. */
target_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
- target_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
- sender_addr.ipv4 = arp_packet->sender_ip;
- target_addr.ipv4 = arp_packet->recv_ip;
sender_addr.option = 0;
target_addr.option = 0;
- if (arp_packet->sender_ip == pending_req)
+ grub_memcpy(&target_addr.ipv4, tmp_ptr, pln);
+
+ if (sender_addr.ipv4 == pending_req)
have_pending = 1;
- have_pending = 1;
- sender_mac_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
- grub_memcpy (sender_mac_addr.mac, arp_packet->sender_mac,
- sizeof (sender_mac_addr.mac));
- grub_net_link_layer_add_address (card, &sender_addr, &sender_mac_addr, 1);
-
+ grub_memcpy(&target_addr.ipv4, tmp_ptr, pln);
+ tmp_ptr += pln;
+
grub_net_link_layer_add_address (card, &sender_addr, &sender_mac_addr, 1);
+ /* The target hardware address. */
+ tmp_ptr += hln;
+
+ /* The target protocol address. */
+ target_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ grub_memcpy(&target_addr.ipv4, tmp_ptr, pln);
+
+ if (sender_addr.ipv4 == pending_req)
+ have_pending = 1;
+
FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
{
/* Verify vlantag id */
@@ -148,11 +183,11 @@ grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card,
@@ -150,11 +186,11 @@ grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card,
/* Am I the protocol address target? */
if (grub_net_addr_cmp (&inf->address, &target_addr) == 0
@ -218,7 +220,7 @@ index 54306e3b1..67b409a8a 100644
grub_uint8_t arp_data[128];
grub_err_t err;
@@ -161,25 +196,39 @@ grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card,
@@ -163,25 +199,39 @@ grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card,
grub_netbuff_clear (&nb_reply);
grub_netbuff_reserve (&nb_reply, 128);
@ -272,10 +274,10 @@ index 54306e3b1..67b409a8a 100644
/* Change operation to REPLY and send packet */
send_ethernet_packet (inf, &nb_reply, target, GRUB_NET_ETHERTYPE_ARP);
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
index 2869482fe..4e55adc55 100644
index e0aec25233d..76e4c11a46f 100644
--- a/grub-core/net/bootp.c
+++ b/grub-core/net/bootp.c
@@ -219,7 +219,6 @@ grub_net_configure_by_dhcp_ack (const char *name,
@@ -325,7 +325,6 @@ grub_net_configure_by_dhcp_ack (const char *name,
int is_def, char **device, char **path)
{
grub_net_network_level_address_t addr;
@ -283,7 +285,7 @@ index 2869482fe..4e55adc55 100644
struct grub_net_network_level_interface *inter;
int mask = -1;
char server_ip[sizeof ("xxx.xxx.xxx.xxx")];
@@ -232,12 +231,8 @@ grub_net_configure_by_dhcp_ack (const char *name,
@@ -343,12 +342,8 @@ grub_net_configure_by_dhcp_ack (const char *name,
if (path)
*path = 0;
@ -298,30 +300,31 @@ index 2869482fe..4e55adc55 100644
if (!inter)
return 0;
@@ -770,7 +765,8 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
grub_memset (pack, 0, sizeof (*pack) + 64);
pack->opcode = 1;
pack->hw_type = 1;
- pack->hw_len = 6;
+ pack->hw_len = ifaces[j].hwaddress.len > 16 ? 0
+ : ifaces[j].hwaddress.len;
err = grub_get_datetime (&date);
if (err || !grub_datetime2unixtime (&date, &t))
{
@@ -781,7 +777,7 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
ifaces[j].dhcp_xid = pack->xid;
pack->seconds = grub_cpu_to_be16 (t);
@@ -660,7 +655,9 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface)
grub_memset (pack, 0, sizeof (*pack));
pack->opcode = 1;
pack->hw_type = 1;
- pack->hw_len = 6;
+ pack->hw_len = iface->hwaddress.len > 16 ? 0
+ : iface->hwaddress.len;
+
err = grub_get_datetime (&date);
if (err || !grub_datetime2unixtime (&date, &t))
{
@@ -673,7 +670,7 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface)
else
pack->ident = iface->xid;
- grub_memcpy (&pack->mac_addr, &ifaces[j].hwaddress.mac, 6);
+ grub_memcpy (&pack->mac_addr, &ifaces[j].hwaddress.mac, pack->hw_len);
grub_netbuff_push (nb, sizeof (*udph));
- grub_memcpy (&pack->mac_addr, &iface->hwaddress.mac, 6);
+ grub_memcpy (&pack->mac_addr, &iface->hwaddress.mac, pack->hw_len);
err = grub_netbuff_push (nb, sizeof (*udph));
if (err)
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
index a4daaa460..cd6dba79f 100644
index 3e2432fb61c..7deb0a32efd 100644
--- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -280,6 +280,9 @@ grub_efinet_findcards (void)
@@ -288,6 +288,9 @@ grub_efinet_findcards (void)
/* This should not happen... Why? */
continue;
@ -329,12 +332,12 @@ index a4daaa460..cd6dba79f 100644
+ continue;
+
if (net->mode->state == GRUB_EFI_NETWORK_STOPPED
&& efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS)
&& net->start (net) != GRUB_EFI_SUCCESS)
continue;
@@ -316,10 +319,11 @@ grub_efinet_findcards (void)
card->name = grub_xasprintf ("efinet%d", i++);
card->driver = &efidriver;
card->flags = 0;
@@ -332,10 +335,11 @@ grub_efinet_findcards (void)
* such as LoadFile2 for initrd loading.
*/
card->flags = GRUB_NET_CARD_NO_CLOSE_ON_FINI_HW;
- card->default_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+ card->default_address.type = net->mode->if_type;
+ card->default_address.len = net->mode->hwaddr_size;
@ -346,7 +349,7 @@ index a4daaa460..cd6dba79f 100644
card->efi_handle = *handle;
diff --git a/grub-core/net/drivers/emu/emunet.c b/grub-core/net/drivers/emu/emunet.c
index b19492086..5b6c5e16a 100644
index 5f311d40f49..7461d13bbc2 100644
--- a/grub-core/net/drivers/emu/emunet.c
+++ b/grub-core/net/drivers/emu/emunet.c
@@ -46,6 +46,7 @@ static struct grub_net_card emucard =
@ -358,7 +361,7 @@ index b19492086..5b6c5e16a 100644
},
.flags = 0
diff --git a/grub-core/net/drivers/i386/pc/pxe.c b/grub-core/net/drivers/i386/pc/pxe.c
index 3f4152d03..9f8fb4b6d 100644
index db17186ee7d..816d1d0eeda 100644
--- a/grub-core/net/drivers/i386/pc/pxe.c
+++ b/grub-core/net/drivers/i386/pc/pxe.c
@@ -386,20 +386,21 @@ GRUB_MOD_INIT(pxe)
@ -390,7 +393,7 @@ index 3f4152d03..9f8fb4b6d 100644
grub_pxe_card.default_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c
index 3df75357a..ba50415f5 100644
index 78f03df8e21..c56461ff1ae 100644
--- a/grub-core/net/drivers/ieee1275/ofnet.c
+++ b/grub-core/net/drivers/ieee1275/ofnet.c
@@ -160,6 +160,7 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath,
@ -401,7 +404,7 @@ index 3df75357a..ba50415f5 100644
args = bootpath + grub_strlen (devpath) + 1;
do
@@ -503,6 +504,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
@@ -491,6 +492,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
grub_memcpy (&lla.mac, pprop, 6);
lla.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
@ -410,7 +413,7 @@ index 3df75357a..ba50415f5 100644
card->txbufsize = ALIGN_UP (card->mtu, 64) + 256;
diff --git a/grub-core/net/drivers/uboot/ubootnet.c b/grub-core/net/drivers/uboot/ubootnet.c
index 056052e40..22ebcbf21 100644
index b9d5a0cd494..9f3354a1b74 100644
--- a/grub-core/net/drivers/uboot/ubootnet.c
+++ b/grub-core/net/drivers/uboot/ubootnet.c
@@ -131,6 +131,7 @@ GRUB_MOD_INIT (ubootnet)
@ -422,7 +425,7 @@ index 056052e40..22ebcbf21 100644
card->txbufsize = ALIGN_UP (card->mtu, 64) + 256;
card->txbuf = grub_zalloc (card->txbufsize);
diff --git a/grub-core/net/ethernet.c b/grub-core/net/ethernet.c
index 4d7ceed6f..9aae83a5e 100644
index 707bbb12cb2..1441a1bacff 100644
--- a/grub-core/net/ethernet.c
+++ b/grub-core/net/ethernet.c
@@ -29,13 +29,6 @@
@ -447,7 +450,7 @@ index 4d7ceed6f..9aae83a5e 100644
+ grub_uint8_t *eth;
grub_err_t err;
- grub_uint8_t etherhdr_size;
- grub_uint16_t vlantag_id = VLANTAG_IDENTIFIER;
- grub_uint16_t vlantag_id = grub_cpu_to_be16_compile_time (VLANTAG_IDENTIFIER);
+ grub_uint32_t vlantag = 0;
+ grub_uint8_t hw_addr_len = inf->card->default_address.len;
+ grub_uint8_t etherhdr_size = 2 * hw_addr_len + 2;
@ -487,7 +490,7 @@ index 4d7ceed6f..9aae83a5e 100644
if (!inf->card->opened)
{
err = GRUB_ERR_NONE;
@@ -85,18 +91,6 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf,
@@ -85,19 +91,6 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf,
inf->card->opened = 1;
}
@ -499,14 +502,15 @@ index 4d7ceed6f..9aae83a5e 100644
- (char *) nb->data + etherhdr_size - 6, 2);
-
- /* Add the tag in the middle */
- grub_uint16_t vlan = grub_cpu_to_be16 (inf->vlantag);
- grub_memcpy ((char *) nb->data + etherhdr_size - 6, &vlantag_id, 2);
- grub_memcpy ((char *) nb->data + etherhdr_size - 4, (char *) &(inf->vlantag), 2);
- grub_memcpy ((char *) nb->data + etherhdr_size - 4, &vlan, 2);
- }
-
return inf->card->driver->send (inf->card, nb);
}
@@ -104,31 +98,40 @@ grub_err_t
@@ -105,31 +98,40 @@ grub_err_t
grub_net_recv_ethernet_packet (struct grub_net_buff *nb,
struct grub_net_card *card)
{
@ -528,7 +532,7 @@ index 4d7ceed6f..9aae83a5e 100644
- /* Check if a vlan-tag is present. If so, the ethernet header is 4 bytes */
- /* longer than the original one. The vlantag id is extracted and the header */
- /* is reseted to the original size. */
- if (grub_get_unaligned16 (nb->data + etherhdr_size - 2) == VLANTAG_IDENTIFIER)
- if (grub_get_unaligned16 (nb->data + etherhdr_size - 2) == grub_cpu_to_be16_compile_time (VLANTAG_IDENTIFIER))
+ hwaddress.type = card->default_address.type;
+ hwaddress.len = hw_addr_len;
+ grub_memcpy (hwaddress.mac, eth, hw_addr_len);
@ -542,7 +546,7 @@ index 4d7ceed6f..9aae83a5e 100644
+ type = grub_be_to_cpu16 (*(grub_uint16_t*)(eth));
+ if (type == VLANTAG_IDENTIFIER)
{
- vlantag = grub_get_unaligned16 (nb->data + etherhdr_size);
- vlantag = grub_be_to_cpu16 (grub_get_unaligned16 (nb->data + etherhdr_size));
+ /* Skip vlan tag */
+ eth += 2;
+ vlantag = grub_be_to_cpu16 (*(grub_uint16_t*)(eth));
@ -559,7 +563,7 @@ index 4d7ceed6f..9aae83a5e 100644
err = grub_netbuff_pull (nb, etherhdr_size);
if (err)
return err;
@@ -148,11 +151,6 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb,
@@ -149,11 +151,6 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb,
}
}
@ -572,7 +576,7 @@ index 4d7ceed6f..9aae83a5e 100644
{
/* ARP packet. */
diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c
index 2cbd95dce..56a3ec5c8 100644
index 9a8c4511285..5924fd53aca 100644
--- a/grub-core/net/icmp6.c
+++ b/grub-core/net/icmp6.c
@@ -231,8 +231,9 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb,
@ -612,25 +616,25 @@ index 2cbd95dce..56a3ec5c8 100644
}
if (ohdr->type == OPTION_PREFIX && ohdr->len == 4)
diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c
index 8411e0ecc..b2ca74b6e 100644
index f967618e53f..3c475762cc0 100644
--- a/grub-core/net/ip.c
+++ b/grub-core/net/ip.c
@@ -277,8 +277,8 @@ handle_dgram (struct grub_net_buff *nb,
@@ -316,8 +316,8 @@ handle_dgram (struct grub_net_buff *nb,
if (inf->card == card
&& inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV
&& inf->dhcp_xid == bootp->xid
&& inf->hwaddress.type == GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET
- && grub_memcmp (inf->hwaddress.mac, &bootp->mac_addr,
- sizeof (inf->hwaddress.mac)) == 0)
+ && (grub_memcmp (inf->hwaddress.mac, &bootp->mac_addr,
+ bootp->hw_len) == 0 || bootp->hw_len == 0))
{
grub_net_process_dhcp (nb, inf->card);
grub_net_process_dhcp (nb, inf);
grub_netbuff_free (nb);
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
index fa3e29126..9b8944292 100644
index 20c55257647..fa6b6537142 100644
--- a/grub-core/net/net.c
+++ b/grub-core/net/net.c
@@ -128,8 +128,9 @@ grub_net_link_layer_resolve (struct grub_net_network_level_interface *inf,
@@ -133,8 +133,9 @@ grub_net_link_layer_resolve (struct grub_net_network_level_interface *inf,
<< 48)
&& proto_addr->ipv6[1] == (grub_be_to_cpu64_compile_time (1))))
{
@ -642,7 +646,7 @@ index fa3e29126..9b8944292 100644
return GRUB_ERR_NONE;
}
@@ -137,6 +138,7 @@ grub_net_link_layer_resolve (struct grub_net_network_level_interface *inf,
@@ -142,6 +143,7 @@ grub_net_link_layer_resolve (struct grub_net_network_level_interface *inf,
&& ((grub_be_to_cpu64 (proto_addr->ipv6[0]) >> 56) == 0xff))
{
hw_addr->type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
@ -650,7 +654,7 @@ index fa3e29126..9b8944292 100644
hw_addr->mac[0] = 0x33;
hw_addr->mac[1] = 0x33;
hw_addr->mac[2] = ((grub_be_to_cpu64 (proto_addr->ipv6[1]) >> 24) & 0xff);
@@ -757,23 +759,21 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target, char *buf)
@@ -772,23 +774,23 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target, char *buf)
void
grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str)
{
@ -658,6 +662,7 @@ index fa3e29126..9b8944292 100644
- switch (addr->type)
+ char *ptr;
+ unsigned i;
+ int maxstr;
+
+ if (addr->len > GRUB_NET_MAX_LINK_ADDRESS_SIZE)
{
@ -678,16 +683,17 @@ index fa3e29126..9b8944292 100644
+ addr->type, addr->len);
+ return;
+ }
+ maxstr = addr->len * grub_strlen ("XX:");
+ for (ptr = str, i = 0; i < addr->len; i++)
+ {
+ ptr += grub_snprintf (ptr, GRUB_NET_MAX_STR_HWADDR_LEN - (ptr - str),
+ ptr += grub_snprintf (ptr, maxstr - (ptr - str),
+ "%02x:", addr->mac[i] & 0xff);
}
- grub_printf (_("Unsupported hw address type %d\n"), addr->type);
}
int
@@ -784,13 +784,17 @@ grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a,
void
@@ -813,13 +815,17 @@ grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a,
return -1;
if (a->type > b->type)
return +1;
@ -711,7 +717,7 @@ index fa3e29126..9b8944292 100644
int
diff --git a/include/grub/net.h b/include/grub/net.h
index de51894cb..e9ebc6a1b 100644
index ff901b96e22..1d76fd9a1f5 100644
--- a/include/grub/net.h
+++ b/include/grub/net.h
@@ -29,7 +29,8 @@
@ -726,7 +732,7 @@ index de51894cb..e9ebc6a1b 100644
GRUB_NET_OUR_IPV4_HEADER_SIZE = 20,
@@ -42,15 +43,17 @@ enum
typedef enum grub_link_level_protocol_id
typedef enum grub_link_level_protocol_id
{
- GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET
+ /* IANA ARP constant to define hardware type. */
@ -744,7 +750,7 @@ index de51894cb..e9ebc6a1b 100644
};
} grub_net_link_level_address_t;
@@ -555,11 +558,13 @@ grub_net_addr_cmp (const grub_net_network_level_address_t *a,
@@ -588,11 +591,13 @@ grub_net_addr_cmp (const grub_net_network_level_address_t *a,
#define GRUB_NET_MAX_STR_ADDR_LEN sizeof ("XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX")
/*
@ -760,5 +766,5 @@ index de51894cb..e9ebc6a1b 100644
+ "XX:XX:XX:XX:XX:XX:XX:XX:"\
+ "XX:XX:XX:XX:XX:XX:XX:XX"))
void
grub_net_addr_to_str (const grub_net_network_level_address_t *target,
/* Max VLAN id = 4094 */
#define GRUB_NET_MAX_STR_VLAN_LEN (sizeof ("vlanXXXX"))

View File

@ -15,12 +15,12 @@ Signed-off-by: Ken Lin <ken.lin@hpe.com>
2 files changed, 46 insertions(+), 27 deletions(-)
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
index 6fd0a4f49..712b4f859 100644
index 7deb0a32efd..92bb7444782 100644
--- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -409,6 +409,8 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
@@ -430,6 +430,8 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
grub_print_error ();
if (device && path)
if (inter && device && path)
grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path);
+ if (grub_errno)
+ grub_print_error ();
@ -28,10 +28,10 @@ index 6fd0a4f49..712b4f859 100644
else
{
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
index 1250d493e..2f164d420 100644
index daa9268fdaa..53f5c781ac3 100644
--- a/include/grub/efi/api.h
+++ b/include/grub/efi/api.h
@@ -1499,31 +1499,6 @@ typedef union
@@ -1571,31 +1571,6 @@ typedef union
grub_efi_pxe_dhcpv6_packet_t dhcpv6;
} grub_efi_pxe_packet_t;
@ -63,7 +63,7 @@ index 1250d493e..2f164d420 100644
typedef struct grub_efi_pxe_icmp_error
{
grub_efi_uint8_t type;
@@ -1549,6 +1524,48 @@ typedef struct grub_efi_pxe_tftp_error
@@ -1621,6 +1596,48 @@ typedef struct grub_efi_pxe_tftp_error
grub_efi_char8_t error_string[127];
} grub_efi_pxe_tftp_error_t;
@ -112,7 +112,7 @@ index 1250d493e..2f164d420 100644
typedef struct grub_efi_pxe_mode
{
grub_efi_boolean_t started;
@@ -1580,9 +1597,9 @@ typedef struct grub_efi_pxe_mode
@@ -1652,9 +1669,9 @@ typedef struct grub_efi_pxe_mode
grub_efi_pxe_packet_t pxe_bis_reply;
grub_efi_pxe_ip_filter_t ip_filter;
grub_efi_uint32_t arp_cache_entries;

View File

@ -12,18 +12,18 @@ Signed-off-by: Ken Lin <ken.lin@hpe.com>
1 file changed, 17 insertions(+)
diff --git a/docs/grub.texi b/docs/grub.texi
index 2b7b7faf8..c54bee316 100644
index c30701b4e1f..44c4e665a0d 100644
--- a/docs/grub.texi
+++ b/docs/grub.texi
@@ -5303,6 +5303,7 @@ This command is only available on AArch64 systems.
@@ -5955,6 +5955,7 @@ Note: The command is not allowed when lockdown is enforced (@pxref{Lockdown}).
* net_add_dns:: Add a DNS server
* net_add_route:: Add routing entry
* net_bootp:: Perform a bootp autoconfiguration
* net_bootp:: Perform a bootp/DHCP autoconfiguration
+* net_bootp6:: Perform a DHCPv6 autoconfiguration
* net_del_addr:: Remove IP address from interface
* net_del_dns:: Remove a DNS server
* net_del_route:: Remove a route entry
@@ -5384,6 +5385,22 @@ Sets environment variable @samp{net_}@var{<card>}@samp{_dhcp_extensionspath}
@@ -6080,6 +6081,22 @@ Sets environment variable @samp{net_}@var{<card>}@samp{_boot_file}
@end deffn
@ -44,5 +44,5 @@ index 2b7b7faf8..c54bee316 100644
+
+@end deffn
@node net_del_addr
@subsection net_del_addr
@node net_get_dhcp_option
@subsection net_get_dhcp_option

View File

@ -0,0 +1,108 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Michael Chang <mchang@suse.com>
Date: Wed, 10 Jul 2019 23:58:28 +0200
Subject: [PATCH] bootp: Add processing DHCPACK packet from HTTP Boot
The vendor class identifier with the string "HTTPClient" is used to denote the
packet as responding to HTTP boot request. In DHCP4 config, the filename for
HTTP boot is the URL of the boot file while for PXE boot it is the path to the
boot file. As a consequence, the next-server becomes obseleted because the HTTP
URL already contains the server address for the boot file. For DHCP6 config,
there's no difference definition in existing config as dhcp6.bootfile-url can
be used to specify URL for both HTTP and PXE boot file.
This patch adds processing for "HTTPClient" vendor class identifier in DHCPACK
packet by treating it as HTTP format, not as the PXE format.
Signed-off-by: Michael Chang <mchang@suse.com>
Signed-off-by: Ken Lin <ken.lin@hpe.com>
---
grub-core/net/bootp.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++
include/grub/net.h | 1 +
2 files changed, 56 insertions(+)
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
index 76e4c11a46f..f56b293ac72 100644
--- a/grub-core/net/bootp.c
+++ b/grub-core/net/bootp.c
@@ -20,6 +20,7 @@
#include <grub/env.h>
#include <grub/i18n.h>
#include <grub/command.h>
+#include <grub/net.h>
#include <grub/net/ip.h>
#include <grub/net/netbuff.h>
#include <grub/net/udp.h>
@@ -501,6 +502,60 @@ grub_net_configure_by_dhcp_ack (const char *name,
if (opt && opt_len)
grub_env_set_net_property (name, "rootpath", (const char *) opt, opt_len);
+ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_VENDOR_CLASS_IDENTIFIER, &opt_len);
+ if (opt && opt_len)
+ {
+ grub_env_set_net_property (name, "vendor_class_identifier", (const char *) opt, opt_len);
+ if (opt && grub_strcmp (opt, "HTTPClient") == 0)
+ {
+ char *proto, *ip, *pa;
+
+ if (!dissect_url (bp->boot_file, &proto, &ip, &pa))
+ return inter;
+
+ grub_env_set_net_property (name, "boot_file", pa, grub_strlen (pa));
+ if (is_def)
+ {
+ grub_net_default_server = grub_strdup (ip);
+ grub_env_set ("net_default_interface", name);
+ grub_env_export ("net_default_interface");
+ }
+ if (device && !*device)
+ {
+ *device = grub_xasprintf ("%s,%s", proto, ip);
+ grub_print_error ();
+ }
+ if (path)
+ {
+ *path = grub_strdup (pa);
+ grub_print_error ();
+ if (*path)
+ {
+ char *slash;
+ slash = grub_strrchr (*path, '/');
+ if (slash)
+ *slash = 0;
+ else
+ **path = 0;
+ }
+ }
+ grub_net_add_ipv4_local (inter, mask);
+ inter->dhcp_ack = grub_malloc (size);
+ if (inter->dhcp_ack)
+ {
+ grub_memcpy (inter->dhcp_ack, bp, size);
+ inter->dhcp_acklen = size;
+ }
+ else
+ grub_errno = GRUB_ERR_NONE;
+
+ grub_free (proto);
+ grub_free (ip);
+ grub_free (pa);
+ return inter;
+ }
+ }
+
opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_EXTENSIONS_PATH, &opt_len);
if (opt && opt_len)
grub_env_set_net_property (name, "extensionspath", (const char *) opt, opt_len);
diff --git a/include/grub/net.h b/include/grub/net.h
index 1d76fd9a1f5..868c9a2ef29 100644
--- a/include/grub/net.h
+++ b/include/grub/net.h
@@ -533,6 +533,7 @@ enum
GRUB_NET_DHCP_MESSAGE_TYPE = 53,
GRUB_NET_DHCP_SERVER_IDENTIFIER = 54,
GRUB_NET_DHCP_PARAMETER_REQUEST_LIST = 55,
+ GRUB_NET_BOOTP_VENDOR_CLASS_IDENTIFIER = 60,
GRUB_NET_BOOTP_CLIENT_ID = 61,
GRUB_NET_DHCP_TFTP_SERVER_NAME = 66,
GRUB_NET_DHCP_BOOTFILE_NAME = 67,

View File

@ -0,0 +1,37 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 20 Jul 2020 12:24:02 -0400
Subject: [PATCH] Fix const char ** pointers in grub-core/net/bootp.c
This will need to get folded back in the right place on the next rebase,
but it's before "Make grub_strtol() "end" pointers have safer const
qualifiers" currently, so for now I'm leaving it here instead of merging
it back with the original patch.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/net/bootp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
index f56b293ac72..9cbdc2264c9 100644
--- a/grub-core/net/bootp.c
+++ b/grub-core/net/bootp.c
@@ -329,7 +329,7 @@ grub_net_configure_by_dhcp_ack (const char *name,
struct grub_net_network_level_interface *inter;
int mask = -1;
char server_ip[sizeof ("xxx.xxx.xxx.xxx")];
- const grub_uint8_t *opt;
+ const char *opt;
grub_uint8_t opt_len, overload = 0;
const char *boot_file = 0, *server_name = 0;
grub_size_t boot_file_len, server_name_len;
@@ -506,7 +506,7 @@ grub_net_configure_by_dhcp_ack (const char *name,
if (opt && opt_len)
{
grub_env_set_net_property (name, "vendor_class_identifier", (const char *) opt, opt_len);
- if (opt && grub_strcmp (opt, "HTTPClient") == 0)
+ if (opt && grub_strcmp ((char *)opt, "HTTPClient") == 0)
{
char *proto, *ip, *pa;

View File

@ -27,15 +27,15 @@ the same way it used to be.
Signed-off-by: Michael Chang <mchang@suse.com>
Signed-off-by: Ken Lin <ken.lin@hpe.com>
---
grub-core/net/drivers/efi/efinet.c | 284 +++++++++++++++++++++++++++++++++++--
grub-core/net/drivers/efi/efinet.c | 286 ++++++++++++++++++++++++++++++++++---
include/grub/efi/api.h | 11 ++
2 files changed, 280 insertions(+), 15 deletions(-)
2 files changed, 281 insertions(+), 16 deletions(-)
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
index 712b4f859..3e51e1064 100644
index 92bb7444782..eb68de22023 100644
--- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -27,6 +27,7 @@
@@ -26,6 +26,7 @@
#include <grub/i18n.h>
#include <grub/lib/hexdump.h>
#include <grub/types.h>
@ -43,7 +43,7 @@ index 712b4f859..3e51e1064 100644
GRUB_MOD_LICENSE ("GPLv3+");
@@ -332,6 +333,227 @@ grub_efinet_findcards (void)
@@ -348,6 +349,227 @@ grub_efinet_findcards (void)
grub_free (handles);
}
@ -271,7 +271,7 @@ index 712b4f859..3e51e1064 100644
static void
grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
char **path)
@@ -347,7 +569,11 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
@@ -367,7 +589,11 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
{
grub_efi_device_path_t *cdp;
struct grub_efi_pxe *pxe;
@ -284,7 +284,7 @@ index 712b4f859..3e51e1064 100644
if (card->driver != &efidriver)
continue;
@@ -370,11 +596,21 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
@@ -391,11 +617,21 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
*/
if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE
|| (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE
@ -307,7 +307,7 @@ index 712b4f859..3e51e1064 100644
dup_ldp = grub_efi_find_last_device_path (dup_dp);
dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
@@ -387,23 +623,37 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
@@ -408,23 +644,37 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
pxe = grub_efi_open_protocol (hnd, &pxe_io_guid,
GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
@ -347,38 +347,45 @@ index 712b4f859..3e51e1064 100644
+ pxe_mode->dhcp_ack_received ? "yes" : "no",
+ pxe_mode->dhcp_ack_received ? "" : " cannot continue");
grub_net_configure_by_dhcpv6_reply (card->name, card, 0,
(struct grub_net_dhcp6_packet *)
- &pxe_mode->dhcp_ack,
- sizeof (pxe_mode->dhcp_ack),
+ packet_buf,
+ packet_bufsz,
1, device, path);
inter = grub_net_configure_by_dhcpv6_reply (card->name, card, 0,
(struct grub_net_dhcp6_packet *)
- &pxe_mode->dhcp_ack,
- sizeof (pxe_mode->dhcp_ack),
+ packet_buf,
+ packet_bufsz,
1, device, path);
if (grub_errno)
grub_print_error ();
@@ -417,11 +667,15 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
@@ -438,8 +688,8 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
grub_dprintf ("efinet", "using ipv4 and dhcp\n");
grub_net_configure_by_dhcp_ack (card->name, card, 0,
(struct grub_net_bootp_packet *)
- &pxe_mode->dhcp_ack,
- sizeof (pxe_mode->dhcp_ack),
+ packet_buf,
+ packet_bufsz,
1, device, path);
inter = grub_net_configure_by_dhcp_ack (card->name, card, 0,
(struct grub_net_bootp_packet *)
- &pxe_mode->dhcp_ack,
- sizeof (pxe_mode->dhcp_ack),
+ packet_buf,
+ packet_bufsz,
1, device, path);
grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path);
@@ -465,8 +715,12 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
vlan_dp = (grub_efi_device_path_t *) ((grub_efi_uint8_t *) vlan_dp + vlan_dp_len);
}
}
- return;
}
+
+ if (nb)
+ grub_netbuff_free (nb);
+
return;
+ return;
}
}
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
index 2f164d420..eb6bb5085 100644
index 53f5c781ac3..fa528e73a27 100644
--- a/include/grub/efi/api.h
+++ b/include/grub/efi/api.h
@@ -839,6 +839,8 @@ struct grub_efi_ipv4_device_path
@@ -891,6 +891,8 @@ struct grub_efi_ipv4_device_path
grub_efi_uint16_t remote_port;
grub_efi_uint16_t protocol;
grub_efi_uint8_t static_ip_address;
@ -387,9 +394,9 @@ index 2f164d420..eb6bb5085 100644
} GRUB_PACKED;
typedef struct grub_efi_ipv4_device_path grub_efi_ipv4_device_path_t;
@@ -893,6 +895,15 @@ struct grub_efi_sata_device_path
@@ -954,6 +956,15 @@ struct grub_efi_vlan_device_path
} GRUB_PACKED;
typedef struct grub_efi_sata_device_path grub_efi_sata_device_path_t;
typedef struct grub_efi_vlan_device_path grub_efi_vlan_device_path_t;
+#define GRUB_EFI_URI_DEVICE_PATH_SUBTYPE 24
+

View File

@ -33,30 +33,30 @@ Signed-off-by: Ken Lin <ken.lin@hpe.com>
2 files changed, 239 insertions(+)
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
index 3e51e1064..3d7750747 100644
index eb68de22023..a91df09ee6d 100644
--- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -34,6 +34,8 @@ GRUB_MOD_LICENSE ("GPLv3+");
@@ -33,6 +33,8 @@ GRUB_MOD_LICENSE ("GPLv3+");
/* GUID. */
static grub_efi_guid_t net_io_guid = GRUB_EFI_SIMPLE_NETWORK_GUID;
static grub_efi_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID;
+static grub_efi_guid_t ip4_config_guid = GRUB_EFI_IP4_CONFIG2_PROTOCOL_GUID;
+static grub_efi_guid_t ip6_config_guid = GRUB_EFI_IP6_CONFIG_PROTOCOL_GUID;
static grub_guid_t net_io_guid = GRUB_EFI_SIMPLE_NETWORK_GUID;
static grub_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID;
+static grub_guid_t ip4_config_guid = GRUB_EFI_IP4_CONFIG2_PROTOCOL_GUID;
+static grub_guid_t ip6_config_guid = GRUB_EFI_IP6_CONFIG_PROTOCOL_GUID;
static grub_err_t
send_card_buffer (struct grub_net_card *dev,
@@ -333,6 +335,125 @@ grub_efinet_findcards (void)
@@ -349,6 +351,125 @@ grub_efinet_findcards (void)
grub_free (handles);
}
+static grub_efi_handle_t
+grub_efi_locate_device_path (grub_efi_guid_t *protocol, grub_efi_device_path_t *device_path,
+grub_efi_locate_device_path (grub_guid_t *protocol, grub_efi_device_path_t *device_path,
+ grub_efi_device_path_t **r_device_path)
+{
+ grub_efi_handle_t handle;
+ grub_efi_status_t status;
+
+ status = efi_call_3 (grub_efi_system_table->boot_services->locate_device_path,
+ status = grub_efi_system_table->boot_services->locate_device_path(
+ protocol, &device_path, &handle);
+
+ if (status != GRUB_EFI_SUCCESS)
@ -92,9 +92,9 @@ index 3e51e1064..3d7750747 100644
+ if (!addrs)
+ return 0;
+
+ status = efi_call_4 (conf->get_data, conf,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER,
+ &data_size, addrs);
+ status = conf->get_data(conf,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER,
+ &data_size, addrs);
+
+ if (status == GRUB_EFI_BUFFER_TOO_SMALL)
+ {
@ -103,9 +103,9 @@ index 3e51e1064..3d7750747 100644
+ if (!addrs)
+ return 0;
+
+ status = efi_call_4 (conf->get_data, conf,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER,
+ &data_size, addrs);
+ status = conf->get_data(conf,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER,
+ &data_size, addrs);
+ }
+
+ if (status != GRUB_EFI_SUCCESS)
@ -142,9 +142,9 @@ index 3e51e1064..3d7750747 100644
+ if (!addrs)
+ return 0;
+
+ status = efi_call_4 (conf->get_data, conf,
+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_DNSSERVER,
+ &data_size, addrs);
+ status = conf->get_data(conf,
+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_DNSSERVER,
+ &data_size, addrs);
+
+ if (status == GRUB_EFI_BUFFER_TOO_SMALL)
+ {
@ -153,9 +153,9 @@ index 3e51e1064..3d7750747 100644
+ if (!addrs)
+ return 0;
+
+ status = efi_call_4 (conf->get_data, conf,
+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_DNSSERVER,
+ &data_size, addrs);
+ status = conf->get_data(conf,
+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_DNSSERVER,
+ &data_size, addrs);
+ }
+
+ if (status != GRUB_EFI_SUCCESS)
@ -171,7 +171,7 @@ index 3e51e1064..3d7750747 100644
static struct grub_net_buff *
grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *use_ipv6)
{
@@ -391,6 +512,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u
@@ -407,6 +528,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u
grub_efi_ipv4_device_path_t *ipv4 = (grub_efi_ipv4_device_path_t *) ldp;
struct grub_net_bootp_packet *bp;
grub_uint8_t *ptr;
@ -180,7 +180,7 @@ index 3e51e1064..3d7750747 100644
bp = (struct grub_net_bootp_packet *) nb->tail;
err = grub_netbuff_put (nb, sizeof (*bp) + 4);
@@ -452,6 +575,25 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u
@@ -468,6 +591,25 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u
*ptr++ = sizeof ("HTTPClient") - 1;
grub_memcpy (ptr, "HTTPClient", sizeof ("HTTPClient") - 1);
@ -206,7 +206,7 @@ index 3e51e1064..3d7750747 100644
ptr = nb->tail;
err = grub_netbuff_put (nb, 1);
if (err)
@@ -484,6 +626,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u
@@ -500,6 +642,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u
struct grub_net_dhcp6_option *opt;
struct grub_net_dhcp6_option_iana *iana;
struct grub_net_dhcp6_option_iaaddr *iaaddr;
@ -215,7 +215,7 @@ index 3e51e1064..3d7750747 100644
d6p = (struct grub_net_dhcp6_packet *)nb->tail;
err = grub_netbuff_put (nb, sizeof(*d6p));
@@ -547,6 +691,25 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u
@@ -563,6 +707,25 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u
opt->len = grub_cpu_to_be16 (uri_len);
grub_memcpy (opt->data, uri_dp->uri, uri_len);
@ -242,11 +242,11 @@ index 3e51e1064..3d7750747 100644
}
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
index eb6bb5085..dd3b07eac 100644
index fa528e73a27..248d6a28ff9 100644
--- a/include/grub/efi/api.h
+++ b/include/grub/efi/api.h
@@ -334,6 +334,16 @@
{ 0x8B, 0x8C, 0xE2, 0x1B, 0x01, 0xAE, 0xF2, 0xB7 } \
@@ -369,6 +369,16 @@
{ 0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 } \
}
+#define GRUB_EFI_IP4_CONFIG2_PROTOCOL_GUID \
@ -259,12 +259,12 @@ index eb6bb5085..dd3b07eac 100644
+ { 0x89, 0x29, 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a } \
+ }
+
struct grub_efi_sal_system_table
{
grub_uint32_t signature;
@@ -1838,6 +1848,72 @@ struct grub_efi_block_io
#define LINUX_EFI_INITRD_MEDIA_GUID \
{ 0x5568e427, 0x68fc, 0x4f3d, \
{ 0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68 } \
@@ -1963,6 +1973,72 @@ struct grub_efi_load_file2
};
typedef struct grub_efi_block_io grub_efi_block_io_t;
typedef struct grub_efi_load_file2 grub_efi_load_file2_t;
+enum grub_efi_ip4_config2_data_type {
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_INTERFACEINFO,
@ -332,6 +332,6 @@ index eb6bb5085..dd3b07eac 100644
+};
+typedef struct grub_efi_ip6_config_protocol grub_efi_ip6_config_protocol_t;
+
#if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \
|| defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__)
struct initrd_media_device_path {
grub_efi_vendor_media_device_path_t vendor;
grub_efi_device_path_t end;

View File

@ -22,25 +22,29 @@ V3:
* Use HEAD request method to test before GET
* Finish HTTP transaction in one go
* Fix bsc#1076132
Signed-off-by: Michael Chang <mchang@suse.com>
[pjones: make efi_netfs not duplicate symbols from efinet]
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/Makefile.core.def | 18 +
grub-core/Makefile.core.def | 12 +
grub-core/io/bufio.c | 2 +-
grub-core/kern/efi/efi.c | 96 ++-
grub-core/net/drivers/efi/efinet.c | 27 +
grub-core/net/efi/dhcp.c | 397 ++++++++++
grub-core/net/efi/efi_netfs.c | 57 ++
grub-core/net/efi/http.c | 419 +++++++++++
grub-core/net/efi/http.c | 410 +++++++++++
grub-core/net/efi/ip4_config.c | 398 ++++++++++
grub-core/net/efi/ip6_config.c | 422 +++++++++++
grub-core/net/efi/net.c | 1428 ++++++++++++++++++++++++++++++++++++
grub-core/net/efi/pxe.c | 424 +++++++++++
grub-core/net/net.c | 74 ++
util/grub-mknetdir.c | 23 +-
include/grub/efi/api.h | 180 ++++-
include/grub/efi/api.h | 195 ++++-
include/grub/efi/dhcp.h | 343 +++++++++
include/grub/efi/http.h | 215 ++++++
include/grub/net/efi.h | 144 ++++
17 files changed, 4626 insertions(+), 41 deletions(-)
17 files changed, 4618 insertions(+), 49 deletions(-)
create mode 100644 grub-core/net/efi/dhcp.c
create mode 100644 grub-core/net/efi/efi_netfs.c
create mode 100644 grub-core/net/efi/http.c
@ -53,32 +57,26 @@ V3:
create mode 100644 include/grub/net/efi.h
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 420831bc8..2851437e0 100644
index 6645fbae34f..56eb6a828e8 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -2181,6 +2181,18 @@ module = {
@@ -2356,6 +2356,12 @@ module = {
common = hook/datehook.c;
};
+module = {
+ name = efi_netfs;
+ common = net/efi/efi_netfs.c;
+ common = net/efi/net.c;
+ common = net/efi/http.c;
+ common = net/efi/pxe.c;
+ common = net/efi/ip4_config.c;
+ common = net/efi/ip6_config.c;
+ common = net/efi/dhcp.c;
+ enable = efi;
+};
+
module = {
name = net;
common = net/net.c;
@@ -2195,6 +2207,12 @@ module = {
@@ -2369,6 +2375,12 @@ module = {
common = net/ethernet.c;
common = net/arp.c;
common = net/netbuff.c;
common = net/url.c;
+ efi = net/efi/net.c;
+ efi = net/efi/http.c;
+ efi = net/efi/pxe.c;
@ -89,7 +87,7 @@ index 420831bc8..2851437e0 100644
module = {
diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c
index dbed64744..6118bade5 100644
index a458c3aca78..1637731535e 100644
--- a/grub-core/io/bufio.c
+++ b/grub-core/io/bufio.c
@@ -139,7 +139,7 @@ grub_bufio_read (grub_file_t file, char *buf, grub_size_t len)
@ -102,10 +100,10 @@ index dbed64744..6118bade5 100644
if (file->offset + res < next_buf)
{
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
index a2a732ffc..4d36fe311 100644
index 2bb8a0e7a38..bf16c4307bc 100644
--- a/grub-core/kern/efi/efi.c
+++ b/grub-core/kern/efi/efi.c
@@ -696,7 +696,7 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
@@ -775,7 +775,7 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
{
grub_efi_ipv4_device_path_t *ipv4
= (grub_efi_ipv4_device_path_t *) dp;
@ -114,7 +112,7 @@ index a2a732ffc..4d36fe311 100644
(unsigned) ipv4->local_ip_address[0],
(unsigned) ipv4->local_ip_address[1],
(unsigned) ipv4->local_ip_address[2],
@@ -709,33 +709,60 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
@@ -788,33 +788,60 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
(unsigned) ipv4->remote_port,
(unsigned) ipv4->protocol,
(unsigned) ipv4->static_ip_address);
@ -192,7 +190,7 @@ index a2a732ffc..4d36fe311 100644
}
break;
case GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE:
@@ -775,6 +802,39 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
@@ -861,6 +888,39 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
dump_vendor_path ("Messaging",
(grub_efi_vendor_device_path_t *) dp);
break;
@ -233,10 +231,10 @@ index a2a732ffc..4d36fe311 100644
grub_printf ("/UnknownMessaging(%x)", (unsigned) subtype);
break;
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
index 3d7750747..df7760ad2 100644
index a91df09ee6d..225dc896da0 100644
--- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -28,6 +28,7 @@
@@ -27,6 +27,7 @@
#include <grub/lib/hexdump.h>
#include <grub/types.h>
#include <grub/net/netbuff.h>
@ -244,7 +242,7 @@ index 3d7750747..df7760ad2 100644
GRUB_MOD_LICENSE ("GPLv3+");
@@ -492,6 +493,17 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u
@@ -508,6 +509,17 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u
ldp = grub_efi_find_last_device_path (ddp);
@ -262,7 +260,7 @@ index 3d7750747..df7760ad2 100644
if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE
|| (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE
&& GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE))
@@ -760,6 +772,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
@@ -781,6 +793,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE
|| (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE
&& GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE
@ -270,7 +268,7 @@ index 3d7750747..df7760ad2 100644
&& GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_URI_DEVICE_PATH_SUBTYPE))
continue;
dup_dp = grub_efi_duplicate_device_path (dp);
@@ -774,6 +787,15 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
@@ -795,6 +808,15 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
dup_ldp->length = sizeof (*dup_ldp);
}
@ -286,7 +284,7 @@ index 3d7750747..df7760ad2 100644
dup_ldp = grub_efi_find_last_device_path (dup_dp);
dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
@@ -845,6 +867,9 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
@@ -889,6 +911,9 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
GRUB_MOD_INIT(efinet)
{
@ -296,8 +294,8 @@ index 3d7750747..df7760ad2 100644
grub_efinet_findcards ();
grub_efi_net_config = grub_efi_net_config_real;
}
@@ -856,5 +881,7 @@ GRUB_MOD_FINI(efinet)
FOR_NET_CARDS_SAFE (card, next)
@@ -900,5 +925,7 @@ GRUB_MOD_FINI(efinet)
FOR_NET_CARDS_SAFE (card, next)
if (card->driver == &efidriver)
grub_net_card_unregister (card);
+
@ -306,7 +304,7 @@ index 3d7750747..df7760ad2 100644
diff --git a/grub-core/net/efi/dhcp.c b/grub-core/net/efi/dhcp.c
new file mode 100644
index 000000000..dbef63d8c
index 00000000000..ca19902441b
--- /dev/null
+++ b/grub-core/net/efi/dhcp.c
@@ -0,0 +1,397 @@
@ -387,7 +385,7 @@ index 000000000..dbef63d8c
+ grub_efi_uint32_t option_count = 0;
+ grub_efi_uint32_t i;
+
+ status = efi_call_4 (dhcp4->parse, dhcp4, reply_packet, &option_count, NULL);
+ status = dhcp4->parse(dhcp4, reply_packet, &option_count, NULL);
+
+ if (status != GRUB_EFI_BUFFER_TOO_SMALL)
+ return NULL;
@ -396,7 +394,7 @@ index 000000000..dbef63d8c
+ if (!option_list)
+ return NULL;
+
+ status = efi_call_4 (dhcp4->parse, dhcp4, reply_packet, &option_count, option_list);
+ status = dhcp4->parse(dhcp4, reply_packet, &option_count, option_list);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_free (option_list);
@ -445,13 +443,13 @@ index 000000000..dbef63d8c
+
+ if (!mode->started)
+ {
+ status = efi_call_2 (pxe->start, pxe, 0);
+ status = pxe->start(pxe, 0);
+
+ if (status != GRUB_EFI_SUCCESS)
+ grub_printf ("Couldn't start PXE\n");
+ }
+
+ status = efi_call_2 (pxe->dhcp, pxe, 0);
+ status = pxe->dhcp(pxe, 0);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_printf ("dhcp4 configure failed, %d\n", (int)status);
@ -502,7 +500,7 @@ index 000000000..dbef63d8c
+ config.option_list = &options;
+
+ /* FIXME: What if the dhcp has bounded */
+ status = efi_call_2 (netdev->dhcp4->configure, netdev->dhcp4, &config);
+ status = netdev->dhcp4->configure(netdev->dhcp4, &config);
+ grub_free (options);
+ if (status != GRUB_EFI_SUCCESS)
+ {
@ -510,14 +508,14 @@ index 000000000..dbef63d8c
+ continue;
+ }
+
+ status = efi_call_2 (netdev->dhcp4->start, netdev->dhcp4, NULL);
+ status = netdev->dhcp4->start(netdev->dhcp4, NULL);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_printf ("dhcp4 start failed, %d\n", (int)status);
+ continue;
+ }
+
+ status = efi_call_2 (netdev->dhcp4->get_mode_data, netdev->dhcp4, &mode);
+ status = netdev->dhcp4->get_mode_data(netdev->dhcp4, &mode);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_printf ("dhcp4 get mode failed, %d\n", (int)status);
@ -618,21 +616,21 @@ index 000000000..dbef63d8c
+ config.rapid_commit = 0;
+ config.solicit_retransmission = &retrans;
+
+ status = efi_call_2 (dev->dhcp6->configure, dev->dhcp6, &config);
+ status = dev->dhcp6->configure(dev->dhcp6, &config);
+ grub_free (opt);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_printf ("dhcp6 configure failed, %d\n", (int)status);
+ continue;
+ }
+ status = efi_call_1 (dev->dhcp6->start, dev->dhcp6);
+ status = dev->dhcp6->start(dev->dhcp6);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_printf ("dhcp6 start failed, %d\n", (int)status);
+ continue;
+ }
+
+ status = efi_call_3 (dev->dhcp6->get_mode_data, dev->dhcp6, &mode, NULL);
+ status = dev->dhcp6->get_mode_data(dev->dhcp6, &mode, NULL);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_printf ("dhcp4 get mode failed, %d\n", (int)status);
@ -668,12 +666,12 @@ index 000000000..dbef63d8c
+ grub_efi_dhcp6_packet_option_t **options = NULL;
+ grub_efi_uint32_t i;
+
+ status = efi_call_4 (dev->dhcp6->parse, dev->dhcp6, mode.ia->reply_packet, &count, NULL);
+ status = dev->dhcp6->parse(dev->dhcp6, mode.ia->reply_packet, &count, NULL);
+
+ if (status == GRUB_EFI_BUFFER_TOO_SMALL && count)
+ {
+ options = grub_malloc (count * sizeof(*options));
+ status = efi_call_4 (dev->dhcp6->parse, dev->dhcp6, mode.ia->reply_packet, &count, options);
+ status = dev->dhcp6->parse(dev->dhcp6, mode.ia->reply_packet, &count, options);
+ }
+
+ if (status != GRUB_EFI_SUCCESS)
@ -698,8 +696,8 @@ index 000000000..dbef63d8c
+ grub_free (options);
+ }
+
+ efi_call_1 (b->free_pool, mode.client_id);
+ efi_call_1 (b->free_pool, mode.ia);
+ b->free_pool(mode.client_id);
+ b->free_pool(mode.ia);
+ }
+
+ return GRUB_ERR_NONE;
@ -709,7 +707,7 @@ index 000000000..dbef63d8c
+grub_command_func_t grub_efi_net_bootp6 = grub_cmd_efi_bootp6;
diff --git a/grub-core/net/efi/efi_netfs.c b/grub-core/net/efi/efi_netfs.c
new file mode 100644
index 000000000..ef371d885
index 00000000000..ef371d885ea
--- /dev/null
+++ b/grub-core/net/efi/efi_netfs.c
@@ -0,0 +1,57 @@
@ -772,10 +770,10 @@ index 000000000..ef371d885
+}
diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c
new file mode 100644
index 000000000..3f61fd2fa
index 00000000000..de28badccb0
--- /dev/null
+++ b/grub-core/net/efi/http.c
@@ -0,0 +1,419 @@
@@ -0,0 +1,410 @@
+
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
@ -804,9 +802,9 @@ index 000000000..3f61fd2fa
+
+ http_config.local_address_is_ipv6 = 1;
+ sz = sizeof (manual_address);
+ status = efi_call_4 (dev->ip6_config->get_data, dev->ip6_config,
+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_MANUAL_ADDRESS,
+ &sz, &manual_address);
+ status = dev->ip6_config->get_data(dev->ip6_config,
+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_MANUAL_ADDRESS,
+ &sz, &manual_address);
+
+ if (status == GRUB_EFI_NOT_FOUND)
+ {
@ -836,19 +834,19 @@ index 000000000..3f61fd2fa
+ http_config.access_point.ipv4_node = &httpv4_node;
+ }
+
+ status = efi_call_2 (http->configure, http, &http_config);
+ status = http->configure(http, &http_config);
+
+ if (status == GRUB_EFI_ALREADY_STARTED)
+ {
+ /* XXX: This hangs HTTPS boot */
+#if 0
+ if (efi_call_2 (http->configure, http, NULL) != GRUB_EFI_SUCCESS)
+ if (http->configure(http, NULL) != GRUB_EFI_SUCCESS)
+ {
+ grub_error (GRUB_ERR_IO, N_("couldn't reset http instance"));
+ grub_print_error ();
+ return;
+ }
+ status = efi_call_2 (http->configure, http, &http_config);
+ status = http->configure(http, &http_config);
+#endif
+ return;
+ }
@ -947,12 +945,9 @@ index 000000000..3f61fd2fa
+ request_token.message = &request_message;
+
+ request_callback_done = 0;
+ status = efi_call_5 (b->create_event,
+ GRUB_EFI_EVT_NOTIFY_SIGNAL,
+ GRUB_EFI_TPL_CALLBACK,
+ grub_efi_http_request_callback,
+ NULL,
+ &request_token.event);
+ status = b->create_event(GRUB_EFI_EVT_NOTIFY_SIGNAL, GRUB_EFI_TPL_CALLBACK,
+ grub_efi_http_request_callback, NULL,
+ &request_token.event);
+
+ if (status != GRUB_EFI_SUCCESS)
+ {
@ -960,17 +955,17 @@ index 000000000..3f61fd2fa
+ return grub_error (GRUB_ERR_IO, "Fail to create an event! status=0x%x\n", status);
+ }
+
+ status = efi_call_2 (http->request, http, &request_token);
+ status = http->request(http, &request_token);
+
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ efi_call_1 (b->close_event, request_token.event);
+ b->close_event(request_token.event);
+ grub_free (request_data.url);
+ return grub_error (GRUB_ERR_IO, "Fail to send a request! status=0x%x\n", status);
+ }
+ /* TODO: Add Timeout */
+ while (!request_callback_done)
+ efi_call_1(http->poll, http);
+ http->poll(http);
+
+ response_data.status_code = GRUB_EFI_HTTP_STATUS_UNSUPPORTED_STATUS;
+ response_message.data.response = &response_data;
@ -983,16 +978,13 @@ index 000000000..3f61fd2fa
+ response_message.body = NULL;
+ response_token.event = NULL;
+
+ status = efi_call_5 (b->create_event,
+ GRUB_EFI_EVT_NOTIFY_SIGNAL,
+ GRUB_EFI_TPL_CALLBACK,
+ grub_efi_http_response_callback,
+ NULL,
+ &response_token.event);
+ status = b->create_event(GRUB_EFI_EVT_NOTIFY_SIGNAL, GRUB_EFI_TPL_CALLBACK,
+ grub_efi_http_response_callback, NULL,
+ &response_token.event);
+
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ efi_call_1 (b->close_event, request_token.event);
+ b->close_event(request_token.event);
+ grub_free (request_data.url);
+ return grub_error (GRUB_ERR_IO, "Fail to create an event! status=0x%x\n", status);
+ }
@ -1002,28 +994,28 @@ index 000000000..3f61fd2fa
+
+ /* wait for HTTP response */
+ response_callback_done = 0;
+ status = efi_call_2 (http->response, http, &response_token);
+ status = http->response(http, &response_token);
+
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ efi_call_1 (b->close_event, response_token.event);
+ efi_call_1 (b->close_event, request_token.event);
+ b->close_event(response_token.event);
+ b->close_event(request_token.event);
+ grub_free (request_data.url);
+ return grub_error (GRUB_ERR_IO, "Fail to receive a response! status=%d\n", (int)status);
+ }
+
+ /* TODO: Add Timeout */
+ while (!response_callback_done)
+ efi_call_1 (http->poll, http);
+ http->poll(http);
+
+ if (response_message.data.response->status_code != GRUB_EFI_HTTP_STATUS_200_OK)
+ {
+ grub_efi_http_status_code_t status_code = response_message.data.response->status_code;
+
+ if (response_message.headers)
+ efi_call_1 (b->free_pool, response_message.headers);
+ efi_call_1 (b->close_event, response_token.event);
+ efi_call_1 (b->close_event, request_token.event);
+ b->free_pool(response_message.headers);
+ b->close_event(response_token.event);
+ b->close_event(request_token.event);
+ grub_free (request_data.url);
+ if (status_code == GRUB_EFI_HTTP_STATUS_404_NOT_FOUND)
+ {
@ -1051,9 +1043,9 @@ index 000000000..3f61fd2fa
+ }
+
+ if (response_message.headers)
+ efi_call_1 (b->free_pool, response_message.headers);
+ efi_call_1 (b->close_event, response_token.event);
+ efi_call_1 (b->close_event, request_token.event);
+ b->free_pool(response_message.headers);
+ b->close_event(response_token.event);
+ b->close_event(request_token.event);
+ grub_free (request_data.url);
+
+ return GRUB_ERR_NONE;
@ -1078,12 +1070,9 @@ index 000000000..3f61fd2fa
+ return -1;
+ }
+
+ efi_call_5 (b->create_event,
+ GRUB_EFI_EVT_NOTIFY_SIGNAL,
+ GRUB_EFI_TPL_CALLBACK,
+ grub_efi_http_response_callback,
+ NULL,
+ &response_token.event);
+ b->create_event(GRUB_EFI_EVT_NOTIFY_SIGNAL, GRUB_EFI_TPL_CALLBACK,
+ grub_efi_http_response_callback, NULL,
+ &response_token.event);
+
+ while (len)
+ {
@ -1098,23 +1087,23 @@ index 000000000..3f61fd2fa
+
+ response_callback_done = 0;
+
+ status = efi_call_2 (http->response, http, &response_token);
+ status = http->response(http, &response_token);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ efi_call_1 (b->close_event, response_token.event);
+ b->close_event(response_token.event);
+ grub_error (GRUB_ERR_IO, "Error! status=%d\n", (int)status);
+ return -1;
+ }
+
+ while (!response_callback_done)
+ efi_call_1(http->poll, http);
+ http->poll(http);
+
+ sum += response_message.body_length;
+ buf += response_message.body_length;
+ len -= response_message.body_length;
+ }
+
+ efi_call_1 (b->close_event, response_token.event);
+ b->close_event(response_token.event);
+
+ return sum;
+}
@ -1197,7 +1186,7 @@ index 000000000..3f61fd2fa
+ };
diff --git a/grub-core/net/efi/ip4_config.c b/grub-core/net/efi/ip4_config.c
new file mode 100644
index 000000000..b711a5d94
index 00000000000..1deba25e79e
--- /dev/null
+++ b/grub-core/net/efi/ip4_config.c
@@ -0,0 +1,398 @@
@ -1307,17 +1296,17 @@ index 000000000..b711a5d94
+ if (!interface_info)
+ return NULL;
+
+ status = efi_call_4 (ip4_config->get_data, ip4_config,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_INTERFACEINFO,
+ &sz, interface_info);
+ status = ip4_config->get_data(ip4_config,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_INTERFACEINFO,
+ &sz, interface_info);
+
+ if (status == GRUB_EFI_BUFFER_TOO_SMALL)
+ {
+ grub_free (interface_info);
+ interface_info = grub_malloc (sz);
+ status = efi_call_4 (ip4_config->get_data, ip4_config,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_INTERFACEINFO,
+ &sz, interface_info);
+ status = ip4_config->get_data(ip4_config,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_INTERFACEINFO,
+ &sz, interface_info);
+ }
+
+ if (status != GRUB_EFI_SUCCESS)
@ -1341,9 +1330,9 @@ index 000000000..b711a5d94
+ if (!manual_address)
+ return NULL;
+
+ status = efi_call_4 (ip4_config->get_data, ip4_config,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_MANUAL_ADDRESS,
+ &sz, manual_address);
+ status = ip4_config->get_data(ip4_config,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_MANUAL_ADDRESS,
+ &sz, manual_address);
+
+ if (status != GRUB_EFI_SUCCESS)
+ {
@ -1548,7 +1537,7 @@ index 000000000..b711a5d94
+ }
+ }
+
+ status = efi_call_4 (dev->ip4_config->set_data, dev->ip4_config,
+ status = dev->ip4_config->set_data(dev->ip4_config,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_MANUAL_ADDRESS,
+ sizeof(*address), address);
+
@ -1564,9 +1553,9 @@ index 000000000..b711a5d94
+{
+ grub_efi_status_t status;
+
+ status = efi_call_4 (dev->ip4_config->set_data, dev->ip4_config,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_GATEWAY,
+ sizeof (address->ip4), &address->ip4);
+ status = dev->ip4_config->set_data(dev->ip4_config,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_GATEWAY,
+ sizeof (address->ip4), &address->ip4);
+
+ if (status != GRUB_EFI_SUCCESS)
+ return 0;
@ -1580,9 +1569,9 @@ index 000000000..b711a5d94
+{
+ grub_efi_status_t status;
+
+ status = efi_call_4 (dev->ip4_config->set_data, dev->ip4_config,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER,
+ sizeof (address->ip4), &address->ip4);
+ status = dev->ip4_config->set_data(dev->ip4_config,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER,
+ sizeof (address->ip4), &address->ip4);
+
+ if (status != GRUB_EFI_SUCCESS)
+ return 0;
@ -1601,7 +1590,7 @@ index 000000000..b711a5d94
+ };
diff --git a/grub-core/net/efi/ip6_config.c b/grub-core/net/efi/ip6_config.c
new file mode 100644
index 000000000..017c4d05b
index 00000000000..29a03973265
--- /dev/null
+++ b/grub-core/net/efi/ip6_config.c
@@ -0,0 +1,422 @@
@ -1731,7 +1720,7 @@ index 000000000..017c4d05b
+ sz = sizeof (*interface_info) + sizeof (*interface_info->route_table);
+ interface_info = grub_malloc (sz);
+
+ status = efi_call_4 (ip6_config->get_data, ip6_config,
+ status = ip6_config->get_data(ip6_config,
+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_INTERFACEINFO,
+ &sz, interface_info);
+
@ -1739,7 +1728,7 @@ index 000000000..017c4d05b
+ {
+ grub_free (interface_info);
+ interface_info = grub_malloc (sz);
+ status = efi_call_4 (ip6_config->get_data, ip6_config,
+ status = ip6_config->get_data(ip6_config,
+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_INTERFACEINFO,
+ &sz, interface_info);
+ }
@ -1765,7 +1754,7 @@ index 000000000..017c4d05b
+ if (!manual_address)
+ return NULL;
+
+ status = efi_call_4 (ip6_config->get_data, ip6_config,
+ status = ip6_config->get_data(ip6_config,
+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_MANUAL_ADDRESS,
+ &sz, manual_address);
+
@ -1976,7 +1965,7 @@ index 000000000..017c4d05b
+ }
+ }
+
+ status = efi_call_4 (dev->ip6_config->set_data, dev->ip6_config,
+ status = dev->ip6_config->set_data(dev->ip6_config,
+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_MANUAL_ADDRESS,
+ sizeof(*address), address);
+
@ -1992,7 +1981,7 @@ index 000000000..017c4d05b
+{
+ grub_efi_status_t status;
+
+ status = efi_call_4 (dev->ip6_config->set_data, dev->ip6_config,
+ status = dev->ip6_config->set_data(dev->ip6_config,
+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_GATEWAY,
+ sizeof (address->ip6), &address->ip6);
+
@ -2008,7 +1997,7 @@ index 000000000..017c4d05b
+
+ grub_efi_status_t status;
+
+ status = efi_call_4 (dev->ip6_config->set_data, dev->ip6_config,
+ status = dev->ip6_config->set_data(dev->ip6_config,
+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_DNSSERVER,
+ sizeof (address->ip6), &address->ip6);
+
@ -2029,7 +2018,7 @@ index 000000000..017c4d05b
+ };
diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c
new file mode 100644
index 000000000..9e0078ac1
index 00000000000..1a19ee27144
--- /dev/null
+++ b/grub-core/net/efi/net.c
@@ -0,0 +1,1428 @@
@ -2052,15 +2041,15 @@ index 000000000..9e0078ac1
+
+#define GRUB_EFI_IP6_PREFIX_LENGTH 64
+
+static grub_efi_guid_t ip4_config_guid = GRUB_EFI_IP4_CONFIG2_PROTOCOL_GUID;
+static grub_efi_guid_t ip6_config_guid = GRUB_EFI_IP6_CONFIG_PROTOCOL_GUID;
+static grub_efi_guid_t http_service_binding_guid = GRUB_EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID;
+static grub_efi_guid_t http_guid = GRUB_EFI_HTTP_PROTOCOL_GUID;
+static grub_efi_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID;
+static grub_efi_guid_t dhcp4_service_binding_guid = GRUB_EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID;
+static grub_efi_guid_t dhcp4_guid = GRUB_EFI_DHCP4_PROTOCOL_GUID;
+static grub_efi_guid_t dhcp6_service_binding_guid = GRUB_EFI_DHCP6_SERVICE_BINDING_PROTOCOL_GUID;
+static grub_efi_guid_t dhcp6_guid = GRUB_EFI_DHCP6_PROTOCOL_GUID;
+static grub_guid_t ip4_config_guid = GRUB_EFI_IP4_CONFIG2_PROTOCOL_GUID;
+static grub_guid_t ip6_config_guid = GRUB_EFI_IP6_CONFIG_PROTOCOL_GUID;
+static grub_guid_t http_service_binding_guid = GRUB_EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID;
+static grub_guid_t http_guid = GRUB_EFI_HTTP_PROTOCOL_GUID;
+static grub_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID;
+static grub_guid_t dhcp4_service_binding_guid = GRUB_EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID;
+static grub_guid_t dhcp4_guid = GRUB_EFI_DHCP4_PROTOCOL_GUID;
+static grub_guid_t dhcp6_service_binding_guid = GRUB_EFI_DHCP6_SERVICE_BINDING_PROTOCOL_GUID;
+static grub_guid_t dhcp6_guid = GRUB_EFI_DHCP6_PROTOCOL_GUID;
+
+struct grub_efi_net_device *net_devices;
+
@ -2075,13 +2064,13 @@ index 000000000..9e0078ac1
+#define efi_net_interface(m,...) efi_net_interface_ ## m (net_interface, ## __VA_ARGS__)
+
+static grub_efi_handle_t
+grub_efi_locate_device_path (grub_efi_guid_t *protocol, grub_efi_device_path_t *device_path,
+grub_efi_locate_device_path (grub_guid_t *protocol, grub_efi_device_path_t *device_path,
+ grub_efi_device_path_t **r_device_path)
+{
+ grub_efi_handle_t handle;
+ grub_efi_status_t status;
+
+ status = efi_call_3 (grub_efi_system_table->boot_services->locate_device_path,
+ status = grub_efi_system_table->boot_services->locate_device_path(
+ protocol, &device_path, &handle);
+
+ if (status != GRUB_EFI_SUCCESS)
@ -2723,7 +2712,7 @@ index 000000000..9e0078ac1
+}
+
+static grub_efi_handle_t
+grub_efi_service_binding (grub_efi_handle_t dev, grub_efi_guid_t *service_binding_guid)
+grub_efi_service_binding (grub_efi_handle_t dev, grub_guid_t *service_binding_guid)
+{
+ grub_efi_service_binding_t *service;
+ grub_efi_status_t status;
@ -2736,7 +2725,7 @@ index 000000000..9e0078ac1
+ return NULL;
+ }
+
+ status = efi_call_2 (service->create_child, service, &child_dev);
+ status = service->create_child(service, &child_dev);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ grub_error (GRUB_ERR_IO, N_("Failed to create child device of http service %x"), status);
@ -2946,7 +2935,7 @@ index 000000000..9e0078ac1
+ {
+ grub_efi_ip4_config2_policy_t ip4_policy = GRUB_EFI_IP4_CONFIG2_POLICY_STATIC;
+
+ if (efi_call_4 (dev->ip4_config->set_data, dev->ip4_config,
+ if (dev->ip4_config->set_data(dev->ip4_config,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_POLICY,
+ sizeof (ip4_policy), &ip4_policy) != GRUB_EFI_SUCCESS)
+ grub_dprintf ("efinetfs", "could not set GRUB_EFI_IP4_CONFIG2_POLICY_STATIC on dev `%s'", dev->card_name);
@ -2955,7 +2944,7 @@ index 000000000..9e0078ac1
+ {
+ grub_efi_ip6_config_policy_t ip6_policy = GRUB_EFI_IP6_CONFIG_POLICY_MANUAL;
+
+ if (efi_call_4 (dev->ip6_config->set_data, dev->ip6_config,
+ if (dev->ip6_config->set_data(dev->ip6_config,
+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_POLICY,
+ sizeof (ip6_policy), &ip6_policy) != GRUB_EFI_SUCCESS)
+ grub_dprintf ("efinetfs", "could not set GRUB_EFI_IP6_CONFIG_POLICY_MANUAL on dev `%s'", dev->card_name);
@ -3326,13 +3315,13 @@ index 000000000..9e0078ac1
+static struct grub_fs grub_efi_netfs =
+ {
+ .name = "efi netfs",
+ .dir = grub_efi_netfs_dir,
+ .open = grub_efi_netfs_open,
+ .read = grub_efi_netfs_read,
+ .close = grub_efi_netfs_close,
+ .label = NULL,
+ .uuid = NULL,
+ .mtime = NULL,
+ .fs_dir = grub_efi_netfs_dir,
+ .fs_open = grub_efi_netfs_open,
+ .fs_read = grub_efi_netfs_read,
+ .fs_close = grub_efi_netfs_close,
+ .fs_label = NULL,
+ .fs_uuid = NULL,
+ .fs_mtime = NULL,
+ };
+
+int
@ -3463,7 +3452,7 @@ index 000000000..9e0078ac1
+}
diff --git a/grub-core/net/efi/pxe.c b/grub-core/net/efi/pxe.c
new file mode 100644
index 000000000..531949cba
index 00000000000..b84f86ea470
--- /dev/null
+++ b/grub-core/net/efi/pxe.c
@@ -0,0 +1,424 @@
@ -3486,7 +3475,7 @@ index 000000000..531949cba
+ if (!manual_address)
+ return NULL;
+
+ status = efi_call_4 (ip6_config->get_data, ip6_config,
+ status = ip6_config->get_data(ip6_config,
+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_MANUAL_ADDRESS,
+ &sz, manual_address);
+
@ -3511,7 +3500,7 @@ index 000000000..531949cba
+ if (!manual_address)
+ return NULL;
+
+ status = efi_call_4 (ip4_config->get_data, ip4_config,
+ status = ip4_config->get_data(ip4_config,
+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_MANUAL_ADDRESS,
+ &sz, manual_address);
+
@ -3534,7 +3523,7 @@ index 000000000..531949cba
+ if (!mode->started)
+ {
+ grub_efi_status_t status;
+ status = efi_call_2 (pxe->start, pxe, prefer_ip6);
+ status = pxe->start(pxe, prefer_ip6);
+
+ if (status != GRUB_EFI_SUCCESS)
+ grub_printf ("Couldn't start PXE\n");
@ -3557,7 +3546,7 @@ index 000000000..531949cba
+ grub_efi_pxe_ip_address_t station_ip;
+
+ grub_memcpy (station_ip.v6.addr, manual_address->address, sizeof (station_ip.v6.addr));
+ status = efi_call_3 (pxe->set_station_ip, pxe, &station_ip, NULL);
+ status = pxe->set_station_ip(pxe, &station_ip, NULL);
+
+ if (status != GRUB_EFI_SUCCESS)
+ grub_printf ("Couldn't set station ip\n");
@ -3580,7 +3569,7 @@ index 000000000..531949cba
+ grub_memcpy (station_ip.v4.addr, manual_address->address, sizeof (station_ip.v4.addr));
+ grub_memcpy (subnet_mask.v4.addr, manual_address->subnet_mask, sizeof (subnet_mask.v4.addr));
+
+ status = efi_call_3 (pxe->set_station_ip, pxe, &station_ip, &subnet_mask);
+ status = pxe->set_station_ip(pxe, &station_ip, &subnet_mask);
+
+ if (status != GRUB_EFI_SUCCESS)
+ grub_printf ("Couldn't set station ip\n");
@ -3733,7 +3722,7 @@ index 000000000..531949cba
+ server_ip.v4.addr[i] = grub_strtoul (p, &p, 10);
+ }
+
+ status = efi_call_10 (pxe->mtftp,
+ status = pxe->mtftp(
+ pxe,
+ GRUB_EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE,
+ NULL,
@ -3818,7 +3807,7 @@ index 000000000..531949cba
+ server_ip.v4.addr[i] = grub_strtoul (p, &p, 10);
+ }
+
+ status = efi_call_10 (pxe->mtftp,
+ status = pxe->mtftp(
+ pxe,
+ GRUB_EFI_PXE_BASE_CODE_TFTP_READ_FILE,
+ buf,
@ -3849,7 +3838,7 @@ index 000000000..531949cba
+ return 0;
+ }
+
+ status = efi_call_10 (pxe->mtftp,
+ status = pxe->mtftp(
+ pxe,
+ GRUB_EFI_PXE_BASE_CODE_TFTP_READ_FILE,
+ buf2,
@ -3892,7 +3881,7 @@ index 000000000..531949cba
+ };
+
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
index 191e8e41b..a571ee92e 100644
index fa6b6537142..fdec64d55ee 100644
--- a/grub-core/net/net.c
+++ b/grub-core/net/net.c
@@ -32,6 +32,9 @@
@ -3905,8 +3894,8 @@ index 191e8e41b..a571ee92e 100644
GRUB_MOD_LICENSE ("GPLv3+");
@@ -2025,8 +2028,49 @@ static grub_command_t cmd_addaddr, cmd_deladdr, cmd_addroute, cmd_delroute;
static grub_command_t cmd_lsroutes, cmd_lscards;
@@ -2092,8 +2095,49 @@ static grub_command_t cmd_addaddr, cmd_deladdr, cmd_addroute, cmd_delroute;
static grub_command_t cmd_setvlan, cmd_lsroutes, cmd_lscards;
static grub_command_t cmd_lsaddr, cmd_slaac;
+#ifdef GRUB_MACHINE_EFI
@ -3955,7 +3944,7 @@ index 191e8e41b..a571ee92e 100644
grub_register_variable_hook ("net_default_server", defserver_get_env,
defserver_set_env);
grub_env_export ("net_default_server");
@@ -2074,10 +2118,37 @@ GRUB_MOD_INIT(net)
@@ -2144,10 +2188,37 @@ GRUB_MOD_INIT(net)
grub_net_restore_hw,
GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK);
grub_net_poll_cards_idle = grub_net_poll_cards_idle_real;
@ -3993,16 +3982,16 @@ index 191e8e41b..a571ee92e 100644
grub_register_variable_hook ("net_default_server", 0, 0);
grub_register_variable_hook ("pxe_default_server", 0, 0);
@@ -2096,4 +2167,7 @@ GRUB_MOD_FINI(net)
@@ -2166,4 +2237,7 @@ GRUB_MOD_FINI(net)
grub_net_fini_hw (0);
grub_loader_unregister_preboot_hook (fini_hnd);
grub_net_poll_cards_idle = grub_net_poll_cards_idle_real;
grub_net_poll_cards_idle = NULL;
+#ifdef GRUB_MACHINE_EFI
+ init_mode = INIT_MODE_NONE;
+#endif
}
diff --git a/util/grub-mknetdir.c b/util/grub-mknetdir.c
index 82073d5cc..ae31271bb 100644
index 46f304c2b47..11c9db11775 100644
--- a/util/grub-mknetdir.c
+++ b/util/grub-mknetdir.c
@@ -32,13 +32,15 @@
@ -4057,7 +4046,7 @@ index 82073d5cc..ae31271bb 100644
{
const char *mkimage_target;
const char *netmodule;
@@ -154,6 +159,7 @@ process_input_dir (const char *input_dir, enum grub_install_plat platform)
@@ -157,6 +162,7 @@ process_input_dir (const char *input_dir, enum grub_install_plat platform)
grub_install_push_module (targets[platform].netmodule);
output = grub_util_path_concat_ext (2, grubdir, "core", targets[platform].ext);
@ -4065,7 +4054,7 @@ index 82073d5cc..ae31271bb 100644
grub_install_make_image_wrap (input_dir, prefix, output,
0, load_cfg,
targets[platform].mkimage_target, 0);
@@ -190,7 +196,16 @@ main (int argc, char *argv[])
@@ -196,7 +202,16 @@ main (int argc, char *argv[])
grub_install_mkdir_p (base);
@ -4084,10 +4073,10 @@ index 82073d5cc..ae31271bb 100644
if (!grub_install_source_directory)
{
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
index dd3b07eac..b337e1a19 100644
index 248d6a28ff9..805a9d7adf9 100644
--- a/include/grub/efi/api.h
+++ b/include/grub/efi/api.h
@@ -602,6 +602,23 @@ typedef union
@@ -668,6 +668,23 @@ typedef union
typedef grub_efi_uint64_t grub_efi_physical_address_t;
typedef grub_efi_uint64_t grub_efi_virtual_address_t;
@ -4109,9 +4098,9 @@ index dd3b07eac..b337e1a19 100644
+ grub_efi_pxe_ipv6_address_t v6;
+} grub_efi_pxe_ip_address_t;
struct grub_efi_guid
{
@@ -865,6 +882,8 @@ struct grub_efi_ipv6_device_path
/* XXX although the spec does not specify the padding, this actually
must have the padding! */
@@ -917,6 +934,8 @@ struct grub_efi_ipv6_device_path
grub_efi_uint16_t remote_port;
grub_efi_uint16_t protocol;
grub_efi_uint8_t static_ip_address;
@ -4120,7 +4109,7 @@ index dd3b07eac..b337e1a19 100644
} GRUB_PACKED;
typedef struct grub_efi_ipv6_device_path grub_efi_ipv6_device_path_t;
@@ -914,6 +933,15 @@ struct grub_efi_uri_device_path
@@ -975,6 +994,15 @@ struct grub_efi_uri_device_path
} GRUB_PACKED;
typedef struct grub_efi_uri_device_path grub_efi_uri_device_path_t;
@ -4136,7 +4125,7 @@ index dd3b07eac..b337e1a19 100644
#define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10
/* Media Device Path. */
@@ -996,6 +1024,23 @@ struct grub_efi_bios_device_path
@@ -1057,6 +1085,23 @@ struct grub_efi_bios_device_path
} GRUB_PACKED;
typedef struct grub_efi_bios_device_path grub_efi_bios_device_path_t;
@ -4160,7 +4149,7 @@ index dd3b07eac..b337e1a19 100644
struct grub_efi_open_protocol_information_entry
{
grub_efi_handle_t agent_handle;
@@ -1545,23 +1590,27 @@ typedef struct grub_efi_pxe_tftp_error
@@ -1617,23 +1662,27 @@ typedef struct grub_efi_pxe_tftp_error
grub_efi_char8_t error_string[127];
} grub_efi_pxe_tftp_error_t;
@ -4202,18 +4191,27 @@ index dd3b07eac..b337e1a19 100644
#define GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT 8
typedef struct grub_efi_pxe_ip_filter
@@ -1628,17 +1677,31 @@ typedef struct grub_efi_pxe_mode
@@ -1700,18 +1749,31 @@ typedef struct grub_efi_pxe_mode
typedef struct grub_efi_pxe
{
grub_uint64_t rev;
- void (*start) (void);
- void *start;
- void *stop;
- void *dhcp;
- void *discover;
- void *mftp;
- void *udpwrite;
- void *udpread;
- void *setipfilter;
- void *arp;
- void *setparams;
- void *setstationip;
- void *setpackets;
+ grub_efi_status_t (*start) (struct grub_efi_pxe *this, grub_efi_boolean_t use_ipv6);
void (*stop) (void);
- void (*dhcp) (void);
+ void (*stop) (void);
+ grub_efi_status_t (*dhcp) (struct grub_efi_pxe *this,
+ grub_efi_boolean_t sort_offers);
void (*discover) (void);
- void (*mftp) (void);
+ void (*discover) (void);
+ grub_efi_status_t (*mtftp) (struct grub_efi_pxe *this,
+ grub_efi_pxe_base_code_tftp_opcode_t operation,
+ void *buffer_ptr,
@ -4225,20 +4223,19 @@ index dd3b07eac..b337e1a19 100644
+ grub_efi_char8_t *filename,
+ grub_efi_pxe_base_code_mtftp_info_t *info,
+ grub_efi_boolean_t dont_use_buffer);
void (*udpwrite) (void);
void (*udpread) (void);
void (*setipfilter) (void);
void (*arp) (void);
void (*setparams) (void);
- void (*setstationip) (void);
+ void (*udpwrite) (void);
+ void (*udpread) (void);
+ void (*setipfilter) (void);
+ void (*arp) (void);
+ void (*setparams) (void);
+ grub_efi_status_t (*set_station_ip) (struct grub_efi_pxe *this,
+ grub_efi_pxe_ip_address_t *new_station_ip,
+ grub_efi_pxe_ip_address_t *new_subnet_mask);
+ //void (*setstationip) (void);
void (*setpackets) (void);
+ void (*setpackets) (void);
struct grub_efi_pxe_mode *mode;
} grub_efi_pxe_t;
@@ -1880,6 +1943,44 @@ struct grub_efi_ip4_config2_protocol
@@ -2005,6 +2067,44 @@ struct grub_efi_ip4_config2_protocol
};
typedef struct grub_efi_ip4_config2_protocol grub_efi_ip4_config2_protocol_t;
@ -4283,7 +4280,7 @@ index dd3b07eac..b337e1a19 100644
enum grub_efi_ip6_config_data_type {
GRUB_EFI_IP6_CONFIG_DATA_TYPE_INTERFACEINFO,
GRUB_EFI_IP6_CONFIG_DATA_TYPE_ALT_INTERFACEID,
@@ -1914,6 +2015,49 @@ struct grub_efi_ip6_config_protocol
@@ -2039,6 +2139,49 @@ struct grub_efi_ip6_config_protocol
};
typedef struct grub_efi_ip6_config_protocol grub_efi_ip6_config_protocol_t;
@ -4330,12 +4327,12 @@ index dd3b07eac..b337e1a19 100644
+};
+typedef struct grub_efi_ip6_config_manual_address grub_efi_ip6_config_manual_address_t;
+
#if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \
|| defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__)
struct initrd_media_device_path {
grub_efi_vendor_media_device_path_t vendor;
grub_efi_device_path_t end;
diff --git a/include/grub/efi/dhcp.h b/include/grub/efi/dhcp.h
new file mode 100644
index 000000000..fdb88eb81
index 00000000000..fdb88eb810e
--- /dev/null
+++ b/include/grub/efi/dhcp.h
@@ -0,0 +1,343 @@
@ -4684,7 +4681,7 @@ index 000000000..fdb88eb81
+#endif /* ! GRUB_EFI_DHCP_HEADER */
diff --git a/include/grub/efi/http.h b/include/grub/efi/http.h
new file mode 100644
index 000000000..c5e9a89f5
index 00000000000..c5e9a89f505
--- /dev/null
+++ b/include/grub/efi/http.h
@@ -0,0 +1,215 @@
@ -4905,7 +4902,7 @@ index 000000000..c5e9a89f5
+#endif /* !GRUB_EFI_HTTP_HEADER */
diff --git a/include/grub/net/efi.h b/include/grub/net/efi.h
new file mode 100644
index 000000000..de90d223e
index 00000000000..de90d223e8e
--- /dev/null
+++ b/include/grub/net/efi.h
@@ -0,0 +1,144 @@

View File

@ -18,11 +18,11 @@ signed code is allowed to be executed.
Signed-off-by: Michael Chang <mchang@suse.com>
---
grub-core/net/efi/net.c | 4 +++-
grub-core/net/http.c | 5 ++++-
2 files changed, 7 insertions(+), 2 deletions(-)
grub-core/net/http.c | 8 +++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c
index 9e0078ac1..2bf15447f 100644
index 1a19ee27144..ed04f05ad21 100644
--- a/grub-core/net/efi/net.c
+++ b/grub-core/net/efi/net.c
@@ -645,8 +645,10 @@ grub_efihttp_chunk_read (grub_file_t file, char *buf,
@ -38,20 +38,23 @@ index 9e0078ac1..2bf15447f 100644
if (buf)
{
diff --git a/grub-core/net/http.c b/grub-core/net/http.c
index 00737c527..c9c59690a 100644
index f389bf03d96..af486198399 100644
--- a/grub-core/net/http.c
+++ b/grub-core/net/http.c
@@ -31,7 +31,8 @@ GRUB_MOD_LICENSE ("GPLv3+");
@@ -29,7 +29,11 @@
enum
{
- HTTP_PORT = 80
GRUB_MOD_LICENSE ("GPLv3+");
-#define HTTP_PORT ((grub_uint16_t) 80)
+enum
+ {
+ HTTP_PORT = 80,
+ HTTP_MAX_CHUNK_SIZE = 0x80000000
};
+ };
@@ -78,6 +79,8 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len)
typedef struct http_data
{
@@ -82,6 +86,8 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len)
if (data->in_chunk_len == 2)
{
data->chunk_rem = grub_strtoul (ptr, 0, 16);

View File

@ -17,7 +17,7 @@ Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 file changed, 50 insertions(+)
diff --git a/util/grub-editenv.c b/util/grub-editenv.c
index 118e89fe5..2918bb71c 100644
index db6f187cc63..948eec8a114 100644
--- a/util/grub-editenv.c
+++ b/util/grub-editenv.c
@@ -53,6 +53,9 @@ static struct argp_option options[] = {
@ -30,7 +30,7 @@ index 118e89fe5..2918bb71c 100644
{0, 0, 0, OPTION_DOC, N_("Options:"), -1},
{"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
@@ -246,6 +249,51 @@ unset_variables (const char *name, int argc, char *argv[])
@@ -253,6 +256,51 @@ unset_variables (const char *name, int argc, char *argv[])
grub_envblk_close (envblk);
}
@ -82,7 +82,7 @@ index 118e89fe5..2918bb71c 100644
int
main (int argc, char *argv[])
{
@@ -285,6 +333,8 @@ main (int argc, char *argv[])
@@ -292,6 +340,8 @@ main (int argc, char *argv[])
set_variables (filename, argc - curindex, argv + curindex);
else if (strcmp (command, "unset") == 0)
unset_variables (filename, argc - curindex, argv + curindex);

View File

@ -35,42 +35,36 @@ fastboot If set to "1" and the conditions for auto-hiding the menu
https://git.launchpad.net/~ubuntu-core-dev/grub/+git/ubuntu/tree/debian/patches/quick_boot.patch
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Drop shutdown_success tests, there is no meaningful way for systemd to set
this flag (by the time it knows all filesystems are unmounted or read-only
-Drop fwsetup_once support, systemd already supports booting directly into
the fwsetup by doing "systemctl reboot --firmware"
---
Makefile.util.def | 6 +++++
util/grub.d/00_menu_auto_hide.in | 50 ++++++++++++++++++++++++++++++++++++++++
util/grub.d/01_menu_auto_hide.in | 48 ++++++++++++++++++++++++++++++++++++++++
util/grub.d/30_os-prober.in | 18 +++++++++++++++
3 files changed, 74 insertions(+)
create mode 100644 util/grub.d/00_menu_auto_hide.in
3 files changed, 72 insertions(+)
create mode 100644 util/grub.d/01_menu_auto_hide.in
diff --git a/Makefile.util.def b/Makefile.util.def
index cbd661d63..0fdfdd91f 100644
index 1079add5bbe..5b9f85d4869 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -448,6 +448,12 @@ script = {
@@ -461,6 +461,12 @@ script = {
installdir = grubconf;
};
+script = {
+ name = '00_menu_auto_hide';
+ common = util/grub.d/00_menu_auto_hide.in;
+ name = '01_menu_auto_hide';
+ common = util/grub.d/01_menu_auto_hide.in;
+ installdir = grubconf;
+};
+
script = {
name = '01_users';
common = util/grub.d/01_users.in;
diff --git a/util/grub.d/00_menu_auto_hide.in b/util/grub.d/00_menu_auto_hide.in
diff --git a/util/grub.d/01_menu_auto_hide.in b/util/grub.d/01_menu_auto_hide.in
new file mode 100644
index 000000000..a10fe45bb
index 00000000000..ad175870a54
--- /dev/null
+++ b/util/grub.d/00_menu_auto_hide.in
@@ -0,0 +1,50 @@
+++ b/util/grub.d/01_menu_auto_hide.in
@@ -0,0 +1,48 @@
+#! /bin/sh
+
+# Disable / skip generating menu-auto-hide config parts on serial terminals
@ -92,21 +86,19 @@ index 000000000..a10fe45bb
+# Reset boot_indeterminate after a successful boot
+if [ "\${boot_success}" = "1" ] ; then
+ set boot_indeterminate=0
+ save_env boot_indeterminate
+# Avoid boot_indeterminate causing the menu to be hidden more then once
+elif [ "\${boot_indeterminate}" = "1" ]; then
+ set boot_indeterminate=2
+ save_env boot_indeterminate
+fi
+set boot_success=0
+save_env boot_success
+save_env boot_success boot_indeterminate
+
+if [ x\$feature_timeout_style = xy ] ; then
+ if [ "\${menu_show_once}" ]; then
+ unset menu_show_once
+ save_env menu_show_once
+ set timeout_style=menu
+ unset timeout
+ set timeout=60
+ elif [ "\${menu_auto_hide}" -a "\${last_boot_ok}" = "1" ]; then
+ set orig_timeout_style=\${timeout_style}
+ set orig_timeout=\${timeout}
@ -122,7 +114,7 @@ index 000000000..a10fe45bb
+fi
+EOF
diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
index 13a3a6bc7..ab634393a 100644
index d7d423b2eaf..18fe02cefd8 100644
--- a/util/grub.d/30_os-prober.in
+++ b/util/grub.d/30_os-prober.in
@@ -42,6 +42,7 @@ if [ -z "${OSPROBED}" ] ; then
@ -133,7 +125,7 @@ index 13a3a6bc7..ab634393a 100644
# TRANSLATORS: it refers on the OS residing on device %s
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
hints=""
@@ -102,6 +103,7 @@ for OS in ${OSPROBED} ; do
@@ -106,6 +107,7 @@ for OS in ${OSPROBED} ; do
case ${BOOT} in
chain)
@ -141,7 +133,7 @@ index 13a3a6bc7..ab634393a 100644
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
cat << EOF
@@ -132,6 +134,7 @@ EOF
@@ -136,6 +138,7 @@ EOF
EOF
;;
efi)
@ -149,7 +141,7 @@ index 13a3a6bc7..ab634393a 100644
EFIPATH=${DEVICE#*@}
DEVICE=${DEVICE%@*}
@@ -176,6 +179,7 @@ EOF
@@ -180,6 +183,7 @@ EOF
LINITRD="${LINITRD#/boot}"
fi
@ -157,7 +149,7 @@ index 13a3a6bc7..ab634393a 100644
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
recovery_params="$(echo "${LPARAMS}" | grep single)" || true
counter=1
@@ -249,6 +253,7 @@ EOF
@@ -261,6 +265,7 @@ EOF
done
;;
hurd)
@ -165,7 +157,7 @@ index 13a3a6bc7..ab634393a 100644
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
cat << EOF
menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class hurd --class gnu --class os \$menuentry_id_option 'osprober-gnuhurd-/boot/gnumach.gz-false-$(grub_get_device_id "${DEVICE}")' {
@@ -275,6 +280,7 @@ EOF
@@ -287,6 +292,7 @@ EOF
EOF
;;
minix)
@ -173,8 +165,8 @@ index 13a3a6bc7..ab634393a 100644
cat << EOF
menuentry "${LONGNAME} (on ${DEVICE}, Multiboot)" {
EOF
@@ -306,3 +312,15 @@ EOF
esac
@@ -303,3 +309,15 @@ EOF
;;
esac
done
+

View File

@ -33,27 +33,27 @@ and a symlink to grub-boot-success.timer should be added to
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
[makhomed: grub-boot-success.timer: Only run if not in a container]
Signed-off-by: Gena Makhomed <makhomed@gmail.com>
[rharwood: migrate to h2m]
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
(cherry-picked from commit 555625062cbb10388bb706620e2d8839644fc015)
---
Makefile.util.def | 7 ++
util/grub-set-bootflag.c | 160 +++++++++++++++++++++++++++++++++++++++++
util/grub-set-bootflag.c | 172 +++++++++++++++++++++++++++++++++++++++++
conf/Makefile.extra-dist | 3 +
docs/grub-boot-success.service | 6 ++
docs/grub-boot-success.timer | 7 ++
util/grub-set-bootflag.1 | 20 ++++++
6 files changed, 203 insertions(+)
docs/man/grub-set-bootflag.h2m | 2 +
6 files changed, 197 insertions(+)
create mode 100644 util/grub-set-bootflag.c
create mode 100644 docs/grub-boot-success.service
create mode 100644 docs/grub-boot-success.timer
create mode 100644 util/grub-set-bootflag.1
create mode 100644 docs/man/grub-set-bootflag.h2m
diff --git a/Makefile.util.def b/Makefile.util.def
index 5a8c390a1..5da553932 100644
index 5b9f85d4869..01096ded815 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -1435,3 +1435,10 @@ program = {
ldadd = grub-core/gnulib/libgnu.a;
@@ -1468,3 +1468,10 @@ program = {
ldadd = grub-core/lib/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
};
+
@ -65,10 +65,10 @@ index 5a8c390a1..5da553932 100644
+};
diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c
new file mode 100644
index 000000000..bb198f023
index 00000000000..d506f7e75bc
--- /dev/null
+++ b/util/grub-set-bootflag.c
@@ -0,0 +1,160 @@
@@ -0,0 +1,172 @@
+/* grub-set-bootflag.c - tool to set boot-flags in the grubenv. */
+/*
+ * GRUB -- GRand Unified Bootloader
@ -102,6 +102,8 @@ index 000000000..bb198f023
+#include <string.h>
+#include <unistd.h>
+
+#include "progname.h"
+
+#define GRUBENV "/" GRUB_BOOT_DIR_NAME "/" GRUB_DIR_NAME "/" GRUB_ENVBLK_DEFCFG
+#define GRUBENV_SIZE 1024
+
@ -111,13 +113,13 @@ index 000000000..bb198f023
+ NULL
+};
+
+static void usage(void)
+static void usage(FILE *out)
+{
+ int i;
+
+ fprintf (stderr, "Usage: 'grub-set-bootflag <bootflag>', where <bootflag> is one of:\n");
+ fprintf (out, "Usage: 'grub-set-bootflag <bootflag>', where <bootflag> is one of:\n");
+ for (i = 0; bootflags[i]; i++)
+ fprintf (stderr, " %s\n", bootflags[i]);
+ fprintf (out, " %s\n", bootflags[i]);
+}
+
+int main(int argc, char *argv[])
@ -130,9 +132,19 @@ index 000000000..bb198f023
+
+ if (argc != 2)
+ {
+ usage();
+ usage (stderr);
+ return 1;
+ }
+ else if (!strcmp (argv[1], "--help"))
+ {
+ usage (stdout);
+ return 0;
+ }
+ else if (!strcmp (argv[1], "--version"))
+ {
+ printf ("grub-set-bootflag (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
+ return 0;
+ }
+
+ for (i = 0; bootflags[i]; i++)
+ if (!strcmp (argv[1], bootflags[i]))
@ -140,7 +152,7 @@ index 000000000..bb198f023
+ if (!bootflags[i])
+ {
+ fprintf (stderr, "Invalid bootflag: '%s'\n", argv[1]);
+ usage();
+ usage (stderr);
+ return 1;
+ }
+
@ -230,10 +242,10 @@ index 000000000..bb198f023
+ return 0;
+}
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
index 39eb94bde..5946ec24a 100644
index 5e7126f9878..26ac8765e30 100644
--- a/conf/Makefile.extra-dist
+++ b/conf/Makefile.extra-dist
@@ -14,6 +14,9 @@ EXTRA_DIST += util/import_unicode.py
@@ -15,6 +15,9 @@ EXTRA_DIST += docs/man
EXTRA_DIST += docs/autoiso.cfg
EXTRA_DIST += docs/grub.cfg
EXTRA_DIST += docs/osdetect.cfg
@ -245,7 +257,7 @@ index 39eb94bde..5946ec24a 100644
diff --git a/docs/grub-boot-success.service b/docs/grub-boot-success.service
new file mode 100644
index 000000000..80e79584c
index 00000000000..80e79584c91
--- /dev/null
+++ b/docs/grub-boot-success.service
@@ -0,0 +1,6 @@
@ -257,7 +269,7 @@ index 000000000..80e79584c
+ExecStart=/usr/sbin/grub2-set-bootflag boot_success
diff --git a/docs/grub-boot-success.timer b/docs/grub-boot-success.timer
new file mode 100644
index 000000000..406f17200
index 00000000000..406f1720056
--- /dev/null
+++ b/docs/grub-boot-success.timer
@@ -0,0 +1,7 @@
@ -268,29 +280,11 @@ index 000000000..406f17200
+
+[Timer]
+OnActiveSec=2min
diff --git a/util/grub-set-bootflag.1 b/util/grub-set-bootflag.1
diff --git a/docs/man/grub-set-bootflag.h2m b/docs/man/grub-set-bootflag.h2m
new file mode 100644
index 000000000..57801da22
index 00000000000..94ec0b92ede
--- /dev/null
+++ b/util/grub-set-bootflag.1
@@ -0,0 +1,20 @@
+.TH GRUB-SET-BOOTFLAG 1 "Tue Jun 12 2018"
+.SH NAME
+\fBgrub-set-bootflag\fR \(em Set a bootflag in the GRUB environment block.
+
+.SH SYNOPSIS
+\fBgrub-set-bootflag\fR <\fIBOOTFLAG\fR>
+
+.SH DESCRIPTION
+\fBgrub-set-bootflag\fR is a command line to set bootflags in GRUB's
+stored environment.
+
+.SH COMMANDS
+.TP
+\fBBOOTFLAG\fR
+.RS 7
+Bootflag to set, one of \fIboot_success\fR or \fIshow_menu_once\fR.
+.RE
+
+.SH SEE ALSO
+.BR "info grub"
+++ b/docs/man/grub-set-bootflag.h2m
@@ -0,0 +1,2 @@
+[NAME]
+grub-set-bootflag \- set a bootflag in the GRUB environment block

View File

@ -16,7 +16,7 @@ Signed-off-by: Hans de Goede <hdegoede@redhat.com>
diff --git a/docs/grub-boot-indeterminate.service b/docs/grub-boot-indeterminate.service
new file mode 100644
index 000000000..6c8dcb186
index 00000000000..6c8dcb186b6
--- /dev/null
+++ b/docs/grub-boot-indeterminate.service
@@ -0,0 +1,11 @@

View File

@ -9,10 +9,10 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/gentpl.py b/gentpl.py
index bf8439fa7..a8cd54055 100644
index bfab2113a1d..6cad9b8231f 100644
--- a/gentpl.py
+++ b/gentpl.py
@@ -589,11 +589,21 @@ def platform_conditional(platform, closure):
@@ -594,11 +594,21 @@ def platform_conditional(platform, closure):
# };
#
def foreach_enabled_platform(defn, closure):
@ -35,7 +35,7 @@ index bf8439fa7..a8cd54055 100644
for platform in GRUB_PLATFORMS:
platform_conditional(platform, closure)
@@ -652,6 +662,8 @@ def first_time(defn, snippet):
@@ -657,6 +667,8 @@ def first_time(defn, snippet):
def is_platform_independent(defn):
if 'enable' in defn:
return False

View File

@ -1,6 +1,6 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 11 Jul 2018 13:43:34 -0400
Date: Thu, 11 Jul 2019 11:04:24 +0200
Subject: [PATCH] gentpl: add 'pc' firmware type
Signed-off-by: Peter Jones <pjones@redhat.com>
@ -9,14 +9,14 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
1 file changed, 1 insertion(+)
diff --git a/gentpl.py b/gentpl.py
index a8cd54055..baac6a2af 100644
index 6cad9b8231f..597129a2bc4 100644
--- a/gentpl.py
+++ b/gentpl.py
@@ -49,6 +49,7 @@ GROUPS["arm"] = [ "arm_uboot", "arm_efi", "arm_coreboot" ]
GROUPS["arm64"] = [ "arm64_efi" ]
@@ -52,6 +52,7 @@ GROUPS["riscv32"] = [ "riscv32_efi" ]
GROUPS["riscv64"] = [ "riscv64_efi" ]
# Groups based on firmware
+GROUPS["pc"] = [ "i386_pc" ]
GROUPS["efi"] = [ "i386_efi", "x86_64_efi", "ia64_efi", "arm_efi", "arm64_efi" ]
GROUPS["efi"] = [ "i386_efi", "x86_64_efi", "ia64_efi", "arm_efi", "arm64_efi",
"loongarch64_efi", "riscv32_efi", "riscv64_efi" ]
GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ]
GROUPS["uboot"] = [ "arm_uboot" ]

View File

@ -9,7 +9,7 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c
index 2bf15447f..f208d1b18 100644
index ed04f05ad21..1f7e1b63557 100644
--- a/grub-core/net/efi/net.c
+++ b/grub-core/net/efi/net.c
@@ -1324,7 +1324,9 @@ grub_efi_net_boot_from_https (void)

View File

@ -12,7 +12,7 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
1 file changed, 19 insertions(+)
diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c
index 3f61fd2fa..243acbaa3 100644
index de28badccb0..b94dbc68eef 100644
--- a/grub-core/net/efi/http.c
+++ b/grub-core/net/efi/http.c
@@ -4,6 +4,7 @@
@ -23,7 +23,7 @@ index 3f61fd2fa..243acbaa3 100644
static void
http_configure (struct grub_efi_net_device *dev, int prefer_ip6)
@@ -351,6 +352,24 @@ grub_efihttp_open (struct grub_efi_net_device *dev,
@@ -342,6 +343,24 @@ grub_efihttp_open (struct grub_efi_net_device *dev,
grub_err_t err;
grub_off_t size;
char *buf;

View File

@ -17,11 +17,11 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
3 files changed, 64 insertions(+), 16 deletions(-)
diff --git a/configure.ac b/configure.ac
index 9ab683fef..819212095 100644
index fcfbcbb664d..c17e83acf87 100644
--- a/configure.ac
+++ b/configure.ac
@@ -850,11 +850,23 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p
TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
@@ -914,11 +914,23 @@ if test "x$target_cpu" = xloongarch64; then
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -Wa,-mla-global-with-abs"
fi
+# Should grub utils get the host CFLAGS, or the target CFLAGS?
@ -45,7 +45,7 @@ index 9ab683fef..819212095 100644
AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
grub_cv_target_cc_soft_float=no
if test "x$target_cpu" = xarm64; then
@@ -1939,6 +1951,41 @@ HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
@@ -2111,6 +2123,41 @@ HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
@ -88,19 +88,19 @@ index 9ab683fef..819212095 100644
GRUB_PLATFORM="${platform}"
diff --git a/conf/Makefile.common b/conf/Makefile.common
index 1ecb921db..b93879804 100644
index 6262f21a772..54f0f7f7664 100644
--- a/conf/Makefile.common
+++ b/conf/Makefile.common
@@ -40,24 +40,25 @@ CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1
CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
STRIPFLAGS_KERNEL = -R .eh_frame -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx -R .note.gnu.property -R .gnu.build.attributes
@@ -50,24 +50,25 @@ else
endif
endif
-CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding
-LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
-LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r
-CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
-CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
+CFLAGS_MODULE = $(TARGET_CFLAGS) $(CFLAGS_PLATFORM) -ffreestanding
+LDFLAGS_MODULE = $(TARGET_LDFLAGS) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
+LDFLAGS_MODULE = $(TARGET_LDFLAGS) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r
+CPPFLAGS_MODULE = $(TARGET_CPPFLAGS) $(CPPFLAGS_DEFAULT) $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
+CCASFLAGS_MODULE = $(TARGET_CCASFLAGS) $(CCASFLAGS_DEFAULT) $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
@ -129,10 +129,10 @@ index 1ecb921db..b93879804 100644
# Other variables
diff --git a/gentpl.py b/gentpl.py
index 6409736e8..1e4635f44 100644
index 597129a2bc4..5826a6b14e8 100644
--- a/gentpl.py
+++ b/gentpl.py
@@ -694,10 +694,10 @@ def module(defn, platform):
@@ -699,10 +699,10 @@ def module(defn, platform):
var_set(cname(defn) + "_SOURCES", platform_sources(defn, platform) + " ## platform sources")
var_set("nodist_" + cname(defn) + "_SOURCES", platform_nodist_sources(defn, platform) + " ## platform nodist sources")
var_set(cname(defn) + "_LDADD", platform_ldadd(defn, platform))

View File

@ -1,6 +1,6 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 12 Jul 2018 11:00:45 -0400
Date: Thu, 11 Jul 2019 13:01:41 +0200
Subject: [PATCH] Rework how the fdt command builds.
Trying to avoid all variants of:
@ -13,19 +13,22 @@ grub_fdt_load in xen_boot is not defined
grub_fdt_unload in xen_boot is not defined
Signed-off-by: Peter Jones <pjones@redhat.com>
[javierm: Fix build with platform emu, aarch64, and risc-v]
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/Makefile.core.def | 5 ++---
grub-core/Makefile.core.def | 4 ++--
grub-core/lib/fdt.c | 2 --
grub-core/loader/efi/fdt.c | 2 ++
include/grub/fdt.h | 4 ++++
include/grub/fdt.h | 6 ++++++
grub-core/Makefile.am | 1 +
5 files changed, 9 insertions(+), 5 deletions(-)
5 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index e35217b86..cf3d549d2 100644
index 56eb6a828e8..4629c179e40 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -166,7 +166,6 @@ kernel = {
@@ -188,7 +188,6 @@ kernel = {
arm_coreboot = kern/arm/coreboot/init.c;
arm_coreboot = kern/arm/coreboot/timer.c;
arm_coreboot = kern/arm/coreboot/coreboot.S;
@ -33,24 +36,16 @@ index e35217b86..cf3d549d2 100644
arm_coreboot = bus/fdt.c;
arm_coreboot = term/ps2.c;
arm_coreboot = term/arm/pl050.c;
@@ -317,6 +316,8 @@ kernel = {
arm64 = kern/arm64/dl.c;
arm64 = kern/arm64/dl_helper.c;
@@ -370,6 +369,8 @@ kernel = {
riscv64 = kern/riscv/cache_flush.S;
riscv64 = kern/riscv/dl.c;
+ fdt = lib/fdt.c;
+
emu = disk/host.c;
emu = kern/emu/cache_s.S;
emu = kern/emu/hostdisk.c;
@@ -1714,7 +1715,6 @@ module = {
arm_uboot = loader/arm/linux.c;
arm64 = loader/arm64/linux.c;
emu = loader/emu/linux.c;
- fdt = lib/fdt.c;
common = loader/linux.c;
common = lib/cmdline.c;
@@ -1725,7 +1725,6 @@ module = {
@@ -1882,7 +1883,6 @@ module = {
module = {
name = fdt;
efi = loader/efi/fdt.c;
@ -59,7 +54,7 @@ index e35217b86..cf3d549d2 100644
};
diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c
index 0d371c563..37e04bd69 100644
index 73cfa94a2df..fbf749e1d61 100644
--- a/grub-core/lib/fdt.c
+++ b/grub-core/lib/fdt.c
@@ -21,8 +21,6 @@
@ -72,12 +67,12 @@ index 0d371c563..37e04bd69 100644
#define FDT_BEGIN_NODE 0x00000001
diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
index a4c6e8036..a9dbcfdfe 100644
index 439964b9ca6..e08d8738afc 100644
--- a/grub-core/loader/efi/fdt.c
+++ b/grub-core/loader/efi/fdt.c
@@ -26,6 +26,8 @@
#include <grub/efi/fdtload.h>
@@ -27,6 +27,8 @@
#include <grub/efi/memory.h>
#include <grub/cpu/efi/memory.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+
@ -85,27 +80,29 @@ index a4c6e8036..a9dbcfdfe 100644
static void *fdt;
diff --git a/include/grub/fdt.h b/include/grub/fdt.h
index 158b1bc4b..6ee57e11a 100644
index e609c7e4111..3514aa4a5b6 100644
--- a/include/grub/fdt.h
+++ b/include/grub/fdt.h
@@ -19,6 +19,8 @@
@@ -19,6 +19,9 @@
#ifndef GRUB_FDT_HEADER
#define GRUB_FDT_HEADER 1
+#if defined(__arm__) || defined(__aarch64__)
+#if !defined(GRUB_MACHINE_EMU) && \
+ (defined(__arm__) || defined(__aarch64__) || defined(__riscv))
+
#include <grub/types.h>
#include <grub/symbol.h>
@@ -141,4 +143,6 @@ int EXPORT_FUNC(grub_fdt_set_prop) (void *fdt, unsigned int nodeoffset, const ch
@@ -144,4 +147,7 @@ int EXPORT_FUNC(grub_fdt_set_prop) (void *fdt, unsigned int nodeoffset, const ch
grub_fdt_set_prop ((fdt), (nodeoffset), "reg", reg_64, 16); \
})
+#endif /* defined(__arm__) || defined(__aarch64__) */
+#endif /* !defined(GRUB_MACHINE_EMU) && \
+ (defined(__arm__) || defined(__aarch64__) || defined(__riscv)) */
+
#endif /* ! GRUB_FDT_HEADER */
diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
index 3781bb9cb..406265250 100644
index b7192a3da82..7953ba95399 100644
--- a/grub-core/Makefile.am
+++ b/grub-core/Makefile.am
@@ -76,6 +76,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/sb.h

View File

@ -9,10 +9,10 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
1 file changed, 20 insertions(+)
diff --git a/configure.ac b/configure.ac
index 819212095..9323c1254 100644
index c17e83acf87..3f3a170ab17 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1234,6 +1234,26 @@ if test "x$target_cpu" = xarm; then
@@ -1346,6 +1346,26 @@ if test "x$target_cpu" = xarm; then
done
])

View File

@ -8,16 +8,18 @@ http_path: /foo/bar
http_url: http://www.example.com/foo/bar
Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Stephen Benjamin <stephen@redhat.com>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/kern/main.c | 10 +++++-
grub-core/net/efi/http.c | 82 ++++++++++++++++++++++++++++++++++++------------
2 files changed, 71 insertions(+), 21 deletions(-)
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
index da47b18b5..dcf48726d 100644
index 463dafdba02..7347a8de676 100644
--- a/grub-core/kern/main.c
+++ b/grub-core/kern/main.c
@@ -130,11 +130,19 @@ grub_set_prefix_and_root (void)
@@ -131,11 +131,19 @@ grub_set_prefix_and_root (void)
if (fwdevice && fwpath)
{
char *fw_path;
@ -39,7 +41,7 @@ index da47b18b5..dcf48726d 100644
}
}
diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c
index 243acbaa3..2a9624dac 100644
index b94dbc68eef..5e97f5d5e70 100644
--- a/grub-core/net/efi/http.c
+++ b/grub-core/net/efi/http.c
@@ -9,10 +9,52 @@
@ -56,7 +58,7 @@ index 243acbaa3..2a9624dac 100644
+ const char *rest, *http_server, *http_path = NULL;
+
+ http_server = grub_env_get ("root");
+ https = grub_strncmp (http_server, "https", 5) ? 1 : 0;
+ https = (grub_strncmp (http_server, "https", 5) == 0) ? 1 : 0;
+
+ /* extract http server + port */
+ if (http_server)
@ -95,23 +97,19 @@ index 243acbaa3..2a9624dac 100644
grub_efi_http_t *http = dev->http;
@@ -352,32 +394,32 @@ grub_efihttp_open (struct grub_efi_net_device *dev,
@@ -343,32 +385,32 @@ grub_efihttp_open (struct grub_efi_net_device *dev,
grub_err_t err;
grub_off_t size;
char *buf;
- char *root_url;
- grub_efi_ipv6_address_t address;
- const char *rest;
+ char *file_name;
+ char *file_name = NULL;
+ const char *http_path;
- if (grub_efi_string_to_ip6_address (file->device->net->server, &address, &rest) && *rest == 0)
- root_url = grub_xasprintf ("%s://[%s]", type ? "https" : "http", file->device->net->server);
+ /* If path is relative, prepend http_path */
+ http_path = grub_env_get ("http_path");
+ if (http_path && file->device->net->name[0] != '/')
+ file_name = grub_xasprintf ("%s/%s", http_path, file->device->net->name);
else
- else
- root_url = grub_xasprintf ("%s://%s", type ? "https" : "http", file->device->net->server);
- if (root_url)
- {
@ -121,15 +119,18 @@ index 243acbaa3..2a9624dac 100644
- }
- else
- {
- return grub_errno;
+ /* If path is relative, prepend http_path */
+ http_path = grub_env_get ("http_path");
+ if (http_path && file->device->net->name[0] != '/') {
+ file_name = grub_xasprintf ("%s/%s", http_path, file->device->net->name);
+ if (!file_name)
return grub_errno;
- }
+ file_name = grub_strdup (file->device->net->name);
+ }
- err = efihttp_request (dev->http, file->device->net->server, file->device->net->name, type, 1, 0);
+ if (!file_name)
+ return grub_errno;
+
+ err = efihttp_request (dev->http, file->device->net->server, file_name, type, 1, 0);
+ err = efihttp_request (dev->http, file->device->net->server,
+ file_name ? file_name : file->device->net->name, type, 1, 0);
if (err != GRUB_ERR_NONE)
- return err;
+ {
@ -138,7 +139,8 @@ index 243acbaa3..2a9624dac 100644
+ }
- err = efihttp_request (dev->http, file->device->net->server, file->device->net->name, type, 0, &size);
+ err = efihttp_request (dev->http, file->device->net->server, file_name, type, 0, &size);
+ err = efihttp_request (dev->http, file->device->net->server,
+ file_name ? file_name : file->device->net->name, type, 0, &size);
+ grub_free (file_name);
if (err != GRUB_ERR_NONE)
- return err;

View File

@ -5,52 +5,12 @@ Subject: [PATCH] Make grub_error() more verbose
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/kern/efi/mm.c | 17 ++++++++++++++---
grub-core/kern/err.c | 13 +++++++++++--
include/grub/err.h | 5 ++++-
3 files changed, 29 insertions(+), 6 deletions(-)
grub-core/kern/err.c | 13 +++++++++++--
include/grub/err.h | 8 ++++++--
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
index 5cdf6c943..7692e63ba 100644
--- a/grub-core/kern/efi/mm.c
+++ b/grub-core/kern/efi/mm.c
@@ -157,12 +157,20 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address,
/* Limit the memory access to less than 4GB for 32-bit platforms. */
if (address > GRUB_EFI_MAX_USABLE_ADDRESS)
- return 0;
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("invalid memory address (0x%llx > 0x%llx)"),
+ address, GRUB_EFI_MAX_USABLE_ADDRESS);
+ return NULL;
+ }
b = grub_efi_system_table->boot_services;
status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address);
if (status != GRUB_EFI_SUCCESS)
- return 0;
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ return NULL;
+ }
if (address == 0)
{
@@ -172,7 +180,10 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address,
status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address);
grub_efi_free_pages (0, pages);
if (status != GRUB_EFI_SUCCESS)
- return 0;
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ return NULL;
+ }
}
grub_efi_store_alloc (address, pages);
diff --git a/grub-core/kern/err.c b/grub-core/kern/err.c
index 53c734de7..aebfe0cf8 100644
index 53c734de70e..aebfe0cf839 100644
--- a/grub-core/kern/err.c
+++ b/grub-core/kern/err.c
@@ -33,15 +33,24 @@ static struct grub_error_saved grub_error_stack_items[GRUB_ERROR_STACK_SIZE];
@ -81,17 +41,20 @@ index 53c734de7..aebfe0cf8 100644
return n;
diff --git a/include/grub/err.h b/include/grub/err.h
index 1590c688e..9b830757d 100644
index 1c07034cd60..3c587b9b822 100644
--- a/include/grub/err.h
+++ b/include/grub/err.h
@@ -84,7 +84,10 @@ struct grub_error_saved
@@ -86,8 +86,12 @@ struct grub_error_saved
extern grub_err_t EXPORT_VAR(grub_errno);
extern char EXPORT_VAR(grub_errmsg)[GRUB_MAX_ERRMSG];
-grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *fmt, ...);
+grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *file, const int line, const char *fmt, ...);
-grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *fmt, ...)
- __attribute__ ((format (GNU_PRINTF, 2, 3)));
+grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *file, const int line, const char *fmt, ...)
+ __attribute__ ((format (GNU_PRINTF, 4, 5)));
+
+#define grub_error(n, fmt, ...) grub_error (n, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
+
+
void EXPORT_FUNC(grub_fatal) (const char *fmt, ...) __attribute__ ((noreturn));
void EXPORT_FUNC(grub_error_push) (void);

View File

@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 31 Aug 2018 16:42:03 -0400
Subject: [PATCH] Make "reset" an alias for the "reboot" command.
I'm really tired of half the tools I get to use having one and the other half
having the other.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/commands/reboot.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/grub-core/commands/reboot.c b/grub-core/commands/reboot.c
index 46d364c99a9..f5cc2283636 100644
--- a/grub-core/commands/reboot.c
+++ b/grub-core/commands/reboot.c
@@ -32,15 +32,18 @@ grub_cmd_reboot (grub_command_t cmd __attribute__ ((unused)),
grub_reboot ();
}
-static grub_command_t cmd;
+static grub_command_t reboot_cmd, reset_cmd;
GRUB_MOD_INIT(reboot)
{
- cmd = grub_register_command ("reboot", grub_cmd_reboot,
- 0, N_("Reboot the computer."));
+ reboot_cmd = grub_register_command ("reboot", grub_cmd_reboot,
+ 0, N_("Reboot the computer."));
+ reset_cmd = grub_register_command ("reset", grub_cmd_reboot,
+ 0, N_("Reboot the computer."));
}
GRUB_MOD_FINI(reboot)
{
- grub_unregister_command (cmd);
+ grub_unregister_command (reboot_cmd);
+ grub_unregister_command (reset_cmd);
}

View File

@ -0,0 +1,134 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 11 Sep 2018 14:20:37 -0400
Subject: [PATCH] Add a "version" command
This adds a command that shows you info about grub's version, the grub
target platform, the compiler version, and if you built with
--with-rpm-version=<string>, the rpm package version.
Signed-off-by: Peter Jones <pjones@redhat.com>
[rharwood: don't say GNU, commit message cleanup]
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
configure.ac | 13 ++++++++++
grub-core/Makefile.core.def | 5 ++++
grub-core/commands/version.c | 56 ++++++++++++++++++++++++++++++++++++++++++++
config.h.in | 1 +
4 files changed, 75 insertions(+)
create mode 100644 grub-core/commands/version.c
diff --git a/configure.ac b/configure.ac
index 3f3a170ab17..2175aa56997 100644
--- a/configure.ac
+++ b/configure.ac
@@ -289,6 +289,19 @@ AC_SUBST(target_cpu)
AC_SUBST(platform)
# Define default variables
+have_with_rpm_version=n
+AC_ARG_WITH([rpm_version],
+ AS_HELP_STRING([--with-rpm-version=VERSION],
+ [set the rpm package version [[guessed]]]),
+ [have_with_rpm_version=y],
+ [have_with_rpm_version=n])
+if test x$have_with_rpm_version = xy; then
+ rpm_version="$with_rpm_version"
+else
+ rpm_version=""
+fi
+GRUB_RPM_VERSION="$rpm_version"
+AC_SUBST(GRUB_RPM_VERSION)
have_with_bootdir=n
AC_ARG_WITH([bootdir],
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 4629c179e40..f26c689723c 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -598,6 +598,11 @@ image = {
enable = mips_loongson;
};
+module = {
+ name = version;
+ common = commands/version.c;
+};
+
module = {
name = disk;
common = lib/disk.c;
diff --git a/grub-core/commands/version.c b/grub-core/commands/version.c
new file mode 100644
index 00000000000..de0acb07ba2
--- /dev/null
+++ b/grub-core/commands/version.c
@@ -0,0 +1,56 @@
+/* version.c - Command to print the grub version and build info. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/term.h>
+#include <grub/time.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/extcmd.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_err_t
+grub_cmd_version (grub_command_t cmd UNUSED, int argc, char **args UNUSED)
+{
+ if (argc != 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("no arguments expected"));
+
+ grub_printf (_("GRUB version %s\n"), PACKAGE_VERSION);
+ grub_printf (_("Platform %s-%s\n"), GRUB_TARGET_CPU, GRUB_PLATFORM);
+ if (grub_strlen(GRUB_RPM_VERSION) != 0)
+ grub_printf (_("RPM package version %s\n"), GRUB_RPM_VERSION);
+ grub_printf (_("Compiler version %s\n"), __VERSION__);
+
+ return 0;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(version)
+{
+ cmd = grub_register_command ("version", grub_cmd_version, NULL,
+ N_("Print version and build information."));
+}
+
+GRUB_MOD_FINI(version)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/config.h.in b/config.h.in
index 9b1d3997185..d294d2c653f 100644
--- a/config.h.in
+++ b/config.h.in
@@ -63,6 +63,7 @@
# define GRUB_TARGET_CPU "@GRUB_TARGET_CPU@"
# define GRUB_PLATFORM "@GRUB_PLATFORM@"
+# define GRUB_RPM_VERSION "@GRUB_RPM_VERSION@"
# define GRUB_STACK_PROTECTOR_INIT @GRUB_STACK_PROTECTOR_INIT@

View File

@ -0,0 +1,74 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 11 Sep 2018 15:58:29 -0400
Subject: [PATCH] Add more dprintf, and nerf dprintf in script.c
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/disk/diskfilter.c | 3 +++
grub-core/disk/efi/efidisk.c | 1 +
grub-core/kern/device.c | 1 +
grub-core/script/script.c | 5 +++++
4 files changed, 10 insertions(+)
diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c
index 21e2395111a..c35ce8915b2 100644
--- a/grub-core/disk/diskfilter.c
+++ b/grub-core/disk/diskfilter.c
@@ -188,6 +188,8 @@ scan_disk (const char *name, int accept_diskfilter)
grub_disk_t disk;
static int scan_depth = 0;
+ grub_dprintf ("diskfilter", "scanning %s\n", name);
+
if (!accept_diskfilter && is_valid_diskfilter_name (name))
return 0;
@@ -1247,6 +1249,7 @@ insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id,
the same. */
if (pv->disk && grub_disk_native_sectors (disk) >= pv->part_size)
return GRUB_ERR_NONE;
+ grub_dprintf ("diskfilter", "checking %s\n", disk->name);
pv->disk = grub_disk_open (disk->name);
if (!pv->disk)
return grub_errno;
diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
index 3b5ed569133..822005456eb 100644
--- a/grub-core/disk/efi/efidisk.c
+++ b/grub-core/disk/efi/efidisk.c
@@ -865,6 +865,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
return 0;
}
+ grub_dprintf ("efidisk", "getting disk for %s\n", device_name);
parent = grub_disk_open (device_name);
grub_free (dup_dp);
diff --git a/grub-core/kern/device.c b/grub-core/kern/device.c
index 670e213cf3c..d019637470d 100644
--- a/grub-core/kern/device.c
+++ b/grub-core/kern/device.c
@@ -34,6 +34,7 @@ grub_device_open (const char *name)
{
grub_device_t dev = 0;
+ grub_dprintf ("device", "opening device %s\n", name);
if (! name)
{
name = grub_env_get ("root");
diff --git a/grub-core/script/script.c b/grub-core/script/script.c
index ec4d4337c66..844e8343ca7 100644
--- a/grub-core/script/script.c
+++ b/grub-core/script/script.c
@@ -22,6 +22,11 @@
#include <grub/parser.h>
#include <grub/mm.h>
+#ifdef grub_dprintf
+#undef grub_dprintf
+#endif
+#define grub_dprintf(no, fmt, ...)
+
/* It is not possible to deallocate the memory when a syntax error was
found. Because of that it is required to keep track of all memory
allocations. The memory is freed in case of an error, or assigned

View File

@ -0,0 +1,185 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 11 Jul 2019 18:03:25 +0200
Subject: [PATCH] Attempt to fix up all the places -Wsign-compare=error finds.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/kern/emu/misc.c | 2 +-
grub-core/lib/reed_solomon.c | 4 ++--
grub-core/osdep/linux/blocklist.c | 2 +-
grub-core/osdep/linux/getroot.c | 2 +-
util/grub-fstest.c | 2 +-
util/grub-menulst2cfg.c | 2 +-
util/grub-mkfont.c | 13 +++++++------
util/grub-probe.c | 2 +-
util/setup.c | 2 +-
9 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c
index 16c79bc9488..d145e5796b3 100644
--- a/grub-core/kern/emu/misc.c
+++ b/grub-core/kern/emu/misc.c
@@ -189,7 +189,7 @@ grub_util_get_image_size (const char *path)
sz = ftello (f);
if (sz < 0)
grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
- if (sz != (size_t) sz)
+ if (sz > (off_t)(GRUB_SIZE_MAX >> 1))
grub_util_error (_("file `%s' is too big"), path);
ret = (size_t) sz;
diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c
index 562bd2e3e3f..5fee7f2a1a4 100644
--- a/grub-core/lib/reed_solomon.c
+++ b/grub-core/lib/reed_solomon.c
@@ -162,7 +162,7 @@ static void
rs_encode (gf_single_t *data, grub_size_t s, grub_size_t rs)
{
gf_single_t *rs_polynomial;
- int i, j;
+ unsigned int i, j;
gf_single_t *m;
m = xcalloc (s + rs, sizeof (gf_single_t));
grub_memcpy (m, data, s * sizeof (gf_single_t));
@@ -333,7 +333,7 @@ static void
encode_block (gf_single_t *ptr, grub_size_t s,
gf_single_t *rptr, grub_size_t rs)
{
- int i, j;
+ unsigned int i, j;
for (i = 0; i < SECTOR_SIZE; i++)
{
grub_size_t ds = (s + SECTOR_SIZE - 1 - i) / SECTOR_SIZE;
diff --git a/grub-core/osdep/linux/blocklist.c b/grub-core/osdep/linux/blocklist.c
index 2efee2c2aee..902cfee53ae 100644
--- a/grub-core/osdep/linux/blocklist.c
+++ b/grub-core/osdep/linux/blocklist.c
@@ -109,7 +109,7 @@ grub_install_get_blocklist (grub_device_t root_dev,
else
{
struct fiemap *fie2;
- int i;
+ unsigned int i;
fie2 = xmalloc (sizeof (*fie2)
+ fie1.fm_mapped_extents
* sizeof (fie1.fm_extents[1]));
diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c
index 74a48c03026..477fb420992 100644
--- a/grub-core/osdep/linux/getroot.c
+++ b/grub-core/osdep/linux/getroot.c
@@ -233,7 +233,7 @@ grub_find_root_devices_from_btrfs (const char *dir)
{
int fd;
struct btrfs_ioctl_fs_info_args fsi;
- int i, j = 0;
+ unsigned int i, j = 0;
char **ret;
fd = open (dir, 0);
diff --git a/util/grub-fstest.c b/util/grub-fstest.c
index 25ae52ab6f4..982ce9ed7d8 100644
--- a/util/grub-fstest.c
+++ b/util/grub-fstest.c
@@ -329,7 +329,7 @@ cmd_cmp (char *src, char *dest)
read_file (src, cmp_hook, ff);
{
- grub_uint64_t pre;
+ long long pre;
pre = ftell (ff);
fseek (ff, 0, SEEK_END);
if (pre != ftell (ff))
diff --git a/util/grub-menulst2cfg.c b/util/grub-menulst2cfg.c
index b80e15cc36e..1ea2a86e129 100644
--- a/util/grub-menulst2cfg.c
+++ b/util/grub-menulst2cfg.c
@@ -34,7 +34,7 @@ main (int argc, char **argv)
char *buf = NULL;
size_t bufsize = 0;
char *suffix = xstrdup ("");
- int suffixlen = 0;
+ size_t suffixlen = 0;
const char *out_fname = 0;
grub_util_host_init (&argc, &argv);
diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c
index 7624d7808b7..e8a914021b2 100644
--- a/util/grub-mkfont.c
+++ b/util/grub-mkfont.c
@@ -143,7 +143,8 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face,
int width, height;
int cuttop, cutbottom, cutleft, cutright;
grub_uint8_t *data;
- int mask, i, j, bitmap_size;
+ int mask, i, bitmap_size;
+ unsigned int j;
FT_GlyphSlot glyph;
int flag = FT_LOAD_RENDER | FT_LOAD_MONOCHROME;
FT_Error err;
@@ -188,7 +189,7 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face,
cuttop = cutbottom = cutleft = cutright = 0;
else
{
- for (cuttop = 0; cuttop < glyph->bitmap.rows; cuttop++)
+ for (cuttop = 0; cuttop < (long)glyph->bitmap.rows; cuttop++)
{
for (j = 0; j < glyph->bitmap.width; j++)
if (glyph->bitmap.buffer[j / 8 + cuttop * glyph->bitmap.pitch]
@@ -208,10 +209,10 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face,
break;
}
cutbottom = glyph->bitmap.rows - 1 - cutbottom;
- if (cutbottom + cuttop >= glyph->bitmap.rows)
+ if (cutbottom + cuttop >= (long)glyph->bitmap.rows)
cutbottom = 0;
- for (cutleft = 0; cutleft < glyph->bitmap.width; cutleft++)
+ for (cutleft = 0; cutleft < (long)glyph->bitmap.width; cutleft++)
{
for (j = 0; j < glyph->bitmap.rows; j++)
if (glyph->bitmap.buffer[cutleft / 8 + j * glyph->bitmap.pitch]
@@ -230,7 +231,7 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face,
break;
}
cutright = glyph->bitmap.width - 1 - cutright;
- if (cutright + cutleft >= glyph->bitmap.width)
+ if (cutright + cutleft >= (long)glyph->bitmap.width)
cutright = 0;
}
@@ -267,7 +268,7 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face,
mask = 0;
data = &glyph_info->bitmap[0] - 1;
- for (j = cuttop; j < height + cuttop; j++)
+ for (j = cuttop; j < (long)height + cuttop; j++)
for (i = cutleft; i < width + cutleft; i++)
add_pixel (&data, &mask,
glyph->bitmap.buffer[i / 8 + j * glyph->bitmap.pitch] &
diff --git a/util/grub-probe.c b/util/grub-probe.c
index 65c1ca3f8b6..08ae915e8d7 100644
--- a/util/grub-probe.c
+++ b/util/grub-probe.c
@@ -799,7 +799,7 @@ argp_parser (int key, char *arg, struct argp_state *state)
case 't':
{
- int i;
+ unsigned int i;
for (i = PRINT_FS; i < ARRAY_SIZE (targets); i++)
if (strcmp (arg, targets[i]) == 0)
diff --git a/util/setup.c b/util/setup.c
index 87a889ff7e3..7aab468b0eb 100644
--- a/util/setup.c
+++ b/util/setup.c
@@ -406,7 +406,7 @@ SETUP (const char *dir,
int is_ldm;
grub_err_t err;
grub_disk_addr_t *sectors;
- int i;
+ unsigned int i;
grub_fs_t fs;
unsigned int nsec, maxsec;

View File

@ -0,0 +1,47 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 11 Jul 2019 18:20:37 +0200
Subject: [PATCH] Don't use -Wno-sign-compare -Wno-conversion -Wno-error, do
use -Wextra.
Updated for grub-2.12 which introduced new sign comparison problems:
we're using -Wno-error=sign-compare
Signed-off-by: Peter Jones <pjones@redhat.com>
---
configure.ac | 8 ++++++++
conf/Makefile.common | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 2175aa56997..81240397384 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2147,6 +2147,14 @@ if test x"$enable_werror" != xno ; then
fi
fi
+AC_ARG_ENABLE([wextra],
+ [AS_HELP_STRING([--disable-wextra],
+ [do not use -Wextra when building GRUB])])
+if test x"$enable_wextra" != xno ; then
+ TARGET_CFLAGS="$TARGET_CFLAGS -Wextra"
+ HOST_CFLAGS="$HOST_CFLAGS -Wextra"
+fi
+
TARGET_CPP="$TARGET_CC -E"
TARGET_CCAS=$TARGET_CC
diff --git a/conf/Makefile.common b/conf/Makefile.common
index 54f0f7f7664..e53ff352407 100644
--- a/conf/Makefile.common
+++ b/conf/Makefile.common
@@ -76,7 +76,7 @@ grubconfdir = $(sysconfdir)/grub.d
platformdir = $(pkglibdir)/$(target_cpu)-$(platform)
starfielddir = $(pkgdatadir)/themes/starfield
-CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-error=attributes
+CFLAGS_GNULIB = -Wno-undef -Wno-error=sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-error=attributes
CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/lib/gnulib -I$(top_srcdir)/grub-core/lib/gnulib
CFLAGS_POSIX = -fno-builtin

View File

@ -6,18 +6,16 @@ Subject: [PATCH] Fix getroot.c's trampolines.
This makes the stack executable on most of the grub utilities, which is
bad, and rpmdiff complains about it.
Related: rhbz#1633646
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/osdep/linux/getroot.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c
index 4c5a13022..388a0f706 100644
index 477fb420992..b32582eb302 100644
--- a/grub-core/osdep/linux/getroot.c
+++ b/grub-core/osdep/linux/getroot.c
@@ -1264,22 +1264,20 @@ grub_util_get_grub_dev_os (const char *os_dev)
@@ -1261,22 +1261,20 @@ grub_util_get_grub_dev_os (const char *os_dev)
return grub_dev;
}

View File

@ -0,0 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 12 Jul 2019 10:06:50 +0200
Subject: [PATCH] Do not allow stack trampolines, anywhere.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
configure.ac | 3 +++
conf/Makefile.common | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 81240397384..ae7683d0693 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2155,6 +2155,9 @@ if test x"$enable_wextra" != xno ; then
HOST_CFLAGS="$HOST_CFLAGS -Wextra"
fi
+TARGET_CFLAGS="$TARGET_CFLAGS -Werror=trampolines -fno-trampolines"
+HOST_CFLAGS="$HOST_CFLAGS -Werror=trampolines -fno-trampolines"
+
TARGET_CPP="$TARGET_CC -E"
TARGET_CCAS=$TARGET_CC
diff --git a/conf/Makefile.common b/conf/Makefile.common
index e53ff352407..91ff6c905fb 100644
--- a/conf/Makefile.common
+++ b/conf/Makefile.common
@@ -76,7 +76,7 @@ grubconfdir = $(sysconfdir)/grub.d
platformdir = $(pkglibdir)/$(target_cpu)-$(platform)
starfielddir = $(pkgdatadir)/themes/starfield
-CFLAGS_GNULIB = -Wno-undef -Wno-error=sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-error=attributes
+CFLAGS_GNULIB = -Wno-undef -Wno-error=sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-error=attributes -Werror=trampolines -fno-trampolines
CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/lib/gnulib -I$(top_srcdir)/grub-core/lib/gnulib
CFLAGS_POSIX = -fno-builtin

View File

@ -23,10 +23,10 @@ Signed-off-by: Christian Glombek <lorbus@fedoraproject.org>
create mode 100644 util/grub.d/01_fallback_counting.in
diff --git a/Makefile.util.def b/Makefile.util.def
index 08cc98ddb..eca3dfa75 100644
index 01096ded815..0bb47c6d40a 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -448,6 +448,12 @@ script = {
@@ -461,6 +461,12 @@ script = {
installdir = grubconf;
};
@ -40,10 +40,10 @@ index 08cc98ddb..eca3dfa75 100644
name = '01_menu_auto_hide';
common = util/grub.d/01_menu_auto_hide.in;
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 6864e780f..c8a50b4fc 100644
index f26c689723c..08c0c67bcf2 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -362,6 +362,11 @@ kernel = {
@@ -417,6 +417,11 @@ kernel = {
extra_dist = kern/mips/cache_flush.S;
};
@ -57,7 +57,7 @@ index 6864e780f..c8a50b4fc 100644
mansection = 1;
diff --git a/grub-core/commands/increment.c b/grub-core/commands/increment.c
new file mode 100644
index 000000000..79cf13765
index 00000000000..79cf137656c
--- /dev/null
+++ b/grub-core/commands/increment.c
@@ -0,0 +1,105 @@
@ -168,7 +168,7 @@ index 000000000..79cf13765
+}
diff --git a/util/grub.d/01_fallback_counting.in b/util/grub.d/01_fallback_counting.in
new file mode 100644
index 000000000..be0e770ea
index 00000000000..be0e770ea82
--- /dev/null
+++ b/util/grub.d/01_fallback_counting.in
@@ -0,0 +1,22 @@

View File

@ -15,12 +15,16 @@ ID as a numeral. In that case, we also require that the entire string
is numeric, not merely a string with leading numeric characters.
Resolves: rhbz#1640979
Signed-off-by: Peter Jones <pjones@redhat.com>
[javierm: fix menu entry selection based on title]
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
grub-core/normal/menu.c | 146 +++++++++++++++++++++++++-----------------------
1 file changed, 75 insertions(+), 71 deletions(-)
grub-core/normal/menu.c | 141 ++++++++++++++++++++++++------------------------
1 file changed, 71 insertions(+), 70 deletions(-)
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
index 6cb2a0714..95f7abaf2 100644
index 6444ee6f969..b0cfa32ddd8 100644
--- a/grub-core/normal/menu.c
+++ b/grub-core/normal/menu.c
@@ -164,12 +164,12 @@ grub_menu_set_timeout (int timeout)
@ -51,7 +55,7 @@ index 6cb2a0714..95f7abaf2 100644
if (*ptr1 == 0)
return ptr1 - id;
ptr1++;
@@ -187,6 +191,61 @@ menuentry_eq (const char *id, const char *spec)
@@ -187,6 +191,58 @@ menuentry_eq (const char *id, const char *spec)
return 0;
}
@ -81,14 +85,11 @@ index 6cb2a0714..95f7abaf2 100644
+
+ for (i = 0, e = menu->entry_list; e; i++)
+ {
+ int l = 0;
+ while (val[l] && !grub_isspace(val[l]))
+ l++;
+
+ if (menuentry_eq (e->title, val, l))
+ if (menuentry_eq (e->title, val, -1))
+ {
+ if (tail)
+ *tail = val + l;
+ *tail = NULL;
+ return i;
+ }
+ e = e->next;
@ -113,18 +114,15 @@ index 6cb2a0714..95f7abaf2 100644
/* Get the first entry number from the value of the environment variable NAME,
which is a space-separated list of non-negative integers. The entry number
which is returned is stripped from the value of NAME. If no entry number
@@ -195,9 +254,8 @@ static int
get_and_remove_first_entry_number (grub_menu_t menu, const char *name)
@@ -196,7 +252,6 @@ get_and_remove_first_entry_number (grub_menu_t menu, const char *name)
{
const char *val;
- char *tail;
+ const char *tail;
const char *val, *tail;
int entry;
- int sz = 0;
val = grub_env_get (name);
if (! val)
@@ -205,50 +263,24 @@ get_and_remove_first_entry_number (grub_menu_t menu, const char *name)
@@ -204,50 +259,24 @@ get_and_remove_first_entry_number (grub_menu_t menu, const char *name)
grub_error_push ();
@ -183,7 +181,7 @@ index 6cb2a0714..95f7abaf2 100644
}
grub_error_pop ();
@@ -525,6 +557,7 @@ static int
@@ -524,6 +553,7 @@ static int
get_entry_number (grub_menu_t menu, const char *name)
{
const char *val;
@ -191,7 +189,7 @@ index 6cb2a0714..95f7abaf2 100644
int entry;
val = grub_env_get (name);
@@ -532,38 +565,9 @@ get_entry_number (grub_menu_t menu, const char *name)
@@ -531,38 +561,9 @@ get_entry_number (grub_menu_t menu, const char *name)
return -1;
grub_error_push ();
@ -228,7 +226,7 @@ index 6cb2a0714..95f7abaf2 100644
- }
-
+ entry = get_entry_number_helper(menu, val, &tail);
+ if (*tail != '\0')
+ if (tail && *tail != '\0')
+ entry = -1;
grub_error_pop ();

View File

@ -23,7 +23,7 @@ Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c
index 8d242b018..7004e08ce 100644
index b194123eb67..b175a1b43b7 100644
--- a/grub-core/commands/menuentry.c
+++ b/grub-core/commands/menuentry.c
@@ -29,7 +29,7 @@ static const struct grub_arg_option options[] =
@ -35,7 +35,7 @@ index 8d242b018..7004e08ce 100644
N_("List of users allowed to boot this entry."), N_("USERNAME[,USERNAME]"),
ARG_TYPE_STRING},
{"hotkey", 3, 0,
@@ -280,7 +280,7 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args)
@@ -281,7 +281,7 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args)
if (! ctxt->state[3].set && ! ctxt->script)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no menuentry definition");

View File

@ -0,0 +1,346 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 16 Jan 2019 13:21:46 -0500
Subject: [PATCH] Add efi-export-env and efi-load-env commands
This adds "efi-export-env VARIABLE" and "efi-load-env", which manipulate the
environment block stored in the EFI variable
GRUB_ENV-91376aff-cba6-42be-949d-06fde81128e8.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/Makefile.core.def | 6 ++
grub-core/commands/efi/env.c | 168 +++++++++++++++++++++++++++++++++++++++++++
grub-core/kern/efi/efi.c | 3 +
grub-core/kern/efi/init.c | 5 --
grub-core/lib/envblk.c | 43 +++++++++++
util/grub-set-bootflag.c | 1 +
include/grub/efi/efi.h | 5 ++
include/grub/lib/envblk.h | 3 +
8 files changed, 229 insertions(+), 5 deletions(-)
create mode 100644 grub-core/commands/efi/env.c
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 08c0c67bcf2..4aa20cdfc13 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -842,6 +842,12 @@ module = {
enable = efi;
};
+module = {
+ name = efienv;
+ common = commands/efi/env.c;
+ enable = efi;
+};
+
module = {
name = efifwsetup;
efi = commands/efi/efifwsetup.c;
diff --git a/grub-core/commands/efi/env.c b/grub-core/commands/efi/env.c
new file mode 100644
index 00000000000..45f107ccd5b
--- /dev/null
+++ b/grub-core/commands/efi/env.c
@@ -0,0 +1,168 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2012 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+#include <grub/env.h>
+#include <grub/lib/envblk.h>
+#include <grub/command.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static const grub_guid_t grub_env_guid = GRUB_EFI_GRUB_VARIABLE_GUID;
+
+static grub_err_t
+grub_efi_export_env(grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ const char *value;
+ char *old_value;
+ struct grub_envblk envblk_s = { NULL, 0 };
+ grub_envblk_t envblk = &envblk_s;
+ grub_err_t err;
+ int changed = 1;
+ grub_efi_status_t status;
+
+ grub_dprintf ("efienv", "argc:%d\n", argc);
+ for (int i = 0; i < argc; i++)
+ grub_dprintf ("efienv", "argv[%d]: %s\n", i, argv[i]);
+
+ if (argc != 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("variable name expected"));
+
+ grub_efi_get_variable ("GRUB_ENV", &grub_env_guid, &envblk_s.size,
+ (void **) &envblk_s.buf);
+ if (!envblk_s.buf || envblk_s.size < 1)
+ {
+ char *buf = grub_malloc (1025);
+ if (!buf)
+ return grub_errno;
+
+ grub_memcpy (buf, GRUB_ENVBLK_SIGNATURE, sizeof (GRUB_ENVBLK_SIGNATURE) - 1);
+ grub_memset (buf + sizeof (GRUB_ENVBLK_SIGNATURE) - 1, '#',
+ DEFAULT_ENVBLK_SIZE - sizeof (GRUB_ENVBLK_SIGNATURE) + 1);
+ buf[1024] = '\0';
+
+ envblk_s.buf = buf;
+ envblk_s.size = 1024;
+ }
+ else
+ {
+ char *buf = grub_realloc (envblk_s.buf, envblk_s.size + 1);
+ if (!buf)
+ return grub_errno;
+
+ envblk_s.buf = buf;
+ envblk_s.buf[envblk_s.size] = '\0';
+ }
+
+ err = grub_envblk_get(envblk, argv[0], &old_value);
+ if (err != GRUB_ERR_NONE)
+ {
+ grub_dprintf ("efienv", "grub_envblk_get returned %d\n", err);
+ return err;
+ }
+
+ value = grub_env_get(argv[0]);
+ if ((!value && !old_value) ||
+ (value && old_value && !grub_strcmp(old_value, value)))
+ changed = 0;
+
+ if (old_value)
+ grub_free(old_value);
+
+ if (changed == 0)
+ {
+ grub_dprintf ("efienv", "No changes necessary\n");
+ return 0;
+ }
+
+ if (value)
+ {
+ grub_dprintf ("efienv", "setting \"%s\" to \"%s\"\n", argv[0], value);
+ grub_envblk_set(envblk, argv[0], value);
+ }
+ else
+ {
+ grub_dprintf ("efienv", "deleting \"%s\" from envblk\n", argv[0]);
+ grub_envblk_delete(envblk, argv[0]);
+ }
+
+ grub_dprintf ("efienv", "envblk is %lu bytes:\n\"%s\"\n", envblk_s.size, envblk_s.buf);
+
+ grub_dprintf ("efienv", "removing GRUB_ENV\n");
+ status = grub_efi_set_variable ("GRUB_ENV", &grub_env_guid, NULL, 0);
+ if (status != GRUB_EFI_SUCCESS)
+ grub_dprintf ("efienv", "removal returned %ld\n", status);
+
+ grub_dprintf ("efienv", "setting GRUB_ENV\n");
+ status = grub_efi_set_variable ("GRUB_ENV", &grub_env_guid,
+ envblk_s.buf, envblk_s.size);
+ if (status != GRUB_EFI_SUCCESS)
+ grub_dprintf ("efienv", "setting GRUB_ENV returned %ld\n", status);
+
+ return 0;
+}
+
+static int
+set_var (const char *name, const char *value,
+ void *whitelist __attribute__((__unused__)))
+{
+ grub_env_set (name, value);
+ return 0;
+}
+
+static grub_err_t
+grub_efi_load_env(grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[] __attribute__((__unused__)))
+{
+ struct grub_envblk envblk_s = { NULL, 0 };
+ grub_envblk_t envblk = &envblk_s;
+
+ grub_efi_get_variable ("GRUB_ENV", &grub_env_guid, &envblk_s.size,
+ (void **) &envblk_s.buf);
+ if (!envblk_s.buf || envblk_s.size < 1)
+ return 0;
+
+ if (argc > 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unexpected argument"));
+
+ grub_envblk_iterate (envblk, NULL, set_var);
+ grub_free (envblk_s.buf);
+}
+
+static grub_command_t export_cmd, loadenv_cmd;
+
+GRUB_MOD_INIT(lsefi)
+{
+ export_cmd = grub_register_command ("efi-export-env", grub_efi_export_env,
+ N_("VARIABLE_NAME"), N_("Export environment variable to UEFI."));
+ loadenv_cmd = grub_register_command ("efi-load-env", grub_efi_load_env,
+ NULL, N_("Load the grub environment from UEFI."));
+}
+
+GRUB_MOD_FINI(lsefi)
+{
+ grub_unregister_command (export_cmd);
+ grub_unregister_command (loadenv_cmd);
+}
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
index bf16c4307bc..ef837387368 100644
--- a/grub-core/kern/efi/efi.c
+++ b/grub-core/kern/efi/efi.c
@@ -227,6 +227,9 @@ grub_efi_set_variable_with_attributes (const char *var, const grub_guid_t *guid,
if (status == GRUB_EFI_SUCCESS)
return GRUB_ERR_NONE;
+ if (status == GRUB_EFI_NOT_FOUND && datasize == 0)
+ return GRUB_ERR_NONE;
+
return grub_error (GRUB_ERR_IO, "could not set EFI variable `%s'", var);
}
diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c
index b5201974a76..dee3918fd35 100644
--- a/grub-core/kern/efi/init.c
+++ b/grub-core/kern/efi/init.c
@@ -106,11 +106,6 @@ stack_protector_init (void)
grub_addr_t grub_modbase;
-#define GRUB_EFI_GRUB_VARIABLE_GUID \
- { 0x91376aff, 0xcba6, 0x42be, \
- { 0x94, 0x9d, 0x06, 0xfd, 0xe8, 0x11, 0x28, 0xe8 } \
- }
-
/* Helper for grub_efi_env_init */
static int
set_var (const char *name, const char *value,
diff --git a/grub-core/lib/envblk.c b/grub-core/lib/envblk.c
index 2e4e78b132d..874506da169 100644
--- a/grub-core/lib/envblk.c
+++ b/grub-core/lib/envblk.c
@@ -223,6 +223,49 @@ grub_envblk_delete (grub_envblk_t envblk, const char *name)
}
}
+struct get_var_state {
+ const char * const name;
+ char * value;
+ int found;
+};
+
+static int
+get_var (const char * const name, const char * const value, void *statep)
+{
+ struct get_var_state *state = (struct get_var_state *)statep;
+
+ if (!grub_strcmp(state->name, name))
+ {
+ state->found = 1;
+ state->value = grub_strdup(value);
+ if (!state->value)
+ grub_errno = grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+
+ return 1;
+ }
+
+ return 0;
+}
+
+grub_err_t
+grub_envblk_get (grub_envblk_t envblk, const char * const name, char ** const value)
+{
+ struct get_var_state state = {
+ .name = name,
+ .value = NULL,
+ .found = 0,
+ };
+
+ grub_envblk_iterate(envblk, (void *)&state, get_var);
+
+ *value = state.value;
+
+ if (state.found && !state.value)
+ return grub_errno;
+
+ return GRUB_ERR_NONE;
+}
+
void
grub_envblk_iterate (grub_envblk_t envblk,
void *hook_data,
diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c
index d506f7e75bc..a6ccc113839 100644
--- a/util/grub-set-bootflag.c
+++ b/util/grub-set-bootflag.c
@@ -25,6 +25,7 @@
#include <config-util.h> /* For *_DIR_NAME defines */
#include <grub/types.h>
+#include <grub/err.h>
#include <grub/lib/envblk.h> /* For GRUB_ENVBLK_DEFCFG define */
#include <errno.h>
#include <stdio.h>
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index 8d98203a784..6c2c1f36e37 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -36,6 +36,11 @@ struct linux_arch_kernel_header {
struct grub_pe_image_header pe_image_header;
};
+#define GRUB_EFI_GRUB_VARIABLE_GUID \
+ { 0x91376aff, 0xcba6, 0x42be, \
+ { 0x94, 0x9d, 0x06, 0xfd, 0xe8, 0x11, 0x28, 0xe8 } \
+ }
+
/* Variables. */
extern grub_efi_system_table_t *EXPORT_VAR(grub_efi_system_table);
extern grub_efi_handle_t EXPORT_VAR(grub_efi_image_handle);
diff --git a/include/grub/lib/envblk.h b/include/grub/lib/envblk.h
index c3e65592170..ab969af2461 100644
--- a/include/grub/lib/envblk.h
+++ b/include/grub/lib/envblk.h
@@ -22,6 +22,8 @@
#define GRUB_ENVBLK_SIGNATURE "# GRUB Environment Block\n"
#define GRUB_ENVBLK_DEFCFG "grubenv"
+#define DEFAULT_ENVBLK_SIZE 1024
+
#ifndef ASM_FILE
struct grub_envblk
@@ -33,6 +35,7 @@ typedef struct grub_envblk *grub_envblk_t;
grub_envblk_t grub_envblk_open (char *buf, grub_size_t size);
int grub_envblk_set (grub_envblk_t envblk, const char *name, const char *value);
+grub_err_t grub_envblk_get (grub_envblk_t envblk, const char * const name, char ** const value);
void grub_envblk_delete (grub_envblk_t envblk, const char *name);
void grub_envblk_iterate (grub_envblk_t envblk,
void *hook_data,

View File

@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Tue, 22 Jan 2019 15:40:25 +0100
Subject: [PATCH] Export all variables from the initial context when creating a
submenu
When a submenu is created, only the exported variables are copied to the
new menu context. But we want the variables to be global, so export lets
export all variables to the new created submenu.
Also, don't unset the default variable when a new submenu is created.
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
grub-core/normal/context.c | 2 +-
grub-core/normal/menu.c | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c
index ba185e91599..b4baa4392cd 100644
--- a/grub-core/normal/context.c
+++ b/grub-core/normal/context.c
@@ -99,7 +99,7 @@ grub_env_new_context (int export_all)
grub_err_t
grub_env_context_open (void)
{
- return grub_env_new_context (0);
+ return grub_env_new_context (1);
}
int grub_extractor_level = 0;
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
index b0cfa32ddd8..30ddcea0c11 100644
--- a/grub-core/normal/menu.c
+++ b/grub-core/normal/menu.c
@@ -375,8 +375,6 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot)
if (ptr && ptr[0] && ptr[1])
grub_env_set ("default", ptr + 1);
- else
- grub_env_unset ("default");
grub_script_execute_new_scope (entry->sourcecode, entry->argc, entry->args);

Some files were not shown because too many files have changed in this diff Show More