Commit Graph

251 Commits

Author SHA1 Message Date
Steve Langasek 46d76f8fef templates: Output a menu entry for firmware setup on UEFI FastBoot systems
The fwsetup command allows to reboot into the EFI firmware setup menu, add
a template to include a menu entry on EFI systems that makes use of that
command to reboot into the EFI firmware settings.

This is useful for users since the hotkey to enter into the EFI setup menu
may not be the same on all systems so users can use the menu entry without
needing to figure out what key needs to be pressed.

Also, if fastboot is enabled in the BIOS then often it is not possible to
enter the firmware setup menu. So the entry is again useful for this case.

Signed-off-by: Steve Langasek <steve.langasek@ubuntu.com>
Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-04-21 22:14:12 +02:00
Peter Jones 0ad07e928a grub-editenv: Make grub-editenv chase symlinks including those across devices
The grub-editenv create command will wrongly overwrite /boot/grub2/grubenv
with a regular file if grubenv is a symbolic link. But instead, it should
create a new file in the path the symlink points to.

This lets /boot/grub2/grubenv be a symlink to /boot/efi/EFI/fedora/grubenv
even when they're different mount points, which allows grub2-editenv to be
the same across platforms (i.e. UEFI vs BIOS).

For example, in Fedora the GRUB EFI builds have prefix set to /EFI/fedora
(on the EFI System Partition), but for BIOS machine it'll be /boot/grub2
(which may or may not be its own mountpoint).

With this patch, on EFI machines we can make /boot/grub2/grubenv a symlink
to /boot/efi/EFI/fedora/grubenv, and the same copy of grub-set-default will
work on both kinds of systems.

Windows doesn't implement a readlink primitive, so the current behaviour is
maintained for this operating system.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Jonathan Lebon <jlebon@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-02-18 15:16:02 +01:00
Javier Martinez Canillas aa096037ae normal: Move common datetime functions out of the normal module
The common datetime helper functions are currently included in the normal
module, but this makes any other module that calls these functions to have
a dependency with the normal module only for this reason.

Since the normal module does a lot of stuff, it calls functions from other
modules. But since other modules may depend on it for calling the datetime
helpers, this could lead to circular dependencies between modules.

As an example, when platform == xen the grub_get_datetime() function from
the datetime module calls to the grub_unixtime2datetime() helper function
from the normal module. Which leads to the following module dependency:

    datetime -> normal

and send_dhcp_packet() from the net module calls the grub_get_datetime()
function, which leads to the following module dependency:

    net -> datetime -> normal

but that means that the normal module is not allowed to depend on net or
any other module that depends on it due the transitive dependency caused
by datetime. A recent patch attempted to add support to fetch the config
file over the network, which leads to the following circular dependency:

    normal -> net -> datetime -> normal

So having the datetime helpers in the normal module makes it quite fragile
and easy to add circular dependencies like these, that break the build due
the genmoddep.awk script catching the issues.

Fix this by taking the datetime helper functions out of the normal module
and instead add them to the datetime module itself. Besides fixing these
issues, it makes more sense to have these helper functions there anyways.

Reported-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-02-18 15:12:06 +01:00
Patrick Steinhardt 365e0cc3e7 disk: Implement support for LUKS2
With cryptsetup 2.0, a new version of LUKS was introduced that breaks
compatibility with the previous version due to various reasons. GRUB
currently lacks any support for LUKS2, making it impossible to decrypt
disks encrypted with that version. This commit implements support for
this new format.

Note that LUKS1 and LUKS2 are quite different data formats. While they
do share the same disk signature in the first few bytes, representation
of encryption parameters is completely different between both versions.
While the former version one relied on a single binary header, only,
LUKS2 uses the binary header only in order to locate the actual metadata
which is encoded in JSON. Furthermore, the new data format is a lot more
complex to allow for more flexible setups, like e.g. having multiple
encrypted segments and other features that weren't previously possible.
Because of this, it was decided that it doesn't make sense to keep both
LUKS1 and LUKS2 support in the same module and instead to implement it
in two different modules luks and luks2.

The proposed support for LUKS2 is able to make use of the metadata to
decrypt such disks. Note though that in the current version, only the
PBKDF2 key derival function is supported. This can mostly attributed to
the fact that the libgcrypt library currently has no support for either
Argon2i or Argon2id, which are the remaining KDFs supported by LUKS2. It
wouldn't have been much of a problem to bundle those algorithms with
GRUB itself, but it was decided against that in order to keep down the
number of patches required for initial LUKS2 support. Adding it in the
future would be trivial, given that the code structure is already in
place.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-01-10 14:30:24 +01:00
Colin Watson 35b909062e gnulib: Upgrade Gnulib and switch to bootstrap tool
Upgrade Gnulib files to 20190105.

It's much easier to maintain GRUB's use of portability support files
from Gnulib when the process is automatic and driven by a single
configuration file, rather than by maintainers occasionally running
gnulib-tool and committing the result.  Removing these
automatically-copied files from revision control also removes the
temptation to hack the output in ways that are difficult for future
maintainers to follow.  Gnulib includes a "bootstrap" program which is
designed for this.

The canonical way to bootstrap GRUB from revision control is now
"./bootstrap", but "./autogen.sh" is still useful if you just want to
generate the GRUB-specific parts of the build system.

GRUB now requires Autoconf >= 2.63 and Automake >= 1.11, in line with
Gnulib.

Gnulib source code is now placed in grub-core/lib/gnulib/ (which should
not be edited directly), and GRUB's patches are in
grub-core/lib/gnulib-patches/.  I've added a few notes to the developer
manual on how to maintain this.

Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2019-03-05 10:48:12 +01:00
Nick Terrell 3861286486 btrfs: Add zstd support to grub btrfs
- Adds zstd support to the btrfs module.
- Adds a test case for btrfs zstd support.
- Changes top_srcdir to srcdir in the btrfs module's lzo include
  following comments from Daniel Kiper about the zstd include.

Tested on Ubuntu-18.04 with a btrfs /boot partition with and without zstd
compression. A test case was also added to the test suite that fails before
the patch, and passes after.

Signed-off-by: Nick Terrell <terrelln@fb.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-11-26 23:10:11 +01:00
Colin Watson bcfa0f08bb build: Capitalise *freetype_* variables
Using FREETYPE_CFLAGS and FREETYPE_LIBS is more in line with the naming
scheme used by pkg-config macros.

Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-09-27 14:45:09 +02:00
Jaegeuk Kim 71f9e4ac44 fs: Add F2FS support
"F2FS (Flash-Friendly File System) is flash-friendly file system which was merged
into Linux kernel v3.8 in 2013.

The motive for F2FS was to build a file system that from the start, takes into
account the characteristics of NAND flash memory-based storage devices (such as
solid-state disks, eMMC, and SD cards).

F2FS was designed on a basis of a log-structured file system approach, which
remedies some known issues of the older log structured file systems, such as
the snowball effect of wandering trees and high cleaning overhead. In addition,
since a NAND-based storage device shows different characteristics according to
its internal geometry or flash memory management scheme (such as the Flash
Translation Layer or FTL), it supports various parameters not only for
configuring on-disk layout, but also for selecting allocation and cleaning
algorithm.", quote by https://en.wikipedia.org/wiki/F2FS.

The source codes for F2FS are available from:

http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs.git
http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs-tools.git

This patch has been integrated in OpenMandriva Lx 3.
  https://www.openmandriva.org/

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-04-10 19:05:04 +02:00
Andrei Borzenkov ee83919e93 Makefile.util.def: add $LIBINTL to grub-macbless flags
Fixes compilation on OpenBSD 5.9.

Reported by Jiri B <jirib@devio.us>
2016-03-13 08:11:58 +03:00
Vladimir Serbinenko 36212460d3 mkimage.c: Split into separate files.
util/grub-mkimagexx.c is included in a special way into mkimage.c.
Interoperation between defines makes this very tricky. Instead
just have a clean interface and compile util/grub-mkimage*.c separately
from mkimage.c
2016-02-27 13:35:36 +01:00
Vladimir Serbinenko 4622f4e1ee Switch procfs to use archelp.
This fixes handling of "." and "..".
2015-07-27 12:44:19 +02:00
Vladimir Serbinenko 1f23c87c19 Make Makefile.util.def independent of platform. 2015-03-27 14:04:41 +01:00
Vladimir Serbinenko d3d2e54911 Add test for syslinux converter 2015-02-16 15:58:59 +01:00
Andrei Borzenkov 1e047e53ae tests: add test command file tests
This requires access to files in both host and grub image, so
implementing as separate test unit instead of script test was
more easy.
2015-01-30 21:42:46 +03:00
Andrei Borzenkov 272e0466da add file filters tests
Tests file access with all filters enabled. It does it both for local
and network access, due to regression in signature checking over network.

This includes all files in distribution to not depend on existence
of compression tools and gpg. Test preloads all required modules to
avoid having to provide signatures for them.

Still not implemented is file offset filter (is not available in grub
script, needs extra module)
2014-12-05 21:04:06 +03:00
Mike Gilbert 6ba983559d * Makefile.util.def: Link grub-ofpathname with zfs libs. 2014-01-18 19:41:15 +01:00
Andrey Borzenkov 1ecf96fcc4 add BUILD_EXEEXT support to fix make clean on Windows
Add $(BUILD_EXEEXT) to ensure files are removed. Also add CLEANFILES where
appropriate.
2014-01-18 20:41:24 +04:00
Colin Watson ccd21a65ed * Makefile.util.def (grub-macbless): Change mansection to 8. 2014-01-08 11:05:20 +00:00
Vladimir Serbinenko faf4a65e1e Revert grub-file usage in grub-mkconfig. 2013-12-24 17:47:27 +01:00
Vladimir Serbinenko 8f5add13ff Implement syslinux parser. 2013-12-18 05:28:05 +01:00
Vladimir Serbinenko b8765fa082 Implement better integration with Mac firmware. 2013-12-17 15:21:02 +01:00
Vladimir Serbinenko ec824e0f2a Implement grub_file tool and use it to implement generating of config
in separate root.
2013-12-17 14:39:48 +01:00
Vladimir Serbinenko 814442ba69 Implement windows flavour of EFI install routines. 2013-12-14 23:35:58 +01:00
Vladimir Serbinenko d6c92cdc34 Merge branch 'master' into leiflindholm/arm64
Conflicts:
	include/grub/util/install.h
2013-11-25 13:02:27 +01:00
Colin Watson 4e7d433dfb * Makefile.util.def (grub-mkimage): Add
grub-core/osdep/aros/config.c to extra_dist.
* conf/Makefile.extra-dist (EXTRA_DIST): Add docs/autoiso.cfg,
docs/osdetect.cfg, grub-core/gnulib-fix-null-deref.diff,
grub-core/gnulib-fix-width.diff, grub-core/gnulib-no-abort.diff, and
grub-core/gnulib-no-gets.diff.
2013-11-19 20:39:16 +00:00
Vladimir Serbinenko 7d44ff7de6 Add automated filesystem checking based on scripts I've used now for
quite some time locally. Most of the test require root so they are
	skipped when run without necessarry privelegies.
2013-11-19 21:05:59 +01:00
Leif Lindholm 15a463d742 ARM 64 port by Leif Lindholm 2013-11-16 20:52:55 +01:00
Vladimir Serbinenko cd46aa6cef Rewrite grub-install, grub-mkrescue, grub-mkstandalone and grub-mknetdir
the function of these files exceeds what can be sanely handled in shell
	in posix-comaptible way. Also writing it in C extends the functionality
	to non-UNIX-like OS and minimal environments.
2013-11-16 20:21:16 +01:00
Vladimir Serbinenko a9f25a0819 * configure.ac: Probe for linking format rather than guessing it based
on target_os.
2013-11-14 23:17:18 +01:00
Andrey Borzenkov e11cb7268e Add grub-core/kern/disk_common.c to extra_dist 2013-10-27 22:55:11 +04:00
Vladimir Serbinenko 442b86de32 Move grub_disk_write out of kernel into disk.mod. 2013-10-27 15:44:55 +01:00
BVK Chaitanya 188929ebee * tests/test_unset.in: New test. 2013-10-26 14:52:54 +02:00
BVK Chaitanya 7994a09a9b * tests/test_sha512sum.in: New test. 2013-10-26 14:35:35 +02:00
Vladimir Serbinenko 3d695d7b93 * tests/date_unit_test.c: New test. 2013-10-26 02:48:19 +02:00
Vladimir 'phcoder' Serbinenko a4012f0764 Split make_system_path_relative_to_its_root into separate file
relpath.c from getroot.c as it's common between unix and haiku
	but otherwise haiku doesn't use any functions from unix getroot.c.
2013-10-19 16:21:08 +02:00
Vladimir 'phcoder' Serbinenko 40346de6d3 * grub-core/osdep/unix/getroot.c: Move exec functions to ...
* osdep/unix/exec.c: ... here. Add few additional exec_* variants.
2013-10-19 02:56:40 +02:00
Vladimir 'phcoder' Serbinenko 6f65237374 * util/grub-render-label.c: Move backend part to ...
* util/render-label.c: ... here.
2013-10-19 02:37:01 +02:00
Vladimir 'phcoder' Serbinenko 44d1c20a13 * util/grub-render-label.c: Move backend part to ...
* util/render-label.c: ... here.
2013-10-19 02:34:18 +02:00
Vladimir 'phcoder' Serbinenko 8104063ce4 * Makefile.util.def: Add util/setup.c to extra_dist. 2013-10-19 02:12:06 +02:00
BVK Chaitanya 3d46c22f5b Added `tr' command support.
* grub-core/commands/tr.c: New file.
	* grub-core/Makefile.core.def: Build rules for new module.

	* tests/grub_cmd_tr.in: New test.
	* Makefile.util.def: Build rules for new test.
2013-10-17 19:06:29 +02:00
Vladimir 'phcoder' Serbinenko bacfefbb0e * util/grub-editenv.c (create_envblk_file): More from here ...
* util/editenv.c (grub_util_create_envblk_file): ... to here.
2013-10-15 21:23:54 +02:00
Vladimir 'phcoder' Serbinenko ec16e02639 * util/grub-mkimage.c: Move backend part to ...
* util/mkimage.c: ... here.
2013-10-15 19:14:55 +02:00
Vladimir 'phcoder' Serbinenko 5a869940de Split out blocklist retrieving from setup.c to
grub-core/osdep/blocklist.c and add windows implementation since
	generic version doesn't work on NTFS on Windows due to aggressive
	unflushable cache.
2013-10-15 17:02:26 +02:00
Vladimir 'phcoder' Serbinenko c06c75201c Split grub-setup.c into frontend (grub-setup.c) and backend (setup.c)
files.
2013-10-15 16:16:04 +02:00
Andrey Borzenkov f8f3f15559 * Makefile.util.def: Add osdep/init.c to grub-mount files. 2013-10-14 15:21:51 +04:00
Vladimir 'phcoder' Serbinenko ae5540d3d4 Move set_program_name and init_nls to host_init. On windows
fix in this fuction console and argument charset as well.
2013-10-13 20:03:42 +02:00
Vladimir 'phcoder' Serbinenko 9a2c903f28 * util/ieee1275/ofpath.c: Move to ...
* grub-core/osdep/linux/ofpath.c: ..here, split stub into ...
	* grub-core/osdep/basic/ofpath.c: ..here.
2013-10-08 18:25:49 +02:00
Vladimir 'phcoder' Serbinenko 4a445f580b Move password-querying (util-version) routines to grub-core/osdep. 2013-10-08 17:51:39 +02:00
Vladimir 'phcoder' Serbinenko c1ca424476 Move sleep routines to grub-core/osdep. 2013-10-08 17:38:46 +02:00
Vladimir 'phcoder' Serbinenko 672fa55e81 Move OS-dependent files to grub-core/osdep and document it. 2013-10-08 17:30:22 +02:00