OSDN Git Service

android-x86/external-efibootmgr.git
6 years agoAndroid: inital porting of efibootmgr nougat-x86 android-x86-7.1-r1 android-x86-7.1-r2 android-x86-7.1-r3 android-x86-7.1-r4 android-x86-7.1-r5
Chih-Wei Huang [Fri, 12 Jan 2018 03:32:54 +0000 (11:32 +0800)]
Android: inital porting of efibootmgr

The libefivar porting is also required.

7 years agomake_linux_load_option(): check data_size correctly.
Peter Jones [Tue, 9 May 2017 20:46:13 +0000 (16:46 -0400)]
make_linux_load_option(): check data_size correctly.

Coverity noticed that we're not checking data_size for NULLness before
dereferencing it to pass the value to efi_loadopt_create().  So now we
pass a temporary variable and assign it only if it's non-NULL.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agounparse_path: remove unneeded include
Josh de Kock [Sun, 12 Mar 2017 11:50:37 +0000 (11:50 +0000)]
unparse_path: remove unneeded include

This fixes an invalid redefinition of wchar_t when compiling with hardened gcc-musl on gentoo.

7 years agoBump version to 15
Peter Jones [Tue, 14 Feb 2017 16:51:54 +0000 (11:51 -0500)]
Bump version to 15

7 years agoMake conditional default loader path use EFIDIR like fwupdate does.
Peter Jones [Mon, 6 Mar 2017 21:24:10 +0000 (16:24 -0500)]
Make conditional default loader path use EFIDIR like fwupdate does.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoMake default '--loader' build-time configurable.
Raymund Will [Fri, 10 Feb 2017 15:35:17 +0000 (16:35 +0100)]
Make default '--loader' build-time configurable.

Each distribution uses a specific 'vendor'-directory in the
'efi' directory on the EFI System Partition to store their
EFI loader.  There's little use in hardcoding the value
for just one in 'efibootmgr', which is displayed in '--help'
and used as default without '--loader'.

Simply use
  make OS_VENDOR=<vendor> EFI_LOADER=<loader>.efi
to get the desired value.  :)

Signed-off-by: Raymund Will <rw@suse.com>
7 years agoefibootmgr: sanitize `set/get_mirror()`
Raymund Will [Mon, 13 Feb 2017 14:33:52 +0000 (15:33 +0100)]
efibootmgr: sanitize `set/get_mirror()`

get_mirror()
- don't short-circuit the assignment of values in case of version mismatch
  as `show_mirror()` happily tries to use them nevertheless
- move redundant warning (from `show_mirror()`s PoV) to `set_mirror()`
- add missing `free(data)`

set_mirror()
- skip obsolete second assignment of `data`
- avoid potentially "uninitialized" access to `above/below4g` by protecting
  it with `opts.set_mirror_hi/_lo` respectively, thus simplifying the code
  down the line
Note: this will prevent unnecessary write-operations!

Signed-off-by: Raymund Will <rw@suse.com>
7 years agoAdd support for parsing optional data as ucs2
Martin T. H. Sandsmark [Fri, 30 Dec 2016 13:33:27 +0000 (14:33 +0100)]
Add support for parsing optional data as ucs2

7 years agoRemove extra const keywords gcc 7 gripes about.
Peter Jones [Mon, 6 Feb 2017 21:34:54 +0000 (16:34 -0500)]
Remove extra const keywords gcc 7 gripes about.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoDon't use -fshort-wchar when building (#63)
steve-mcintyre [Fri, 6 Jan 2017 18:18:47 +0000 (18:18 +0000)]
Don't use -fshort-wchar when building (#63)

It's not needed and is causing build failures with gcc 6. Closes
Debian bug #849651

Signed-off-by: Steve McIntyre <steve@einval.com>
7 years agoBump version to 14
Peter Jones [Tue, 27 Sep 2016 18:43:19 +0000 (14:43 -0400)]
Bump version to 14

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoefibootdump: Get rid of extra debug print
Peter Jones [Tue, 27 Sep 2016 19:02:13 +0000 (15:02 -0400)]
efibootdump: Get rid of extra debug print

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoMove -flto from cflags to CFLAGS
Mike Gilbert [Tue, 23 Aug 2016 14:11:12 +0000 (10:11 -0400)]
Move -flto from cflags to CFLAGS

LTO is an optimization that isn't always desired. This change allows it
to be disabled easily.

7 years agoDon't bother with --default-symver since we've got no library code here.
Peter Jones [Mon, 22 Aug 2016 15:03:08 +0000 (11:03 -0400)]
Don't bother with --default-symver since we've got no library code here.

ld.gold breaks with it, for basically no reason, but we're not really
using it anyway.

Resolves github issue #56.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoMake compiler detection slightly better.
Peter Jones [Mon, 22 Aug 2016 14:59:58 +0000 (10:59 -0400)]
Make compiler detection slightly better.

Resolves github issue #57.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoFix EFIBOOTMGR_VERSION setting and -V output
Peter Jones [Mon, 22 Aug 2016 14:49:39 +0000 (10:49 -0400)]
Fix EFIBOOTMGR_VERSION setting and -V output

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoefibootmgr: fixes in man page synopsis and README
Chris Mayo [Fri, 19 Aug 2016 07:02:47 +0000 (08:02 +0100)]
efibootmgr: fixes in man page synopsis and README

- more --delete-bootnum description fixes
- make -r | -y bold
- delete -H and -U (removed in 83f34d39299)

7 years agoInstall efibootdump with make
Chris Mayo [Thu, 18 Aug 2016 18:56:19 +0000 (19:56 +0100)]
Install efibootdump with make

7 years agoCreate README.md
Jonathan [Thu, 18 Aug 2016 08:40:50 +0000 (10:40 +0200)]
Create README.md

7 years agoFix a typo in popt options.
Peter Jones [Thu, 11 Aug 2016 15:48:06 +0000 (11:48 -0400)]
Fix a typo in popt options.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoefibootmgr: remove "(hex)" from description of --delete-bootnum
Chris Mayo [Mon, 15 Aug 2016 18:41:16 +0000 (19:41 +0100)]
efibootmgr: remove "(hex)" from description of --delete-bootnum

Boot entry selected with --bootnum

7 years agoefibootmgr 13
Peter Jones [Wed, 10 Aug 2016 21:58:07 +0000 (17:58 -0400)]
efibootmgr 13

- Add support for --sysprep and --driver to support UEFI System Prep
  Applications and UEFI Drivers.
- use efivar's error reporting facility, and show error traces when
  "-v -v" is used.
- Still yet better error codes returned on failures.
- Add -m and -M to support Memory Address Range Mirroring.
- Add efibootdump, to examine Boot* variables found in tarballs in bug
  reports and similar.
- miscellaneous bugfixes.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoefibootdump: give it the error.h treatment
Peter Jones [Thu, 11 Aug 2016 15:48:06 +0000 (11:48 -0400)]
efibootdump: give it the error.h treatment

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoAdd support for --sysprep and --driver
Peter Jones [Mon, 2 May 2016 14:49:49 +0000 (10:49 -0400)]
Add support for --sysprep and --driver

Maybe this fixes issue rhinstaller/efibootmgr#40 .

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years ago.spec: fix requirements for newer efivar and man page path.
Peter Jones [Wed, 10 Aug 2016 21:57:56 +0000 (17:57 -0400)]
.spec: fix requirements for newer efivar and man page path.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoefibootmgr: use efivar's error facility.
Peter Jones [Wed, 10 Aug 2016 21:54:49 +0000 (17:54 -0400)]
efibootmgr: use efivar's error facility.

8 years agoStop preceeding our version number with a "0.".
Peter Jones [Tue, 19 Jul 2016 15:54:17 +0000 (11:54 -0400)]
Stop preceeding our version number with a "0.".

It's useless and it just makes people whine about it not being >1.0.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoREADME: update github link
Mike Gilbert [Mon, 30 May 2016 16:06:52 +0000 (12:06 -0400)]
README: update github link

8 years agoREADME: fix netboot command line since we have acpi bits now.
Peter Jones [Tue, 24 May 2016 15:56:33 +0000 (11:56 -0400)]
README: fix netboot command line since we have acpi bits now.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootmgr: fix usage of efi_loadopt_path() /again/.
Peter Jones [Tue, 24 May 2016 15:33:20 +0000 (11:33 -0400)]
efibootmgr: fix usage of efi_loadopt_path() /again/.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootmgr: fix up a lot of error result codes.
Peter Jones [Mon, 2 May 2016 17:12:58 +0000 (13:12 -0400)]
efibootmgr: fix up a lot of error result codes.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoHandle "-@ -" correctly again.
Peter Jones [Mon, 2 May 2016 15:38:07 +0000 (11:38 -0400)]
Handle "-@ -" correctly again.

This should fix issue #39.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoAdd lacking description of man for -m and -M option
Taku Izumi [Fri, 11 Mar 2016 02:45:27 +0000 (11:45 +0900)]
Add lacking description of man for -m and -M option

Currently there's no description of efibootmgr man page
for -m and -M option.

This patch adds the lacking description for -m and -M
option.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
8 years agoAdd lacking description of man for -m and -M option
Taku Izumi [Thu, 10 Mar 2016 01:45:57 +0000 (10:45 +0900)]
Add lacking description of man for -m and -M option

Currently there's no description of efibootmgr man page
for -m and -M option.

This patch adds the lacking description for -m and -M
option.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
8 years agoExplicitly pass a mode to efi_set_variable() in all cases.
Peter Jones [Thu, 3 Mar 2016 14:50:03 +0000 (09:50 -0500)]
Explicitly pass a mode to efi_set_variable() in all cases.

We'll have to do this for efivar-0.24 .

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootmgr.spec: allow building on arm
Peter Jones [Thu, 25 Feb 2016 19:29:37 +0000 (14:29 -0500)]
efibootmgr.spec: allow building on arm

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootmgr.spec: require popt-devel
Peter Jones [Thu, 25 Feb 2016 19:29:16 +0000 (14:29 -0500)]
efibootmgr.spec: require popt-devel

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootmgr: fix some types the compiler doesn't like.
Peter Jones [Thu, 25 Feb 2016 19:16:38 +0000 (14:16 -0500)]
efibootmgr: fix some types the compiler doesn't like.

Basically uint8_t * vs char *.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootdump: add efibootdump
Peter Jones [Thu, 25 Feb 2016 15:54:23 +0000 (10:54 -0500)]
efibootdump: add efibootdump

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootnext: add make targets (but not default)
Peter Jones [Thu, 25 Feb 2016 15:53:22 +0000 (10:53 -0500)]
efibootnext: add make targets (but not default)

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefoconman: remove from default make targets for now
Peter Jones [Thu, 25 Feb 2016 15:52:40 +0000 (10:52 -0500)]
efoconman: remove from default make targets for now

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefibootmgr: update for efivar 0.24
Peter Jones [Thu, 25 Feb 2016 15:43:40 +0000 (10:43 -0500)]
efibootmgr: update for efivar 0.24

As of 0.24 efi_loadopt_pathlen() and efi_loadopt_path() require a limit
argument to avoid overruns of the input data.

This patch adds reasonable limits to those calls.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoAdd -Wextra, because it finds a lot of bugs in GCC6
Peter Jones [Thu, 18 Feb 2016 16:10:08 +0000 (11:10 -0500)]
Add -Wextra, because it finds a lot of bugs in GCC6

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoeficonman: intialize poptOptions with named initializers.
Peter Jones [Thu, 18 Feb 2016 16:05:21 +0000 (11:05 -0500)]
eficonman: intialize poptOptions with named initializers.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoAdd efibootnext beginnings
Peter Jones [Thu, 19 Nov 2015 19:48:19 +0000 (14:48 -0500)]
Add efibootnext beginnings

efibootnext will (eventually) attempt to find any suitable boot device
and set it as BootNext.  To be used when other variable writes have
failed, in case it will use less space.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoAdd eficonman beginnings
Peter Jones [Thu, 12 Nov 2015 15:56:22 +0000 (10:56 -0500)]
Add eficonman beginnings

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoFix insusufficient validation check of -M option
Taku Izumi [Tue, 26 Jan 2016 05:32:50 +0000 (14:32 +0900)]
Fix insusufficient validation check of -M option

The acceptable range of -M (--mirror-above-4G) option should
be from 0 to 50. So the negative value should be rejected.
Otherwise unintended value can be specified.

e.g.

 > efibootmgr -M -3
...
MirroredPercentageAbove4G: 25.00
MirrorMemoryBelow4GB: true
RequestMirroredPercentageAbove4G: 652.36
RequestMirrorMemoryBelow4GB: true

 652.36 is invalid value for MirroredPercentageAbove4G and should
 not be specified.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
8 years agoAdd LOCALEDIR make goo
Peter Jones [Thu, 12 Nov 2015 15:57:15 +0000 (10:57 -0500)]
Add LOCALEDIR make goo

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoSimplify directory structure.
Peter Jones [Tue, 4 Aug 2015 14:36:31 +0000 (10:36 -0400)]
Simplify directory structure.

We're making a lot less stuff than we did before libefivar.so existed,
and there's not a lot of reason for it.  Collapse the directory
structure entirely, and move to more modern makefiles.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoSet pkg-config binary as variable
Timo Gurr [Tue, 30 Jun 2015 09:33:14 +0000 (11:33 +0200)]
Set pkg-config binary as variable

Allow the location of the pkg-config binary to be set using the
parameter PKG_CONFIG. Needed to support cross compilation toolchains.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake it a little clearer what's going on when efi_del_variable() fails.
Peter Jones [Thu, 25 Jun 2015 13:56:37 +0000 (09:56 -0400)]
Make it a little clearer what's going on when efi_del_variable() fails.

Right now if efi_del_variable() fails we try a couple of things for
compatibility reasons and we have too many different error messages.
Hopefully this makes it clearer.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoINSTALL: add note about missing efivar.h error
Jody Bruchon [Thu, 21 May 2015 12:16:08 +0000 (08:16 -0400)]
INSTALL: add note about missing efivar.h error

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoSet guid when reading boot entries in read_vars.
Alexis Murzeau [Sat, 18 Apr 2015 21:03:23 +0000 (23:03 +0200)]
Set guid when reading boot entries in read_vars.

set_active_state use boot->guid, so set it to EFI_GLOBAL_GUID.

9 years agoDelete BootOrder only when necessary.
Shih-Yuan Lee (FourDollars) [Mon, 1 Jun 2015 10:36:40 +0000 (18:36 +0800)]
Delete BootOrder only when necessary.

Signed-off-by: Shih-Yuan Lee (FourDollars) <sylee@ubuntu.com>
9 years agoAdd -m and -M options to support address range mirror
Luck, Tony [Tue, 9 Jun 2015 17:14:58 +0000 (10:14 -0700)]
Add -m and -M options to support address range mirror

BIOS and OS pass messages for address range mirror using a pair of
UEFI variables:

   MirrorCurrent: Written by BIOS to tell the OS that the platform supports
address range mirror and to say whether mirroring was set up using
the desired parameters
   MirrorRequest: Written by OS to tell BIOS new paramters to use on next boot

This is documented in the RAS validation guide for memory address range
mirroring for the Xeon E7-v3 family:

  https://software.intel.com/sites/default/files/managed/43/6a/Memory%20Address%20Range%20Mirroring%20Validation%20Guide.pdf

Signed-off-by: Tony Luck <tony.luck@intel.com>
9 years agoUpdate version to 0.12
Peter Jones [Thu, 28 May 2015 13:50:37 +0000 (09:50 -0400)]
Update version to 0.12

- use -lefivar and -lefiboot to make device paths and load options.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoUpdate build deps in the spec to match what libraries we actually use.
Peter Jones [Thu, 28 May 2015 14:16:47 +0000 (10:16 -0400)]
Update build deps in the spec to match what libraries we actually use.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake the release procedure a bit more streamlined.
Peter Jones [Thu, 28 May 2015 13:50:20 +0000 (09:50 -0400)]
Make the release procedure a bit more streamlined.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoAdd some language about efivar in INSTALL
Peter Jones [Wed, 27 May 2015 18:22:44 +0000 (14:22 -0400)]
Add some language about efivar in INSTALL

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoGet rid of pci-utils and zlib deps; we don't need them any more.
Peter Jones [Wed, 27 May 2015 18:06:26 +0000 (14:06 -0400)]
Get rid of pci-utils and zlib deps; we don't need them any more.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake loadopt function names use efivar-0.19 names.
Peter Jones [Wed, 27 May 2015 18:06:06 +0000 (14:06 -0400)]
Make loadopt function names use efivar-0.19 names.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoGet us back to where we were before with network entries.
Peter Jones [Thu, 30 Apr 2015 17:59:00 +0000 (13:59 -0400)]
Get us back to where we were before with network entries.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoWe don't need the ucs2/utf8 code either.
Peter Jones [Thu, 30 Apr 2015 15:31:39 +0000 (11:31 -0400)]
We don't need the ucs2/utf8 code either.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoGet rid of efichar.h; it's no longer used.
Peter Jones [Thu, 30 Apr 2015 15:23:18 +0000 (11:23 -0400)]
Get rid of efichar.h; it's no longer used.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoFix the github url once more.
Peter Jones [Thu, 30 Apr 2015 15:14:42 +0000 (11:14 -0400)]
Fix the github url once more.

This currently lives under the rhinstaller github account.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoGet rid of manually specified ACPI arguments; we don't need them.
Peter Jones [Thu, 30 Apr 2015 15:08:21 +0000 (11:08 -0400)]
Get rid of manually specified ACPI arguments; we don't need them.

Since we have pretty good detection of acpi hid/uid now, we don't
actually need them to be manually specified anywhere.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake -e 1 and -e 3 work again after the libefiboot shuffle.
Peter Jones [Wed, 29 Apr 2015 19:13:10 +0000 (15:13 -0400)]
Make -e 1 and -e 3 work again after the libefiboot shuffle.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake file boot option creation use libefiboot to create the device path.
Peter Jones [Tue, 7 Apr 2015 20:14:43 +0000 (16:14 -0400)]
Make file boot option creation use libefiboot to create the device path.

(right now network options are horribly broken, but they never really
worked anyway, so... yeah, I'll fix them in a subsequent commit.)

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoAdd "efibootmgr -C"; create only without appending to BootOrder
Peter Jones [Tue, 31 Mar 2015 14:56:08 +0000 (10:56 -0400)]
Add "efibootmgr -C"; create only without appending to BootOrder

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoGet rid of a lot of DP stuff that efivar does now.
Peter Jones [Tue, 31 Mar 2015 14:55:35 +0000 (10:55 -0400)]
Get rid of a lot of DP stuff that efivar does now.

9 years agoGet run of unparse_path() and unparse_raw()
Peter Jones [Mon, 2 Mar 2015 20:23:47 +0000 (15:23 -0500)]
Get run of unparse_path() and unparse_raw()

We don't use these any more.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake show_boot_vars use efivars DP formatting code.
Peter Jones [Fri, 27 Feb 2015 18:31:11 +0000 (13:31 -0500)]
Make show_boot_vars use efivars DP formatting code.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't depend on vendor-defined calloc(n, 0) behavior.
Peter Jones [Mon, 12 Jan 2015 19:15:24 +0000 (14:15 -0500)]
Don't depend on vendor-defined calloc(n, 0) behavior.

If we don't have any boot variables, we know that 0 is free, so just
return that.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoTest a couple of pointers for NULL-ness.
Peter Jones [Mon, 12 Jan 2015 19:09:23 +0000 (14:09 -0500)]
Test a couple of pointers for NULL-ness.

In both of these cases buf is NULL if and only if the size is also 0,
and thus we'll fail the test anyway, but coverify isn't noticing that.
And I'm tired of talking to a piece of software about its deficiencies.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoFree some stuff in error pathways.
Peter Jones [Mon, 12 Jan 2015 19:03:06 +0000 (14:03 -0500)]
Free some stuff in error pathways.

This is just to make covscan gripe less.  These variables are legitimate
leaks, though the program is just going to exit afterward anyway.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't malloc(0).
Peter Jones [Mon, 12 Jan 2015 19:05:17 +0000 (14:05 -0500)]
Don't malloc(0).

This is covscan noticing that we're starting at 0 hunks instead of 1
hunk, and that means the first allocation is of 0 bytes, which is inane.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoFix buffer overflow when remove_from_boot_order removes nothing
Lenny Szubowicz [Tue, 6 Jan 2015 16:17:01 +0000 (11:17 -0500)]
Fix buffer overflow when remove_from_boot_order removes nothing

Deleting a boot entry via "-b xxxx -B" also attempts to remove
that entry from boot order via a call to remove_from_boot_order.
Although unusual, it's possible that the entry being deleted is
not in boot order. Correct the handling of this case in
remove_from_boot_order, which malloc's space for the new boot
order list wrongly assuming that at least one entry will be
removed. However, if no entry is removed, then 2 bytes are
overwritten beyond the malloc'ed space. This can result in heap
corruption and possible termination via a SIGABRT if the
corruption is detected by the heap allocation routines.

While there, simplify the routine to do the removal of boot
entries in place in the original data buffer, skip the
unnecessary BootOrder variable update if nothing got removed,
and free the malloc'ed boot_order struct on the way out.

Resolves: RH BZ 1168019

Signed-off-by: Lenny Szubowicz <lszubowi@redhat.com>
9 years agoSkip unreadable variables, but don't exit when we do so.
Daniel Jared Dominguez [Thu, 18 Dec 2014 19:35:27 +0000 (14:35 -0500)]
Skip unreadable variables, but don't exit when we do so.

Old versions of efibootmgr and libefivar0 allowed the installation of
necessary EFI boot entries on the affected systems. It seems that an old
libefivar0 did not report read errors.

Then libefivar0 started to crash on unreadable variables (see Debian bug
764386). Since that bug has been fixed, efibootmgr doesn't crash
anymore, but the read errors are reported and efibootmgr always fails
with an input/output error.

Resolves: debian bug 768880

Signed-off-by: Jan Echternach <jan@goneko.de>
Signed-off-by: Daniel Jared Dominguez <Jared_Dominguez@Dell.com>
Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake IPv6 network paths print correctly.
Peter Jones [Tue, 16 Dec 2014 15:01:10 +0000 (10:01 -0500)]
Make IPv6 network paths print correctly.

This should fix issue #13 .

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake IPv4() device paths print correctly.
Peter Jones [Tue, 16 Dec 2014 14:59:53 +0000 (09:59 -0500)]
Make IPv4() device paths print correctly.

We need to give the size to snprintf, not the offset.  The offset is
zero, so it'll only ever tell us the buffer size we need, even if we
have a reasonable buffer.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake the optional_data_len size signed.
Peter Jones [Tue, 16 Dec 2014 14:57:27 +0000 (09:57 -0500)]
Make the optional_data_len size signed.

Steve McIntyre's testing on i386 with efivars using the legacy path
(i.e. not efivarfs) also found a bug here - we're checking
optional_data_len for negative error values, but it's unsigned.  We're
not going to have 4GB of optional loader data, so just make it signed.

This should fix Issue #21 .

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoFix MAC() device path printing.
Peter Jones [Fri, 12 Dec 2014 21:01:00 +0000 (16:01 -0500)]
Fix MAC() device path printing.

67491a308 accidentally made it print MAC(MAC( .

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoPrint a better message if BootOrder is unset.
Peter Jones [Thu, 11 Dec 2014 15:18:37 +0000 (10:18 -0500)]
Print a better message if BootOrder is unset.

This resolves issue #7 .

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't name something efi_variable_t; that namespace is used by efivar.
Peter Jones [Thu, 11 Dec 2014 14:37:00 +0000 (09:37 -0500)]
Don't name something efi_variable_t; that namespace is used by efivar.

Newer efivar has efi_variable_t as a type for its import/export api
(which efibootmgr can use at some point), so don't make a type with that
name internally here.

This fixes github issue #20

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoUpdate version to 0.10
Peter Jones [Tue, 21 Oct 2014 20:17:27 +0000 (16:17 -0400)]
Update version to 0.10

- Fix "-n" and friends not being assigned/checked right sometimes from
  0.10.0-1
- Generate more archives to avoid people using github's, because
  they're just bad.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDo even more absurd stuff to avoid github's terrible tarballs.
Peter Jones [Tue, 21 Oct 2014 20:14:54 +0000 (16:14 -0400)]
Do even more absurd stuff to avoid github's terrible tarballs.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoActually /set/ the values we're using to the results of parsing the number.
Peter Jones [Tue, 21 Oct 2014 20:02:13 +0000 (16:02 -0400)]
Actually /set/ the values we're using to the results of parsing the number.

This should fix https://github.com/vathpela/efibootmgr/issues/18

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't check if '-n' is a current boot entry so early.
Peter Jones [Tue, 21 Oct 2014 19:01:03 +0000 (15:01 -0400)]
Don't check if '-n' is a current boot entry so early.

We haven't made the list yet, so it'll always be wrong.

This should fix part of https://github.com/vathpela/efibootmgr/issues/18

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoAudit error checking in main().
Peter Jones [Mon, 20 Oct 2014 18:34:17 +0000 (14:34 -0400)]
Audit error checking in main().

Previously, one return value wound up not being checked at all,
resulting in https://github.com/vathpela/efibootmgr/issues/14 , and
several weren't checked as they should have been.

Sorry about that.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake the version 0.10.0
Peter Jones [Mon, 20 Oct 2014 16:21:02 +0000 (12:21 -0400)]
Make the version 0.10.0

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake all the other places we're parsing XXXX also do a better job.
Peter Jones [Mon, 20 Oct 2014 16:15:26 +0000 (12:15 -0400)]
Make all the other places we're parsing XXXX also do a better job.

This is related to https://github.com/vathpela/efibootmgr/issues/12 .

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake -o's behavior actually match the documented behavior.
Peter Jones [Mon, 20 Oct 2014 16:04:34 +0000 (12:04 -0400)]
Make -o's behavior actually match the documented behavior.

Also make it a bit better and reporting errors.

This should actually resolve
https://github.com/vathpela/efibootmgr/issues/12 .

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't error on unset BootOrder when we're trying to add to or rm from it.
Peter Jones [Wed, 15 Oct 2014 14:28:13 +0000 (10:28 -0400)]
Don't error on unset BootOrder when we're trying to add to or rm from it.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoProduce a slightly more succinct error when we get -EPERM on the disk.
Peter Jones [Wed, 15 Oct 2014 14:16:55 +0000 (10:16 -0400)]
Produce a slightly more succinct error when we get -EPERM on the disk.

Because one error message is enough.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoDon't call EPERM "not found" when deleting variables.
Peter Jones [Wed, 15 Oct 2014 14:09:13 +0000 (10:09 -0400)]
Don't call EPERM "not found" when deleting variables.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agomanpage lists option '--test' which doesn't seem to exist
D. Jared Dominguez [Tue, 14 Oct 2014 21:24:02 +0000 (16:24 -0500)]
manpage lists option '--test' which doesn't seem to exist

I'm passing along this bug report from Debian:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=759714

Here's a quick fix:

9 years agoAdd more error messages and better return codes.
Peter Jones [Wed, 15 Oct 2014 13:20:04 +0000 (09:20 -0400)]
Add more error messages and better return codes.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoOne more place we're not printing the error code.
Peter Jones [Tue, 14 Oct 2014 21:15:43 +0000 (17:15 -0400)]
One more place we're not printing the error code.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoFix a segfault in append_extra_args_ascii()
Peter Jones [Tue, 14 Oct 2014 21:09:37 +0000 (17:09 -0400)]
Fix a segfault in append_extra_args_ascii()

How that worked at all before was beyond me.

Signed-off-by: Peter Jones <pjones@redhat.com>
9 years agoMake a few more return paths print some modicum of error message.
Peter Jones [Tue, 14 Oct 2014 19:09:56 +0000 (15:09 -0400)]
Make a few more return paths print some modicum of error message.

Signed-off-by: Peter Jones <pjones@redhat.com>