summaryrefslogtreecommitdiffstats
path: root/discover/grub2/builtins.c
Commit message (Collapse)AuthorAgeFilesLines
* discover/grub2: implement 'source' commandJeremy Kerr2019-11-291-1/+50
| | | | | | | | | | This change add support for the grub2 'source' command, executing a referenced script in the current parse context. We impose a limit of 10 (concurrent) source commands, to prevent infinite recursion. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Allow (device)/path references in general script usageJeremy Kerr2019-11-291-7/+43
| | | | | | | | | | | Currently, we have support for grub2 (device)/path syntax for boot resources. This change allows this syntax for general paths in grub2 scripts (for example, -f tests). This involves exposing grub2_lookup_device, to allow the script execution code to resolve pathnames. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: add support for grub2-style path specifiers in resourcesJeremy Kerr2019-11-291-11/+4
| | | | | | | | | | | | This change incorporates the grub2-style (device)/path specifiers in the grub2 parser's resource code. This allows the boot option paths to use device-specific references. Device names are looked-up using the UUID and kernel IDs, but with the lookup logic specific to a new function (grub2_lookup_device), so that can be extended in a future change. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add support for UUID and label for 'search' commandJeremy Kerr2019-11-291-3/+52
| | | | | | | | This change adds support for searching by UUID and filesystem label. We still fall back to passthrough if the UUID is not found, but we now resolve to device ID strings. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Use getopt for `search` argument parsingJeremy Kerr2019-11-291-5/+28
| | | | | | | | | | | | The search command will be extended to add the full set of grub2-style arguments, so switch to using getopt, rather than manual parsing. This means we now support `--set=foo` and `--set foo` style arguments, both of which appear in the docs and common grub configs. Also, add a small test for the search argument handling. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: 'search' set-variable defaults to rootJeremy Kerr2019-11-291-2/+2
| | | | | | | If no --set= argument is specified, default to the variable named 'root', as per current grub docs. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add support for initrd16 builtinShawn Anastasio2018-11-221-0/+4
| | | | | | | | | This commit adds support for the initrd16 builtin which compliments the existing linux16 support and improves usability on x86 platforms. Signed-off-by: Shawn Anastasio <shawn@anastas.io> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/grub: Add blscfg command support to parse BootLoaderSpec filesJavier Martinez Canillas2018-03-231-1/+8
| | | | | | | | | | | | | | | | | The BootLoaderSpec (BLS) defines a file format for boot configurations, so bootloaders can parse these files and create their boot menu entries by using the information provided by them [0]. This allow to configure the boot items as drop-in files in a directory instead of having to parse and modify a bootloader configuration file. The GRUB 2 bootloader provides a blscfg command that parses these files and creates menu entries using this information. Add support for it. [0]: https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Add support for GPG signature enforcement on bootedtpearson@raptorengineering.com2016-08-261-0/+8
| | | | | | | | | | | | | kernels and related blobs This can be used to implement a form of organization-controlled secure boot, whereby kernels may be loaded from a variety of sources but they will only boot if a valid signature file is found for each component, and only if the signature is listed in the /etc/pb-lockdown file. Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> (Minor build fixes and gpgme.m4, comment on secure boot in gpg.c)
* Change parser interface to allow statAlan Dunn2016-03-151-9/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the GRUB2 parser incorrectly reports "[ -f <path> ]" as false if the size of the file is above 1 MB. This patch changes the parser interface to allow stating files (with parser_stat_file). Then in the implementation of "[ -f <path> ]", we can use parser_stat_file instead of parser_request_file which has the size limitation. I eliminate parser_check_dir in lieu of this new interface, which has the side effect of making "[ -d <path> ]" work (the error code for stat was not checked correctly before). I add a basic test for the test file operations -f, -s, and -d (to show that my changes to test file operations do not break them) and minorly modify the test framework to ensure it has enough fidelity to cause the expected results. Unfortunately the test wouldn't have caught the issue with -d, since the test framework stubs out the parser interface itself. Nor can the test framework catch the initial problem with -f because the imposed limit is (transitively) in function parser_request_file. Note that -f and -d follow symlinks despite the fact that GRUB does not (see http://lists.gnu.org/archive/html/grub-devel/2016-02/msg00142.html discussing GRUB's behavior). This is not a change to Petitboot's behavior though. Tested: The test test-grub2-test-file-ops passes. I booted Petitboot against a GRUB snippet: status=success if [ ! -f /large_file -a $status = success ] then status=fail_large_file fi if [ ! -d /a_directory -a $status = success ] then status=fail_dir fi menuentry $status { linux /vmlinux } (after making /large_file a file of size > 1 MiB and /a_directory a directory) and the menuentry had title "success", as desired. Signed-off-by: Alan Dunn <amdunn@google.com> Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* discover: Add support for checking directories in parser APIJeremy Kerr2014-01-301-0/+14
| | | | | | | | | | | | | This change adds a function to the parser API: int parser_check_dir(struct discover_context *ctx, struct discover_device *dev, const char *dirname) - which allows parsers to check for the presence of a directory (path of 'dirname') on the device ('dev'). We use this in the GRUB2 parser to implement the `test -d` check. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add support for -s and -f commandsJeremy Kerr2013-11-271-5/+36
| | | | | | | Implement -s and -f checks for grub, and test with the standard GRUB2 saved_default config. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib: consolidate util macros in util/util.hJeremy Kerr2013-11-131-1/+1
| | | | | | | This change groups the offsetof, container_of and ARRAY_SIZE macros in a single header file util/util.h. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Implement save_env commandJeremy Kerr2013-10-041-0/+8
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Implement load_envJeremy Kerr2013-10-011-0/+8
| | | | | | | Use the new parser_request_file API to access the GRUB environment block. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Fix uninitialised op variableJeremy Kerr2013-09-241-0/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add true & false builtinsJeremy Kerr2013-09-241-0/+24
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add linux16 commandJeremy Kerr2013-09-241-0/+4
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Implement test builtinJeremy Kerr2013-09-241-1/+117
| | | | | | A faily simple implementation now, and could do with some testing... Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add nops for unnecessary builtinsJeremy Kerr2013-09-241-0/+15
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Implement 'search' commandJeremy Kerr2013-09-241-0/+30
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Implement 'linux' & 'initrd' commandsJeremy Kerr2013-09-241-1/+73
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Function infrastructure improvementsJeremy Kerr2013-09-241-5/+11
| | | | | | | | For user-defined functions, we'll need a data pointer to the function's execution callback. Add this as a void *, and change references from 'command' to 'function'. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/grub2: Add initial command executionJeremy Kerr2013-09-241-0/+47
.. with a simple 'set' command to update the environment Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
OpenPOWER on IntegriCloud