Accepting request 477131 from home:rwill:Factory

- Update to 14 plus upstream fixes.  (fate#322108)
- Forward port and refresh SLE patches

OBS-URL: https://build.opensuse.org/request/show/477131
OBS-URL: https://build.opensuse.org/package/show/Base:System/efibootmgr?expand=0&rev=37
This commit is contained in:
Raymund Will 2017-03-06 10:25:22 +00:00 committed by Git OBS Bridge
parent d72495ce93
commit 3117d284d2
13 changed files with 710 additions and 310 deletions

View File

@ -0,0 +1,29 @@
From 3466fd05c8c6f1052e0426d64eed40f8a88fd78f Mon Sep 17 00:00:00 2001
From: steve-mcintyre <steve-github@einval.com>
Date: Fri, 6 Jan 2017 18:18:47 +0000
Subject: [PATCH 1/4] 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>
---
Make.defaults | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Make.defaults b/Make.defaults
index 50f1f4d..0ac50ef 100644
--- a/Make.defaults
+++ b/Make.defaults
@@ -26,7 +26,7 @@ clang_cflags =
gcc_cflags =
cflags = $(CFLAGS) $(SUBDIR_CFLAGS) \
-Werror -Wall -Wextra -Wsign-compare -Wstrict-aliasing \
- -std=gnu11 -fshort-wchar -fPIC \
+ -std=gnu11 -fPIC \
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DLOCALEDIR=\"$(localedir)\" \
-DEFIBOOTMGR_VERSION="\"$(VERSION)\"" \
$(if $(findstring clang,$(CC)),$(clang_cflags),) \
--
2.6.6

View File

@ -0,0 +1,49 @@
From 3217ab97776a6493099014f9a4820cbd39f1393a Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 6 Feb 2017 16:34:54 -0500
Subject: [PATCH 2/4] Remove extra const keywords gcc 7 gripes about.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/efibootdump.c | 2 +-
src/efibootmgr.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/efibootdump.c b/src/efibootdump.c
index 6ff8360..30a1943 100644
--- a/src/efibootdump.c
+++ b/src/efibootdump.c
@@ -39,7 +39,7 @@ print_boot_entry(efi_load_option *loadopt, size_t data_size)
uint8_t *optional_data = NULL;
size_t optional_data_len = 0;
uint16_t pathlen;
- const unsigned char const *desc;
+ const unsigned char *desc;
char *raw;
size_t raw_len;
diff --git a/src/efibootmgr.c b/src/efibootmgr.c
index 493f2cf..90a0998 100644
--- a/src/efibootmgr.c
+++ b/src/efibootmgr.c
@@ -221,7 +221,7 @@ warn_duplicate_name(list_t *var_list)
list_t *pos;
var_entry_t *entry;
efi_load_option *load_option;
- const unsigned char const *desc;
+ const unsigned char *desc;
list_for_each(pos, var_list) {
entry = list_entry(pos, var_entry_t, list);
@@ -873,7 +873,7 @@ show_vars(const char *prefix)
{
list_t *pos;
var_entry_t *boot;
- const unsigned char const *description;
+ const unsigned char *description;
efi_load_option *load_option;
efidp dp = NULL;
unsigned char *optional_data = NULL;
--
2.6.6

View File

@ -0,0 +1,113 @@
From c444d8c19de7ea28a0eb4ac4639d6d99d982ca31 Mon Sep 17 00:00:00 2001
From: "Martin T. H. Sandsmark" <martin.sandsmark@kde.org>
Date: Fri, 30 Dec 2016 14:33:27 +0100
Subject: [PATCH 3/4] Add support for parsing optional data as ucs2
---
src/efibootmgr.8 | 2 +-
src/efibootmgr.c | 62 +++++++++++++++++++++++++++++++++++++++++++-------------
2 files changed, 49 insertions(+), 15 deletions(-)
diff --git a/src/efibootmgr.8 b/src/efibootmgr.8
index 9208608..20a20b8 100644
--- a/src/efibootmgr.8
+++ b/src/efibootmgr.8
@@ -106,7 +106,7 @@ Boot Manager timeout, in \fIseconds\fR\&.
Delete Timeout variable.
.TP
\fB-u | --unicode | --UCS-2 \fR
-pass extra command line arguments as UCS-2 (default is
+Handle extra command line arguments as UCS-2 (default is
ASCII)
.TP
\fB-v | --verbose\fR
diff --git a/src/efibootmgr.c b/src/efibootmgr.c
index 90a0998..20d71e2 100644
--- a/src/efibootmgr.c
+++ b/src/efibootmgr.c
@@ -868,6 +868,36 @@ err:
return rc;
}
+#define ev_bits(val, mask, shift) \
+ (((val) & ((mask) << (shift))) >> (shift))
+
+static inline char *
+ucs2_to_utf8(const uint16_t * const chars, ssize_t limit)
+{
+ ssize_t i, j;
+ char *ret;
+
+ ret = alloca(limit * 6 + 1);
+ if (!ret)
+ return NULL;
+ memset(ret, 0, limit * 6 +1);
+
+ for (i=0, j=0; chars[i] && i < (limit >= 0 ? limit : i+1); i++,j++) {
+ if (chars[i] <= 0x7f) {
+ ret[j] = chars[i];
+ } else if (chars[i] > 0x7f && chars[i] <= 0x7ff) {
+ ret[j++] = 0xc0 | ev_bits(chars[i], 0x1f, 6);
+ ret[j] = 0x80 | ev_bits(chars[i], 0x3f, 0);
+ } else if (chars[i] > 0x7ff) {
+ ret[j++] = 0xe0 | ev_bits(chars[i], 0xf, 12);
+ ret[j++] = 0x80 | ev_bits(chars[i], 0x3f, 6);
+ ret[j] = 0x80| ev_bits(chars[i], 0x3f, 0);
+ }
+ }
+ ret[j] = '\0';
+ return strdup(ret);
+}
+
static void
show_vars(const char *prefix)
{
@@ -928,19 +958,23 @@ show_vars(const char *prefix)
if (rc < 0)
error(21, "Could not parse optional data");
- rc = unparse_raw_text(NULL, 0, optional_data,
- optional_data_len);
- if (rc < 0)
- error(22, "Could not parse optional data");
- rc += 1;
- text_path_len = rc;
- text_path = calloc(1, rc);
- if (!text_path)
- error(23, "Could not parse optional data");
- rc = unparse_raw_text(text_path, text_path_len,
- optional_data, optional_data_len);
- if (rc < 0)
- error(24, "Could not parse device path");
+ if (opts.unicode) {
+ text_path = ucs2_to_utf8((uint16_t*)optional_data, optional_data_len/2);
+ } else {
+ rc = unparse_raw_text(NULL, 0, optional_data,
+ optional_data_len);
+ if (rc < 0)
+ error(22, "Could not parse optional data");
+ rc += 1;
+ text_path_len = rc;
+ text_path = calloc(1, rc);
+ if (!text_path)
+ error(23, "Could not parse optional data");
+ rc = unparse_raw_text(text_path, text_path_len,
+ optional_data, optional_data_len);
+ if (rc < 0)
+ error(24, "Could not parse device path");
+ }
printf("%s", text_path);
free(text_path);
}
@@ -1211,7 +1245,7 @@ usage()
printf("\t-q | --quiet be quiet\n");
printf("\t-t | --timeout seconds set boot manager timeout waiting for user input.\n");
printf("\t-T | --delete-timeout delete Timeout.\n");
- printf("\t-u | --unicode | --UCS-2 pass extra args as UCS-2 (default is ASCII)\n");
+ printf("\t-u | --unicode | --UCS-2 handle extra args as UCS-2 (default is ASCII)\n");
printf("\t-v | --verbose print additional information\n");
printf("\t-V | --version return version and exit\n");
printf("\t-w | --write-signature write unique sig to MBR if needed\n");
--
2.6.6

View File

@ -0,0 +1,84 @@
From d89633f608177283e9ae0f16c7065768e64da0ca Mon Sep 17 00:00:00 2001
From: Raymund Will <rw@suse.com>
Date: Mon, 13 Feb 2017 15:33:52 +0100
Subject: [PATCH] efibootmgr: sanitize `set/get_mirror()`
References: bsc#987599
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>
---
src/efibootmgr.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/efibootmgr.c b/src/efibootmgr.c
index 20d71e2..15659c6 100644
--- a/src/efibootmgr.c
+++ b/src/efibootmgr.c
@@ -1106,12 +1106,12 @@ get_mirror(int which, int *below4g, int *above4g, int *mirrorstatus)
if (rc == 0) {
abm = (ADDRESS_RANGE_MIRROR_VARIABLE_DATA *)data;
if (!which && abm->mirror_version != MIRROR_VERSION) {
- warningx("** Warning ** : unrecognised version for memory mirror i/f");
- return 2;
+ rc = 2;
}
*below4g = abm->mirror_memory_below_4gb;
*above4g = abm->mirror_amount_above_4gb;
*mirrorstatus = abm->mirror_status;
+ free(data);
} else {
cond_warning(opts.verbose >= 2,
"Could not read variable '%s'", name);
@@ -1130,14 +1130,19 @@ set_mirror(int below4g, int above4g)
uint32_t attributes;
int oldbelow4g, oldabove4g;
- if ((s = get_mirror(0, &oldbelow4g, &oldabove4g, &status)) == 0) {
- if (oldbelow4g == below4g && oldabove4g == above4g)
- return 0;
- } else {
- warningx("** Warning ** : platform does not support memory mirror");
+ if ((s = get_mirror(0, &oldbelow4g, &oldabove4g, &status)) != 0) {
+ if (s == 2)
+ warningx("** Warning ** : unrecognised version for memory mirror i/f");
+ else
+ warningx("** Warning ** : platform does not support memory mirror");
return s;
}
+ below4g = opts.set_mirror_lo ? below4g : oldbelow4g;
+ above4g = opts.set_mirror_hi ? above4g : oldabove4g;
+ if (oldbelow4g == below4g && oldabove4g == above4g)
+ return 0;
+
data = (uint8_t *)&abm;
data_size = sizeof (abm);
attributes = EFI_VARIABLE_NON_VOLATILE
@@ -1145,10 +1151,9 @@ set_mirror(int below4g, int above4g)
| EFI_VARIABLE_RUNTIME_ACCESS;
abm.mirror_version = MIRROR_VERSION;
- abm.mirror_amount_above_4gb = opts.set_mirror_hi ? above4g : oldabove4g;
- abm.mirror_memory_below_4gb = opts.set_mirror_lo ? below4g : oldbelow4g;
+ abm.mirror_amount_above_4gb = above4g;
+ abm.mirror_memory_below_4gb = below4g;
abm.mirror_status = 0;
- data = (uint8_t *)&abm;
rc = efi_set_variable(ADDRESS_RANGE_MIRROR_VARIABLE_GUID,
ADDRESS_RANGE_MIRROR_VARIABLE_REQUEST, data,
data_size, attributes, 0644);
--
2.6.6

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a66f5850677e86255d93cb1cead04c3c48a823a2b864c579321f2a07f00256e6
size 35816

3
efibootmgr-14.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:377ec16484414b80afd1b8a586153d7ef55ccf048638080101d49b7c77f37ad8
size 34972

View File

@ -1,18 +0,0 @@
---
src/efibootmgr/efibootmgr.c | 3 +++
1 file changed, 3 insertions(+)
Index: efibootmgr-0.12/src/efibootmgr/efibootmgr.c
===================================================================
--- efibootmgr-0.12.orig/src/efibootmgr/efibootmgr.c
+++ efibootmgr-0.12/src/efibootmgr/efibootmgr.c
@@ -451,6 +451,9 @@ remove_dupes_from_boot_order(void)
/* Adjust the size if we didn't copy everything. */
new_data_size = sizeof(new_data[0]) * new_i;
+ if (new_i == 0)
+ return efi_del_variable(EFI_GLOBAL_GUID, "BootOrder");
+
/* Now new_data has what we need */
free(boot_order->data);
boot_order->data = (uint8_t *)new_data;

View File

@ -0,0 +1,310 @@
From 21741160071c83e4ae6b9fa268947abfd0d3405f Mon Sep 17 00:00:00 2001
From: Raymund Will <rw@suse.com>
Date: Fri, 3 Mar 2017 18:47:44 +0100
Subject: [PATCH] Extended Delete
References: bsc#870211, bsc#945705
Delete boot entries not only by number. but alse based on
- partition UUID, optionally restricted by loader
or
- disk and partition, again optionally restricted by loader.
This does unfortunately require an API-change of efivar!
Signed-off-by: Raymund Will <rw@suse.com>
---
src/efibootmgr.c | 187 ++++++++++++++++++++++++++++++++++++++++++++++-
src/include/efibootmgr.h | 3 +-
2 files changed, 185 insertions(+), 5 deletions(-)
diff --git a/src/efibootmgr.c b/src/efibootmgr.c
index 20d71e2..93663cb 100644
--- a/src/efibootmgr.c
+++ b/src/efibootmgr.c
@@ -608,6 +608,146 @@ delete_var(const char *prefix, uint16_t num)
return 0;
}
+static int
+delete_by_uuid(const char *prefix, char *uuid_str, char *loader)
+{
+ int count = 0;
+ list_t *pos, *tmp;
+ var_entry_t *entry;
+ const unsigned char *description;
+ efi_load_option *load_option;
+ efidp path = NULL;
+ char text_path[1024];
+
+ list_for_each_safe(pos, tmp, &entry_list) {
+ uint16_t pathlen;
+ ssize_t rc;
+
+ entry = list_entry(pos, var_entry_t, list);
+ load_option = (efi_load_option *)entry->data;
+ pathlen = efi_loadopt_pathlen(load_option,
+ entry->data_size);
+ path = efi_loadopt_path(load_option, entry->data_size);
+ rc = efidp_format_device_path(text_path, 1024,
+ path, pathlen);
+
+ if (rc < 0 || rc > 1024)
+ error(20, "Could not parse device path");
+
+ if (strlen(text_path) == 0)
+ continue;
+ if (strcasestr(text_path, uuid_str) == NULL)
+ continue;
+ if (loader && strcasestr(text_path, loader) == NULL)
+ continue;
+ /* found! */
+ if (opts.verbose) {
+ description = efi_loadopt_desc(load_option,
+ entry->data_size);
+ printf("Delete %s%04X %s\t%s\n",
+ prefix, entry->num, description, text_path);
+ }
+ if (delete_var(prefix, entry->num) != 0)
+ return -1;
+ count++;
+ }
+ if (count==0) {
+ /* Nothing changed => exit early */
+ exit(0);
+ }
+ return 0;
+}
+
+static int
+delete_by_dpl(const char *prefix, char *disk, uint32_t part, char *loader)
+{
+ int fd, rc;
+ uint64_t start, size;
+ efi_guid_t signature;
+ char sigstr[40];
+ char *sigstrp = sigstr;
+ uint8_t mbr_type, signature_type;
+
+ if (disk == NULL && part == 0 && loader == NULL)
+ errx(42, "Cowardly refusing to delete ALL %s entries.",
+ prefix);
+ if (disk == NULL) {
+ /* foreach d in gpt_disks
+ * delete_by_dpl(prefix, d, part, loader)
+ */
+ errx(42, "Future extension.");
+ }
+ if (part == 0) {
+ /* foreach p in partions_on_gpt_disk
+ * delete_by_dpl(prefix, disk, p, loader)
+ */
+ errx(42, "Future extension.");
+ }
+ memset((char *)&signature, 0, sizeof(signature));
+
+ fd = open(disk, O_RDONLY|O_DIRECT);
+ if (fd == -1)
+ error(42, "Could not open disk %s", disk);
+ rc = efi_disk_get_partition_info(fd, part, &start, &size,
+ (uint8_t*)&signature, &mbr_type, &signature_type);
+ close(fd);
+
+ if (rc)
+ return -1;
+ if (mbr_type != 0x02) {
+ errx(42, "Cowardly refusing non-GPT disk %s", disk);
+ }
+
+ efi_guid_to_str(&signature, &sigstrp);
+
+ if (opts.verbose && !loader) {
+ printf("About to delete all entries referring to UUID %s\n",
+ sigstr);
+ } else if ( opts.delete != 15) {
+ printf("About to delete all entries referring to loader %s\n"
+ " on UUID %s\n",
+ loader, sigstr);
+ }
+ return delete_by_uuid(prefix,sigstr,loader);
+}
+
+/* verbatim copy of same function in efivar/src/creator.c */
+static char *
+tilt_slashes(char *s)
+{
+ char *p;
+ for (p = s; *p; p++)
+ if (*p == '/')
+ *p = '\\';
+ return s;
+}
+
+static int
+check_uuid(const char *s)
+{
+ /* algorithm derived from efivar/src/guid.h */
+ size_t len = 36;
+ unsigned int i;
+ if (strlen(s) != len)
+ return -1;
+ for (i = 0; i < len; i++) {
+ if (i == 8 || i == 13 || i == 18 || i == 23) {
+ if (s[i] != '-')
+ return -1;
+ continue;
+ }
+ if (s[i] >= '0' && s[i] <= '9')
+ continue;
+ /* "| 0x20" is tolower() without having to worry about
+ * locale concerns, since we know everything here must
+ * be within traditional ascii space. */
+ if ((s[i] | 0x20) >= 'a' && (s[i] | 0x20) <= 'f')
+ continue;
+ return -1;
+ }
+ return 0;
+}
+
static void
set_var_nums(const char *prefix, list_t *list)
{
@@ -1215,7 +1355,9 @@ usage()
printf("\t-a | --active sets bootnum active\n");
printf("\t-A | --inactive sets bootnum inactive\n");
printf("\t-b | --bootnum XXXX modify BootXXXX (hex)\n");
- printf("\t-B | --delete-bootnum delete bootnum\n");
+ printf("\t-B | --delete-bootnum delete bootnum (specified with -b)\n");
+ printf("\t --delete delete entry by bootnum (-b), by UUID (-P)\n");
+ printf("\t or by disk+partition[+file] (-d -p -l)\n");
printf("\t-c | --create create new variable bootnum and add to bootorder\n");
printf("\t-C | --create-only create new variable bootnum and do not add to bootorder\n");
printf("\t-D | --remove-dups remove duplicate values from BootOrder\n");
@@ -1242,6 +1384,7 @@ usage()
printf("\t-o | --bootorder XXXX,YYYY,ZZZZ,... explicitly set BootOrder (hex)\n");
printf("\t-O | --delete-bootorder delete BootOrder\n");
printf("\t-p | --part part (defaults to 1) containing loader\n");
+ printf("\t-P | --part-uuid UUID select all variables for given partition UUID\n");
printf("\t-q | --quiet be quiet\n");
printf("\t-t | --timeout seconds set boot manager timeout waiting for user input.\n");
printf("\t-T | --delete-timeout delete Timeout.\n");
@@ -1267,6 +1410,7 @@ set_default_opts()
opts.label = (unsigned char *)"Linux";
opts.disk = "/dev/sda";
opts.part = 1;
+ opts.part_uuid = NULL;
}
static void
@@ -1288,6 +1432,7 @@ parse_opts(int argc, char **argv)
{"delete-bootnum", no_argument, 0, 'B'},
{"create", no_argument, 0, 'c'},
{"create-only", no_argument, 0, 'C'},
+ {"delete", no_argument, 0, 2},
{"remove-dups", no_argument, 0, 'D'},
{"disk", required_argument, 0, 'd'},
{"iface", required_argument, 0, 'i'},
@@ -1320,7 +1465,7 @@ parse_opts(int argc, char **argv)
};
c = getopt_long (argc, argv,
- "AaBb:cCDd:e:E:gH:i:l:L:M:m:n:No:Op:qt:TuU:v::Vw"
+ "AaBb:cCDd:e:E:gH:i:l:L:M:m:n:No:Op:P:qt:TuU:v::Vw"
"@:hry",
long_options, &option_index);
if (c == -1)
@@ -1368,11 +1513,16 @@ parse_opts(int argc, char **argv)
opts.create = 1;
opts.no_order = 1;
break;
+ case 2:
+ opts.delete |= 1;
+ break;
case 'D':
opts.deduplicate = 1;
break;
case 'd':
opts.disk = optarg;
+ if (opts.delete)
+ opts.delete |= 2;
break;
case 'e':
rc = sscanf(optarg, "%u", &num);
@@ -1410,6 +1560,9 @@ parse_opts(int argc, char **argv)
break;
case 'l':
opts.loader = optarg;
+ tilt_slashes(opts.loader);
+ if (opts.delete)
+ opts.delete |= 8;
break;
case 'L':
opts.label = (unsigned char *)optarg;
@@ -1474,6 +1627,17 @@ parse_opts(int argc, char **argv)
else
errorx(37, "invalid numeric value %s\n",
optarg);
+ if (opts.delete)
+ opts.delete |= 4;
+ break;
+ case 'P':
+ if ((rc=check_uuid(optarg)) < 0) {
+ fprintf(stderr,
+ "malformed partition UUID: %s (%d)\n",
+ optarg, rc);
+ exit(1);
+ }
+ opts.part_uuid = optarg;
break;
case 'q':
opts.quiet = 1;
@@ -1595,9 +1759,24 @@ main(int argc, char **argv)
set_var_nums(prefices[mode], &entry_list);
if (opts.delete) {
- if (opts.num == -1)
+ if (opts.part_uuid) {
+ ret = delete_by_uuid(prefices[mode], opts.part_uuid,
+ (opts.delete & 8) ? opts.loader : NULL);
+ if (ret < 0)
+ error(42, "Could not delete variable(s)");
+ } else if (opts.delete & 2) {
+ ret = delete_by_dpl(prefices[mode],
+ (opts.delete & 2) ? opts.disk : NULL,
+ (opts.delete & 4) ? opts.part : 0,
+ (opts.delete & 8) ? opts.loader : NULL);
+ if (ret < 0)
+ error(42, "Could not delete variable(s)");
+ } else if (opts.delete > 1)
+ errorx(3, "Disk and partition must be specified "
+ "(see the --delete option).");
+ else if (opts.num == -1)
errorx(3, "You must specify an entry to delete "
- "(see the -b option).");
+ "(e.g. with the -b option).");
else {
ret = delete_var(prefices[mode], opts.num);
if (ret < 0)
diff --git a/src/include/efibootmgr.h b/src/include/efibootmgr.h
index d692d0c..d2d90dc 100644
--- a/src/include/efibootmgr.h
+++ b/src/include/efibootmgr.h
@@ -60,6 +60,7 @@ typedef struct {
int keep_old_entries;
char *testfile;
char *extra_opts_file;
+ char *part_uuid;
uint32_t part;
int edd_version;
uint32_t edd10_devicenum;
@@ -70,7 +71,7 @@ typedef struct {
int below4g;
int above4g;
int deduplicate;
- unsigned int delete:1;
+ unsigned int delete:4;
unsigned int delete_order:1;
unsigned int delete_bootnext:1;
unsigned int quiet:1;
--
2.6.6

View File

@ -8,45 +8,46 @@ for just one in 'efibootmgr', which is displayed in '--help'
and used as default without '--loader'.
Simply use
make OS_VENDOR=redhat EFI_LOADER=grub.efi
to get the previous value. :)
make OS_VENDOR=<vendor> EFI_LOADER=<loader>.efi
to get the desired value. :)
Signed-off-by: Raymund Will <rw@suse.com>
---
Makefile | 4 ++++
src/efibootmgr/efibootmgr.c | 12 ++++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
Make.defaults | 4 ++++
src/efibootmgr.c | 9 +++++----
2 files changed, 9 insertions(+), 4 deletions(-)
Index: efibootmgr-0.12/Makefile
===================================================================
--- efibootmgr-0.12.orig/Makefile
+++ efibootmgr-0.12/Makefile
@@ -1,5 +1,8 @@
default: all
diff --git a/Make.defaults b/Make.defaults
index 0ac50ef..7ca17e3 100644
--- a/Make.defaults
+++ b/Make.defaults
@@ -9,6 +9,9 @@ localedir ?= $(datadir)/locale/
PCDIR ?= $(libdir)/pkgconfig
DESTDIR ?=
+ OS_VENDOR := vendor
+ EFI_LOADER := boot.efi
+OS_VENDOR := redhat
+EFI_LOADER := grub.efi
+
SIGNING_KEY := pjones
RELEASE_MAJOR := 0
RELEASE_MINOR := 12
@@ -8,6 +11,7 @@
RELEASE_STRING := $(RELEASE_NAME)-$(RELEASE_MAJOR).$(RELEASE_MINOR)
CFLAGS = $(EXTRA_CFLAGS) -DEFIBOOTMGR_VERSION=\"$(RELEASE_MAJOR).$(RELEASE_MINOR)\" \
+ -DDEFAULT_LOADER=\"\\\\efi\\\\$(OS_VENDOR)\\\\$(EFI_LOADER)\" \
-Wsign-compare -Wall -Werror -g -D_FILE_OFFSET_BITS=64 \
-I/usr/include/efivar
Index: efibootmgr-0.12/src/efibootmgr/efibootmgr.c
===================================================================
--- efibootmgr-0.12.orig/src/efibootmgr/efibootmgr.c
+++ efibootmgr-0.12/src/efibootmgr/efibootmgr.c
INSTALL ?= install
CROSS_COMPILE ?=
PKG_CONFIG = $(CROSS_COMPILE)pkg-config
@@ -29,6 +32,7 @@ cflags = $(CFLAGS) $(SUBDIR_CFLAGS) \
-std=gnu11 -fPIC \
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DLOCALEDIR=\"$(localedir)\" \
-DEFIBOOTMGR_VERSION="\"$(VERSION)\"" \
+ -DDEFAULT_LOADER=\"\\\\efi\\\\$(OS_VENDOR)\\\\$(EFI_LOADER)\" \
$(if $(findstring clang,$(CC)),$(clang_cflags),) \
$(if $(findstring gcc,$(CC)),$(gcc_cflags),) \
$(call pkg-config-cflags)
diff --git a/src/efibootmgr.c b/src/efibootmgr.c
index 20d71e2..825435e 100644
--- a/src/efibootmgr.c
+++ b/src/efibootmgr.c
@@ -1,5 +1,6 @@
/*
- efibootmgr.c - Manipulates EFI variables as exported in /proc/efi/vars
+ efibootmgr.c - Manipulates EFI variables as exported in
+ /sys/firmware/efi/vars (previously was /proc/efi/vars)
+ efibootmgr.c - Manipulates EFI variables as exported in /sys/firmware/efi/
+ efivars or vars (previously /proc/efi/vars)
Copyright (C) 2001-2004 Dell, Inc. <Matt_Domsch@dell.com>
@ -55,34 +56,28 @@ Index: efibootmgr-0.12/src/efibootmgr/efibootmgr.c
- This must tie the EFI_DEVICE_PATH to /boot/efi/EFI/redhat/grub.efi
+ This must tie the EFI_DEVICE_PATH to /boot/efi/efi/<vendor>/<loader>.efi
+ This must tie the EFI_DEVICE_PATH to /boot/efi/EFI/<vendor>/<loader>.efi
The EFI_DEVICE_PATH will look something like:
ACPI device path, length 12 bytes
Hardware Device Path, PCI, length 6 bytes
@@ -58,6 +59,9 @@
#define EFIBOOTMGR_VERSION "unknown (fix Makefile!)"
#endif
+#ifndef DEFAULT_LOADER
+#define DEFAULT_LOADER "unknown (fix Makefile!)"
+#endif
typedef struct _var_entry {
char *name;
@@ -985,7 +989,7 @@ usage()
@@ -1233,7 +1234,7 @@ usage()
printf("\t --ip-port <local>,<remote> set local and remote IP ports\n");
printf("\t --ip-origin { {dhcp|static} | { static|stateless|stateful} }\n");
#endif
- printf("\t-l | --loader name (defaults to \\EFI\\redhat\\grub.efi)\n");
+ printf("\t-l | --loader name (defaults to \""DEFAULT_LOADER"\")\n");
+ printf("\t-l | --loader name (defaults to \""DEFAULT_LOADER"\")\n");
printf("\t-L | --label label Boot manager display label (defaults to \"Linux\")\n");
printf("\t-n | --bootnext XXXX set BootNext to XXXX (hex)\n");
printf("\t-N | --delete-bootnext delete BootNext\n");
@@ -1013,6 +1017,7 @@ set_default_opts()
printf("\t-m | --mirror-below-4G t|f mirror memory below 4GB\n");
printf("\t-M | --mirror-above-4G X percentage memory to mirror above 4GB\n");
@@ -1263,7 +1264,7 @@ set_default_opts()
opts.active = -1; /* Don't set it */
opts.timeout = -1; /* Don't set it */
opts.edd10_devicenum = 0x80;
opts.loader = "\\EFI\\redhat\\grub.efi";
+ opts.loader = DEFAULT_LOADER;
- opts.loader = "\\EFI\\redhat\\grub.efi";
+ opts.loader = DEFAULT_LOADER;
opts.label = (unsigned char *)"Linux";
opts.disk = "/dev/sda";
opts.part = 1;
--
2.6.6

View File

@ -1,202 +0,0 @@
From cddc48752cbb1c0d74b581f8aa6b2d9e51fd69d9 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 25 Feb 2016 10:43:40 -0500
Subject: [PATCH 1/3] 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>
---
src/efibootmgr/efibootmgr.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index a5b5bf9..09489ab 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -219,13 +219,12 @@ warn_duplicate_name(list_t *boot_list)
list_for_each(pos, boot_list) {
boot = list_entry(pos, var_entry_t, list);
- load_option = (efi_load_option *)
- boot->data;
- desc = efi_loadopt_desc(load_option);
+ load_option = (efi_load_option *)boot->data;
+ desc = efi_loadopt_desc(load_option, boot->data_size);
if (!strcmp((char *)opts.label, (char *)desc)) {
- fprintf(stderr, "** Warning ** : %.8s has same label %s\n",
- boot->name,
- opts.label);
+ fprintf(stderr,
+ "** Warning ** : %.8s has same label %s\n",
+ boot->name, opts.label);
}
}
}
@@ -821,8 +820,7 @@ show_boot_vars()
list_for_each(pos, &boot_entry_list) {
boot = list_entry(pos, var_entry_t, list);
load_option = (efi_load_option *)boot->data;
- description = efi_loadopt_desc(load_option);
- dp = efi_loadopt_path(load_option);
+ description = efi_loadopt_desc(load_option, boot->data_size);
if (boot->name)
printf("%.8s", boot->name);
else
@@ -835,9 +833,12 @@ show_boot_vars()
if (opts.verbose) {
char *text_path = NULL;
size_t text_path_len = 0;
- uint16_t pathlen = efi_loadopt_pathlen(load_option);
+ uint16_t pathlen;
ssize_t rc;
+ pathlen = efi_loadopt_pathlen(load_option,
+ boot->data_size);
+ dp = efi_loadopt_path(load_option, pathlen);
rc = efidp_format_device_path(text_path, text_path_len,
dp, pathlen);
if (rc < 0)
--
2.9.0
From 62944db11c87a936368525e4b480d1a0af61fd5e Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 25 Feb 2016 14:16:38 -0500
Subject: [PATCH 2/3] efibootmgr: fix some types the compiler doesn't like.
Basically uint8_t * vs char *.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/lib/efi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lib/efi.c b/src/lib/efi.c
index c2b8152..91ed11e 100644
--- a/src/lib/efi.c
+++ b/src/lib/efi.c
@@ -424,7 +424,7 @@ get_extra_args(uint8_t *data, ssize_t data_size)
sz = efi_loadopt_args_as_ucs2(
(uint16_t *)(data+off),
data_size?data_size+off:0,
- opts.argv[i]);
+ (uint8_t *)opts.argv[i]);
if (sz < 0)
return -1;
off += sz;
@@ -436,7 +436,7 @@ get_extra_args(uint8_t *data, ssize_t data_size)
} else {
sz = efi_loadopt_args_as_utf8(data+off,
data_size?data_size+off:0,
- opts.argv[i]);
+ (uint8_t *)opts.argv[i]);
if (sz < 0)
return -1;
off += sz;
--
2.9.0
From 3d68945362177a762e6331a02b8896e38b984a12 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 3 Mar 2016 09:50:03 -0500
Subject: [PATCH 3/3] 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>
---
src/efibootmgr/efibootmgr.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
index 09489ab..d1d4fe2 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -304,7 +304,7 @@ make_boot_var(list_t *boot_list)
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS;
rc = efi_set_variable(boot->guid, boot->name, boot->data,
- boot->data_size, boot->attributes);
+ boot->data_size, boot->attributes, 0644);
if (rc < 0)
goto err;
list_add_tail(&boot->list, boot_list);
@@ -362,7 +362,8 @@ set_boot_u16(const char *name, uint16_t num)
return efi_set_variable(EFI_GLOBAL_GUID, name, (uint8_t *)&num,
sizeof (num), EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
- EFI_VARIABLE_RUNTIME_ACCESS);
+ EFI_VARIABLE_RUNTIME_ACCESS,
+ 0644);
}
static int
@@ -398,7 +399,7 @@ add_to_boot_order(uint16_t num)
boot_order->data_size = new_data_size;
rc = efi_set_variable(EFI_GLOBAL_GUID, "BootOrder", boot_order->data,
- boot_order->data_size, boot_order->attributes);
+ boot_order->data_size, boot_order->attributes, 0644);
free(boot_order->data);
free(boot_order);
return rc;
@@ -452,7 +453,8 @@ remove_dupes_from_boot_order(void)
boot_order->data_size = new_data_size;
efi_del_variable(EFI_GLOBAL_GUID, "BootOrder");
rc = efi_set_variable(EFI_GLOBAL_GUID, "BootOrder", boot_order->data,
- boot_order->data_size, boot_order->attributes);
+ boot_order->data_size, boot_order->attributes,
+ 0644);
free(boot_order->data);
free(boot_order);
return rc;
@@ -501,7 +503,8 @@ remove_from_boot_order(uint16_t num)
boot_order->data_size = sizeof(data[0]) * new_i;
rc = efi_set_variable(EFI_GLOBAL_GUID, "BootOrder", boot_order->data,
- boot_order->data_size, boot_order->attributes);
+ boot_order->data_size, boot_order->attributes,
+ 0644);
all_done:
free(boot_order->data);
free(boot_order);
@@ -801,7 +804,8 @@ set_boot_order(int keep_old_entries)
rc = efi_set_variable(EFI_GLOBAL_GUID, "BootOrder", data, data_size,
EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
- EFI_VARIABLE_RUNTIME_ACCESS);
+ EFI_VARIABLE_RUNTIME_ACCESS,
+ 0644);
free(data);
return rc;
}
@@ -936,7 +940,8 @@ set_active_state()
boot->name,
boot->data,
boot->data_size,
- boot->attributes);
+ boot->attributes,
+ 0644);
}
}
else if (opts.active == 0) {
@@ -950,7 +955,8 @@ set_active_state()
boot->name,
boot->data,
boot->data_size,
- boot->attributes);
+ boot->attributes,
+ 0644);
}
}
}
--
2.9.0

View File

@ -1,26 +0,0 @@
From f5e09ec26bd03490903330f121b18b8aaa56cf85 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 24 May 2016 11:33:20 -0400
Subject: [PATCH] efibootmgr: fix usage of efi_loadopt_path() /again/.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/efibootmgr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/efibootmgr.c b/src/efibootmgr.c
index baefa68..199eb28 100644
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -848,7 +848,7 @@ show_boot_vars()
pathlen = efi_loadopt_pathlen(load_option,
boot->data_size);
- dp = efi_loadopt_path(load_option, pathlen);
+ dp = efi_loadopt_path(load_option, boot->data_size);
rc = efidp_format_device_path(text_path, text_path_len,
dp, pathlen);
if (rc < 0)
--
1.9.1

View File

@ -1,3 +1,22 @@
-------------------------------------------------------------------
Fri Mar 3 20:46:25 UTC 2017 - rw@suse.com
- Update to 14 plus upstream fixes. (fate#322108)
(0001-Don-t-use-fshort-wchar-when-building-63.patch,
0002-Remove-extra-const-keywords-gcc-7-gripes-about.patch,
0003-Add-support-for-parsing-optional-data-as-ucs2.patch)
- Forward port and refresh SLE patches
(efibootmgr-derhat.diff, MARM-sanitize-set_mirror.diff
efibootmgr-delete-multiple.diff)
- Drop upstreamed patches
(efibootmgr-check-boot-order.diff,
efibootmgr-fix-efivar-0.24.patch,
efibootmgr-fix-usage-of-efi_loadopt_path-again.patch,
MARM-add-m-and-M-options.diff,
MARM-extend-man-for-M-option.diff,
MARM-fix-insufficient-validation-check-of-M-option.diff,
MARM-introduce-man-for-m-and-M-option.diff)
-------------------------------------------------------------------
Thu Feb 16 12:49:42 UTC 2017 - msuchanek@suse.com
@ -10,12 +29,35 @@ Sat Aug 20 16:17:42 UTC 2016 - arvidjaar@gmail.com
- add efibootmgr-fix-usage-of-efi_loadopt_path-again.patch - fix
efibootmgr -v with new efivar (boo#993458)
-------------------------------------------------------------------
Thu Jul 14 11:11:15 UTC 2016 - rw@suse.com
- Add support for Memory Address Range Mirroring.
[fate#320999, bsc#987599]
(add MARM-add-m-and-M-options.diff,
MARM-fix-insufficient-validation-check-of-M-option.diff,
MARM-introduce-man-for-m-and-M-option.diff,
MARM-extend-man-for-M-option.diff,
MARM-sanitize-set_mirror.diff)
-------------------------------------------------------------------
Wed Jul 13 04:42:38 UTC 2016 - glin@suse.com
- Add efibootmgr-fix-efivar-0.24.patch fix the compilation errors
caused by the efivar update
-------------------------------------------------------------------
Tue Sep 15 16:44:37 UTC 2015 - rw@suse.com
- Properly latch long to short option for delete. [bsc#945705]
(efibootmgr-delete-multiple.diff)
-------------------------------------------------------------------
Fri Jul 24 14:24:00 UTC 2015 - rw@suse.com
- Refresh for SLE12. [bsc#929677]
(efibootmgr-gcc-Wall.diff, efibootmgr-delete-multiple.diff)
-------------------------------------------------------------------
Fri Jun 12 07:45:20 UTC 2015 - mpluskal@suse.com
@ -31,6 +73,28 @@ Fri Jun 12 07:45:20 UTC 2015 - mpluskal@suse.com
efibootmgr-check-boot-order.diff
- Update project and download url
-------------------------------------------------------------------
Wed Mar 11 15:26:59 UTC 2015 - rw@suse.com
- Allow disk/partition as selector for delete as well. [bsc#870211]
(efibootmgr-delete-multiple.diff)
- Remove version number from patches.
(add efibootmgr-derhat.diff, efibootmgr-fail-visibly.diff,
efibootmgr-gcc-Wall.diff, efibootmgr-set_boot_order.diff,
efibootmgr-write-unique-id-once.diff;
drop efibootmgr-0.6.0-check-boot-order.diff,
efibootmgr-0.6.0-delete-by-uuid.diff, efibootmgr-0.6.0-derhat.diff,
efibootmgr-0.6.0-fail-visibly.diff, efibootmgr-0.6.0-gcc-Wall.diff,
efibootmgr-0.6.0-set_boot_order.diff,
efibootmgr-0.6.0-write-unique-id-once.diff)
Note: this entry reflects obsoleted, SLE-only changes!
-------------------------------------------------------------------
Fri Jan 30 10:47:13 UTC 2015 - rw@suse.com
- Introduce partition UUID as selector for delete. [bsc#870211]
(efibootmgr-0.6.0-delete-by-uuid.diff)
-------------------------------------------------------------------
Mon Dec 22 21:43:12 UTC 2014 - mpluskal@suse.com
@ -61,7 +125,7 @@ Wed Oct 29 03:51:49 UTC 2014 - glin@suse.com
-------------------------------------------------------------------
Tue Sep 9 13:24:25 UTC 2014 - schwab@suse.de
- Enable for aarch64
- Enable for aarch64 (fate#318444)
-------------------------------------------------------------------
Mon Jul 7 10:45:04 UTC 2014 - glin@suse.com

View File

@ -17,20 +17,23 @@
Name: efibootmgr
Version: 0.12
Version: 14
Release: 0
Summary: EFI Boot Manager
License: GPL-2.0+
Group: System/Boot
Url: https://github.com/rhinstaller/efibootmgr
Source: https://github.com/rhinstaller/efibootmgr/releases/download/efibootmgr-%{version}/efibootmgr-%{version}.tar.bz2
Patch1: %{name}-derhat.diff
Patch2: %{name}-check-boot-order.diff
Patch3: %{name}-fix-efivar-0.24.patch
Patch4: %{name}-fix-usage-of-efi_loadopt_path-again.patch
BuildRequires: efivar-devel >= 0.24
Patch1: 0001-Don-t-use-fshort-wchar-when-building-63.patch
Patch2: 0002-Remove-extra-const-keywords-gcc-7-gripes-about.patch
Patch3: 0003-Add-support-for-parsing-optional-data-as-ucs2.patch
Patch4: %{name}-derhat.diff
Patch5: MARM-sanitize-set_mirror.diff
Patch6: %{name}-delete-multiple.diff
BuildRequires: efivar-devel >= 31
BuildRequires: pciutils-devel
BuildRequires: pkg-config
BuildRequires: popt-devel
BuildRequires: zlib-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -46,6 +49,8 @@ information about the EFI can be found at
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%build
LOADER="grub.efi" # default loader
@ -57,19 +62,16 @@ case "%{_repository}" in
(SUSE*|SLE*) VENDOR="SUSE";;
(*) VENDOR="linux";;
esac
make %{?_smp_mflags} EXTRA_CFLAGS="%{optflags}" \
make %{?_smp_mflags} CFLAGS="%{optflags} -flto" \
OS_VENDOR="$VENDOR" EFI_LOADER="$LOADER"
%install
install -d %{buildroot}%{_sbindir}
make install BINDIR=%{buildroot}%{_sbindir}
install -d %{buildroot}%{_mandir}/man8
install -m 644 src/man/man8/efibootmgr.8 %{buildroot}%{_mandir}/man8
make DESTDIR=%{buildroot} sbindir=%{_sbindir} install
%files
%defattr(-, root, root)
%doc README COPYING
%{_sbindir}/efibootmgr
%{_sbindir}/efiboot*
%{_mandir}/man8/*.gz
%changelog