390 Commits

Author SHA1 Message Date
Richard Hughes
0a85e9baaa Move the internal headers into src
They're never going to be installed, and moving them here makes adding a
test-suite (and porting to meson) easier.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2024-03-15 16:48:15 -04:00
Peter Jones
1a4a912849 efibootmgr: add support for listing cryptographic signature types.
Since UEFI 2.2, firmware has provided a list of supported signature
types for Secure Boot binaries in a global variable named
"SignatureSupport".

This patch adds a new command line flag to efibootmgr,
"--list-signature-types" ("-s") which collects that information from the
firmware and displays it to the user, either by symbolic name if
libefivar knows about that signature type or by GUID if it does not.

On the system in front of me, that looks something like this:

random:efibootmgr/signaturesupport$ ./src/efibootmgr -s
x509_sha256
x509_sha384
x509_sha512
sha256
x509_cert
rsa2048
rsa2048_sha256
rsa2048_sha1
external_management
random:efibootmgr/signaturesupport$ ./src/efibootmgr -s -v
x509_sha256 3bd2a492-96c0-4079-b420-fcf98ef103ed
x509_sha384 7076876e-80c2-4ee6-aad2-28b349a6865b
x509_sha512 446dbf63-2502-4cda-bcfa-2465d2b0fe9d
sha256 c1c41626-504c-4092-aca9-41f936934328
x509_cert a5c059a1-94e4-4aa7-87b5-ab155c2bf072
rsa2048 3c5766e8-269c-4e34-aa14-ed776e85b3b6
rsa2048_sha256 e2b36190-879b-4a3d-ad8d-f2e7bba32784
rsa2048_sha1 67f8444f-8743-48f1-a328-1eaab8736080
external_management 452e8ced-dfff-4b8c-ae01-5118862e682c
random:efibootmgr/signaturesupport$

Signed-off-by: Peter Jones <pjones@redhat.com>
2024-03-15 16:33:30 -04:00
Peter Jones
e616023ec3 Revert "Implement --uri option for use with --ifname"
This reverts commit 5ce076c88670eeb63dea80fcaec60e79f0e57ac6.

This was pulled in prematurely; the support code isn't merged in efivar yet.

Signed-off-by: Peter Jones <pjones@redhat.com>
2024-03-15 16:24:25 -04:00
Richard Hughes
9cbf722a5f Use #pragma once in header files
All compilers have supported this for at least the 5 years, some like gcc and
clang much longer.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2024-02-19 10:43:51 -05:00
Dima Zavin
0ca99d442e efibootmgr: delete_bootnext is just a boolean, not an entry id
When deleting bootnext, there's nothing to validate (other than
the variable existing, in which case del will fail as expected).

This appears to be a copy/paste error when adding the delete-bootnext
option from the [create] bootnext option.

Signed-off-by: Dima Zavin <dmitriyz@waymo.com>
2024-01-23 10:02:35 -05:00
century6
af5b168d1c Fix the incorrect long parameter in help messages
- fix the incorrect long parameter of --device

Signed-off-by: Qiumiao Zhang <zhangqiumiao1@huawei.com>
2024-01-23 09:50:38 -05:00
Kamil Aronowski
015f95cc37 Remove the --write-signature support
According to https://github.com/rhboot/efibootmgr/issues/101, the
--write-signature option does nothing. This change removes the option.

Signed-off-by: Kamil Aronowski <kamil.aronowski@yahoo.com>
2024-01-23 09:49:58 -05:00
Renaud Métrich
5ce076c886 Implement --uri option for use with --ifname
New --uri option enables to specify a URI when creating a network boot
entry, e.g.

  # efibootmgr -L NetBoot -i enp7s0 --uri http://foobar/grubx64.efi

This requires support in libefiboot, which is provided by version 39 of
efivar.

Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
2024-01-23 09:48:10 -05:00
kamillo
4a8d9c6905 Fix segfault when passed --index is greater than current boot order size
Size of the order entry size (uint16_t) hasn't been taken into account for all calculations and caused memory corruption.

Signed-off-by: kamillo <kamilgolunski@gmail.com>
2023-02-20 14:50:40 -05:00
kamillo
b0f8108948 Add missing short option handling for --index (-I)
Signed-off-by: kamillo <kamilgolunski@gmail.com>
2023-02-20 14:50:40 -05:00
kmicki
3eac27c5fc Update efibootmgr.c
get_entry: return entry if it was found before reaching the end of the list

Signed-off-by: kmicki <1463619+kmicki@users.noreply.github.com>
2023-02-06 16:45:42 -05:00
Robert Scheck
1904f9cd5a CI: Reflect branch rename and use F36 container
Signed-off-by: Robert Scheck <robert@fedoraproject.org>
2022-10-05 21:32:12 +02:00
a1346054
811ec82fc6 Fix typos and trim whitepace
Signed-off-by: a1346054 <36859588+a1346054@users.noreply.github.com>
[rharwood: squish commits]
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
2022-10-04 13:25:26 -04:00
Robbie Harwood
95cd072832 Add man page entry for --index (-I)
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
2022-07-11 14:38:12 -04:00
Robbie Harwood
c3f9f0534e Bump version to 18
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
18
2022-07-07 17:47:52 -04:00
Robbie Harwood
f9b641a799 Fix branch naming in release script
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
2022-07-07 17:47:43 -04:00
Robbie Harwood
971aeda4e1 Add option for insertion location of new entries
Add --index (-I) and modify documentation of --create (-c)
accordingly.

Signed-off-by: Robbie Harwood <rharwood@redhat.com>
2022-06-30 16:08:43 -04:00
Robert Scheck
892cb7444c Fix help messages
- Add missing -f/-F option in README.
- Start first letter of help message with a capital letter and
  end with a period punctuation to make things consistent with
  other option messages.
- Use two spaces after period punctuation before new sentence.
- Correct some spelling mistakes.

Signed-off-by: Robert Scheck <robert@fedoraproject.org>
2021-11-25 01:34:19 +01:00
Robbie Harwood
b9fedd6b6f Add code of conduct
This is the standard Contributor Covenant.

See-also: https://www.contributor-covenant.org/
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
2021-11-04 14:38:43 -04:00
Robbie Harwood
d2dece4b18 CI: migrate to GitHub Actions
Drop the code to test development heads against each other since it has
atrophied (last updated when rawhide was fc32).

Signed-off-by: Robbie Harwood <rharwood@redhat.com>
2021-10-08 16:01:12 -04:00
Robbie Harwood
103aa22ece Fix missing comma in getopt fixup
Related: d370d5ece383fdceed78caed51fb777d8ddf9d0d
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
2021-10-08 11:47:02 -04:00
Dan Robertson
b6bb490e21 Fix possible read out of bounds in ucs2_to_utf8
Check that the current character is not the null character after
ensuring we are not beyond the end of the buffer.

Signed-off-by: Dan Robertson <dan@dlrobertson.com>
2021-09-30 11:48:27 -04:00
Robbie Harwood
572defbaf1 Eliminate obvious dead code
Coverity helper left alone because it's not worth thinking about.

Signed-off-by: Robbie Harwood <rharwood@redhat.com>
2021-09-28 18:20:16 -04:00
Robbie Harwood
d370d5ece3 Match efibootmgr options and their documentation
Fixes several issues, including --enable-dups and -k not being
recognized, as well as -g requiring an unused argument.

Signed-off-by: Robbie Harwood <rharwood@redhat.com>
2021-09-28 18:17:43 -04:00
Peter Jones
4069341e18 Add "gcc -fanalyzer" make targets.
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-06-17 12:09:40 -04:00
Peter Jones
d32c8ff9a2 Minor coding style/whitespace cleanups
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-06-17 11:00:19 -04:00
Peter Jones
bb39aa0285 Fix a couple of NULL dereferences scan-build found.
Signed-off-by: Peter Jones <pjones@redhat.com>
2021-06-17 10:16:04 -04:00
Brian Klock
06fdba7f7c Allow deletion of entries by label
Currently there is no way to delete entries specified by a label.  This
patch adds that ability, such that "efibootmgr -B -L Debian" will delete
any entry with the label 'Debian'.
2021-06-17 10:07:11 -04:00
Chris Mayo
2e360ed7dc README: Note efivarfs as the current required kernel module
efivars is now deprecated and only available on x86 and IA-64 [1].

Drop mention of modprobe, probably not needed on the average system and
advanced users will know what to do.

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=963fabf37f6a

Signed-off-by: Chris Mayo <aklhfex@gmail.com>
2021-06-17 10:44:04 +02:00
Samanta Navarro
b02ea9482a Fix typo in manual page
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2021-06-17 10:30:58 +02:00
Ryan Harper
edc8b9b6ec
remove-dupes: update error message (#127)
The existing error message looks to be a copy and paste
from the set_order handler.  Replace the error message
with something related to the specified command.

Signed-off-by: Ryan Harper <ryan.harper@canonical.com>
2020-04-27 16:21:12 -04:00
Chih-Wei Huang
2140c03a3e
Android: correct the sources list (#124)
Fixes: e8ce9fec ("Try a little harder on formatting known Loader Optional Data blobs")

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
2020-04-27 16:20:30 -04:00
Peter Jones
2c1b8fc54d Update travis to use a newer distro.
Signed-off-by: Peter Jones <pjones@redhat.com>
2020-02-18 18:03:56 -05:00
Peter Jones
def4bebd6c Rework raw optional loader data printing to be more useful.
Previously we decided if a character was printable on a byte-by-byte
basis, and if the character was not printable, showed "." like "hexdump -C"
does.  hexdump gets away with this because the hex is there, but we
don't have that going on.

This patch changes it to decide up front if there are *any* unprintable
characters, and if so, dump hex for the whole thing instead of printing
useless nonsense.

(Incidentally this also alphabetizes the include files, because I like
that better.)

Fixes github issue #123

Signed-off-by: Peter Jones <pjones@redhat.com>
2020-01-13 15:26:21 -05:00
Peter Jones
dc436b3ebe Add --full-path and --no-full-path
We've currently got "-e N" and "-E num" arguments that effectively just
force a full device path or an abbreviated device path, but may
sometimes detect some shell mapping that got left around.  This leaves
some people thinking they're actually doing something with EDD, which
they really aren't.

This patch does a couple of things:
- adds --full-dev-path, which forces a full (ACPI/PCIe/etc-rooted)
  device path to be generated.
- adds --file-dev-path, which forces a File() based device path to be
  generated.
- Adds an alias for --edd30 to --edd
- makes "-e 3" / "--edd 3" do the same thing as --full-dev-path.
- removes "-e -1", which makes no sense anyway
- gets rid of the EFI shell device map parsing, which probably worked
  anyway, since the old edk shell code here
  https://github.com/tianocore/edk-Shell/blob/master/shellenv/map.c#L1019
  only ever generates the binaries with EFI_VARIABLE_BOOTSERVICE_ACCESS,
  so that could never have worked.  The code in edk2's shell package
  doesn't expose these as variables.
- updates docs to say what it's actually doing.

Signed-off-by: Peter Jones <pjones@redhat.com>
2020-01-13 15:26:18 -05:00
Peter Jones
42bf5c5ce7 Clean up --help a little
Signed-off-by: Peter Jones <pjones@redhat.com>
2020-01-13 15:24:49 -05:00
Peter Jones
ab23f43d82 Fix the tests for opts.reconnect.
The intent is that force is not default, so all the tests for it need to
be testing for >0 rather than !0.

Fixes github issue #119

Signed-off-by: Peter Jones <pjones@redhat.com>
2020-01-13 10:20:29 -05:00
Peter Jones
e8ce9feceb Try a little harder on formatting known Loader Optional Data blobs
This tries to do a better job printing optional data blobs:

- if it detects a device path that ends in shim, it assumes it's a file
  path:
  before:
    Boot0000* Linux Firmware Updater	HD(1,GPT,58da233f-b177-4c57-8bee-3d888b3047d4,0x800,0x64000)/File(\EFI\fedora\shimx64.efi)\.f.w.u.p.d.x.6.4...e.f.i...
  after:
    Boot0000* Linux Firmware Updater	HD(1,GPT,58da233f-b177-4c57-8bee-3d888b3047d4,0x800,0x64000)/File(\EFI\fedora\shimx64.efi) File(.\fwupdx64.efi)
- if the loader is 16-bytes, it formats it as an id guid
  before:
    Boot0004* UEFI ATAPI iHAS324 E 3524706 2B8427502710 PciRoot(0x0)/Pci(0x1f,0x2)/Sata(1,65535,0)N.....YM....R,Y.
  after:
    Boot0004* UEFI ATAPI iHAS324 E 3524706 2B8427502710 PciRoot(0x0)/Pci(0x1f,0x2)/Sata(1,65535,0){8108ac4e-9f11-4d59-850e-e21a522c59b2}
  or if it recognizes the guid (which in this case depends on a newer libefivar):
    Boot0004* UEFI ATAPI iHAS324 E 3524706 2B8427502710 PciRoot(0x0)/Pci(0x1f,0x2)/Sata(1,65535,0){auto_created_boot_option}
  where the value between {} is the value from "efivar -L":
    trillian:~/devel/github.com/efivar/master$ LD_LIBRARY_PATH=$PWD/src/ ./src/efivar -L | grep auto_created_boot_option
    {8108ac4e-9f11-4d59-850e-e21a522c59b2} {auto_created_boot_option} efi_guid_auto_created_boot_option	Automatically Created Boot Entry

Signed-off-by: Peter Jones <pjones@redhat.com>
2019-10-11 16:17:36 -04:00
Robert Bisewski
93494ce815 adjusting readmes and man page to correct partition + mount word order 2019-10-11 16:17:36 -04:00
Chih-Wei Huang
1f8561f59a Android: inital porting of efibootmgr
The libefivar porting is also required.

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
2019-10-11 16:16:11 -04:00
Sly_tom_cat
58cfa9ff8f Add options to allow driver entries to have the reconnect flag.
Signed-off-by: Peter Jones <pjones@redhat.com>
2019-10-11 16:14:03 -04:00
Peter Jones
17120dfc23 Add definitions for all currently defined load option attributes.
Signed-off-by: Peter Jones <pjones@redhat.com>
2019-10-11 16:14:03 -04:00
Peter Jones
d1d1274101 Refactor entry list searching and attribute updating
Signed-off-by: Peter Jones <pjones@redhat.com>
2019-10-11 16:14:03 -04:00
Peter Jones
d9eb7f1536 Get rid of a memory leak of deleted boot entries.
Signed-off-by: Peter Jones <pjones@redhat.com>
2019-05-28 17:00:31 -04:00
Peter Jones
438ba96669 Make the man pages honor DEFAULT_LOADER and similar.
Fixes github issue #93.

Signed-off-by: Peter Jones <pjones@redhat.com>
2019-03-06 14:14:56 -05:00
Andy Shevchenko
a4a5296247 Allow build with uClibc
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2019-03-06 13:50:08 -05:00
Robert Bisewski
393e9b869c minor fix to restore activation error message (#89) 2019-03-06 13:33:48 -05:00
Rene Kjellerup
7076cea3d7 fixed the simple run example (#88)
made the simple invocation and its output
more reader friendly in the rendered markdown
2019-03-06 13:32:16 -05:00
Peter Jones
97668ae0bc Make sure PKGS= is propogated into the submake for "make deps"
When we're doing make deps with "$(CC) -MF", gcc and clang have different
behavior, both broken in different ways, which we're hitting because of a
missing -I argument for libefivar's includes.  On clang, when a header can't
be found, it emits a rule with the header as a prerequisite without a path,
such as efivar.h here:

efibootmgr.o: efibootmgr.c fix_coverity.h efivar.h efiboot.h \
  /home/pjones/devel/github.com/efibootmgr/master/src/include/list.h \
  /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \
  /home/pjones/devel/github.com/efibootmgr/master/src/include/unparse_path.h \
  /home/pjones/devel/github.com/efibootmgr/master/src/include/efibootmgr.h \
  error.h

Then the build that utilizes that rule will fail to find the
prerequisite and tell you something like:

make[1]: *** No rule to make target 'efivar.h', needed by 'efibootmgr.o'.  Stop.
make[1]: Leaving directory '/home/pjones/devel/github.com/efibootmgr/master/src'

With gcc, when a header can't be found, it emits a rule without that header
as a prerequisite, as such (again with efivar.h):

efibootmgr.o: efibootmgr.c fix_coverity.h \
 /home/pjones/devel/github.com/efibootmgr/master/src/include/list.h \
 /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \
 /home/pjones/devel/github.com/efibootmgr/master/src/include/unparse_path.h \
 /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \
 /home/pjones/devel/github.com/efibootmgr/master/src/include/efibootmgr.h \
 error.h

And then your build will fail if you haven't adjusted CFLAGS to tell it
where to find the header.

Both of these would be better just erroring, but at least gcc's doesn't
insert a *wrong* dependency.

This patch adds "PKGS=efivar efibootmgr popt" for all deps under src/.
Technically that's overkill, as efibootmgr itself doesn't need popt, but it
doesn't hurt anything to have the extra part there.  The resulting
.efibootmgr.d file has the prerequisites expressed correctly:

efibootmgr.o: efibootmgr.c fix_coverity.h /usr/include/efivar/efivar.h \
 /usr/include/efivar/efiboot.h \
 /home/pjones/devel/github.com/efibootmgr/master/src/include/list.h \
 /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \
 /home/pjones/devel/github.com/efibootmgr/master/src/include/unparse_path.h \
 /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \
 /home/pjones/devel/github.com/efibootmgr/master/src/include/efibootmgr.h \
 error.h

This fixes the issue described in github PR #96

Signed-off-by: Peter Jones <pjones@redhat.com>
2019-03-06 13:27:21 -05:00
Hans Meine
b7c1c42cd6 In verbose mode, don’t exit() with ec when parsing an entry, just warn
Signed-off-by: Peter Jones <pjones@redhat.com>
2019-03-06 10:26:28 -05:00