diff --git a/0016-Make-exit-take-a-return-code.patch b/0016-Make-exit-take-a-return-code.patch index 937c774..40c848f 100644 --- a/0016-Make-exit-take-a-return-code.patch +++ b/0016-Make-exit-take-a-return-code.patch @@ -20,11 +20,11 @@ Signed-off-by: Peter Jones grub-core/kern/mips/arc/init.c | 2 +- grub-core/kern/mips/loongson/init.c | 2 +- grub-core/kern/mips/qemu_mips/init.c | 2 +- - grub-core/kern/misc.c | 2 +- + grub-core/kern/misc.c | 11 ++++++++++- grub-core/kern/uboot/init.c | 6 +++--- grub-core/kern/xen/init.c | 2 +- include/grub/misc.h | 2 +- - 14 files changed, 39 insertions(+), 21 deletions(-) + 14 files changed, 48 insertions(+), 21 deletions(-) diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c index a3a11824172..b25ca4b9f17 100644 @@ -191,10 +191,10 @@ index be88b77d22d..8b6c55ffc01 100644 grub_halt (); } diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 3b633d51f4c..952411d5dc6 100644 +index 3b633d51f4c..cd63a8cea73 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -1095,7 +1095,7 @@ grub_abort (void) +@@ -1095,9 +1095,18 @@ grub_abort (void) grub_getkey (); } @@ -202,7 +202,18 @@ index 3b633d51f4c..952411d5dc6 100644 + grub_exit (1); } ++#if defined (__clang__) && !defined (GRUB_UTIL) ++/* clang emits references to abort(). */ ++void __attribute__ ((noreturn)) ++abort (void) ++{ ++ grub_abort (); ++} ++#endif ++ void + grub_fatal (const char *fmt, ...) + { diff --git a/grub-core/kern/uboot/init.c b/grub-core/kern/uboot/init.c index 3e338645c57..be2a5be1d07 100644 --- a/grub-core/kern/uboot/init.c diff --git a/0021-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch b/0020-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch similarity index 100% rename from 0021-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch rename to 0020-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch diff --git a/0020-trim-arp-packets-with-abnormal-size.patch b/0020-trim-arp-packets-with-abnormal-size.patch deleted file mode 100644 index 1a6990a..0000000 --- a/0020-trim-arp-packets-with-abnormal-size.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Paulo Flabiano Smorigo -Date: Wed, 5 Feb 2014 09:42:42 -0200 -Subject: [PATCH] trim arp packets with abnormal size - -GRUB uses arp request to create the arp response. If the incoming packet -is foobared, GRUB needs to trim the arp response packet before sending it. ---- - grub-core/net/arp.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c -index 54306e3b16d..d1c69ed2b55 100644 ---- a/grub-core/net/arp.c -+++ b/grub-core/net/arp.c -@@ -150,6 +150,12 @@ grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card, - if (grub_net_addr_cmp (&inf->address, &target_addr) == 0 - && arp_packet->op == grub_cpu_to_be16_compile_time (ARP_REQUEST)) - { -+ if ((nb->tail - nb->data) > 50) -+ { -+ grub_dprintf ("net", "arp packet with abnormal size (%ld bytes).\n", -+ nb->tail - nb->data); -+ nb->tail = nb->data + 50; -+ } - grub_net_link_level_address_t target; - struct grub_net_buff nb_reply; - struct arppkt *arp_reply; diff --git a/0022-Add-support-for-UEFI-operating-systems-returned-by-o.patch b/0021-Add-support-for-UEFI-operating-systems-returned-by-o.patch similarity index 100% rename from 0022-Add-support-for-UEFI-operating-systems-returned-by-o.patch rename to 0021-Add-support-for-UEFI-operating-systems-returned-by-o.patch diff --git a/0023-Migrate-PPC-from-Yaboot-to-Grub2.patch b/0022-Migrate-PPC-from-Yaboot-to-Grub2.patch similarity index 100% rename from 0023-Migrate-PPC-from-Yaboot-to-Grub2.patch rename to 0022-Migrate-PPC-from-Yaboot-to-Grub2.patch diff --git a/0024-Add-fw_path-variable-revised.patch b/0023-Add-fw_path-variable-revised.patch similarity index 100% rename from 0024-Add-fw_path-variable-revised.patch rename to 0023-Add-fw_path-variable-revised.patch diff --git a/0025-Pass-x-hex-hex-straight-through-unmolested.patch b/0024-Pass-x-hex-hex-straight-through-unmolested.patch similarity index 100% rename from 0025-Pass-x-hex-hex-straight-through-unmolested.patch rename to 0024-Pass-x-hex-hex-straight-through-unmolested.patch diff --git a/0026-Add-X-option-to-printf-functions.patch b/0025-Add-X-option-to-printf-functions.patch similarity index 97% rename from 0026-Add-X-option-to-printf-functions.patch rename to 0025-Add-X-option-to-printf-functions.patch index 4fd28fc..5f2a075 100644 --- a/0026-Add-X-option-to-printf-functions.patch +++ b/0025-Add-X-option-to-printf-functions.patch @@ -8,7 +8,7 @@ Subject: [PATCH] Add %X option to printf functions. 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 952411d5dc6..8344526be7f 100644 +index cd63a8cea73..2656a670e09 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -588,7 +588,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r) diff --git a/0027-Search-for-specific-config-file-for-netboot.patch b/0026-Search-for-specific-config-file-for-netboot.patch similarity index 100% rename from 0027-Search-for-specific-config-file-for-netboot.patch rename to 0026-Search-for-specific-config-file-for-netboot.patch diff --git a/0027-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch b/0027-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch new file mode 100644 index 0000000..107f16e --- /dev/null +++ b/0027-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch @@ -0,0 +1,1528 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 22 Jan 2013 06:31:38 +0100 +Subject: [PATCH] blscfg: add blscfg module to parse Boot Loader Specification + snippets + +The BootLoaderSpec (BLS) defines a scheme where different bootloaders can +share a format for boot items and a configuration directory that accepts +these common configurations as drop-in files. + +Signed-off-by: Peter Jones +Signed-off-by: Javier Martinez Canillas +[wjt: some cleanups and fixes] +Signed-off-by: Will Thompson +--- + grub-core/Makefile.core.def | 11 + + grub-core/commands/blscfg.c | 1096 ++++++++++++++++++++++++++++++++++++++++ + grub-core/commands/legacycfg.c | 5 +- + grub-core/commands/loadenv.c | 77 +-- + grub-core/commands/menuentry.c | 20 +- + grub-core/normal/main.c | 6 + + grub-core/commands/loadenv.h | 93 ++++ + include/grub/compiler.h | 2 + + include/grub/menu.h | 13 + + include/grub/normal.h | 2 +- + 10 files changed, 1243 insertions(+), 82 deletions(-) + create mode 100644 grub-core/commands/blscfg.c + create mode 100644 grub-core/commands/loadenv.h + +diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def +index f8065388213..8bd220a41ba 100644 +--- a/grub-core/Makefile.core.def ++++ b/grub-core/Makefile.core.def +@@ -768,6 +768,16 @@ module = { + common = commands/blocklist.c; + }; + ++module = { ++ name = blscfg; ++ common = commands/blscfg.c; ++ common = commands/loadenv.h; ++ enable = powerpc_ieee1275; ++ enable = efi; ++ enable = i386_pc; ++ enable = emu; ++}; ++ + module = { + name = boot; + common = commands/boot.c; +@@ -929,6 +939,7 @@ module = { + module = { + name = loadenv; + common = commands/loadenv.c; ++ common = commands/loadenv.h; + common = lib/envblk.c; + }; + +diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c +new file mode 100644 +index 00000000000..26dbe873fe4 +--- /dev/null ++++ b/grub-core/commands/blscfg.c +@@ -0,0 +1,1096 @@ ++/*-*- Mode: C; c-basic-offset: 2; indent-tabs-mode: t -*-*/ ++ ++/* bls.c - implementation of the boot loader spec */ ++ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * ++ * GRUB is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * GRUB is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with GRUB. If not, see . ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++GRUB_MOD_LICENSE ("GPLv3+"); ++ ++#include "loadenv.h" ++ ++#define GRUB_BLS_CONFIG_PATH "/loader/entries/" ++#ifdef GRUB_MACHINE_EMU ++#define GRUB_BOOT_DEVICE "/boot" ++#else ++#define GRUB_BOOT_DEVICE "($root)" ++#endif ++ ++struct keyval ++{ ++ const char *key; ++ char *val; ++}; ++ ++static struct bls_entry *entries = NULL; ++ ++#define FOR_BLS_ENTRIES(var) FOR_LIST_ELEMENTS (var, entries) ++ ++static int bls_add_keyval(struct bls_entry *entry, char *key, char *val) ++{ ++ char *k, *v; ++ struct keyval **kvs, *kv; ++ int new_n = entry->nkeyvals + 1; ++ ++ kvs = grub_realloc (entry->keyvals, new_n * sizeof (struct keyval *)); ++ if (!kvs) ++ return grub_error (GRUB_ERR_OUT_OF_MEMORY, ++ "couldn't find space for BLS entry"); ++ entry->keyvals = kvs; ++ ++ kv = grub_malloc (sizeof (struct keyval)); ++ if (!kv) ++ return grub_error (GRUB_ERR_OUT_OF_MEMORY, ++ "couldn't find space for BLS entry"); ++ ++ k = grub_strdup (key); ++ if (!k) ++ { ++ grub_free (kv); ++ return grub_error (GRUB_ERR_OUT_OF_MEMORY, ++ "couldn't find space for BLS entry"); ++ } ++ ++ v = grub_strdup (val); ++ if (!v) ++ { ++ grub_free (k); ++ grub_free (kv); ++ return grub_error (GRUB_ERR_OUT_OF_MEMORY, ++ "couldn't find space for BLS entry"); ++ } ++ ++ kv->key = k; ++ kv->val = v; ++ ++ entry->keyvals[entry->nkeyvals] = kv; ++ grub_dprintf("blscfg", "new keyval at %p:%s:%s\n", entry->keyvals[entry->nkeyvals], k, v); ++ entry->nkeyvals = new_n; ++ ++ return 0; ++} ++ ++/* Find they value of the key named by keyname. If there are allowed to be ++ * more than one, pass a pointer to an int set to -1 the first time, and pass ++ * the same pointer through each time after, and it'll return them in sorted ++ * order as defined in the BLS fragment file */ ++static char *bls_get_val(struct bls_entry *entry, const char *keyname, int *last) ++{ ++ int idx, start = 0; ++ struct keyval *kv = NULL; ++ ++ if (last) ++ start = *last + 1; ++ ++ for (idx = start; idx < entry->nkeyvals; idx++) { ++ kv = entry->keyvals[idx]; ++ ++ if (!grub_strcmp (keyname, kv->key)) ++ break; ++ } ++ ++ if (idx == entry->nkeyvals) { ++ if (last) ++ *last = -1; ++ return NULL; ++ } ++ ++ if (last) ++ *last = idx; ++ ++ return kv->val; ++} ++ ++#define goto_return(x) ({ ret = (x); goto finish; }) ++ ++/* compare alpha and numeric segments of two versions */ ++/* return 1: a is newer than b */ ++/* 0: a and b are the same version */ ++/* -1: b is newer than a */ ++static int vercmp(const char * a, const char * b) ++{ ++ char oldch1, oldch2; ++ char *abuf, *bbuf; ++ char *str1, *str2; ++ char * one, * two; ++ int rc; ++ int isnum; ++ int ret = 0; ++ ++ grub_dprintf("blscfg", "%s comparing %s and %s\n", __func__, a, b); ++ if (!grub_strcmp(a, b)) ++ return 0; ++ ++ abuf = grub_malloc(grub_strlen(a) + 1); ++ bbuf = grub_malloc(grub_strlen(b) + 1); ++ str1 = abuf; ++ str2 = bbuf; ++ grub_strcpy(str1, a); ++ grub_strcpy(str2, b); ++ ++ one = str1; ++ two = str2; ++ ++ /* loop through each version segment of str1 and str2 and compare them */ ++ while (*one || *two) { ++ while (*one && !grub_isalnum(*one) && *one != '~') one++; ++ while (*two && !grub_isalnum(*two) && *two != '~') two++; ++ ++ /* handle the tilde separator, it sorts before everything else */ ++ if (*one == '~' || *two == '~') { ++ if (*one != '~') goto_return (1); ++ if (*two != '~') goto_return (-1); ++ one++; ++ two++; ++ continue; ++ } ++ ++ /* If we ran to the end of either, we are finished with the loop */ ++ if (!(*one && *two)) break; ++ ++ str1 = one; ++ str2 = two; ++ ++ /* grab first completely alpha or completely numeric segment */ ++ /* leave one and two pointing to the start of the alpha or numeric */ ++ /* segment and walk str1 and str2 to end of segment */ ++ if (grub_isdigit(*str1)) { ++ while (*str1 && grub_isdigit(*str1)) str1++; ++ while (*str2 && grub_isdigit(*str2)) str2++; ++ isnum = 1; ++ } else { ++ while (*str1 && grub_isalpha(*str1)) str1++; ++ while (*str2 && grub_isalpha(*str2)) str2++; ++ isnum = 0; ++ } ++ ++ /* save character at the end of the alpha or numeric segment */ ++ /* so that they can be restored after the comparison */ ++ oldch1 = *str1; ++ *str1 = '\0'; ++ oldch2 = *str2; ++ *str2 = '\0'; ++ ++ /* this cannot happen, as we previously tested to make sure that */ ++ /* the first string has a non-null segment */ ++ if (one == str1) goto_return(-1); /* arbitrary */ ++ ++ /* take care of the case where the two version segments are */ ++ /* different types: one numeric, the other alpha (i.e. empty) */ ++ /* numeric segments are always newer than alpha segments */ ++ /* XXX See patch #60884 (and details) from bugzilla #50977. */ ++ if (two == str2) goto_return (isnum ? 1 : -1); ++ ++ if (isnum) { ++ grub_size_t onelen, twolen; ++ /* this used to be done by converting the digit segments */ ++ /* to ints using atoi() - it's changed because long */ ++ /* digit segments can overflow an int - this should fix that. */ ++ ++ /* throw away any leading zeros - it's a number, right? */ ++ while (*one == '0') one++; ++ while (*two == '0') two++; ++ ++ /* whichever number has more digits wins */ ++ onelen = grub_strlen(one); ++ twolen = grub_strlen(two); ++ if (onelen > twolen) goto_return (1); ++ if (twolen > onelen) goto_return (-1); ++ } ++ ++ /* grub_strcmp will return which one is greater - even if the two */ ++ /* segments are alpha or if they are numeric. don't return */ ++ /* if they are equal because there might be more segments to */ ++ /* compare */ ++ rc = grub_strcmp(one, two); ++ if (rc) goto_return (rc < 1 ? -1 : 1); ++ ++ /* restore character that was replaced by null above */ ++ *str1 = oldch1; ++ one = str1; ++ *str2 = oldch2; ++ two = str2; ++ } ++ ++ /* this catches the case where all numeric and alpha segments have */ ++ /* compared identically but the segment sepparating characters were */ ++ /* different */ ++ if ((!*one) && (!*two)) goto_return (0); ++ ++ /* whichever version still has characters left over wins */ ++ if (!*one) goto_return (-1); else goto_return (1); ++ ++finish: ++ grub_free (abuf); ++ grub_free (bbuf); ++ return ret; ++} ++ ++/* returns name/version/release */ ++/* NULL string pointer returned if nothing found */ ++static void ++split_package_string (char *package_string, char **name, ++ char **version, char **release) ++{ ++ char *package_version, *package_release; ++ ++ /* Release */ ++ package_release = grub_strrchr (package_string, '-'); ++ ++ if (package_release != NULL) ++ *package_release++ = '\0'; ++ ++ *release = package_release; ++ ++ if (name == NULL) ++ { ++ *version = package_string; ++ } ++ else ++ { ++ /* Version */ ++ package_version = grub_strrchr(package_string, '-'); ++ ++ if (package_version != NULL) ++ *package_version++ = '\0'; ++ ++ *version = package_version; ++ /* Name */ ++ *name = package_string; ++ } ++ ++ /* Bubble up non-null values from release to name */ ++ if (name != NULL && *name == NULL) ++ { ++ *name = (*version == NULL ? *release : *version); ++ *version = *release; ++ *release = NULL; ++ } ++ if (*version == NULL) ++ { ++ *version = *release; ++ *release = NULL; ++ } ++} ++ ++static int ++split_cmp(char *nvr0, char *nvr1, int has_name) ++{ ++ int ret = 0; ++ char *name0, *version0, *release0; ++ char *name1, *version1, *release1; ++ ++ split_package_string(nvr0, has_name ? &name0 : NULL, &version0, &release0); ++ split_package_string(nvr1, has_name ? &name1 : NULL, &version1, &release1); ++ ++ if (has_name) ++ { ++ ret = vercmp(name0 == NULL ? "" : name0, ++ name1 == NULL ? "" : name1); ++ if (ret != 0) ++ return ret; ++ } ++ ++ ret = vercmp(version0 == NULL ? "" : version0, ++ version1 == NULL ? "" : version1); ++ if (ret != 0) ++ return ret; ++ ++ ret = vercmp(release0 == NULL ? "" : release0, ++ release1 == NULL ? "" : release1); ++ return ret; ++} ++ ++/* return 1: e0 is newer than e1 */ ++/* 0: e0 and e1 are the same version */ ++/* -1: e1 is newer than e0 */ ++static int bls_cmp(const struct bls_entry *e0, const struct bls_entry *e1) ++{ ++ char *id0, *id1; ++ int r; ++ ++ id0 = grub_strdup(e0->filename); ++ id1 = grub_strdup(e1->filename); ++ ++ r = split_cmp(id0, id1, 1); ++ ++ grub_free(id0); ++ grub_free(id1); ++ ++ return r; ++} ++ ++static void list_add_tail(struct bls_entry *head, struct bls_entry *item) ++{ ++ item->next = head; ++ if (head->prev) ++ head->prev->next = item; ++ item->prev = head->prev; ++ head->prev = item; ++} ++ ++static int bls_add_entry(struct bls_entry *entry) ++{ ++ struct bls_entry *e, *last = NULL; ++ int rc; ++ ++ if (!entries) { ++ grub_dprintf ("blscfg", "Add entry with id \"%s\"\n", entry->filename); ++ entries = entry; ++ return 0; ++ } ++ ++ FOR_BLS_ENTRIES(e) { ++ rc = bls_cmp(entry, e); ++ ++ if (!rc) ++ return GRUB_ERR_BAD_ARGUMENT; ++ ++ if (rc == 1) { ++ grub_dprintf ("blscfg", "Add entry with id \"%s\"\n", entry->filename); ++ list_add_tail (e, entry); ++ if (e == entries) { ++ entries = entry; ++ entry->prev = NULL; ++ } ++ return 0; ++ } ++ last = e; ++ } ++ ++ if (last) { ++ grub_dprintf ("blscfg", "Add entry with id \"%s\"\n", entry->filename); ++ last->next = entry; ++ entry->prev = last; ++ } ++ ++ return 0; ++} ++ ++struct read_entry_info { ++ const char *devid; ++ const char *dirname; ++ grub_file_t file; ++}; ++ ++static int read_entry ( ++ const char *filename, ++ const struct grub_dirhook_info *dirhook_info UNUSED, ++ void *data) ++{ ++ grub_size_t m = 0, n, clip = 0; ++ int rc = 0; ++ char *p = NULL; ++ grub_file_t f = NULL; ++ struct bls_entry *entry; ++ struct read_entry_info *info = (struct read_entry_info *)data; ++ ++ grub_dprintf ("blscfg", "filename: \"%s\"\n", filename); ++ ++ n = grub_strlen (filename); ++ ++ if (info->file) ++ { ++ f = info->file; ++ } ++ else ++ { ++ if (filename[0] == '.') ++ return 0; ++ ++ if (n <= 5) ++ return 0; ++ ++ if (grub_strcmp (filename + n - 5, ".conf") != 0) ++ return 0; ++ ++ p = grub_xasprintf ("(%s)%s/%s", info->devid, info->dirname, filename); ++ ++ f = grub_file_open (p); ++ if (!f) ++ goto finish; ++ } ++ ++ entry = grub_zalloc (sizeof (*entry)); ++ if (!entry) ++ goto finish; ++ ++ if (info->file) ++ { ++ char *slash; ++ ++ if (n > 5 && !grub_strcmp (filename + n - 5, ".conf") == 0) ++ clip = 5; ++ ++ slash = grub_strrchr (filename, '/'); ++ if (!slash) ++ slash = grub_strrchr (filename, '\\'); ++ ++ while (*slash == '/' || *slash == '\\') ++ slash++; ++ ++ m = slash ? slash - filename : 0; ++ } ++ else ++ { ++ m = 0; ++ clip = 5; ++ } ++ n -= m; ++ ++ entry->filename = grub_strndup(filename + m, n - clip); ++ if (!entry->filename) ++ goto finish; ++ ++ entry->filename[n - 5] = '\0'; ++ ++ for (;;) ++ { ++ char *buf; ++ char *separator; ++ ++ buf = grub_file_getline (f); ++ if (!buf) ++ break; ++ ++ while (buf && buf[0] && (buf[0] == ' ' || buf[0] == '\t')) ++ buf++; ++ if (buf[0] == '#') ++ continue; ++ ++ separator = grub_strchr (buf, ' '); ++ ++ if (!separator) ++ separator = grub_strchr (buf, '\t'); ++ ++ if (!separator || separator[1] == '\0') ++ { ++ grub_free (buf); ++ break; ++ } ++ ++ separator[0] = '\0'; ++ ++ do { ++ separator++; ++ } while (*separator == ' ' || *separator == '\t'); ++ ++ rc = bls_add_keyval (entry, buf, separator); ++ grub_free (buf); ++ if (rc < 0) ++ break; ++ } ++ ++ if (!rc) ++ bls_add_entry(entry); ++ ++finish: ++ if (p) ++ grub_free (p); ++ ++ if (f) ++ grub_file_close (f); ++ ++ return 0; ++} ++ ++static grub_envblk_t saved_env = NULL; ++ ++static int UNUSED ++save_var (const char *name, const char *value, void *whitelist UNUSED) ++{ ++ const char *val = grub_env_get (name); ++ grub_dprintf("blscfg", "saving \"%s\"\n", name); ++ ++ if (val) ++ grub_envblk_set (saved_env, name, value); ++ ++ return 0; ++} ++ ++static int UNUSED ++unset_var (const char *name, const char *value UNUSED, void *whitelist) ++{ ++ grub_dprintf("blscfg", "restoring \"%s\"\n", name); ++ if (! whitelist) ++ { ++ grub_env_unset (name); ++ return 0; ++ } ++ ++ if (test_whitelist_membership (name, ++ (const grub_env_whitelist_t *) whitelist)) ++ grub_env_unset (name); ++ ++ return 0; ++} ++ ++static char **bls_make_list (struct bls_entry *entry, const char *key, int *num) ++{ ++ int last = -1; ++ char *val; ++ ++ int nlist = 0; ++ char **list = NULL; ++ ++ list = grub_malloc (sizeof (char *)); ++ if (!list) ++ return NULL; ++ list[0] = NULL; ++ ++ while (1) ++ { ++ char **new; ++ ++ val = bls_get_val (entry, key, &last); ++ if (!val) ++ break; ++ ++ new = grub_realloc (list, (nlist + 2) * sizeof (char *)); ++ if (!new) ++ break; ++ ++ list = new; ++ list[nlist++] = val; ++ list[nlist] = NULL; ++ } ++ ++ if (num) ++ *num = nlist; ++ ++ return list; ++} ++ ++static char *field_append(bool is_var, char *buffer, char *start, char *end) ++{ ++ char *temp = grub_strndup(start, end - start + 1); ++ const char *field = temp; ++ ++ if (is_var) { ++ field = grub_env_get (temp); ++ if (!field) ++ return buffer; ++ } ++ ++ if (!buffer) { ++ buffer = grub_strdup(field); ++ if (!buffer) ++ return NULL; ++ } else { ++ buffer = grub_realloc (buffer, grub_strlen(buffer) + grub_strlen(field)); ++ if (!buffer) ++ return NULL; ++ ++ grub_stpcpy (buffer + grub_strlen(buffer), field); ++ } ++ ++ return buffer; ++} ++ ++static char *expand_val(char *value) ++{ ++ char *buffer = NULL; ++ char *start = value; ++ char *end = value; ++ bool is_var = false; ++ ++ if (!value) ++ return NULL; ++ ++ while (*value) { ++ if (*value == '$') { ++ if (start != end) { ++ buffer = field_append(is_var, buffer, start, end); ++ if (!buffer) ++ return NULL; ++ } ++ ++ is_var = true; ++ start = value + 1; ++ } else if (is_var) { ++ if (!grub_isalnum(*value) && *value != '_') { ++ buffer = field_append(is_var, buffer, start, end); ++ is_var = false; ++ start = value; ++ } ++ } ++ ++ end = value; ++ value++; ++ } ++ ++ if (start != end) { ++ buffer = field_append(is_var, buffer, start, end); ++ if (!buffer) ++ return NULL; ++ } ++ ++ return buffer; ++} ++ ++static char **early_initrd_list (const char *initrd) ++{ ++ int nlist = 0; ++ char **list = NULL; ++ char *separator; ++ ++ while ((separator = grub_strchr (initrd, ' '))) ++ { ++ list = grub_realloc (list, (nlist + 2) * sizeof (char *)); ++ if (!list) ++ return NULL; ++ ++ list[nlist++] = grub_strndup(initrd, separator - initrd); ++ list[nlist] = NULL; ++ initrd = separator + 1; ++ } ++ ++ list = grub_realloc (list, (nlist + 2) * sizeof (char *)); ++ if (!list) ++ return NULL; ++ ++ list[nlist++] = grub_strndup(initrd, grub_strlen(initrd)); ++ list[nlist] = NULL; ++ ++ return list; ++} ++ ++static void create_entry (struct bls_entry *entry) ++{ ++ int argc = 0; ++ const char **argv = NULL; ++ ++ char *title = NULL; ++ char *clinux = NULL; ++ char *options = NULL; ++ char **initrds = NULL; ++ char *initrd = NULL; ++ const char *early_initrd = NULL; ++ char **early_initrds = NULL; ++ char *initrd_prefix = NULL; ++ char *id = entry->filename; ++ char *dotconf = id; ++ char *hotkey = NULL; ++ ++ char *users = NULL; ++ char **classes = NULL; ++ ++ char **args = NULL; ++ ++ char *src = NULL; ++ int i, index; ++ ++ grub_dprintf("blscfg", "%s got here\n", __func__); ++ clinux = bls_get_val (entry, "linux", NULL); ++ if (!clinux) ++ { ++ grub_dprintf ("blscfg", "Skipping file %s with no 'linux' key.\n", entry->filename); ++ goto finish; ++ } ++ ++ /* ++ * strip the ".conf" off the end before we make it our "id" field. ++ */ ++ do ++ { ++ dotconf = grub_strstr(dotconf, ".conf"); ++ } while (dotconf != NULL && dotconf[5] != '\0'); ++ if (dotconf) ++ dotconf[0] = '\0'; ++ ++ title = bls_get_val (entry, "title", NULL); ++ options = expand_val (bls_get_val (entry, "options", NULL)); ++ ++ if (!options) ++ options = expand_val (grub_env_get("default_kernelopts")); ++ ++ initrds = bls_make_list (entry, "initrd", NULL); ++ ++ hotkey = bls_get_val (entry, "grub_hotkey", NULL); ++ users = expand_val (bls_get_val (entry, "grub_users", NULL)); ++ classes = bls_make_list (entry, "grub_class", NULL); ++ args = bls_make_list (entry, "grub_arg", &argc); ++ ++ argc += 1; ++ argv = grub_malloc ((argc + 1) * sizeof (char *)); ++ argv[0] = title ? title : clinux; ++ for (i = 1; i < argc; i++) ++ argv[i] = args[i-1]; ++ argv[argc] = NULL; ++ ++ early_initrd = grub_env_get("early_initrd"); ++ ++ grub_dprintf ("blscfg", "adding menu entry for \"%s\" with id \"%s\"\n", ++ title, id); ++ if (early_initrd) ++ { ++ early_initrds = early_initrd_list(early_initrd); ++ if (!early_initrds) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ goto finish; ++ } ++ ++ if (initrds != NULL && initrds[0] != NULL) ++ { ++ initrd_prefix = grub_strrchr (initrds[0], '/'); ++ initrd_prefix = grub_strndup(initrds[0], initrd_prefix - initrds[0] + 1); ++ } ++ else ++ { ++ initrd_prefix = grub_strrchr (clinux, '/'); ++ initrd_prefix = grub_strndup(clinux, initrd_prefix - clinux + 1); ++ } ++ ++ if (!initrd_prefix) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ goto finish; ++ } ++ } ++ ++ if (early_initrds || initrds) ++ { ++ int initrd_size = sizeof ("initrd"); ++ char *tmp; ++ ++ for (i = 0; early_initrds != NULL && early_initrds[i] != NULL; i++) ++ initrd_size += sizeof (" " GRUB_BOOT_DEVICE) \ ++ + grub_strlen(initrd_prefix) \ ++ + grub_strlen (early_initrds[i]) + 1; ++ ++ for (i = 0; initrds != NULL && initrds[i] != NULL; i++) ++ initrd_size += sizeof (" " GRUB_BOOT_DEVICE) \ ++ + grub_strlen (initrds[i]) + 1; ++ initrd_size += 1; ++ ++ initrd = grub_malloc (initrd_size); ++ if (!initrd) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ goto finish; ++ } ++ ++ ++ tmp = grub_stpcpy(initrd, "initrd"); ++ for (i = 0; early_initrds != NULL && early_initrds[i] != NULL; i++) ++ { ++ grub_dprintf ("blscfg", "adding early initrd %s\n", early_initrds[i]); ++ tmp = grub_stpcpy (tmp, " " GRUB_BOOT_DEVICE); ++ tmp = grub_stpcpy (tmp, initrd_prefix); ++ tmp = grub_stpcpy (tmp, early_initrds[i]); ++ grub_free(early_initrds[i]); ++ } ++ ++ for (i = 0; initrds != NULL && initrds[i] != NULL; i++) ++ { ++ grub_dprintf ("blscfg", "adding initrd %s\n", initrds[i]); ++ tmp = grub_stpcpy (tmp, " " GRUB_BOOT_DEVICE); ++ tmp = grub_stpcpy (tmp, initrds[i]); ++ } ++ tmp = grub_stpcpy (tmp, "\n"); ++ } ++ ++ src = grub_xasprintf ("load_video\n" ++ "set gfx_payload=keep\n" ++ "insmod gzio\n" ++ "linux %s%s%s%s\n" ++ "%s", ++ GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", ++ initrd ? initrd : ""); ++ ++ grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0, &index, entry); ++ grub_dprintf ("blscfg", "Added entry %d id:\"%s\"\n", index, id); ++ ++finish: ++ grub_free (initrd); ++ grub_free (initrd_prefix); ++ grub_free (early_initrds); ++ grub_free (initrds); ++ grub_free (options); ++ grub_free (classes); ++ grub_free (args); ++ grub_free (argv); ++ grub_free (src); ++} ++ ++struct find_entry_info { ++ const char *dirname; ++ const char *devid; ++ grub_device_t dev; ++ grub_fs_t fs; ++}; ++ ++/* ++ * info: the filesystem object the file is on. ++ */ ++static int find_entry (struct find_entry_info *info) ++{ ++ struct read_entry_info read_entry_info; ++ grub_fs_t blsdir_fs = NULL; ++ grub_device_t blsdir_dev = NULL; ++ const char *blsdir = info->dirname; ++ int fallback = 0; ++ int r = 0; ++ ++ if (!blsdir) { ++ blsdir = grub_env_get ("blsdir"); ++ if (!blsdir) ++ blsdir = GRUB_BLS_CONFIG_PATH; ++ } ++ ++ read_entry_info.file = NULL; ++ read_entry_info.dirname = blsdir; ++ ++ grub_dprintf ("blscfg", "scanning blsdir: %s\n", blsdir); ++ ++ blsdir_dev = info->dev; ++ blsdir_fs = info->fs; ++ read_entry_info.devid = info->devid; ++ ++read_fallback: ++ r = blsdir_fs->dir (blsdir_dev, read_entry_info.dirname, read_entry, ++ &read_entry_info); ++ if (r != 0) { ++ grub_dprintf ("blscfg", "read_entry returned error\n"); ++ grub_err_t e; ++ do ++ { ++ e = grub_error_pop(); ++ } while (e); ++ } ++ ++ if (r && !info->dirname && !fallback) { ++ read_entry_info.dirname = "/boot" GRUB_BLS_CONFIG_PATH; ++ grub_dprintf ("blscfg", "Entries weren't found in %s, fallback to %s\n", ++ blsdir, read_entry_info.dirname); ++ fallback = 1; ++ goto read_fallback; ++ } ++ ++ return 0; ++} ++ ++static grub_err_t ++bls_load_entries (const char *path) ++{ ++ grub_size_t len; ++ grub_fs_t fs; ++ grub_device_t dev; ++ static grub_err_t r; ++ const char *devid = NULL; ++ char *blsdir = NULL; ++ struct find_entry_info info = { ++ .dev = NULL, ++ .fs = NULL, ++ .dirname = NULL, ++ }; ++ struct read_entry_info rei = { ++ .devid = NULL, ++ .dirname = NULL, ++ }; ++ ++ if (path) { ++ len = grub_strlen (path); ++ if (grub_strcmp (path + len - 5, ".conf") == 0) { ++ rei.file = grub_file_open (path); ++ if (!rei.file) ++ return grub_errno; ++ /* ++ * read_entry() closes the file ++ */ ++ return read_entry(path, NULL, &rei); ++ } else if (path[0] == '(') { ++ devid = path + 1; ++ ++ blsdir = grub_strchr (path, ')'); ++ if (!blsdir) ++ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Filepath isn't correct")); ++ ++ *blsdir = '\0'; ++ blsdir = blsdir + 1; ++ } ++ } ++ ++ if (!devid) { ++#ifdef GRUB_MACHINE_EMU ++ devid = "host"; ++#elif defined(GRUB_MACHINE_EFI) ++ devid = grub_env_get ("root"); ++#else ++ devid = grub_env_get ("boot"); ++#endif ++ if (!devid) ++ return grub_error (GRUB_ERR_FILE_NOT_FOUND, ++ N_("variable `%s' isn't set"), "boot"); ++ } ++ ++ grub_dprintf ("blscfg", "opening %s\n", devid); ++ dev = grub_device_open (devid); ++ if (!dev) ++ return grub_errno; ++ ++ grub_dprintf ("blscfg", "probing fs\n"); ++ fs = grub_fs_probe (dev); ++ if (!fs) ++ { ++ r = grub_errno; ++ goto finish; ++ } ++ ++ info.dirname = blsdir; ++ info.devid = devid; ++ info.dev = dev; ++ info.fs = fs; ++ find_entry(&info); ++ ++finish: ++ if (dev) ++ grub_device_close (dev); ++ ++ return r; ++} ++ ++static bool ++is_default_entry(const char *def_entry, struct bls_entry *entry, int idx) ++{ ++ const char *title; ++ int def_idx; ++ ++ if (!def_entry) ++ return false; ++ ++ if (grub_strcmp(def_entry, entry->filename) == 0) ++ return true; ++ ++ title = bls_get_val(entry, "title", NULL); ++ ++ if (title && grub_strcmp(def_entry, title) == 0) ++ return true; ++ ++ def_idx = (int)grub_strtol(def_entry, NULL, 0); ++ if (grub_errno == GRUB_ERR_BAD_NUMBER) { ++ grub_errno = GRUB_ERR_NONE; ++ return false; ++ } ++ ++ if (def_idx == idx) ++ return true; ++ ++ return false; ++} ++ ++static grub_err_t ++bls_create_entries (bool show_default, bool show_non_default, char *entry_id) ++{ ++ const char *def_entry = NULL; ++ struct bls_entry *entry = NULL; ++ int idx = 0; ++ ++ def_entry = grub_env_get("default"); ++ ++ grub_dprintf ("blscfg", "%s Creating entries from bls\n", __func__); ++ FOR_BLS_ENTRIES(entry) { ++ if (entry->visible) { ++ idx++; ++ continue; ++ } ++ ++ if ((show_default && is_default_entry(def_entry, entry, idx)) || ++ (show_non_default && !is_default_entry(def_entry, entry, idx)) || ++ (entry_id && grub_strcmp(entry_id, entry->filename) == 0)) { ++ create_entry(entry); ++ entry->visible = 1; ++ } ++ idx++; ++ } ++ ++ return GRUB_ERR_NONE; ++} ++ ++static grub_err_t ++grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, ++ int argc, char **args) ++{ ++ grub_err_t r; ++ char *path = NULL; ++ char *entry_id = NULL; ++ bool show_default = true; ++ bool show_non_default = true; ++ ++ if (argc == 1) { ++ if (grub_strcmp (args[0], "default") == 0) { ++ show_non_default = false; ++ } else if (grub_strcmp (args[0], "non-default") == 0) { ++ show_default = false; ++ } else if (args[0][0] == '(') { ++ path = args[0]; ++ } else { ++ entry_id = args[0]; ++ show_default = false; ++ show_non_default = false; ++ } ++ } ++ ++ r = bls_load_entries(path); ++ if (r) ++ return r; ++ ++ return bls_create_entries(show_default, show_non_default, entry_id); ++} ++ ++static grub_extcmd_t cmd; ++static grub_extcmd_t oldcmd; ++ ++GRUB_MOD_INIT(blscfg) ++{ ++ grub_dprintf("blscfg", "%s got here\n", __func__); ++ cmd = grub_register_extcmd ("blscfg", ++ grub_cmd_blscfg, ++ 0, ++ NULL, ++ N_("Import Boot Loader Specification snippets."), ++ NULL); ++ oldcmd = grub_register_extcmd ("bls_import", ++ grub_cmd_blscfg, ++ 0, ++ NULL, ++ N_("Import Boot Loader Specification snippets."), ++ NULL); ++} ++ ++GRUB_MOD_FINI(blscfg) ++{ ++ grub_unregister_extcmd (cmd); ++ grub_unregister_extcmd (oldcmd); ++} +diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c +index b32f3c74cb1..ef8dd74c589 100644 +--- a/grub-core/commands/legacycfg.c ++++ b/grub-core/commands/legacycfg.c +@@ -133,7 +133,7 @@ legacy_file (const char *filename) + args[0] = oldname; + grub_normal_add_menu_entry (1, args, NULL, NULL, "legacy", + NULL, NULL, +- entrysrc, 0); ++ entrysrc, 0, NULL, NULL); + grub_free (args); + entrysrc[0] = 0; + grub_free (oldname); +@@ -186,7 +186,8 @@ legacy_file (const char *filename) + } + args[0] = entryname; + grub_normal_add_menu_entry (1, args, NULL, NULL, NULL, +- NULL, NULL, entrysrc, 0); ++ NULL, NULL, entrysrc, 0, NULL, ++ NULL); + grub_free (args); + } + +diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c +index acd93d123ed..91c99456091 100644 +--- a/grub-core/commands/loadenv.c ++++ b/grub-core/commands/loadenv.c +@@ -28,6 +28,8 @@ + #include + #include + ++#include "loadenv.h" ++ + GRUB_MOD_LICENSE ("GPLv3+"); + + static const struct grub_arg_option options[] = +@@ -84,81 +86,6 @@ open_envblk_file (char *filename, int untrusted) + return file; + } + +-static grub_envblk_t +-read_envblk_file (grub_file_t file) +-{ +- grub_off_t offset = 0; +- char *buf; +- grub_size_t size = grub_file_size (file); +- grub_envblk_t envblk; +- +- buf = grub_malloc (size); +- if (! buf) +- return 0; +- +- while (size > 0) +- { +- grub_ssize_t ret; +- +- ret = grub_file_read (file, buf + offset, size); +- if (ret <= 0) +- { +- grub_free (buf); +- return 0; +- } +- +- size -= ret; +- offset += ret; +- } +- +- envblk = grub_envblk_open (buf, offset); +- if (! envblk) +- { +- grub_free (buf); +- grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid environment block"); +- return 0; +- } +- +- return envblk; +-} +- +-struct grub_env_whitelist +-{ +- grub_size_t len; +- char **list; +-}; +-typedef struct grub_env_whitelist grub_env_whitelist_t; +- +-static int +-test_whitelist_membership (const char* name, +- const grub_env_whitelist_t* whitelist) +-{ +- grub_size_t i; +- +- for (i = 0; i < whitelist->len; i++) +- if (grub_strcmp (name, whitelist->list[i]) == 0) +- return 1; /* found it */ +- +- return 0; /* not found */ +-} +- +-/* Helper for grub_cmd_load_env. */ +-static int +-set_var (const char *name, const char *value, void *whitelist) +-{ +- if (! whitelist) +- { +- grub_env_set (name, value); +- return 0; +- } +- +- if (test_whitelist_membership (name, +- (const grub_env_whitelist_t *) whitelist)) +- grub_env_set (name, value); +- +- return 0; +-} +- + static grub_err_t + grub_cmd_load_env (grub_extcmd_context_t ctxt, int argc, char **args) + { +diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c +index 2c5363da7f5..9faf2be0f64 100644 +--- a/grub-core/commands/menuentry.c ++++ b/grub-core/commands/menuentry.c +@@ -78,7 +78,7 @@ grub_normal_add_menu_entry (int argc, const char **args, + char **classes, const char *id, + const char *users, const char *hotkey, + const char *prefix, const char *sourcecode, +- int submenu) ++ int submenu, int *index, struct bls_entry *bls) + { + int menu_hotkey = 0; + char **menu_args = NULL; +@@ -149,9 +149,12 @@ grub_normal_add_menu_entry (int argc, const char **args, + if (! menu_title) + goto fail; + ++ grub_dprintf ("menu", "id:\"%s\"\n", id); ++ grub_dprintf ("menu", "title:\"%s\"\n", menu_title); + menu_id = grub_strdup (id ? : menu_title); + if (! menu_id) + goto fail; ++ grub_dprintf ("menu", "menu_id:\"%s\"\n", menu_id); + + /* Save argc, args to pass as parameters to block arg later. */ + menu_args = grub_malloc (sizeof (char*) * (argc + 1)); +@@ -170,8 +173,12 @@ grub_normal_add_menu_entry (int argc, const char **args, + } + + /* Add the menu entry at the end of the list. */ ++ int ind=0; + while (*last) +- last = &(*last)->next; ++ { ++ ind++; ++ last = &(*last)->next; ++ } + + *last = grub_zalloc (sizeof (**last)); + if (! *last) +@@ -188,8 +195,11 @@ grub_normal_add_menu_entry (int argc, const char **args, + (*last)->args = menu_args; + (*last)->sourcecode = menu_sourcecode; + (*last)->submenu = submenu; ++ (*last)->bls = bls; + + menu->size++; ++ if (index) ++ *index = ind; + return GRUB_ERR_NONE; + + fail: +@@ -286,7 +296,8 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args) + users, + ctxt->state[2].arg, 0, + ctxt->state[3].arg, +- ctxt->extcmd->cmd->name[0] == 's'); ++ ctxt->extcmd->cmd->name[0] == 's', ++ NULL, NULL); + + src = args[argc - 1]; + args[argc - 1] = NULL; +@@ -303,7 +314,8 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args) + ctxt->state[0].args, ctxt->state[4].arg, + users, + ctxt->state[2].arg, prefix, src + 1, +- ctxt->extcmd->cmd->name[0] == 's'); ++ ctxt->extcmd->cmd->name[0] == 's', NULL, ++ NULL); + + src[len - 1] = ch; + args[argc - 1] = src; +diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c +index b2654ef62e8..5116aac6614 100644 +--- a/grub-core/normal/main.c ++++ b/grub-core/normal/main.c +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -70,6 +71,11 @@ grub_normal_free_menu (grub_menu_t menu) + grub_free (entry->args); + } + ++ if (entry->bls) ++ { ++ entry->bls->visible = 0; ++ } ++ + grub_free ((void *) entry->id); + grub_free ((void *) entry->users); + grub_free ((void *) entry->title); +diff --git a/grub-core/commands/loadenv.h b/grub-core/commands/loadenv.h +new file mode 100644 +index 00000000000..952f46121bd +--- /dev/null ++++ b/grub-core/commands/loadenv.h +@@ -0,0 +1,93 @@ ++/* loadenv.c - command to load/save environment variable. */ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 2008,2009,2010 Free Software Foundation, Inc. ++ * ++ * GRUB is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * GRUB is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with GRUB. If not, see . ++ */ ++ ++static grub_envblk_t UNUSED ++read_envblk_file (grub_file_t file) ++{ ++ grub_off_t offset = 0; ++ char *buf; ++ grub_size_t size = grub_file_size (file); ++ grub_envblk_t envblk; ++ ++ buf = grub_malloc (size); ++ if (! buf) ++ return 0; ++ ++ while (size > 0) ++ { ++ grub_ssize_t ret; ++ ++ ret = grub_file_read (file, buf + offset, size); ++ if (ret <= 0) ++ { ++ grub_free (buf); ++ return 0; ++ } ++ ++ size -= ret; ++ offset += ret; ++ } ++ ++ envblk = grub_envblk_open (buf, offset); ++ if (! envblk) ++ { ++ grub_free (buf); ++ grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid environment block"); ++ return 0; ++ } ++ ++ return envblk; ++} ++ ++struct grub_env_whitelist ++{ ++ grub_size_t len; ++ char **list; ++}; ++typedef struct grub_env_whitelist grub_env_whitelist_t; ++ ++static int UNUSED ++test_whitelist_membership (const char* name, ++ const grub_env_whitelist_t* whitelist) ++{ ++ grub_size_t i; ++ ++ for (i = 0; i < whitelist->len; i++) ++ if (grub_strcmp (name, whitelist->list[i]) == 0) ++ return 1; /* found it */ ++ ++ return 0; /* not found */ ++} ++ ++/* Helper for grub_cmd_load_env. */ ++static int UNUSED ++set_var (const char *name, const char *value, void *whitelist) ++{ ++ if (! whitelist) ++ { ++ grub_env_set (name, value); ++ return 0; ++ } ++ ++ if (test_whitelist_membership (name, ++ (const grub_env_whitelist_t *) whitelist)) ++ grub_env_set (name, value); ++ ++ return 0; ++} +diff --git a/include/grub/compiler.h b/include/grub/compiler.h +index c9e1d7a73dc..9859ff4cc79 100644 +--- a/include/grub/compiler.h ++++ b/include/grub/compiler.h +@@ -48,4 +48,6 @@ + # define WARN_UNUSED_RESULT + #endif + ++#define UNUSED __attribute__((__unused__)) ++ + #endif /* ! GRUB_COMPILER_HEADER */ +diff --git a/include/grub/menu.h b/include/grub/menu.h +index ee2b5e91045..0acdc2aa6bf 100644 +--- a/include/grub/menu.h ++++ b/include/grub/menu.h +@@ -20,6 +20,16 @@ + #ifndef GRUB_MENU_HEADER + #define GRUB_MENU_HEADER 1 + ++struct bls_entry ++{ ++ struct bls_entry *next; ++ struct bls_entry *prev; ++ struct keyval **keyvals; ++ int nkeyvals; ++ char *filename; ++ int visible; ++}; ++ + struct grub_menu_entry_class + { + char *name; +@@ -60,6 +70,9 @@ struct grub_menu_entry + + /* The next element. */ + struct grub_menu_entry *next; ++ ++ /* BLS used to populate the entry */ ++ struct bls_entry *bls; + }; + typedef struct grub_menu_entry *grub_menu_entry_t; + +diff --git a/include/grub/normal.h b/include/grub/normal.h +index 218cbabccaf..8839ad85a19 100644 +--- a/include/grub/normal.h ++++ b/include/grub/normal.h +@@ -145,7 +145,7 @@ grub_normal_add_menu_entry (int argc, const char **args, char **classes, + const char *id, + const char *users, const char *hotkey, + const char *prefix, const char *sourcecode, +- int submenu); ++ int submenu, int *index, struct bls_entry *bls); + + grub_err_t + grub_normal_set_password (const char *user, const char *password); diff --git a/0029-Add-devicetree-loading.patch b/0028-Add-devicetree-loading.patch similarity index 100% rename from 0029-Add-devicetree-loading.patch rename to 0028-Add-devicetree-loading.patch diff --git a/0028-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch b/0028-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch deleted file mode 100644 index fd63493..0000000 --- a/0028-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch +++ /dev/null @@ -1,248 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Fedora Ninjas -Date: Tue, 22 Jan 2013 06:31:38 +0100 -Subject: [PATCH] blscfg: add blscfg module to parse Boot Loader Specification - snippets - -http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec - -Works like this: - - insmod blscfg - bls_import - -Done! You should now have menu items for your snippets in place. - -Signed-off-by: Peter Jones ---- - grub-core/Makefile.core.def | 8 ++ - grub-core/commands/blscfg.c | 201 ++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 209 insertions(+) - create mode 100644 grub-core/commands/blscfg.c - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index f8065388213..cd0902b46b8 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -768,6 +768,14 @@ module = { - common = commands/blocklist.c; - }; - -+module = { -+ name = blscfg; -+ common = commands/blscfg.c; -+ enable = i386_efi; -+ enable = x86_64_efi; -+ enable = i386_pc; -+}; -+ - module = { - name = boot; - common = commands/boot.c; -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -new file mode 100644 -index 00000000000..4274aca5a9d ---- /dev/null -+++ b/grub-core/commands/blscfg.c -@@ -0,0 +1,201 @@ -+/*-*- Mode: C; c-basic-offset: 2; indent-tabs-mode: t -*-*/ -+ -+/* bls.c - implementation of the boot loader spec */ -+ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+GRUB_MOD_LICENSE ("GPLv3+"); -+ -+#ifdef GRUB_MACHINE_EFI -+#define GRUB_LINUX_CMD "linuxefi" -+#define GRUB_INITRD_CMD "initrdefi" -+#define GRUB_BLS_CONFIG_PATH "/EFI/fedora/loader/entries/" -+#define GRUB_BOOT_DEVICE "($boot)" -+#else -+#define GRUB_LINUX_CMD "linux" -+#define GRUB_INITRD_CMD "initrd" -+#define GRUB_BLS_CONFIG_PATH "/loader/entries/" -+#define GRUB_BOOT_DEVICE "($root)" -+#endif -+ -+static int parse_entry ( -+ const char *filename, -+ const struct grub_dirhook_info *info __attribute__ ((unused)), -+ void *data __attribute__ ((unused))) -+{ -+ grub_size_t n; -+ char *p; -+ grub_file_t f = NULL; -+ grub_off_t sz; -+ char *title = NULL, *options = NULL, *clinux = NULL, *initrd = NULL, *src = NULL; -+ const char *args[2] = { NULL, NULL }; -+ -+ if (filename[0] == '.') -+ return 0; -+ -+ n = grub_strlen (filename); -+ if (n <= 5) -+ return 0; -+ -+ if (grub_strcmp (filename + n - 5, ".conf") != 0) -+ return 0; -+ -+ p = grub_xasprintf (GRUB_BLS_CONFIG_PATH "%s", filename); -+ -+ f = grub_file_open (p); -+ if (!f) -+ goto finish; -+ -+ sz = grub_file_size (f); -+ if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024) -+ goto finish; -+ -+ for (;;) -+ { -+ char *buf; -+ -+ buf = grub_file_getline (f); -+ if (!buf) -+ break; -+ -+ if (grub_strncmp (buf, "title ", 6) == 0) -+ { -+ grub_free (title); -+ title = grub_strdup (buf + 6); -+ if (!title) -+ goto finish; -+ } -+ else if (grub_strncmp (buf, "options ", 8) == 0) -+ { -+ grub_free (options); -+ options = grub_strdup (buf + 8); -+ if (!options) -+ goto finish; -+ } -+ else if (grub_strncmp (buf, "linux ", 6) == 0) -+ { -+ grub_free (clinux); -+ clinux = grub_strdup (buf + 6); -+ if (!clinux) -+ goto finish; -+ } -+ else if (grub_strncmp (buf, "initrd ", 7) == 0) -+ { -+ grub_free (initrd); -+ initrd = grub_strdup (buf + 7); -+ if (!initrd) -+ goto finish; -+ } -+ -+ grub_free(buf); -+ } -+ -+ if (!linux) -+ { -+ grub_printf ("Skipping file %s with no 'linux' key.", p); -+ goto finish; -+ } -+ -+ args[0] = title ? title : filename; -+ -+ src = grub_xasprintf ("load_video\n" -+ "set gfx_payload=keep\n" -+ "insmod gzio\n" -+ GRUB_LINUX_CMD " %s%s%s%s\n" -+ "%s%s%s%s", -+ GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", -+ initrd ? GRUB_INITRD_CMD " " : "", initrd ? GRUB_BOOT_DEVICE : "", initrd ? initrd : "", initrd ? "\n" : ""); -+ -+ grub_normal_add_menu_entry (1, args, NULL, NULL, "bls", NULL, NULL, src, 0); -+ -+finish: -+ grub_free (p); -+ grub_free (title); -+ grub_free (options); -+ grub_free (clinux); -+ grub_free (initrd); -+ grub_free (src); -+ -+ if (f) -+ grub_file_close (f); -+ -+ return 0; -+} -+ -+static grub_err_t -+grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)), -+ int argc __attribute__ ((unused)), -+ char **args __attribute__ ((unused))) -+{ -+ grub_fs_t fs; -+ grub_device_t dev; -+ static grub_err_t r; -+ const char *devid; -+ -+ devid = grub_env_get ("root"); -+ if (!devid) -+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "root"); -+ -+ dev = grub_device_open (devid); -+ if (!dev) -+ return grub_errno; -+ -+ fs = grub_fs_probe (dev); -+ if (!fs) -+ { -+ r = grub_errno; -+ goto finish; -+ } -+ -+ r = fs->dir (dev, GRUB_BLS_CONFIG_PATH, parse_entry, NULL); -+ -+finish: -+ if (dev) -+ grub_device_close (dev); -+ -+ return r; -+} -+ -+static grub_extcmd_t cmd; -+ -+GRUB_MOD_INIT(bls) -+{ -+ cmd = grub_register_extcmd ("bls_import", -+ grub_cmd_bls_import, -+ 0, -+ NULL, -+ N_("Import Boot Loader Specification snippets."), -+ NULL); -+} -+ -+GRUB_MOD_FINI(bls) -+{ -+ grub_unregister_extcmd (cmd); -+} diff --git a/0030-Don-t-write-messages-to-the-screen.patch b/0029-Don-t-write-messages-to-the-screen.patch similarity index 100% rename from 0030-Don-t-write-messages-to-the-screen.patch rename to 0029-Don-t-write-messages-to-the-screen.patch diff --git a/0031-Don-t-print-GNU-GRUB-header.patch b/0030-Don-t-print-GNU-GRUB-header.patch similarity index 86% rename from 0031-Don-t-print-GNU-GRUB-header.patch rename to 0030-Don-t-print-GNU-GRUB-header.patch index cdcdb13..505c6f7 100644 --- a/0031-Don-t-print-GNU-GRUB-header.patch +++ b/0030-Don-t-print-GNU-GRUB-header.patch @@ -9,10 +9,10 @@ No one cares. 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index b2654ef62e8..f57b7508a76 100644 +index 5116aac6614..31b624a23cf 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -202,15 +202,16 @@ read_config_file (const char *config) +@@ -208,15 +208,16 @@ read_config_file (const char *config) /* Initialize the screen. */ void grub_normal_init_page (struct grub_term_output *term, @@ -32,7 +32,7 @@ index b2654ef62e8..f57b7508a76 100644 msg_formatted = grub_xasprintf (_("GNU GRUB version %s"), PACKAGE_VERSION); if (!msg_formatted) -@@ -235,6 +236,7 @@ grub_normal_init_page (struct grub_term_output *term, +@@ -241,6 +242,7 @@ grub_normal_init_page (struct grub_term_output *term, grub_putcode ('\n', term); grub_putcode ('\n', term); grub_free (unicode_msg); diff --git a/0032-Don-t-add-to-highlighted-row.patch b/0031-Don-t-add-to-highlighted-row.patch similarity index 100% rename from 0032-Don-t-add-to-highlighted-row.patch rename to 0031-Don-t-add-to-highlighted-row.patch diff --git a/0033-Message-string-cleanups.patch b/0032-Message-string-cleanups.patch similarity index 100% rename from 0033-Message-string-cleanups.patch rename to 0032-Message-string-cleanups.patch diff --git a/0034-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch b/0033-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch similarity index 100% rename from 0034-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch rename to 0033-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch diff --git a/0035-Use-the-correct-indentation-for-the-term-help-text.patch b/0034-Use-the-correct-indentation-for-the-term-help-text.patch similarity index 90% rename from 0035-Use-the-correct-indentation-for-the-term-help-text.patch rename to 0034-Use-the-correct-indentation-for-the-term-help-text.patch index d2bf366..b20f0e9 100644 --- a/0035-Use-the-correct-indentation-for-the-term-help-text.patch +++ b/0034-Use-the-correct-indentation-for-the-term-help-text.patch @@ -9,10 +9,10 @@ That is consistent with the menu help text 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index f57b7508a76..0ce59fdc3f0 100644 +index 31b624a23cf..7f295e3946b 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -426,8 +426,8 @@ grub_normal_reader_init (int nested) +@@ -432,8 +432,8 @@ grub_normal_reader_init (int nested) grub_normal_init_page (term, 1); grub_term_setcursor (term, 1); diff --git a/0036-Indent-menu-entries.patch b/0035-Indent-menu-entries.patch similarity index 100% rename from 0036-Indent-menu-entries.patch rename to 0035-Indent-menu-entries.patch diff --git a/0037-Fix-margins.patch b/0036-Fix-margins.patch similarity index 100% rename from 0037-Fix-margins.patch rename to 0036-Fix-margins.patch diff --git a/0038-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch b/0037-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch similarity index 100% rename from 0038-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch rename to 0037-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch diff --git a/0039-Enable-pager-by-default.-985860.patch b/0038-Enable-pager-by-default.-985860.patch similarity index 100% rename from 0039-Enable-pager-by-default.-985860.patch rename to 0038-Enable-pager-by-default.-985860.patch diff --git a/0040-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch b/0039-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch similarity index 100% rename from 0040-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch rename to 0039-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch diff --git a/0041-Don-t-say-GNU-Linux-in-generated-menus.patch b/0040-Don-t-say-GNU-Linux-in-generated-menus.patch similarity index 100% rename from 0041-Don-t-say-GNU-Linux-in-generated-menus.patch rename to 0040-Don-t-say-GNU-Linux-in-generated-menus.patch diff --git a/0042-Don-t-draw-a-border-around-the-menu.patch b/0041-Don-t-draw-a-border-around-the-menu.patch similarity index 100% rename from 0042-Don-t-draw-a-border-around-the-menu.patch rename to 0041-Don-t-draw-a-border-around-the-menu.patch diff --git a/0043-Use-the-standard-margin-for-the-timeout-string.patch b/0042-Use-the-standard-margin-for-the-timeout-string.patch similarity index 100% rename from 0043-Use-the-standard-margin-for-the-timeout-string.patch rename to 0042-Use-the-standard-margin-for-the-timeout-string.patch diff --git a/0044-Add-.eh_frame-to-list-of-relocations-stripped.patch b/0043-Add-.eh_frame-to-list-of-relocations-stripped.patch similarity index 100% rename from 0044-Add-.eh_frame-to-list-of-relocations-stripped.patch rename to 0043-Add-.eh_frame-to-list-of-relocations-stripped.patch diff --git a/0045-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch b/0044-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch similarity index 100% rename from 0045-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch rename to 0044-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch diff --git a/0046-Don-t-require-a-password-to-boot-entries-generated-b.patch b/0045-Don-t-require-a-password-to-boot-entries-generated-b.patch similarity index 100% rename from 0046-Don-t-require-a-password-to-boot-entries-generated-b.patch rename to 0045-Don-t-require-a-password-to-boot-entries-generated-b.patch diff --git a/0047-Don-t-emit-Booting-.-message.patch b/0046-Don-t-emit-Booting-.-message.patch similarity index 100% rename from 0047-Don-t-emit-Booting-.-message.patch rename to 0046-Don-t-emit-Booting-.-message.patch diff --git a/0048-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch b/0047-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch similarity index 100% rename from 0048-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch rename to 0047-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch diff --git a/0049-use-fw_path-prefix-when-fallback-searching-for-grub-.patch b/0048-use-fw_path-prefix-when-fallback-searching-for-grub-.patch similarity index 89% rename from 0049-use-fw_path-prefix-when-fallback-searching-for-grub-.patch rename to 0048-use-fw_path-prefix-when-fallback-searching-for-grub-.patch index 0035e62..bac4eee 100644 --- a/0049-use-fw_path-prefix-when-fallback-searching-for-grub-.patch +++ b/0048-use-fw_path-prefix-when-fallback-searching-for-grub-.patch @@ -17,10 +17,10 @@ Signed-off-by: Mark Salter 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 0ce59fdc3f0..a3713efcd90 100644 +index 7f295e3946b..231f3f86371 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -343,7 +343,7 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), +@@ -349,7 +349,7 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), char *config; const char *prefix, *fw_path; @@ -29,7 +29,7 @@ index 0ce59fdc3f0..a3713efcd90 100644 if (fw_path) { config = grub_xasprintf ("%s/grub.cfg", fw_path); -@@ -366,7 +366,8 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), +@@ -372,7 +372,8 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), } } diff --git a/0050-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch b/0049-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch similarity index 96% rename from 0050-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch rename to 0049-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch index 84b8d7a..2e8dffd 100644 --- a/0050-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch +++ b/0049-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch @@ -9,10 +9,10 @@ Signed-off-by: Peter Jones 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index a3713efcd90..7d9c4f09b9b 100644 +index 231f3f86371..cf5c0b273ce 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -341,53 +341,59 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), +@@ -347,53 +347,59 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), /* Guess the config filename. It is necessary to make CONFIG static, so that it won't get broken by longjmp. */ char *config; diff --git a/0051-Fix-convert-function-to-support-NVMe-devices.patch b/0050-Fix-convert-function-to-support-NVMe-devices.patch similarity index 100% rename from 0051-Fix-convert-function-to-support-NVMe-devices.patch rename to 0050-Fix-convert-function-to-support-NVMe-devices.patch diff --git a/0054-Add-grub_util_readlink.patch b/0051-Add-grub_util_readlink.patch similarity index 100% rename from 0054-Add-grub_util_readlink.patch rename to 0051-Add-grub_util_readlink.patch diff --git a/0055-Make-editenv-chase-symlinks-including-those-across-d.patch b/0052-Make-editenv-chase-symlinks-including-those-across-d.patch similarity index 92% rename from 0055-Make-editenv-chase-symlinks-including-those-across-d.patch rename to 0052-Make-editenv-chase-symlinks-including-those-across-d.patch index 73e316e..2f23fda 100644 --- a/0055-Make-editenv-chase-symlinks-including-those-across-d.patch +++ b/0052-Make-editenv-chase-symlinks-including-those-across-d.patch @@ -11,15 +11,15 @@ which allows /usr/bin/grub2-editenv to be the same across platforms Signed-off-by: Peter Jones Reviewed-by: Adam Jackson --- - Makefile.util.def | 9 +++++++++ + Makefile.util.def | 11 +++++++++++ util/editenv.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- - 2 files changed, 53 insertions(+), 2 deletions(-) + 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/Makefile.util.def b/Makefile.util.def -index c7b775bce73..d08713b5500 100644 +index c7b775bce73..3efc5718ae8 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -231,8 +231,17 @@ program = { +@@ -231,8 +231,19 @@ program = { common = util/grub-editenv.c; common = util/editenv.c; @@ -29,6 +29,8 @@ index c7b775bce73..d08713b5500 100644 + extra_dist = grub-core/osdep/unix/compress.c; + extra_dist = grub-core/osdep/basic/compress.c; + common = util/mkimage.c; ++ common = util/grub-mkimage32.c; ++ common = util/grub-mkimage64.c; + common = grub-core/osdep/config.c; + common = util/config.c; + common = util/resolve.c; diff --git a/0052-reopen-SNP-protocol-for-exclusive-use-by-grub.patch b/0052-reopen-SNP-protocol-for-exclusive-use-by-grub.patch deleted file mode 100644 index fb2875b..0000000 --- a/0052-reopen-SNP-protocol-for-exclusive-use-by-grub.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Fedora Ninjas -Date: Sat, 15 Feb 2014 15:10:22 -0500 -Subject: [PATCH] reopen SNP protocol for exclusive use by grub - ---- - grub-core/net/drivers/efi/efinet.c | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 5388f952ba9..ea0e0ca360e 100644 ---- a/grub-core/net/drivers/efi/efinet.c -+++ b/grub-core/net/drivers/efi/efinet.c -@@ -330,6 +330,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - { - struct grub_net_card *card; - grub_efi_device_path_t *dp; -+ grub_efi_simple_network_t *net; - - dp = grub_efi_get_device_path (hnd); - if (! dp) -@@ -383,6 +384,21 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - &pxe_mode->dhcp_ack, - sizeof (pxe_mode->dhcp_ack), - 1, device, path); -+ net = grub_efi_open_protocol (card->efi_handle, &net_io_guid, -+ GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE); -+ if (net) { -+ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED -+ && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) -+ continue; -+ -+ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED) -+ continue; -+ -+ if (net->mode->state == GRUB_EFI_NETWORK_STARTED -+ && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS) -+ continue; -+ card->efi_net = net; -+ } - return; - } - } diff --git a/0056-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch b/0053-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch similarity index 100% rename from 0056-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch rename to 0053-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch diff --git a/0053-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch b/0053-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch deleted file mode 100644 index 4238b7d..0000000 --- a/0053-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 4 Mar 2016 15:13:59 -0500 -Subject: [PATCH] Revert "reopen SNP protocol for exclusive use by grub" - -This reverts commit a3f2c756ce34c9666bddef35e3b3b85ccecdcffc , which is -obsoleted by these: - -49426e9 efinet: open Simple Network Protocol exclusively -f348aee efinet: enable hardware filters when opening interface -c52ae40 efinet: skip virtual IPv4 and IPv6 devices when enumerating cards - -Signed-off-by: Peter Jones ---- - grub-core/net/drivers/efi/efinet.c | 16 ---------------- - 1 file changed, 16 deletions(-) - -diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index ea0e0ca360e..5388f952ba9 100644 ---- a/grub-core/net/drivers/efi/efinet.c -+++ b/grub-core/net/drivers/efi/efinet.c -@@ -330,7 +330,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - { - struct grub_net_card *card; - grub_efi_device_path_t *dp; -- grub_efi_simple_network_t *net; - - dp = grub_efi_get_device_path (hnd); - if (! dp) -@@ -384,21 +383,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - &pxe_mode->dhcp_ack, - sizeof (pxe_mode->dhcp_ack), - 1, device, path); -- net = grub_efi_open_protocol (card->efi_handle, &net_io_guid, -- GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE); -- if (net) { -- if (net->mode->state == GRUB_EFI_NETWORK_STOPPED -- && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) -- continue; -- -- if (net->mode->state == GRUB_EFI_NETWORK_STOPPED) -- continue; -- -- if (net->mode->state == GRUB_EFI_NETWORK_STARTED -- && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS) -- continue; -- card->efi_net = net; -- } - return; - } - } diff --git a/0057-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch b/0054-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch similarity index 100% rename from 0057-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch rename to 0054-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch diff --git a/0058-Try-prefix-if-fw_path-doesn-t-work.patch b/0055-Try-prefix-if-fw_path-doesn-t-work.patch similarity index 98% rename from 0058-Try-prefix-if-fw_path-doesn-t-work.patch rename to 0055-Try-prefix-if-fw_path-doesn-t-work.patch index 1ded908..6878d1a 100644 --- a/0058-Try-prefix-if-fw_path-doesn-t-work.patch +++ b/0055-Try-prefix-if-fw_path-doesn-t-work.patch @@ -69,10 +69,10 @@ index 0769bf850d3..16d2ce06d5a 100644 static struct grub_preboot *fini_hnd; diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 7d9c4f09b9b..b69f9e738fa 100644 +index cf5c0b273ce..ea749f26fd5 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -331,74 +331,72 @@ grub_enter_normal_mode (const char *config) +@@ -337,74 +337,72 @@ grub_enter_normal_mode (const char *config) grub_boot_time ("Exiting normal mode"); } diff --git a/0059-Update-info-with-grub.cfg-netboot-selection-order-11.patch b/0056-Update-info-with-grub.cfg-netboot-selection-order-11.patch similarity index 100% rename from 0059-Update-info-with-grub.cfg-netboot-selection-order-11.patch rename to 0056-Update-info-with-grub.cfg-netboot-selection-order-11.patch diff --git a/0060-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch b/0057-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch similarity index 93% rename from 0060-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch rename to 0057-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch index d686cf3..305480a 100644 --- a/0060-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch +++ b/0057-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch @@ -9,19 +9,23 @@ starting with the most recent. Added an option for rpm-based systems to use the rpm-sort library to sort kernels instead. Resolves rhbz#1124074 + +Signed-off-by: Robert Marshall +[pjones: fix --enable-rpm-sort configure option] +Signed-off-by: Peter Jones --- configure.ac | 29 +++++ Makefile.util.def | 16 +++ util/grub-rpm-sort.c | 281 ++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 2 + - util/grub-mkconfig_lib.in | 8 +- + util/grub-mkconfig_lib.in | 11 +- util/grub-rpm-sort.8 | 12 ++ - 6 files changed, 347 insertions(+), 1 deletion(-) + 6 files changed, 350 insertions(+), 1 deletion(-) create mode 100644 util/grub-rpm-sort.c create mode 100644 util/grub-rpm-sort.8 diff --git a/configure.ac b/configure.ac -index d5db2803ec4..056df1cbaf9 100644 +index d5db2803ec4..00f1db29b1a 100644 --- a/configure.ac +++ b/configure.ac @@ -65,6 +65,7 @@ grub_TRANSFORM([grub-mkrelpath]) @@ -47,7 +51,7 @@ index d5db2803ec4..056df1cbaf9 100644 +AC_ARG_ENABLE([rpm-sort], + [AS_HELP_STRING([--enable-rpm-sort], + [enable native rpm sorting of kernels in grub (default=guessed)])]) -+if test x"$enable_rpm-sort" = xno ; then ++if test x"$enable_rpm_sort" = xno ; then + rpm_sort_excuse="explicitly disabled" +fi + @@ -75,10 +79,10 @@ index d5db2803ec4..056df1cbaf9 100644 if test x$host_kernel = xkfreebsd; then AC_CHECK_LIB([geom], [geom_gettree], [], diff --git a/Makefile.util.def b/Makefile.util.def -index d08713b5500..406d96861b6 100644 +index 3efc5718ae8..bb21c87c8ed 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -685,6 +685,22 @@ program = { +@@ -687,6 +687,22 @@ program = { ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -402,23 +406,33 @@ index 43f04d47277..fa2e5b609b1 100644 /grub*-script-check.1 /grub*-set-default diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 1a4a57898f9..7fe3598435c 100644 +index 1a4a57898f9..113a41f9409 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in -@@ -214,6 +214,12 @@ version_sort () +@@ -33,6 +33,9 @@ fi + if test "x$grub_mkrelpath" = x; then + grub_mkrelpath="${bindir}/@grub_mkrelpath@" + fi ++if test "x$grub_rpm_sort" = x; then ++ grub_rpm_sort="${sbindir}/@grub_rpm_sort@" ++fi + + if which gettext >/dev/null 2>/dev/null; then + : +@@ -214,6 +217,12 @@ version_sort () esac } -+if [ "x$RPMLIB" = x ]; then -+ kernel_sort=version_sort ++if [ "x$grub_rpm_sort" != x -a -x "$grub_rpm_sort" ]; then ++ kernel_sort="$grub_rpm_sort" +else -+ kernel_sort="${sbindir}/grub-rpm-sort" ++ kernel_sort=version_sort +fi + version_test_numeric () { version_test_numeric_a="$1" -@@ -230,7 +236,7 @@ version_test_numeric () +@@ -230,7 +239,7 @@ version_test_numeric () version_test_numeric_a="$version_test_numeric_b" version_test_numeric_b="$version_test_numeric_c" fi diff --git a/0061-Handle-rssd-storage-devices.patch b/0058-Handle-rssd-storage-devices.patch similarity index 100% rename from 0061-Handle-rssd-storage-devices.patch rename to 0058-Handle-rssd-storage-devices.patch diff --git a/0062-Make-grub2-mkconfig-construct-titles-that-look-like-.patch b/0059-Make-grub2-mkconfig-construct-titles-that-look-like-.patch similarity index 100% rename from 0062-Make-grub2-mkconfig-construct-titles-that-look-like-.patch rename to 0059-Make-grub2-mkconfig-construct-titles-that-look-like-.patch diff --git a/0063-Add-friendly-grub2-password-config-tool-985962.patch b/0060-Add-friendly-grub2-password-config-tool-985962.patch similarity index 66% rename from 0063-Add-friendly-grub2-password-config-tool-985962.patch rename to 0060-Add-friendly-grub2-password-config-tool-985962.patch index 49ebfa7..838d2f4 100644 --- a/0063-Add-friendly-grub2-password-config-tool-985962.patch +++ b/0060-Add-friendly-grub2-password-config-tool-985962.patch @@ -8,36 +8,42 @@ without having to alter the grub.cfg. The hashed password now lives in a root-only-readable configuration file. Resolves: rhbz#985962 + +Signed-off-by: Robert Marshall +[pjones: fix the efidir in grub-setpassword and rename tool] +Signed-off-by: Peter Jones +[luto: fix grub-setpassword -o's output path] +Andy Lutomirski --- - configure.ac | 1 + - Makefile.util.def | 13 +++++ - .gitignore | 2 + - util/grub-mkconfig.in | 2 + - util/grub-setpassword.8 | 28 +++++++++++ - util/grub-setpassword.in | 123 +++++++++++++++++++++++++++++++++++++++++++++++ - util/grub.d/01_users.in | 11 +++++ - 7 files changed, 180 insertions(+) - create mode 100644 util/grub-setpassword.8 - create mode 100644 util/grub-setpassword.in + configure.ac | 1 + + Makefile.util.def | 13 +++++ + .gitignore | 2 + + util/grub-mkconfig.in | 2 + + util/grub-set-password.8 | 28 ++++++++++ + util/grub-set-password.in | 128 ++++++++++++++++++++++++++++++++++++++++++++++ + util/grub.d/01_users.in | 11 ++++ + 7 files changed, 185 insertions(+) + create mode 100644 util/grub-set-password.8 + create mode 100644 util/grub-set-password.in create mode 100644 util/grub.d/01_users.in diff --git a/configure.ac b/configure.ac -index 056df1cbaf9..679f634ce4c 100644 +index 00f1db29b1a..1cb6a9615db 100644 --- a/configure.ac +++ b/configure.ac @@ -65,6 +65,7 @@ grub_TRANSFORM([grub-mkrelpath]) grub_TRANSFORM([grub-mkrescue]) grub_TRANSFORM([grub-probe]) grub_TRANSFORM([grub-reboot]) -+grub_TRANSFORM([grub-setpassword]) ++grub_TRANSFORM([grub-set-password]) grub_TRANSFORM([grub-rpm-sort]) grub_TRANSFORM([grub-script-check]) grub_TRANSFORM([grub-set-default]) diff --git a/Makefile.util.def b/Makefile.util.def -index 406d96861b6..fd91045bd6d 100644 +index bb21c87c8ed..7729e65c607 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -440,6 +440,12 @@ script = { +@@ -442,6 +442,12 @@ script = { installdir = grubconf; }; @@ -50,13 +56,13 @@ index 406d96861b6..fd91045bd6d 100644 script = { name = '10_windows'; common = util/grub.d/10_windows.in; -@@ -722,6 +728,13 @@ script = { +@@ -724,6 +730,13 @@ script = { installdir = sbin; }; +script = { -+ name = grub-setpassword; -+ common = util/grub-setpassword.in; ++ name = grub-set-password; ++ common = util/grub-set-password.in; + mansection = 8; + installdir = sbin; +}; @@ -65,15 +71,15 @@ index 406d96861b6..fd91045bd6d 100644 name = grub-mkconfig_lib; common = util/grub-mkconfig_lib.in; diff --git a/.gitignore b/.gitignore -index fa2e5b609b1..5066689bc0a 100644 +index fa2e5b609b1..141684867d1 100644 --- a/.gitignore +++ b/.gitignore @@ -111,6 +111,8 @@ grub-*.tar.* /grub*-script-check.1 /grub*-set-default /grub*-set-default.8 -+/grub*-setsetpassword -+/grub*-setsetpassword.8 ++/grub*-set-password ++/grub*-set-password.8 /grub*-shell /grub*-shell-tester /grub*-sparc64-setup @@ -90,21 +96,21 @@ index f68d4925ee6..bdb9982aefb 100644 *) if grub_file_is_not_garbage "$i" && test -x "$i" ; then echo -diff --git a/util/grub-setpassword.8 b/util/grub-setpassword.8 +diff --git a/util/grub-set-password.8 b/util/grub-set-password.8 new file mode 100644 -index 00000000000..49200a848b7 +index 00000000000..9646546e43d --- /dev/null -+++ b/util/grub-setpassword.8 ++++ b/util/grub-set-password.8 @@ -0,0 +1,28 @@ -+.TH GRUB-SETPASSWORD 3 "Thu Jun 25 2015" ++.TH GRUB-SET-PASSWORD 3 "Thu Jun 25 2015" +.SH NAME -+\fBgrub-setpassword\fR \(em Generate the user.cfg file containing the hashed grub bootloader password. ++\fBgrub-set-password\fR \(em Generate the user.cfg file containing the hashed grub bootloader password. + +.SH SYNOPSIS -+\fBgrub-setpassword\fR [OPTION] ++\fBgrub-set-password\fR [OPTION] + +.SH DESCRIPTION -+\fBgrub-setpassword\fR outputs the user.cfg file which contains the hashed GRUB bootloader password. This utility only supports configurations where there is a single root user. ++\fBgrub-set-password\fR outputs the user.cfg file which contains the hashed GRUB bootloader password. This utility only supports configurations where there is a single root user. + +The file has the format: +GRUB2_PASSWORD=<\fIhashed password\fR>. @@ -117,23 +123,24 @@ index 00000000000..49200a848b7 +-v, --version +Display the current version. +.TP -+-o, --output[=\fIDIRECTORY PATH\fR] ++-o, --output=<\fIDIRECTORY\fR> +Choose the file path to which user.cfg will be written. + +.SH SEE ALSO +.BR "info grub" + +.BR "info grub2-mkpasswd-pbkdf2" -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in +diff --git a/util/grub-set-password.in b/util/grub-set-password.in new file mode 100644 -index 00000000000..dd76f00fc0e +index 00000000000..5ebf50576d6 --- /dev/null -+++ b/util/grub-setpassword.in -@@ -0,0 +1,123 @@ ++++ b/util/grub-set-password.in +@@ -0,0 +1,128 @@ +#!/bin/sh -e + ++EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') +if [ -d /sys/firmware/efi/efivars/ ]; then -+ grubdir=`echo "/@bootdirname@/efi/EFI/redhat/" | sed 's,//*,/,g'` ++ grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'` +else + grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'` +fi @@ -148,15 +155,14 @@ index 00000000000..dd76f00fc0e +# Print the usage. +usage () { + cat < put user.cfg in a user-selected directory + +Report bugs at https://bugzilla.redhat.com. +EOF @@ -237,7 +243,7 @@ index 00000000000..dd76f00fc0e + P1="$1" && shift + + ( echo ${P0} ; echo ${P1} ) | \ -+ ${grub_mkpasswd} | \ ++ LC_ALL=C ${grub_mkpasswd} | \ + grep -v '[eE]nter password:' | \ + sed -e "s/PBKDF2 hash of your password is //" +} @@ -250,9 +256,14 @@ index 00000000000..dd76f00fc0e + +# on the ESP, these will fail to set the permissions, but it's okay because +# the directory is protected. -+install -m 0600 /dev/null "${grubdir}/user.cfg" 2>/dev/null || : -+chmod 0600 "${grubdir}/user.cfg" 2>/dev/null || : -+echo "GRUB2_PASSWORD=${MYPASS}" > "${grubdir}/user.cfg" ++install -m 0600 /dev/null "${OUTPUT_PATH}/user.cfg" 2>/dev/null || : ++chmod 0600 "${OUTPUT_PATH}/user.cfg" 2>/dev/null || : ++echo "GRUB2_PASSWORD=${MYPASS}" > "${OUTPUT_PATH}/user.cfg" ++ ++if ! grep -q "^### BEGIN /etc/grub.d/01_users ###$" "${OUTPUT_PATH}/grub.cfg"; then ++ echo "WARNING: The current configuration lacks password support!" ++ echo "Update your configuration with @grub_mkconfig@ to support this feature." ++fi diff --git a/util/grub.d/01_users.in b/util/grub.d/01_users.in new file mode 100644 index 00000000000..db2f44bfb78 diff --git a/0065-tcp-add-window-scaling-support.patch b/0061-tcp-add-window-scaling-support.patch similarity index 100% rename from 0065-tcp-add-window-scaling-support.patch rename to 0061-tcp-add-window-scaling-support.patch diff --git a/0067-Fix-security-issue-when-reading-username-and-passwor.patch b/0062-Fix-security-issue-when-reading-username-and-passwor.patch similarity index 100% rename from 0067-Fix-security-issue-when-reading-username-and-passwor.patch rename to 0062-Fix-security-issue-when-reading-username-and-passwor.patch diff --git a/0074-Add-a-url-parser.patch b/0063-Add-a-url-parser.patch similarity index 99% rename from 0074-Add-a-url-parser.patch rename to 0063-Add-a-url-parser.patch index 2697fd2..34edd4e 100644 --- a/0074-Add-a-url-parser.patch +++ b/0063-Add-a-url-parser.patch @@ -20,10 +20,10 @@ Signed-off-by: Peter Jones create mode 100644 include/grub/net/url.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index cd0902b46b8..991891a6e09 100644 +index 8bd220a41ba..d0c8a8b1908 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -2185,6 +2185,7 @@ module = { +@@ -2188,6 +2188,7 @@ module = { common = net/ethernet.c; common = net/arp.c; common = net/netbuff.c; @@ -32,7 +32,7 @@ index cd0902b46b8..991891a6e09 100644 module = { diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 8344526be7f..f1fab700048 100644 +index 2656a670e09..1c560ea570a 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -296,6 +296,19 @@ grub_strrchr (const char *s, int c) diff --git a/0064-Try-to-make-sure-configure.ac-and-grub-rpm-sort-play.patch b/0064-Try-to-make-sure-configure.ac-and-grub-rpm-sort-play.patch deleted file mode 100644 index 09061ce..0000000 --- a/0064-Try-to-make-sure-configure.ac-and-grub-rpm-sort-play.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 3 Aug 2015 11:46:42 -0400 -Subject: [PATCH] Try to make sure configure.ac and grub-rpm-sort play nice. - -Apparently the test for whether to use grub-rpm-sort and also the -renaming of it to grub2-rpm-sort on the runtime side weren't right. - -Related: rhbz#1124074 - -Signed-off-by: Peter Jones ---- - configure.ac | 2 +- - util/grub-mkconfig_lib.in | 9 ++++++--- - 2 files changed, 7 insertions(+), 4 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 679f634ce4c..71d1056969e 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1796,7 +1796,7 @@ AC_SUBST([LIBDEVMAPPER]) - AC_ARG_ENABLE([rpm-sort], - [AS_HELP_STRING([--enable-rpm-sort], - [enable native rpm sorting of kernels in grub (default=guessed)])]) --if test x"$enable_rpm-sort" = xno ; then -+if test x"$enable_rpm_sort" = xno ; then - rpm_sort_excuse="explicitly disabled" - fi - -diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 7fe3598435c..113a41f9409 100644 ---- a/util/grub-mkconfig_lib.in -+++ b/util/grub-mkconfig_lib.in -@@ -33,6 +33,9 @@ fi - if test "x$grub_mkrelpath" = x; then - grub_mkrelpath="${bindir}/@grub_mkrelpath@" - fi -+if test "x$grub_rpm_sort" = x; then -+ grub_rpm_sort="${sbindir}/@grub_rpm_sort@" -+fi - - if which gettext >/dev/null 2>/dev/null; then - : -@@ -214,10 +217,10 @@ version_sort () - esac - } - --if [ "x$RPMLIB" = x ]; then -+if [ "x$grub_rpm_sort" != x -a -x "$grub_rpm_sort" ]; then -+ kernel_sort="$grub_rpm_sort" -+else - kernel_sort=version_sort --else -- kernel_sort="${sbindir}/grub-rpm-sort" - fi - - version_test_numeric () diff --git a/0075-efinet-and-bootp-add-support-for-dhcpv6.patch b/0064-efinet-and-bootp-add-support-for-dhcpv6.patch similarity index 100% rename from 0075-efinet-and-bootp-add-support-for-dhcpv6.patch rename to 0064-efinet-and-bootp-add-support-for-dhcpv6.patch diff --git a/0076-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch b/0065-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch similarity index 91% rename from 0076-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch rename to 0065-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch index 7ea79d1..ab50e84 100644 --- a/0076-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch +++ b/0065-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch @@ -12,19 +12,19 @@ debug stanzas. Resolves: rhbz#1226325 --- configure.ac | 2 + - Makefile.util.def | 7 +++ + Makefile.util.def | 7 ++ .gitignore | 2 + - util/bash-completion.d/grub-completion.bash.in | 22 ++++++++ - util/grub-get-kernel-settings.3 | 20 +++++++ - util/grub-get-kernel-settings.in | 78 ++++++++++++++++++++++++++ + util/bash-completion.d/grub-completion.bash.in | 22 +++++++ + util/grub-get-kernel-settings.3 | 20 ++++++ + util/grub-get-kernel-settings.in | 88 ++++++++++++++++++++++++++ util/grub-mkconfig.in | 3 + - util/grub.d/10_linux.in | 23 ++++++-- - 8 files changed, 152 insertions(+), 5 deletions(-) + util/grub.d/10_linux.in | 23 +++++-- + 8 files changed, 162 insertions(+), 5 deletions(-) create mode 100644 util/grub-get-kernel-settings.3 create mode 100644 util/grub-get-kernel-settings.in diff --git a/configure.ac b/configure.ac -index 71d1056969e..aa06ed59c8d 100644 +index 1cb6a9615db..2a6fde5be81 100644 --- a/configure.ac +++ b/configure.ac @@ -58,6 +58,7 @@ grub_TRANSFORM([grub-install]) @@ -44,10 +44,10 @@ index 71d1056969e..aa06ed59c8d 100644 grub_TRANSFORM([grub-install.1]) grub_TRANSFORM([grub-kbdcomp.3]) diff --git a/Makefile.util.def b/Makefile.util.def -index fd91045bd6d..2d032643de7 100644 +index 7729e65c607..c39b3ce6aa9 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -714,6 +714,13 @@ script = { +@@ -716,6 +716,13 @@ script = { installdir = sbin; }; @@ -62,7 +62,7 @@ index fd91045bd6d..2d032643de7 100644 name = grub-set-default; common = util/grub-set-default.in; diff --git a/.gitignore b/.gitignore -index 5066689bc0a..54795fa60be 100644 +index 141684867d1..096eeff7de8 100644 --- a/.gitignore +++ b/.gitignore @@ -68,6 +68,8 @@ grub-*.tar.* @@ -135,10 +135,10 @@ index 00000000000..ba33330e28d +.BR "info grub" diff --git a/util/grub-get-kernel-settings.in b/util/grub-get-kernel-settings.in new file mode 100644 -index 00000000000..12046219878 +index 00000000000..7e87dfccc0e --- /dev/null +++ b/util/grub-get-kernel-settings.in -@@ -0,0 +1,78 @@ +@@ -0,0 +1,88 @@ +#!/bin/sh +set -e + @@ -217,6 +217,16 @@ index 00000000000..12046219878 + echo GRUB_LINUX_DEBUG_TITLE_POSTFIX=\" with debugging\" + echo export GRUB_LINUX_DEBUG_TITLE_POSTFIX +fi ++if [ "$DEFAULTDEBUG" = "yes" ]; then ++ echo GRUB_DEFAULT_TO_DEBUG=true ++else ++ echo GRUB_DEFAULT_TO_DEBUG=false ++fi ++echo export GRUB_DEFAULT_TO_DEBUG ++if [ "$UPDATEDEFAULT" = "yes" ]; then ++ echo GRUB_UPDATE_DEFAULT_KERNEL=true ++ echo export GRUB_UPDATE_DEFAULT_KERNEL ++fi diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index bdb9982aefb..8218f3d477f 100644 --- a/util/grub-mkconfig.in diff --git a/0077-Normalize-slashes-in-tftp-paths.patch b/0066-Normalize-slashes-in-tftp-paths.patch similarity index 70% rename from 0077-Normalize-slashes-in-tftp-paths.patch rename to 0066-Normalize-slashes-in-tftp-paths.patch index 5ea5afa..bed0a5c 100644 --- a/0077-Normalize-slashes-in-tftp-paths.patch +++ b/0066-Normalize-slashes-in-tftp-paths.patch @@ -6,13 +6,15 @@ Subject: [PATCH] Normalize slashes in tftp paths. Some tftp servers do not handle multiple consecutive slashes correctly; this patch avoids sending tftp requests with non-normalized paths. -Signed-off-by: Peter Jones +Signed-off-by: Lenny Szubowicz +[msalter: fix malformed tftp packets] +Signed-off-by: Mark Salter --- - grub-core/net/tftp.c | 24 +++++++++++++++++++++++- - 1 file changed, 23 insertions(+), 1 deletion(-) + grub-core/net/tftp.c | 28 +++++++++++++++++++++++++--- + 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index 1157524fc50..5ca0a96a6f6 100644 +index 1157524fc50..dcd82494309 100644 --- a/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c @@ -300,6 +300,25 @@ destroy_pq (tftp_data_t data) @@ -41,15 +43,19 @@ index 1157524fc50..5ca0a96a6f6 100644 static grub_err_t tftp_open (struct grub_file *file, const char *filename) { -@@ -337,7 +356,10 @@ tftp_open (struct grub_file *file, const char *filename) +@@ -337,9 +356,12 @@ tftp_open (struct grub_file *file, const char *filename) rrqlen = 0; tftph->opcode = grub_cpu_to_be16_compile_time (TFTP_RRQ); - grub_strcpy (rrq, filename); +- rrqlen += grub_strlen (filename) + 1; +- rrq += grub_strlen (filename) + 1; + + /* Copy and normalize the filename to work-around issues on some tftp + servers when file names are being matched for remapping. */ + grub_normalize_filename (rrq, filename); - rrqlen += grub_strlen (filename) + 1; - rrq += grub_strlen (filename) + 1; ++ rrqlen += grub_strlen (rrq) + 1; ++ rrq += grub_strlen (rrq) + 1; + grub_strcpy (rrq, "octet"); + rrqlen += grub_strlen ("octet") + 1; diff --git a/0066-efinet-add-filter-for-the-first-exclusive-reopen-of-.patch b/0066-efinet-add-filter-for-the-first-exclusive-reopen-of-.patch deleted file mode 100644 index 691d4dc..0000000 --- a/0066-efinet-add-filter-for-the-first-exclusive-reopen-of-.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: RHEL Ninjas -Date: Fri, 25 Sep 2015 16:24:23 +0900 -Subject: [PATCH] efinet: add filter for the first exclusive reopen of SNP - ---- - grub-core/net/drivers/efi/efinet.c | 39 ++++++++++++++++++++++++++++++++++++++ - 1 file changed, 39 insertions(+) - -diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 5388f952ba9..d15a799f29a 100644 ---- a/grub-core/net/drivers/efi/efinet.c -+++ b/grub-core/net/drivers/efi/efinet.c -@@ -383,6 +383,45 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - &pxe_mode->dhcp_ack, - sizeof (pxe_mode->dhcp_ack), - 1, device, path); -+ net = grub_efi_open_protocol (card->efi_handle, &net_io_guid, -+ GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE); -+ if (net) { -+ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED -+ && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) -+ continue; -+ -+ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED) -+ continue; -+ -+ if (net->mode->state == GRUB_EFI_NETWORK_STARTED -+ && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS) -+ continue; -+ -+ /* Enable hardware receive filters if driver declares support for it. -+ We need unicast and broadcast and additionaly all nodes and -+ solicited multicast for IPv6. Solicited multicast is per-IPv6 -+ address and we currently do not have API to do it so simply -+ try to enable receive of all multicast packets or evertyhing in -+ the worst case (i386 PXE driver always enables promiscuous too). -+ -+ This does trust firmware to do what it claims to do. -+ */ -+ if (net->mode->receive_filter_mask) -+ { -+ grub_uint32_t filters = GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST | -+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST | -+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST; -+ -+ filters &= net->mode->receive_filter_mask; -+ if (!(filters & GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST)) -+ filters |= (net->mode->receive_filter_mask & -+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS); -+ -+ efi_call_6 (net->receive_filters, net, filters, 0, 0, 0, NULL); -+ } -+ -+ card->efi_net = net; -+ } - return; - } - } diff --git a/0079-bz1374141-fix-incorrect-mask-for-ppc64.patch b/0067-bz1374141-fix-incorrect-mask-for-ppc64.patch similarity index 100% rename from 0079-bz1374141-fix-incorrect-mask-for-ppc64.patch rename to 0067-bz1374141-fix-incorrect-mask-for-ppc64.patch diff --git a/0080-Make-grub_fatal-also-backtrace.patch b/0068-Make-grub_fatal-also-backtrace.patch similarity index 98% rename from 0080-Make-grub_fatal-also-backtrace.patch rename to 0068-Make-grub_fatal-also-backtrace.patch index a9af329..ee0b5c1 100644 --- a/0080-Make-grub_fatal-also-backtrace.patch +++ b/0068-Make-grub_fatal-also-backtrace.patch @@ -13,7 +13,7 @@ Subject: [PATCH] Make grub_fatal() also backtrace. create mode 100644 grub-core/lib/arm64/backtrace.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 991891a6e09..27563743ba9 100644 +index d0c8a8b1908..8bb5eb0f47f 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -175,6 +175,9 @@ kernel = { @@ -27,7 +27,7 @@ index 991891a6e09..27563743ba9 100644 i386_xen = kern/i386/dl.c; diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index f1fab700048..5ce89a40c68 100644 +index 1c560ea570a..04371ac49f2 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -24,6 +24,7 @@ diff --git a/0068-Warn-if-grub-password-will-not-be-read-1290803.patch b/0068-Warn-if-grub-password-will-not-be-read-1290803.patch deleted file mode 100644 index de4a6ae..0000000 --- a/0068-Warn-if-grub-password-will-not-be-read-1290803.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robert Marshall -Date: Mon, 22 Feb 2016 15:30:05 -0500 -Subject: [PATCH] Warn if grub password will not be read (#1290803) - -It is possible for a system to have never run grub-mkconfig and add the -section that reads the user.cfg file which contains a user set GRUB -password. Users in that scenario will now be warned that grub-mkconfig -must be run prior to their newly set password taking effect. - -Resolves: rhbz#1290803 ---- - util/grub-setpassword.in | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in -index dd76f00fc0e..fb9d3a3b6f9 100644 ---- a/util/grub-setpassword.in -+++ b/util/grub-setpassword.in -@@ -121,3 +121,8 @@ fi - install -m 0600 /dev/null "${grubdir}/user.cfg" 2>/dev/null || : - chmod 0600 "${grubdir}/user.cfg" 2>/dev/null || : - echo "GRUB2_PASSWORD=${MYPASS}" > "${grubdir}/user.cfg" -+ -+if ! grep -q "^### BEGIN /etc/grub.d/01_users ###$" "${grubdir}/grub.cfg"; then -+ echo "WARNING: The current configuration lacks password support!" -+ echo "Update your configuration with @grub_mkconfig@ to support this feature." -+fi diff --git a/0069-Clean-up-grub-setpassword-documentation-1290799.patch b/0069-Clean-up-grub-setpassword-documentation-1290799.patch deleted file mode 100644 index a405e88..0000000 --- a/0069-Clean-up-grub-setpassword-documentation-1290799.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robert Marshall -Date: Tue, 26 Jan 2016 10:28:35 -0500 -Subject: [PATCH] Clean up grub-setpassword documentation (#1290799) - -The output for --help had some errors. Corrected those and polished the -text to be a little easier to follow. Carried verbage over to man page -to maintain internal consistency. - -Resolves: rhbz#1290799 ---- - util/grub-setpassword.8 | 2 +- - util/grub-setpassword.in | 15 +++++++-------- - 2 files changed, 8 insertions(+), 9 deletions(-) - -diff --git a/util/grub-setpassword.8 b/util/grub-setpassword.8 -index 49200a848b7..dc91dd6697b 100644 ---- a/util/grub-setpassword.8 -+++ b/util/grub-setpassword.8 -@@ -19,7 +19,7 @@ Display program usage and exit. - -v, --version - Display the current version. - .TP ---o, --output[=\fIDIRECTORY PATH\fR] -+-o, --output=<\fIDIRECTORY\fR> - Choose the file path to which user.cfg will be written. - - .SH SEE ALSO -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in -index fb9d3a3b6f9..c8c0fa4199d 100644 ---- a/util/grub-setpassword.in -+++ b/util/grub-setpassword.in -@@ -16,15 +16,14 @@ grub_mkpasswd="${bindir}/@grub_mkpasswd_pbkdf2@" - # Print the usage. - usage () { - cat < put user.cfg in a user-selected directory - - Report bugs at https://bugzilla.redhat.com. - EOF diff --git a/0082-Fix-up-some-man-pages-rpmdiff-noticed.patch b/0069-Fix-up-some-man-pages-rpmdiff-noticed.patch similarity index 99% rename from 0082-Fix-up-some-man-pages-rpmdiff-noticed.patch rename to 0069-Fix-up-some-man-pages-rpmdiff-noticed.patch index 71b0a22..1b2caa6 100644 --- a/0082-Fix-up-some-man-pages-rpmdiff-noticed.patch +++ b/0069-Fix-up-some-man-pages-rpmdiff-noticed.patch @@ -13,7 +13,7 @@ Subject: [PATCH] Fix up some man pages rpmdiff noticed. create mode 100644 util/grub-syslinux2cfg.1 diff --git a/configure.ac b/configure.ac -index aa06ed59c8d..f69f8986791 100644 +index 2a6fde5be81..9318c281108 100644 --- a/configure.ac +++ b/configure.ac @@ -80,6 +80,7 @@ grub_TRANSFORM([grub-get-kernel-settings.3]) diff --git a/0070-Fix-locale-issue-in-grub-setpassword-1294243.patch b/0070-Fix-locale-issue-in-grub-setpassword-1294243.patch deleted file mode 100644 index 9b315cc..0000000 --- a/0070-Fix-locale-issue-in-grub-setpassword-1294243.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robert Marshall -Date: Fri, 29 Jan 2016 16:56:11 -0500 -Subject: [PATCH] Fix locale issue in grub-setpassword (#1294243) - -A shell substitution was expecting non-translated output to grab the -hashed password and put it in the user.cfg file. Modified code to force -the generic C locale when this particular piece of code is run. - -Resolves: rhbz#1294243 ---- - util/grub-setpassword.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in -index c8c0fa4199d..d7924af5192 100644 ---- a/util/grub-setpassword.in -+++ b/util/grub-setpassword.in -@@ -104,7 +104,7 @@ getpass() { - P1="$1" && shift - - ( echo ${P0} ; echo ${P1} ) | \ -- ${grub_mkpasswd} | \ -+ LC_ALL=C ${grub_mkpasswd} | \ - grep -v '[eE]nter password:' | \ - sed -e "s/PBKDF2 hash of your password is //" - } diff --git a/0084-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch b/0070-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch similarity index 100% rename from 0084-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch rename to 0070-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch diff --git a/0085-Make-our-info-pages-say-grub2-where-appropriate.patch b/0071-Make-our-info-pages-say-grub2-where-appropriate.patch similarity index 100% rename from 0085-Make-our-info-pages-say-grub2-where-appropriate.patch rename to 0071-Make-our-info-pages-say-grub2-where-appropriate.patch diff --git a/0071-efiemu-Handle-persistent-RAM-and-unknown-possible-fu.patch b/0071-efiemu-Handle-persistent-RAM-and-unknown-possible-fu.patch deleted file mode 100644 index 0891f8f..0000000 --- a/0071-efiemu-Handle-persistent-RAM-and-unknown-possible-fu.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robert Elliott -Date: Fri, 22 Jan 2016 13:32:30 +0100 -Subject: [PATCH] efiemu: Handle persistent RAM and unknown possible future - additions. - -(cherry picked from commit ae3b83a4d4df75a01198a2fed7542391e7c449e0) - -Resolves: rhbz#1288608 ---- - grub-core/efiemu/mm.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c -index 52a032f7b2e..92e7df7e501 100644 ---- a/grub-core/efiemu/mm.c -+++ b/grub-core/efiemu/mm.c -@@ -410,8 +410,8 @@ fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, - return grub_efiemu_add_to_mmap (addr, size, - GRUB_EFI_ACPI_MEMORY_NVS); - -- case GRUB_MEMORY_PERSISTENT: -- case GRUB_MEMORY_PERSISTENT_LEGACY: -+ case GRUB_MEMORY_PRAM: -+ case GRUB_MEMORY_PMEM: - return grub_efiemu_add_to_mmap (addr, size, - GRUB_EFI_PERSISTENT_MEMORY); - default: diff --git a/0072-efiemu-Fix-compilation-failure.patch b/0072-efiemu-Fix-compilation-failure.patch deleted file mode 100644 index 0c1c10f..0000000 --- a/0072-efiemu-Fix-compilation-failure.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Vladimir Serbinenko -Date: Fri, 22 Jan 2016 14:10:30 +0100 -Subject: [PATCH] efiemu: Fix compilation failure - -(cherry picked from commit b6a03dfd327489d53ee07c6d7d593b99c7b7cb62) - -Resolves: rhbz#1288608 ---- - grub-core/efiemu/mm.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c -index 92e7df7e501..52a032f7b2e 100644 ---- a/grub-core/efiemu/mm.c -+++ b/grub-core/efiemu/mm.c -@@ -410,8 +410,8 @@ fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, - return grub_efiemu_add_to_mmap (addr, size, - GRUB_EFI_ACPI_MEMORY_NVS); - -- case GRUB_MEMORY_PRAM: -- case GRUB_MEMORY_PMEM: -+ case GRUB_MEMORY_PERSISTENT: -+ case GRUB_MEMORY_PERSISTENT_LEGACY: - return grub_efiemu_add_to_mmap (addr, size, - GRUB_EFI_PERSISTENT_MEMORY); - default: diff --git a/0086-print-more-debug-info-in-our-module-loader.patch b/0072-print-more-debug-info-in-our-module-loader.patch similarity index 100% rename from 0086-print-more-debug-info-in-our-module-loader.patch rename to 0072-print-more-debug-info-in-our-module-loader.patch diff --git a/0073-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch b/0073-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch deleted file mode 100644 index 9482299..0000000 --- a/0073-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 7 Apr 2016 10:58:06 -0400 -Subject: [PATCH] Revert "reopen SNP protocol for exclusive use by grub" - -I *think* this should have been replaced by upstream's -49426e9fd2e562c73a4f1206f32eff9e424a1a73, so I'm reverting for now. - -May resolve rhbz#1273974. - -This reverts commit 147daeab22db793978f952b6f0d832919a1b0081. ---- - grub-core/net/drivers/efi/efinet.c | 39 -------------------------------------- - 1 file changed, 39 deletions(-) - -diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index d15a799f29a..5388f952ba9 100644 ---- a/grub-core/net/drivers/efi/efinet.c -+++ b/grub-core/net/drivers/efi/efinet.c -@@ -383,45 +383,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - &pxe_mode->dhcp_ack, - sizeof (pxe_mode->dhcp_ack), - 1, device, path); -- net = grub_efi_open_protocol (card->efi_handle, &net_io_guid, -- GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE); -- if (net) { -- if (net->mode->state == GRUB_EFI_NETWORK_STOPPED -- && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) -- continue; -- -- if (net->mode->state == GRUB_EFI_NETWORK_STOPPED) -- continue; -- -- if (net->mode->state == GRUB_EFI_NETWORK_STARTED -- && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS) -- continue; -- -- /* Enable hardware receive filters if driver declares support for it. -- We need unicast and broadcast and additionaly all nodes and -- solicited multicast for IPv6. Solicited multicast is per-IPv6 -- address and we currently do not have API to do it so simply -- try to enable receive of all multicast packets or evertyhing in -- the worst case (i386 PXE driver always enables promiscuous too). -- -- This does trust firmware to do what it claims to do. -- */ -- if (net->mode->receive_filter_mask) -- { -- grub_uint32_t filters = GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST | -- GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST | -- GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST; -- -- filters &= net->mode->receive_filter_mask; -- if (!(filters & GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST)) -- filters |= (net->mode->receive_filter_mask & -- GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS); -- -- efi_call_6 (net->receive_filters, net, filters, 0, 0, 0, NULL); -- } -- -- card->efi_net = net; -- } - return; - } - } diff --git a/0087-macos-just-build-chainloader-entries-don-t-try-any-x.patch b/0073-macos-just-build-chainloader-entries-don-t-try-any-x.patch similarity index 100% rename from 0087-macos-just-build-chainloader-entries-don-t-try-any-x.patch rename to 0073-macos-just-build-chainloader-entries-don-t-try-any-x.patch diff --git a/0088-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch b/0074-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch similarity index 100% rename from 0088-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch rename to 0074-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch diff --git a/0089-export-btrfs_subvol-and-btrfs_subvolid.patch b/0075-export-btrfs_subvol-and-btrfs_subvolid.patch similarity index 100% rename from 0089-export-btrfs_subvol-and-btrfs_subvolid.patch rename to 0075-export-btrfs_subvol-and-btrfs_subvolid.patch diff --git a/0090-grub2-btrfs-03-follow_default.patch b/0076-grub2-btrfs-03-follow_default.patch similarity index 100% rename from 0090-grub2-btrfs-03-follow_default.patch rename to 0076-grub2-btrfs-03-follow_default.patch diff --git a/0091-grub2-btrfs-04-grub2-install.patch b/0077-grub2-btrfs-04-grub2-install.patch similarity index 100% rename from 0091-grub2-btrfs-04-grub2-install.patch rename to 0077-grub2-btrfs-04-grub2-install.patch diff --git a/0078-Fix-malformed-tftp-packets.patch b/0078-Fix-malformed-tftp-packets.patch deleted file mode 100644 index 2445137..0000000 --- a/0078-Fix-malformed-tftp-packets.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Mark Salter -Date: Tue, 7 Mar 2017 18:26:17 -0500 -Subject: [PATCH] Fix malformed tftp packets - -0088-Normalize-slashes-in-tftp-paths.patch collapses multiple contiguous -slashes in a filename into one slash in the tftp packet filename field. -However, the packet buffer pointer is advanced using the original name. -This leaves unitialized data between the name field and the type field -leading to tftp errors. Use the length of the normalized name to avoid -this. - -Signed-off-by: Mark Salter ---- - grub-core/net/tftp.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index 5ca0a96a6f6..dcd82494309 100644 ---- a/grub-core/net/tftp.c -+++ b/grub-core/net/tftp.c -@@ -360,8 +360,8 @@ tftp_open (struct grub_file *file, const char *filename) - /* Copy and normalize the filename to work-around issues on some tftp - servers when file names are being matched for remapping. */ - grub_normalize_filename (rrq, filename); -- rrqlen += grub_strlen (filename) + 1; -- rrq += grub_strlen (filename) + 1; -+ rrqlen += grub_strlen (rrq) + 1; -+ rrq += grub_strlen (rrq) + 1; - - grub_strcpy (rrq, "octet"); - rrqlen += grub_strlen ("octet") + 1; diff --git a/0092-grub2-btrfs-05-grub2-mkconfig.patch b/0078-grub2-btrfs-05-grub2-mkconfig.patch similarity index 85% rename from 0092-grub2-btrfs-05-grub2-mkconfig.patch rename to 0078-grub2-btrfs-05-grub2-mkconfig.patch index d7bfb4d..4829526 100644 --- a/0092-grub2-btrfs-05-grub2-mkconfig.patch +++ b/0078-grub2-btrfs-05-grub2-mkconfig.patch @@ -3,13 +3,16 @@ From: Michael Chang Date: Thu, 21 Aug 2014 03:39:11 +0000 Subject: [PATCH] grub2-btrfs-05-grub2-mkconfig +Signed-off-by: Michael Chang +[dusty: No more "Bootable Snapshot" submenu in grub.cfg.] +Signed-off-by: Dusty Mabe --- util/grub-mkconfig.in | 3 ++- util/grub-mkconfig_lib.in | 4 ++++ - util/grub.d/00_header.in | 24 +++++++++++++++++++++++- + util/grub.d/00_header.in | 12 +++++++++++- util/grub.d/10_linux.in | 4 ++++ util/grub.d/20_linux_xen.in | 4 ++++ - 5 files changed, 37 insertions(+), 2 deletions(-) + 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 8218f3d477f..4248b9341ab 100644 @@ -42,7 +45,7 @@ index 113a41f9409..b3aae534ddc 100644 is_path_readable_by_grub () diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in -index 858b526c925..e2a53300126 100644 +index 858b526c925..8a16fea347e 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -27,6 +27,14 @@ export TEXTDOMAINDIR="@localedir@" @@ -71,22 +74,6 @@ index 858b526c925..e2a53300126 100644 load_env fi EOF -@@ -356,3 +366,15 @@ fi - if [ "x${GRUB_BADRAM}" != "x" ] ; then - echo "badram ${GRUB_BADRAM}" - fi -+ -+if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] && -+ [ "x${GRUB_FS}" = "xbtrfs" ] ; then -+ # Note: No $snapshot_num on *read-only* rollback! (bsc#901487) -+ cat < -Date: Fri, 4 Mar 2016 16:29:13 -0500 -Subject: [PATCH] Make grub-editenv build again. - -36212460d3565b18439a3a8130b28e6c97702c6a split how some of the mkimage -utility functions are defined, and they wind up being linked into -grub-editenv. Most utilities got fixed, but this one was missed. - -Signed-off-by: Peter Jones ---- - Makefile.util.def | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/Makefile.util.def b/Makefile.util.def -index 2d032643de7..879e8eb98a4 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -237,6 +237,8 @@ program = { - extra_dist = grub-core/osdep/unix/compress.c; - extra_dist = grub-core/osdep/basic/compress.c; - common = util/mkimage.c; -+ common = util/grub-mkimage32.c; -+ common = util/grub-mkimage64.c; - common = grub-core/osdep/config.c; - common = util/config.c; - common = util/resolve.c; diff --git a/0097-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch b/0082-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch similarity index 100% rename from 0097-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch rename to 0082-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch diff --git a/0083-Make-exit-take-a-return-code.patch b/0083-Make-exit-take-a-return-code.patch deleted file mode 100644 index b886e12..0000000 --- a/0083-Make-exit-take-a-return-code.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 26 Feb 2014 21:49:12 -0500 -Subject: [PATCH] Make "exit" take a return code. - -This adds "exit" with a return code. With this patch, any "exit" -command /may/ include a return code, and on platforms that support -returning with an exit status, we will do so. By default we return the -same exit status we did before this patch. - -Signed-off-by: Peter Jones ---- - grub-core/kern/emu/main.c | 6 ++++++ - grub-core/kern/misc.c | 9 +++++++++ - 2 files changed, 15 insertions(+) - -diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c -index 55ea5a11ccd..7e47ec81263 100644 ---- a/grub-core/kern/emu/main.c -+++ b/grub-core/kern/emu/main.c -@@ -72,6 +72,12 @@ grub_exit (int retval __attribute__((unused))) - grub_reboot (); - } - -+void -+grub_exit (int retval __attribute__((unused))) -+{ -+ grub_reboot (); -+} -+ - void - grub_machine_init (void) - { -diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 5ce89a40c68..04371ac49f2 100644 ---- a/grub-core/kern/misc.c -+++ b/grub-core/kern/misc.c -@@ -1120,6 +1120,15 @@ grub_abort (void) - grub_exit (1); - } - -+#if defined (__clang__) && !defined (GRUB_UTIL) -+/* clang emits references to abort(). */ -+void __attribute__ ((noreturn)) -+abort (void) -+{ -+ grub_abort (); -+} -+#endif -+ - void - grub_fatal (const char *fmt, ...) - { diff --git a/0098-Use-grub_efi_.-memory-helpers-where-reasonable.patch b/0083-Use-grub_efi_.-memory-helpers-where-reasonable.patch similarity index 100% rename from 0098-Use-grub_efi_.-memory-helpers-where-reasonable.patch rename to 0083-Use-grub_efi_.-memory-helpers-where-reasonable.patch diff --git a/0099-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch b/0084-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch similarity index 100% rename from 0099-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch rename to 0084-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch diff --git a/0100-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch b/0085-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch similarity index 100% rename from 0100-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch rename to 0085-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch diff --git a/0101-don-t-ignore-const.patch b/0086-don-t-ignore-const.patch similarity index 100% rename from 0101-don-t-ignore-const.patch rename to 0086-don-t-ignore-const.patch diff --git a/0102-don-t-use-int-for-efi-status.patch b/0087-don-t-use-int-for-efi-status.patch similarity index 100% rename from 0102-don-t-use-int-for-efi-status.patch rename to 0087-don-t-use-int-for-efi-status.patch diff --git a/0103-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch b/0088-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch similarity index 100% rename from 0103-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch rename to 0088-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch diff --git a/0104-editenv-handle-relative-symlinks.patch b/0089-editenv-handle-relative-symlinks.patch similarity index 100% rename from 0104-editenv-handle-relative-symlinks.patch rename to 0089-editenv-handle-relative-symlinks.patch diff --git a/0105-Make-libgrub.pp-depend-on-config-util.h.patch b/0090-Make-libgrub.pp-depend-on-config-util.h.patch similarity index 100% rename from 0105-Make-libgrub.pp-depend-on-config-util.h.patch rename to 0090-Make-libgrub.pp-depend-on-config-util.h.patch diff --git a/0106-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch b/0091-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch similarity index 100% rename from 0106-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch rename to 0091-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch diff --git a/0107-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch b/0092-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch similarity index 100% rename from 0107-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch rename to 0092-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch diff --git a/0108-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch b/0093-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch similarity index 100% rename from 0108-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch rename to 0093-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch diff --git a/0094-No-more-Bootable-Snapshot-submenu-in-grub.cfg.patch b/0094-No-more-Bootable-Snapshot-submenu-in-grub.cfg.patch deleted file mode 100644 index b51b025..0000000 --- a/0094-No-more-Bootable-Snapshot-submenu-in-grub.cfg.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dusty Mabe -Date: Sat, 18 Jul 2015 15:38:08 +0000 -Subject: [PATCH] No more "Bootable Snapshot" submenu in grub.cfg. - -This breaks grubby (run on kernel upgrades) because grubby just -does a search for "menuentry". ---- - util/grub.d/00_header.in | 12 ------------ - 1 file changed, 12 deletions(-) - -diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in -index e2a53300126..8a16fea347e 100644 ---- a/util/grub.d/00_header.in -+++ b/util/grub.d/00_header.in -@@ -366,15 +366,3 @@ fi - if [ "x${GRUB_BADRAM}" != "x" ] ; then - echo "badram ${GRUB_BADRAM}" - fi -- --if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] && -- [ "x${GRUB_FS}" = "xbtrfs" ] ; then -- # Note: No $snapshot_num on *read-only* rollback! (bsc#901487) -- cat < -Date: Wed, 3 Oct 2018 20:48:32 +0200 -Subject: [PATCH] add 10_linux_bls grub.d snippet to generate menu entries from - BLS files +From: Peter Jones +Date: Fri, 9 Dec 2016 15:40:29 -0500 +Subject: [PATCH] Add BLS support to grub-mkconfig -This grub.d snippet can be used on platforms where the bootloader doesn't +GRUB now has BootLoaderSpec support, the user can choose to use this by +setting GRUB_ENABLE_BLSCFG to true in /etc/default/grub. On this setup, +the boot menu entries are not added to the grub.cfg, instead BLS config +files are parsed by blscfg command and the entries created dynamically. + +A 10_linux_bls grub.d snippet to generate menu entries from BLS files +is also added that can be used on platforms where the bootloader doesn't have BLS support and only can parse a normal grub configuration file. -Portions of this script were taken from the ostree-grub-generator script -included in the OSTree project. +Portions of the 10_linux_bls were taken from the ostree-grub-generator +script that's included in the OSTree project. -Resolves: rhbz#1636013 +Fixes to support multi-devices and generate a BLS section even if no +kernels are found in the boot directory were proposed by Yclept Nemo +and Tom Gundersen respectively. +Signed-off-by: Peter Jones Signed-off-by: Javier Martinez Canillas --- Makefile.util.def | 7 + - util/grub.d/10_linux_bls.in | 440 ++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 447 insertions(+) + util/grub-mkconfig.8 | 4 + + util/grub-mkconfig.in | 9 +- + util/grub-mkconfig_lib.in | 20 +- + util/grub.d/10_linux.in | 67 ++++++- + util/grub.d/10_linux_bls.in | 478 ++++++++++++++++++++++++++++++++++++++++++++ + 6 files changed, 580 insertions(+), 5 deletions(-) create mode 100644 util/grub.d/10_linux_bls.in diff --git a/Makefile.util.def b/Makefile.util.def -index c8cb91308d9..eca3dfa753f 100644 +index c39b3ce6aa9..c16c2ca545a 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -508,6 +508,13 @@ script = { +@@ -490,6 +490,13 @@ script = { condition = COND_HOST_LINUX; }; @@ -37,12 +49,218 @@ index c8cb91308d9..eca3dfa753f 100644 script = { name = '10_xnu'; common = util/grub.d/10_xnu.in; +diff --git a/util/grub-mkconfig.8 b/util/grub-mkconfig.8 +index a2d1f577b9b..434fa4deda4 100644 +--- a/util/grub-mkconfig.8 ++++ b/util/grub-mkconfig.8 +@@ -13,5 +13,9 @@ + \fB--output\fR=\fIFILE\fR + Write generated output to \fIFILE\fR. + ++.TP ++\fB--no-grubenv-update\fR ++Do not update variables in the grubenv file. ++ + .SH SEE ALSO + .BR "info grub" +diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in +index 4248b9341ab..5e643e16973 100644 +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -50,6 +50,8 @@ grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@" + export TEXTDOMAIN=@PACKAGE@ + export TEXTDOMAINDIR="@localedir@" + ++export GRUB_GRUBENV_UPDATE="yes" ++ + . "${pkgdatadir}/grub-mkconfig_lib" + + # Usage: usage +@@ -59,6 +61,7 @@ usage () { + gettext "Generate a grub config file"; echo + echo + print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")" ++ print_option_help "--no-grubenv-update" "$(gettext "do not update variables in the grubenv file")" + print_option_help "-h, --help" "$(gettext "print this message and exit")" + print_option_help "-v, --version" "$(gettext "print the version information and exit")" + echo +@@ -94,6 +97,9 @@ do + --output=*) + grub_cfg=`echo "$option" | sed 's/--output=//'` + ;; ++ --no-grubenv-update) ++ GRUB_GRUBENV_UPDATE="no" ++ ;; + -*) + gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2 + usage +@@ -259,7 +265,8 @@ export GRUB_DEFAULT \ + GRUB_OS_PROBER_SKIP_LIST \ + GRUB_DISABLE_SUBMENU \ + GRUB_DEFAULT_DTB \ +- SUSE_BTRFS_SNAPSHOT_BOOTING ++ SUSE_BTRFS_SNAPSHOT_BOOTING \ ++ GRUB_ENABLE_BLSCFG + + if test "x${grub_cfg}" != "x"; then + rm -f "${grub_cfg}.new" +diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in +index b3aae534ddc..bc11df2bd84 100644 +--- a/util/grub-mkconfig_lib.in ++++ b/util/grub-mkconfig_lib.in +@@ -30,6 +30,9 @@ fi + if test "x$grub_file" = x; then + grub_file="${bindir}/@grub_file@" + fi ++if test "x$grub_editenv" = x; then ++ grub_editenv="${bindir}/@grub_editenv@" ++fi + if test "x$grub_mkrelpath" = x; then + grub_mkrelpath="${bindir}/@grub_mkrelpath@" + fi +@@ -125,8 +128,19 @@ EOF + fi + } + ++prepare_grub_to_access_device_with_variable () ++{ ++ device_variable="$1" ++ shift ++ prepare_grub_to_access_device "$@" ++ unset "device_variable" ++} ++ + prepare_grub_to_access_device () + { ++ if [ -z "$device_variable" ]; then ++ device_variable="root" ++ fi + old_ifs="$IFS" + IFS=' + ' +@@ -161,14 +175,14 @@ prepare_grub_to_access_device () + # otherwise set root as per value in device.map. + fs_hint="`"${grub_probe}" --device $@ --target=compatibility_hint`" + if [ "x$fs_hint" != x ]; then +- echo "set root='$fs_hint'" ++ echo "set ${device_variable}='$fs_hint'" + fi + if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then + hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints= + echo "if [ x\$feature_platform_search_hint = xy ]; then" +- echo " search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}" ++ echo " search --no-floppy --fs-uuid --set=${device_variable} ${hints} ${fs_uuid}" + echo "else" +- echo " search --no-floppy --fs-uuid --set=root ${fs_uuid}" ++ echo " search --no-floppy --fs-uuid --set=${device_variable} ${fs_uuid}" + echo "fi" + fi + IFS="$old_ifs" +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index d9a05937e46..3919b8aff4e 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -82,6 +82,67 @@ case x"$GRUB_FS" in + ;; + esac + ++populate_header_warn() ++{ ++cat <$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then +@@ -224,6 +286,7 @@ is_top_level=true + while [ "x$list" != "x" ] ; do + linux=`version_find_latest $list` + gettext_printf "Found linux image: %s\n" "$linux" >&2 ++ + basename=`basename $linux` + dirname=`dirname $linux` + rel_dirname=`make_system_path_relative_to_its_root $dirname` +@@ -262,7 +325,9 @@ while [ "x$list" != "x" ] ; do + for i in ${initrd}; do + initrd_display="${initrd_display} ${dirname}/${i}" + done +- gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 ++ if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then ++ gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 ++ fi + fi + + fdt= diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in new file mode 100644 -index 00000000000..3cc7803c6a1 +index 00000000000..1b7536435f1 --- /dev/null +++ b/util/grub.d/10_linux_bls.in -@@ -0,0 +1,440 @@ +@@ -0,0 +1,478 @@ +#! /bin/sh +set -e + @@ -172,6 +390,9 @@ index 00000000000..3cc7803c6a1 + initrd="" + options="" + linux="" ++ grub_users="" ++ grub_arg="" ++ grub_class="" + + while read -r line + do @@ -190,17 +411,39 @@ index 00000000000..3cc7803c6a1 + "options") + options=${value} + ;; ++ "grub_users") ++ grub_users=${value} ++ ;; ++ "grub_arg") ++ grub_arg=${value} ++ ;; ++ "grub_class") ++ grub_class=${value} ++ ;; + esac + done < ${config_file} +} + +populate_menu() +{ -+ entries_path="/boot/loader/entries" ++ blsdir="/boot/loader/entries" ++ local -a files ++ local IFS=$'\n' + gettext_printf "Generating boot entries from BLS files...\n" >&2 -+ for config in $(ls -v -r $entries_path/*.conf); do -+ read_config ${config} -+ menu="${menu}menuentry '${title}' {\n" ++ ++ files=($(for bls in ${blsdir}/*.conf ; do ++ if ! [[ -e "${bls}" ]] ; then ++ continue ++ fi ++ bls="${bls%.conf}" ++ bls="${bls##*/}" ++ echo "${bls}" ++ done | ${kernel_sort} | tac)) || : ++ ++ for bls in "${files[@]}" ; do ++ read_config "${blsdir}/${bls}.conf" ++ ++ menu="${menu}menuentry '${title}' --class ${grub_class} ${grub_arg} --id=${bls} {\n" + menu="${menu}\t linux ${linux} ${options}\n" + if [ -n "${initrd}" ] ; then + menu="${menu}\t initrd ${boot_prefix}${initrd}\n" @@ -236,17 +479,30 @@ index 00000000000..3cc7803c6a1 + + if [ -d /sys/firmware/efi ]; then + bootefi_device="`${grub_probe} --target=device /boot/efi/`" -+ prepare_grub_to_access_device ${bootefi_device} boot ++ prepare_grub_to_access_device_with_variable boot ${bootefi_device} + else + boot_device="`${grub_probe} --target=device /boot/`" -+ prepare_grub_to_access_device ${boot_device} boot ++ prepare_grub_to_access_device_with_variable boot ${boot_device} + fi + + populate_header_warn + populate_menu + -+ ${grub_editenv} - set saved_entry=0 -+ ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" ++ if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then ++ blsdir="/boot/loader/entries" ++ [ -d "${blsdir}" ] && GRUB_BLS_FS="$(${grub_probe} --target=fs ${blsdir})" ++ if [ "x${GRUB_BLS_FS}" = "xbtrfs" ] || [ "x${GRUB_BLS_FS}" = "xzfs" ]; then ++ blsdir=$(make_system_path_relative_to_its_root "${blsdir}") ++ if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then ++ ${grub_editenv} - set blsdir="${blsdir}" ++ fi ++ fi ++ ++ ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" ++ if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then ++ ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ++ fi ++ fi + + exit 0 + fi diff --git a/0114-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch b/0096-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch similarity index 100% rename from 0114-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch rename to 0096-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch diff --git a/0116-Add-linux-and-initrd-commands-for-grub-emu.patch b/0097-Add-linux-and-initrd-commands-for-grub-emu.patch similarity index 99% rename from 0116-Add-linux-and-initrd-commands-for-grub-emu.patch rename to 0097-Add-linux-and-initrd-commands-for-grub-emu.patch index d2368f3..6b758f6 100644 --- a/0116-Add-linux-and-initrd-commands-for-grub-emu.patch +++ b/0097-Add-linux-and-initrd-commands-for-grub-emu.patch @@ -18,10 +18,10 @@ to the kexec command line tool, to allow booting the selected menu entry. create mode 100644 grub-core/loader/emu/linux.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index e52d776887a..067b97a4221 100644 +index 8bb5eb0f47f..e70558a800a 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -1710,7 +1710,6 @@ module = { +@@ -1712,7 +1712,6 @@ module = { common = loader/linux.c; common = lib/cmdline.c; diff --git a/0118-Add-grub2-switch-to-blscfg.patch b/0098-Add-grub2-switch-to-blscfg.patch similarity index 65% rename from 0118-Add-grub2-switch-to-blscfg.patch rename to 0098-Add-grub2-switch-to-blscfg.patch index 17984a2..ec9e766 100644 --- a/0118-Add-grub2-switch-to-blscfg.patch +++ b/0098-Add-grub2-switch-to-blscfg.patch @@ -4,20 +4,24 @@ Date: Thu, 15 Mar 2018 14:12:40 -0400 Subject: [PATCH] Add grub2-switch-to-blscfg Signed-off-by: Peter Jones +Signed-off-by: Javier Martinez Canillas +[jhlavac: Use ${etcdefaultgrub} instead of /etc/default/grub] +Signed-off-by: Jan Hlavac --- - Makefile.util.def | 7 ++ + Makefile.util.def | 7 + .gitignore | 2 + - util/grub-switch-to-blscfg.8 | 25 ++++ - util/grub-switch-to-blscfg.in | 262 ++++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 296 insertions(+) + util/grub-set-password.in | 2 +- + util/grub-switch-to-blscfg.8 | 33 +++++ + util/grub-switch-to-blscfg.in | 314 ++++++++++++++++++++++++++++++++++++++++++ + 5 files changed, 357 insertions(+), 1 deletion(-) create mode 100644 util/grub-switch-to-blscfg.8 create mode 100644 util/grub-switch-to-blscfg.in diff --git a/Makefile.util.def b/Makefile.util.def -index 879e8eb98a4..f4fbd250630 100644 +index c16c2ca545a..aa59418ff2c 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -1348,6 +1348,13 @@ program = { +@@ -1355,6 +1355,13 @@ program = { ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -32,7 +36,7 @@ index 879e8eb98a4..f4fbd250630 100644 name = grub-glue-efi; mansection = 1; diff --git a/.gitignore b/.gitignore -index 54795fa60be..42475592123 100644 +index 096eeff7de8..7aaae594d51 100644 --- a/.gitignore +++ b/.gitignore @@ -121,6 +121,8 @@ grub-*.tar.* @@ -44,12 +48,24 @@ index 54795fa60be..42475592123 100644 /grub_fstest.pp /grub_fstest_init.c /grub_fstest_init.lst +diff --git a/util/grub-set-password.in b/util/grub-set-password.in +index 5ebf50576d6..c0b5ebbfdc5 100644 +--- a/util/grub-set-password.in ++++ b/util/grub-set-password.in +@@ -1,6 +1,6 @@ + #!/bin/sh -e + +-EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') ++EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/' -e 's/\"//g') + if [ -d /sys/firmware/efi/efivars/ ]; then + grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'` + else diff --git a/util/grub-switch-to-blscfg.8 b/util/grub-switch-to-blscfg.8 new file mode 100644 -index 00000000000..134dfc62a7b +index 00000000000..9a886282976 --- /dev/null +++ b/util/grub-switch-to-blscfg.8 -@@ -0,0 +1,25 @@ +@@ -0,0 +1,33 @@ +.TH GRUB-SWITCH-TO-BLSCFG 1 "Wed Feb 26 2014" +.SH NAME +\fBgrub-switch-to-blscfg\fR \(em Switch to using BLS config files. @@ -73,14 +89,22 @@ index 00000000000..134dfc62a7b +--grub-defaults=\fIFILE\fR +The defaults file for grub-mkconfig. The default value is \fI/etc/default/grub\fR. + ++.TP ++--bls-directory=\fIDIR\fR ++Create BootLoaderSpec fragments in \fIDIR\fR. The default value is \fI/boot/loader/entries\fR. ++ ++.TP ++--backup-suffix=\fSUFFIX\fR ++The suffix to use for saved backup files. The default value is \fI.bak\fR. ++ +.SH SEE ALSO +.BR "info grub" diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in new file mode 100644 -index 00000000000..3ae5e4ea8d0 +index 00000000000..49b3985fadb --- /dev/null +++ b/util/grub-switch-to-blscfg.in -@@ -0,0 +1,262 @@ +@@ -0,0 +1,314 @@ +#! /bin/sh +# +# Set a default boot entry for GRUB. @@ -104,6 +128,7 @@ index 00000000000..3ae5e4ea8d0 +# Initialize some variables. +prefix=@prefix@ +exec_prefix=@exec_prefix@ ++sbindir=@sbindir@ +bindir=@bindir@ +sysconfdir="@sysconfdir@" +PACKAGE_NAME=@PACKAGE_NAME@ @@ -116,22 +141,27 @@ index 00000000000..3ae5e4ea8d0 + +self=`basename $0` + ++grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@" +grub_editenv=${bindir}/@grub_editenv@ +etcdefaultgrub=/etc/default/grub + -+EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') ++eval "$("${grub_get_kernel_settings}")" || true ++ ++EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/' -e 's/\"//g') +if [ -d /sys/firmware/efi/efivars/ ]; then + startlink=/etc/grub2-efi.cfg + grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'` -+ blsdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/loader/entries" | sed 's,//*,/,g'` +else + startlink=/etc/grub2.cfg + grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'` -+ blsdir=`echo "/@bootdirname@" | sed 's,//*,/,g'` +fi + ++blsdir=`echo "/@bootdirname@/loader/entries" | sed 's,//*,/,g'` ++ +backupsuffix=.bak + ++arch="$(uname -m)" ++ +export TEXTDOMAIN=@PACKAGE@ +export TEXTDOMAINDIR="@localedir@" + @@ -230,18 +260,18 @@ index 00000000000..3ae5e4ea8d0 + +find_grub_cfg() { + local candidate="" -+ while [[ -e "${candidate}" || $# -gt 0 ]] ++ while [ -e "${candidate}" -o $# -gt 0 ] + do -+ if [[ ! -e "${candidate}" ]] ; then ++ if [ ! -e "${candidate}" ] ; then + candidate="$1" + shift + fi + -+ if [[ -L "${candidate}" ]]; then ++ if [ -L "${candidate}" ]; then + candidate="$(realpath "${candidate}")" + fi + -+ if [[ -f "${candidate}" ]]; then ++ if [ -f "${candidate}" ]; then + export GRUB_CONFIG_FILE="${candidate}" + return 0 + fi @@ -254,11 +284,11 @@ index 00000000000..3ae5e4ea8d0 + exit 1 +fi + -+if [[ ! -d "${blsdir}" ]]; then ++if [ ! -d "${blsdir}" ]; then + install -m 700 -d "${blsdir}" +fi + -+if [[ -f /etc/machine-id ]]; then ++if [ -f /etc/machine-id ]; then + MACHINE_ID=$(cat /etc/machine-id) +else + MACHINE_ID=$(dmesg | sha256sum) @@ -267,14 +297,17 @@ index 00000000000..3ae5e4ea8d0 +mkbls() { + local kernelver=$1 && shift + local datetime=$1 && shift ++ local bootprefix=$1 && shift + + local debugname="" ++ local debugid="" + local flavor="" + -+ if [[ "$kernelver" == *\+* ]] ; then ++ if [ "$kernelver" == *\+* ] ; then + local flavor=-"${kernelver##*+}" -+ if [[ "${flavor}" == "-debug" ]]; then ++ if [ "${flavor}" == "-debug" ]; then + local debugname=" with debugging" ++ local debugid="-debug" + fi + fi + ( @@ -282,8 +315,9 @@ index 00000000000..3ae5e4ea8d0 + + cat <"${bls_target}" ++ fi ++ ++ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then ++ bls_debug="$(echo ${bls_target} | sed -e "s/${kernelver}/${kernelver}~debug/")" ++ cp -aT "${bls_target}" "${bls_debug}" ++ title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')" ++ blsid="$(grep '^id[ \t]' "${bls_debug}" | sed -e "s/\.${ARCH}/-debug.${arch}/")" ++ sed -i -e "s/^title.*/title ${title}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${bls_debug}" ++ sed -i -e "s/^id.*/${blsid}/" "${bls_debug}" ++ sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${bls_debug}" ++ fi ++ done ++ ++ if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then ++ mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" + fi -+ if [[ ! -f "/boot/vmlinuz-${kernelver}" ]]; then -+ continue -+ fi -+ bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf" -+ kernel_dir="/lib/modules/${kernelver}" -+ if [[ -f "${kernel_dir}/bls.conf" ]]; then -+ cp -af "${kernel_dir}/bls.conf" "${bls_target}" -+ else -+ mkbls "${kernelver}" \ -+ "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \ -+ >"${bls_target}" -+ fi -+done ++} + +GENERATE=0 +if grep '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" \ @@ -329,13 +391,27 @@ index 00000000000..3ae5e4ea8d0 + GENERATE=1 +fi + -+if [[ "${GENERATE}" -eq 1 ]] ; then ++if [ "${GENERATE}" -eq 1 ] ; then ++ copy_bls ++ ++ if [ $arch = "x86_64" ] && [ ! -d /sys/firmware/efi ]; then ++ mod_dir="i386-pc" ++ elif [ $arch = "ppc64" -o $arch = "ppc64le" ] && [ ! -d /sys/firmware/opal ]; then ++ mod_dir="powerpc-ieee1275" ++ fi ++ ++ if [ -n "${mod_dir}" ]; then ++ for mod in blscfg increment; do ++ cp ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1 ++ done ++ fi ++ + cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}" + if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then + cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}" + sed -i"${backupsuffix}" \ + -e 's,^GRUB_ENABLE_BLSCFG=.*,GRUB_ENABLE_BLSCFG=false,' \ -+ /etc/default/grub ++ "${etcdefaultgrub}" + gettext_printf "Updating %s failed\n" "${GRUB_CONFIG_FILE}" + exit 1 + fi diff --git a/0119-Add-grub_debug_enabled.patch b/0099-Add-grub_debug_enabled.patch similarity index 97% rename from 0119-Add-grub_debug_enabled.patch rename to 0099-Add-grub_debug_enabled.patch index d8e4bde..480628a 100644 --- a/0119-Add-grub_debug_enabled.patch +++ b/0099-Add-grub_debug_enabled.patch @@ -47,7 +47,7 @@ index 636f97e1ba1..e758ab3416d 100644 grub_printf ("%s:%d: ", file, line); va_start (args, fmt); diff --git a/include/grub/misc.h b/include/grub/misc.h -index cbfae75a1b4..f7473c154f0 100644 +index fcaf1201e39..0f5abc4638e 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -367,6 +367,7 @@ grub_puts (const char *s) diff --git a/0120-make-better-backtraces.patch b/0100-make-better-backtraces.patch similarity index 99% rename from 0120-make-better-backtraces.patch rename to 0100-make-better-backtraces.patch index e017c77..8751441 100644 --- a/0120-make-better-backtraces.patch +++ b/0100-make-better-backtraces.patch @@ -38,7 +38,7 @@ Signed-off-by: Peter Jones delete mode 100644 grub-core/lib/i386/backtrace.c diff --git a/Makefile.util.def b/Makefile.util.def -index f4fbd250630..cbd661d6348 100644 +index aa59418ff2c..4e722ab766b 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -49,6 +49,12 @@ library = { @@ -55,13 +55,13 @@ index f4fbd250630..cbd661d6348 100644 library = { diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 067b97a4221..cb24f92a431 100644 +index e70558a800a..63b33490b11 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -130,6 +130,12 @@ kernel = { +@@ -129,6 +129,12 @@ kernel = { + common = kern/rescue_parser.c; common = kern/rescue_reader.c; common = kern/term.c; - common = kern/qsort.c; + common = kern/backtrace.c; + + x86 = kern/i386/backtrace.c; @@ -71,7 +71,7 @@ index 067b97a4221..cb24f92a431 100644 noemu = kern/compiler-rt.c; noemu = kern/mm.c; -@@ -176,9 +182,6 @@ kernel = { +@@ -175,9 +181,6 @@ kernel = { softdiv = lib/division.c; @@ -81,7 +81,7 @@ index 067b97a4221..cb24f92a431 100644 i386 = kern/i386/dl.c; i386_xen = kern/i386/dl.c; -@@ -2277,13 +2280,11 @@ module = { +@@ -2279,13 +2282,11 @@ module = { module = { name = backtrace; diff --git a/0121-normal-don-t-draw-our-startup-message-if-debug-is-se.patch b/0101-normal-don-t-draw-our-startup-message-if-debug-is-se.patch similarity index 89% rename from 0121-normal-don-t-draw-our-startup-message-if-debug-is-se.patch rename to 0101-normal-don-t-draw-our-startup-message-if-debug-is-se.patch index d2a8fd0..22da7de 100644 --- a/0121-normal-don-t-draw-our-startup-message-if-debug-is-se.patch +++ b/0101-normal-don-t-draw-our-startup-message-if-debug-is-se.patch @@ -8,10 +8,10 @@ Subject: [PATCH] normal: don't draw our startup message if debug is set 1 file changed, 3 insertions(+) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index b69f9e738fa..04ae9ed02f6 100644 +index ea749f26fd5..4117317c4c4 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -419,6 +419,9 @@ grub_normal_reader_init (int nested) +@@ -425,6 +425,9 @@ grub_normal_reader_init (int nested) const char *msg_esc = _("ESC at any time exits."); char *msg_formatted; diff --git a/0122-Work-around-some-minor-include-path-weirdnesses.patch b/0102-Work-around-some-minor-include-path-weirdnesses.patch similarity index 100% rename from 0122-Work-around-some-minor-include-path-weirdnesses.patch rename to 0102-Work-around-some-minor-include-path-weirdnesses.patch diff --git a/0123-Make-it-possible-to-enabled-build-id-sha1.patch b/0103-Make-it-possible-to-enabled-build-id-sha1.patch similarity index 98% rename from 0123-Make-it-possible-to-enabled-build-id-sha1.patch rename to 0103-Make-it-possible-to-enabled-build-id-sha1.patch index 2ed085c..a241885 100644 --- a/0123-Make-it-possible-to-enabled-build-id-sha1.patch +++ b/0103-Make-it-possible-to-enabled-build-id-sha1.patch @@ -10,7 +10,7 @@ Signed-off-by: Peter Jones 2 files changed, 27 insertions(+) diff --git a/configure.ac b/configure.ac -index f69f8986791..359cac3c26b 100644 +index 9318c281108..5f47a9265f3 100644 --- a/configure.ac +++ b/configure.ac @@ -1386,7 +1386,15 @@ grub_PROG_TARGET_CC diff --git a/0124-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch b/0104-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch similarity index 97% rename from 0124-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch rename to 0104-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch index 8bd5548..e5048f9 100644 --- a/0124-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch +++ b/0104-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch @@ -42,7 +42,7 @@ index 5c2d2039d0b..0e89c483d5e 100644 int diff --git a/include/grub/misc.h b/include/grub/misc.h -index f7473c154f0..5f1c1c1be4e 100644 +index 0f5abc4638e..de9016ab709 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -372,6 +372,8 @@ void EXPORT_FUNC(grub_real_dprintf) (const char *file, diff --git a/0125-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch b/0105-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch similarity index 100% rename from 0125-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch rename to 0105-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch diff --git a/0127-Core-TPM-support.patch b/0106-TPM-support.patch similarity index 65% rename from 0127-Core-TPM-support.patch rename to 0106-TPM-support.patch index 43ab689..5656da4 100644 --- a/0127-Core-TPM-support.patch +++ b/0106-TPM-support.patch @@ -1,40 +1,55 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Tue, 14 Jul 2015 17:06:35 -0700 -Subject: [PATCH] Core TPM support +Subject: [PATCH] TPM support Add support for performing basic TPM measurements. Right now this only -supports extending PCRs statically and only on UEFI and BIOS systems, but -will measure all modules as they're loaded. +supports extending PCRs statically and only on UEFI, but will measure +all modules as they're loaded, kernel and initrd images, command line, +grub commands and multiboot images. + +Signed-off-by: Matthew Garrett +[hdegoede: fix hash_log_extend_event prototype and compile warnings] +Signed-off-by: Hans de Goede +[michael.marineau: fix warnings when compiling for other platforms] +Michael Marineau +[javierm: squash in a single patch and drop legacy BIOS support] +Javier Martinez Canillas --- - grub-core/Makefile.core.def | 3 + - grub-core/kern/dl.c | 3 + - grub-core/kern/efi/tpm.c | 282 +++++++++++++++++++++++++++++++++++++++++++ - grub-core/kern/i386/pc/tpm.c | 132 ++++++++++++++++++++ - grub-core/kern/tpm.c | 13 ++ - include/grub/efi/tpm.h | 153 +++++++++++++++++++++++ - include/grub/tpm.h | 91 ++++++++++++++ - grub-core/Makefile.am | 1 + - 8 files changed, 678 insertions(+) + grub-core/Makefile.core.def | 2 + + grub-core/kern/dl.c | 4 + + grub-core/kern/efi/tpm.c | 274 ++++++++++++++++++++++++++++++++++ + grub-core/kern/tpm.c | 19 +++ + grub-core/lib/cmdline.c | 7 +- + grub-core/loader/i386/efi/linux.c | 6 + + grub-core/loader/i386/linux.c | 6 + + grub-core/loader/i386/multiboot_mbi.c | 4 + + grub-core/loader/linux.c | 4 + + grub-core/loader/multiboot.c | 3 + + grub-core/loader/multiboot_mbi2.c | 5 +- + grub-core/script/execute.c | 26 +++- + include/grub/efi/tpm.h | 153 +++++++++++++++++++ + include/grub/tpm.h | 94 ++++++++++++ + grub-core/Makefile.am | 1 + + 15 files changed, 604 insertions(+), 4 deletions(-) create mode 100644 grub-core/kern/efi/tpm.c - create mode 100644 grub-core/kern/i386/pc/tpm.c create mode 100644 grub-core/kern/tpm.c create mode 100644 include/grub/efi/tpm.h create mode 100644 include/grub/tpm.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index cb24f92a431..420831bc89e 100644 +index 63b33490b11..3be42a95195 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -131,6 +131,7 @@ kernel = { +@@ -130,6 +130,7 @@ kernel = { + common = kern/rescue_reader.c; common = kern/term.c; - common = kern/qsort.c; common = kern/backtrace.c; + common = kern/tpm.c; x86 = kern/i386/backtrace.c; i386_xen = kern/i386/backtrace.c; -@@ -199,6 +200,7 @@ kernel = { +@@ -198,6 +199,7 @@ kernel = { efi = kern/acpi.c; efi = kern/efi/acpi.c; efi = lib/envblk.c; @@ -42,16 +57,8 @@ index cb24f92a431..420831bc89e 100644 i386_coreboot = kern/i386/pc/acpi.c; i386_multiboot = kern/i386/pc/acpi.c; i386_coreboot = kern/acpi.c; -@@ -245,6 +247,7 @@ kernel = { - - i386_pc = kern/i386/pc/init.c; - i386_pc = kern/i386/pc/mmap.c; -+ i386_pc = kern/i386/pc/tpm.c; - i386_pc = term/i386/pc/console.c; - - i386_qemu = bus/pci.c; diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index eb8b969cded..387d1e6446d 100644 +index eb8b969cded..91105bc4677 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -33,6 +33,7 @@ @@ -62,21 +69,22 @@ index eb8b969cded..387d1e6446d 100644 /* Platforms where modules are in a readonly area of memory. */ #if defined(GRUB_MACHINE_QEMU) -@@ -829,6 +830,8 @@ grub_dl_load_file (const char *filename) +@@ -829,6 +830,9 @@ grub_dl_load_file (const char *filename) opens of the same device. */ grub_file_close (file); -+ grub_tpm_measure(core, size, GRUB_TPM_PCR, filename); ++ grub_tpm_measure(core, size, GRUB_BINARY_PCR, "grub_module", filename); ++ grub_print_error(); + mod = grub_dl_load_core (core, size); grub_free (core); if (! mod) diff --git a/grub-core/kern/efi/tpm.c b/grub-core/kern/efi/tpm.c new file mode 100644 -index 00000000000..c9fb3c133f3 +index 00000000000..0d3ebe22e57 --- /dev/null +++ b/grub-core/kern/efi/tpm.c -@@ -0,0 +1,282 @@ +@@ -0,0 +1,274 @@ +#include +#include +#include @@ -240,21 +248,12 @@ index 00000000000..c9fb3c133f3 + } +} + -+typedef struct { -+ grub_uint32_t pcrindex; -+ grub_uint32_t eventtype; -+ grub_uint8_t digest[20]; -+ grub_uint32_t eventsize; -+ grub_uint8_t event[1]; -+} Event; -+ -+ +static grub_err_t +grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf, + grub_size_t size, grub_uint8_t pcr, + const char *description) +{ -+ Event *event; ++ TCG_PCR_EVENT *event; + grub_efi_status_t status; + grub_efi_tpm_protocol_t *tpm; + grub_efi_physical_address_t lastevent; @@ -267,18 +266,19 @@ index 00000000000..c9fb3c133f3 + if (!grub_tpm_present(tpm)) + return 0; + -+ event = grub_zalloc(sizeof (Event) + grub_strlen(description) + 1); ++ event = grub_zalloc(sizeof (TCG_PCR_EVENT) + grub_strlen(description) + 1); + if (!event) + return grub_error (GRUB_ERR_OUT_OF_MEMORY, + N_("cannot allocate TPM event buffer")); + -+ event->pcrindex = pcr; -+ event->eventtype = EV_IPL; -+ event->eventsize = grub_strlen(description) + 1; -+ grub_memcpy(event->event, description, event->eventsize); ++ event->PCRIndex = pcr; ++ event->EventType = EV_IPL; ++ event->EventSize = grub_strlen(description) + 1; ++ grub_memcpy(event->Event, description, event->EventSize); + + algorithm = TCG_ALG_SHA; -+ status = efi_call_7 (tpm->log_extend_event, tpm, buf, (grub_uint64_t) size, ++ status = efi_call_7 (tpm->log_extend_event, tpm, ++ (unsigned long) buf, (grub_uint64_t) size, + algorithm, event, &eventnum, &lastevent); + + switch (status) { @@ -324,7 +324,7 @@ index 00000000000..c9fb3c133f3 + event->Size = sizeof(*event) - sizeof(event->Event) + grub_strlen(description) + 1; + grub_memcpy(event->Event, description, grub_strlen(description) + 1); + -+ status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, buf, ++ status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (unsigned long) buf, + (grub_uint64_t) size, event); + + switch (status) { @@ -359,150 +359,12 @@ index 00000000000..c9fb3c133f3 + return grub_tpm2_log_event(tpm_handle, buf, size, pcr, description); + } +} -diff --git a/grub-core/kern/i386/pc/tpm.c b/grub-core/kern/i386/pc/tpm.c -new file mode 100644 -index 00000000000..8c6c1e6ece2 ---- /dev/null -+++ b/grub-core/kern/i386/pc/tpm.c -@@ -0,0 +1,132 @@ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define TCPA_MAGIC 0x41504354 -+ -+int tpm_present(void); -+ -+int tpm_present(void) -+{ -+ struct grub_bios_int_registers regs; -+ -+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; -+ regs.eax = 0xbb00; -+ regs.ebx = TCPA_MAGIC; -+ grub_bios_interrupt (0x1a, ®s); -+ -+ if (regs.eax == 0) -+ return 1; -+ -+ return 0; -+} -+ -+grub_err_t -+grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, -+ PassThroughToTPM_OutputParamBlock *outbuf) -+{ -+ struct grub_bios_int_registers regs; -+ grub_addr_t inaddr, outaddr; -+ -+ if (!tpm_present()) -+ return 0; -+ -+ inaddr = (grub_addr_t) inbuf; -+ outaddr = (grub_addr_t) outbuf; -+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; -+ regs.eax = 0xbb02; -+ regs.ebx = TCPA_MAGIC; -+ regs.ecx = 0; -+ regs.edx = 0; -+ regs.es = (inaddr & 0xffff0000) >> 4; -+ regs.edi = inaddr & 0xffff; -+ regs.ds = outaddr >> 4; -+ regs.esi = outaddr & 0xf; -+ -+ grub_bios_interrupt (0x1a, ®s); -+ -+ if (regs.eax) -+ return grub_error (GRUB_ERR_IO, N_("TPM error %x\n"), regs.eax); -+ -+ return 0; -+} -+ -+typedef struct { -+ grub_uint32_t pcrindex; -+ grub_uint32_t eventtype; -+ grub_uint8_t digest[20]; -+ grub_uint32_t eventdatasize; -+ grub_uint8_t event[0]; -+} GRUB_PACKED Event; -+ -+typedef struct { -+ grub_uint16_t ipblength; -+ grub_uint16_t reserved; -+ grub_uint32_t hashdataptr; -+ grub_uint32_t hashdatalen; -+ grub_uint32_t pcr; -+ grub_uint32_t reserved2; -+ grub_uint32_t logdataptr; -+ grub_uint32_t logdatalen; -+} GRUB_PACKED EventIncoming; -+ -+typedef struct { -+ grub_uint16_t opblength; -+ grub_uint16_t reserved; -+ grub_uint32_t eventnum; -+ grub_uint8_t hashvalue[20]; -+} GRUB_PACKED EventOutgoing; -+ -+grub_err_t -+grub_tpm_log_event(unsigned char *buf, grub_size_t size, grub_uint8_t pcr, -+ const char *description) -+{ -+ struct grub_bios_int_registers regs; -+ EventIncoming incoming; -+ EventOutgoing outgoing; -+ Event *event; -+ grub_uint32_t datalength; -+ -+ if (!tpm_present()) -+ return 0; -+ -+ datalength = grub_strlen(description); -+ event = grub_zalloc(datalength + sizeof(Event)); -+ if (!event) -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ N_("cannot allocate TPM event buffer")); -+ -+ event->pcrindex = pcr; -+ event->eventtype = 0x0d; -+ event->eventdatasize = grub_strlen(description); -+ grub_memcpy(event->event, description, datalength); -+ -+ incoming.ipblength = sizeof(incoming); -+ incoming.hashdataptr = (grub_uint32_t)buf; -+ incoming.hashdatalen = size; -+ incoming.pcr = pcr; -+ incoming.logdataptr = (grub_uint32_t)event; -+ incoming.logdatalen = datalength + sizeof(Event); -+ -+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; -+ regs.eax = 0xbb01; -+ regs.ebx = TCPA_MAGIC; -+ regs.ecx = 0; -+ regs.edx = 0; -+ regs.es = (((grub_addr_t) &incoming) & 0xffff0000) >> 4; -+ regs.edi = ((grub_addr_t) &incoming) & 0xffff; -+ regs.ds = (((grub_addr_t) &outgoing) & 0xffff0000) >> 4; -+ regs.esi = ((grub_addr_t) &outgoing) & 0xffff; -+ -+ grub_bios_interrupt (0x1a, ®s); -+ -+ grub_free(event); -+ -+ if (regs.eax) -+ return grub_error (GRUB_ERR_IO, N_("TPM error %x\n"), regs.eax); -+ -+ return 0; -+} diff --git a/grub-core/kern/tpm.c b/grub-core/kern/tpm.c new file mode 100644 -index 00000000000..1a991876c83 +index 00000000000..e5e8fced624 --- /dev/null +++ b/grub-core/kern/tpm.c -@@ -0,0 +1,13 @@ +@@ -0,0 +1,19 @@ +#include +#include +#include @@ -512,13 +374,253 @@ index 00000000000..1a991876c83 + +grub_err_t +grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, -+ const char *description) ++ const char *kind, const char *description) +{ -+ return grub_tpm_log_event(buf, size, pcr, description); ++ grub_err_t ret; ++ char *desc = grub_xasprintf("%s %s", kind, description); ++ if (!desc) ++ return GRUB_ERR_OUT_OF_MEMORY; ++ ret = grub_tpm_log_event(buf, size, pcr, desc); ++ grub_free(desc); ++ return ret; +} +diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c +index 970ea868c14..d5c12957cad 100644 +--- a/grub-core/lib/cmdline.c ++++ b/grub-core/lib/cmdline.c +@@ -19,6 +19,7 @@ + + #include + #include ++#include + + static int + is_hex(char c) +@@ -79,7 +80,7 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, + { + int i, space; + unsigned int arg_size; +- char *c; ++ char *c, *orig = buf; + + for (i = 0; i < argc; i++) + { +@@ -125,5 +126,9 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, + + *buf = 0; + ++ grub_tpm_measure ((void *)orig, grub_strlen (orig), GRUB_ASCII_PCR, ++ "grub_kernel_cmdline", orig); ++ grub_print_error(); ++ + return i; + } +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index 800c3e54022..ea9f5134e67 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -27,6 +27,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -131,6 +132,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + argv[i]); + goto fail; + } ++ grub_tpm_measure (ptr, cursize, GRUB_BINARY_PCR, "grub_linuxefi", "Initrd"); ++ grub_print_error(); + ptr += cursize; + grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); + ptr += ALIGN_UP_OVERHEAD (cursize, 4); +@@ -195,6 +198,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + ++ grub_tpm_measure (kernel, filelen, GRUB_BINARY_PCR, "grub_linuxefi", "Kernel"); ++ grub_print_error(); ++ + rc = grub_linuxefi_secure_validate (kernel, filelen); + if (rc < 0) + { +diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c +index c84747ea857..76304f05700 100644 +--- a/grub-core/loader/i386/linux.c ++++ b/grub-core/loader/i386/linux.c +@@ -36,6 +36,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -724,7 +725,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + ++ grub_tpm_measure (kernel, len, GRUB_BINARY_PCR, "grub_linux", "Kernel"); ++ grub_print_error(); ++ + grub_memcpy (&lh, kernel, sizeof (lh)); ++ + kernel_offset = sizeof (lh); + + if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) +@@ -1038,6 +1043,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + + len = prot_file_size; + grub_memcpy (prot_mode_mem, kernel + kernel_offset, len); ++ kernel_offset += len; + + if (grub_errno == GRUB_ERR_NONE) + { +diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c +index dc98dbcae25..ca85358f771 100644 +--- a/grub-core/loader/i386/multiboot_mbi.c ++++ b/grub-core/loader/i386/multiboot_mbi.c +@@ -36,6 +36,7 @@ + #include + #include + #include ++#include + + #ifdef GRUB_MACHINE_EFI + #include +@@ -173,6 +174,9 @@ grub_multiboot_load (grub_file_t file, const char *filename) + return grub_errno; + } + ++ grub_tpm_measure((unsigned char*)buffer, len, GRUB_BINARY_PCR, "grub_multiboot", filename); ++ grub_print_error(); ++ + header = find_header (buffer, len); + + if (header == 0) +diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c +index be6fa0f4d45..c2c7cfcd0fd 100644 +--- a/grub-core/loader/linux.c ++++ b/grub-core/loader/linux.c +@@ -4,6 +4,7 @@ + #include + #include + #include ++#include + + struct newc_head + { +@@ -288,6 +289,9 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, + grub_initrd_close (initrd_ctx); + return grub_errno; + } ++ grub_tpm_measure (ptr, cursize, GRUB_BINARY_PCR, "grub_initrd", "Initrd"); ++ grub_print_error(); ++ + ptr += cursize; + } + if (newc) +diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c +index 26df46a4161..9a8dae5565b 100644 +--- a/grub-core/loader/multiboot.c ++++ b/grub-core/loader/multiboot.c +@@ -51,6 +51,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -440,6 +441,8 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), + } + + grub_file_close (file); ++ grub_tpm_measure (module, size, GRUB_BINARY_PCR, "grub_multiboot", argv[0]); ++ grub_print_error(); + return GRUB_ERR_NONE; + } + +diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c +index 4df6595954d..54078455e2f 100644 +--- a/grub-core/loader/multiboot_mbi2.c ++++ b/grub-core/loader/multiboot_mbi2.c +@@ -36,6 +36,7 @@ + #include + #include + #include ++#include + + #if defined (GRUB_MACHINE_EFI) + #include +@@ -131,8 +132,10 @@ grub_multiboot2_load (grub_file_t file, const char *filename) + + COMPILE_TIME_ASSERT (MULTIBOOT_HEADER_ALIGN % 4 == 0); + ++ grub_tpm_measure ((unsigned char *)mld.buffer, len, GRUB_BINARY_PCR, "grub_multiboot", filename); ++ grub_print_error(); ++ + header = find_header (mld.buffer, len); +- + if (header == 0) + { + grub_free (mld.buffer); +diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c +index cf6cd6601d6..93965777138 100644 +--- a/grub-core/script/execute.c ++++ b/grub-core/script/execute.c +@@ -30,6 +30,7 @@ + #ifdef GRUB_MACHINE_IEEE1275 + #include + #endif ++#include + + /* Max digits for a char is 3 (0xFF is 255), similarly for an int it + is sizeof (int) * 3, and one extra for a possible -ve sign. */ +@@ -967,8 +968,9 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) + grub_err_t ret = 0; + grub_script_function_t func = 0; + char errnobuf[18]; +- char *cmdname; +- int argc; ++ char *cmdname, *cmdstring; ++ int argc, offset = 0, cmdlen = 0; ++ unsigned int i; + char **args; + int invert; + struct grub_script_argv argv = { 0, 0, 0 }; +@@ -977,6 +979,26 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) + if (grub_script_arglist_to_argv (cmdline->arglist, &argv) || ! argv.args[0]) + return grub_errno; + ++ for (i = 0; i < argv.argc; i++) { ++ cmdlen += grub_strlen (argv.args[i]) + 1; ++ } ++ ++ cmdstring = grub_malloc (cmdlen); ++ if (!cmdstring) ++ { ++ return grub_error (GRUB_ERR_OUT_OF_MEMORY, ++ N_("cannot allocate command buffer")); ++ } ++ ++ for (i = 0; i < argv.argc; i++) { ++ offset += grub_snprintf (cmdstring + offset, cmdlen - offset, "%s ", ++ argv.args[i]); ++ } ++ cmdstring[cmdlen-1]= '\0'; ++ grub_tpm_measure ((unsigned char *)cmdstring, cmdlen, GRUB_ASCII_PCR, ++ "grub_cmd", cmdstring); ++ grub_print_error(); ++ grub_free(cmdstring); + invert = 0; + argc = argv.argc - 1; + args = argv.args + 1; diff --git a/include/grub/efi/tpm.h b/include/grub/efi/tpm.h new file mode 100644 -index 00000000000..e2aff4a3c22 +index 00000000000..63d8a0fe714 --- /dev/null +++ b/include/grub/efi/tpm.h @@ -0,0 +1,153 @@ @@ -653,7 +755,7 @@ index 00000000000..e2aff4a3c22 + grub_efi_boolean_t *EventLogTruncated); + grub_efi_status_t (*hash_log_extend_event) (struct grub_efi_tpm2_protocol *this, + grub_efi_uint64_t Flags, -+ grub_efi_physical_address_t *DataToHash, ++ grub_efi_physical_address_t DataToHash, + grub_efi_uint64_t DataToHashLen, + EFI_TCG2_EVENT *EfiTcgEvent); + grub_efi_status_t (*submit_command) (struct grub_efi_tpm2_protocol *this, @@ -677,10 +779,10 @@ index 00000000000..e2aff4a3c22 +#endif diff --git a/include/grub/tpm.h b/include/grub/tpm.h new file mode 100644 -index 00000000000..40d3cf65ba6 +index 00000000000..ce52be4ff7f --- /dev/null +++ b/include/grub/tpm.h -@@ -0,0 +1,91 @@ +@@ -0,0 +1,94 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2015 Free Software Foundation, Inc. @@ -709,10 +811,8 @@ index 00000000000..40d3cf65ba6 +#define TPM_AUTHFAIL (TPM_BASE + 0x1) +#define TPM_BADINDEX (TPM_BASE + 0x2) + -+#define GRUB_TPM_PCR 9 -+#define GRUB_KERNEL_PCR 10 -+#define GRUB_INITRD_PCR 11 -+#define GRUB_CMDLINE_PCR 12 ++#define GRUB_ASCII_PCR 8 ++#define GRUB_BINARY_PCR 9 + +#define TPM_TAG_RQU_COMMAND 0x00C1 +#define TPM_ORD_Extend 0x14 @@ -752,20 +852,25 @@ index 00000000000..40d3cf65ba6 +} GRUB_PACKED ExtendOutgoing; + +grub_err_t EXPORT_FUNC(grub_tpm_measure) (unsigned char *buf, grub_size_t size, -+ grub_uint8_t pcr, ++ grub_uint8_t pcr, const char *kind, + const char *description); -+#if defined (GRUB_MACHINE_EFI) || defined (GRUB_MACHINE_PCBIOS) ++#if defined (GRUB_MACHINE_EFI) +grub_err_t grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, + PassThroughToTPM_OutputParamBlock *outbuf); +grub_err_t grub_tpm_log_event(unsigned char *buf, grub_size_t size, + grub_uint8_t pcr, const char *description); +#else -+static inline grub_err_t grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, -+ PassThroughToTPM_OutputParamBlock *outbuf) { return 0; }; -+static inline grub_err_t grub_tpm_log_event(unsigned char *buf, -+ grub_size_t size, -+ grub_uint8_t pcr, -+ const char *description) ++static inline grub_err_t grub_tpm_execute( ++ PassThroughToTPM_InputParamBlock *inbuf __attribute__ ((unused)), ++ PassThroughToTPM_OutputParamBlock *outbuf __attribute__ ((unused))) ++{ ++ return 0; ++}; ++static inline grub_err_t grub_tpm_log_event( ++ unsigned char *buf __attribute__ ((unused)), ++ grub_size_t size __attribute__ ((unused)), ++ grub_uint8_t pcr __attribute__ ((unused)), ++ const char *description __attribute__ ((unused))) +{ + return 0; +}; diff --git a/0150-Fixup-for-newer-compiler.patch b/0107-Fixup-for-newer-compiler.patch similarity index 100% rename from 0150-Fixup-for-newer-compiler.patch rename to 0107-Fixup-for-newer-compiler.patch diff --git a/0151-Don-t-attempt-to-export-the-start-and-_start-symbols.patch b/0108-Don-t-attempt-to-export-the-start-and-_start-symbols.patch similarity index 100% rename from 0151-Don-t-attempt-to-export-the-start-and-_start-symbols.patch rename to 0108-Don-t-attempt-to-export-the-start-and-_start-symbols.patch diff --git a/0155-Fixup-for-newer-compiler.patch b/0109-Fixup-for-newer-compiler.patch similarity index 100% rename from 0155-Fixup-for-newer-compiler.patch rename to 0109-Fixup-for-newer-compiler.patch diff --git a/0110-Add-quicksort-implementation.patch b/0110-Add-quicksort-implementation.patch deleted file mode 100644 index 06fe563..0000000 --- a/0110-Add-quicksort-implementation.patch +++ /dev/null @@ -1,322 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 9 Dec 2016 15:39:47 -0500 -Subject: [PATCH] Add quicksort implementation - -This will be used to sort the boot menu entries that are read from -the BootLoaderSpec config files. ---- - grub-core/kern/qsort.c | 279 +++++++++++++++++++++++++++++++++++++++++++++++++ - include/grub/misc.h | 15 +++ - 2 files changed, 294 insertions(+) - create mode 100644 grub-core/kern/qsort.c - -diff --git a/grub-core/kern/qsort.c b/grub-core/kern/qsort.c -new file mode 100644 -index 00000000000..7f3fc9ffdae ---- /dev/null -+++ b/grub-core/kern/qsort.c -@@ -0,0 +1,279 @@ -+/* quicksort -+ * This file from the GNU C Library. -+ * Copyright (C) 1991-2016 Free Software Foundation, Inc. -+ * Written by Douglas C. Schmidt (schmidt@ics.uci.edu). -+ * -+ * GRUB -- GRand Unified Bootloader -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+/* If you consider tuning this algorithm, you should consult first: -+ Engineering a sort function; Jon Bentley and M. Douglas McIlroy; -+ Software - Practice and Experience; Vol. 23 (11), 1249-1265, 1993. */ -+ -+#include -+#include -+#include -+ -+#define CHAR_BIT 8 -+ -+/* Byte-wise swap two items of size SIZE. */ -+#define SWAP(a, b, size) \ -+ do \ -+ { \ -+ grub_size_t __size = (size); \ -+ char *__a = (a), *__b = (b); \ -+ do \ -+ { \ -+ char __tmp = *__a; \ -+ *__a++ = *__b; \ -+ *__b++ = __tmp; \ -+ } while (--__size > 0); \ -+ } while (0) -+ -+/* Discontinue quicksort algorithm when partition gets below this size. -+ This particular magic number was chosen to work best on a Sun 4/260. */ -+#define MAX_THRESH 4 -+ -+/* Stack node declarations used to store unfulfilled partition obligations. */ -+typedef struct -+ { -+ char *lo; -+ char *hi; -+ } stack_node; -+ -+/* The next 4 #defines implement a very fast in-line stack abstraction. */ -+/* The stack needs log (total_elements) entries (we could even subtract -+ log(MAX_THRESH)). Since total_elements has type grub_size_t, we get as -+ upper bound for log (total_elements): -+ bits per byte (CHAR_BIT) * sizeof(grub_size_t). */ -+#define STACK_SIZE (CHAR_BIT * sizeof(grub_size_t)) -+#define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) -+#define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) -+#define STACK_NOT_EMPTY (stack < top) -+ -+ -+/* Order size using quicksort. This implementation incorporates -+ four optimizations discussed in Sedgewick: -+ -+ 1. Non-recursive, using an explicit stack of pointer that store the -+ next array partition to sort. To save time, this maximum amount -+ of space required to store an array of SIZE_MAX is allocated on the -+ stack. Assuming a 32-bit (64 bit) integer for grub_size_t, this needs -+ only 32 * sizeof(stack_node) == 256 bytes (for 64 bit: 1024 bytes). -+ Pretty cheap, actually. -+ -+ 2. Chose the pivot element using a median-of-three decision tree. -+ This reduces the probability of selecting a bad pivot value and -+ eliminates certain extraneous comparisons. -+ -+ 3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving -+ insertion sort to order the MAX_THRESH items within each partition. -+ This is a big win, since insertion sort is faster for small, mostly -+ sorted array segments. -+ -+ 4. The larger of the two sub-partitions is always pushed onto the -+ stack first, with the algorithm then concentrating on the -+ smaller partition. This *guarantees* no more than log (total_elems) -+ stack size is needed (actually O(1) in this case)! */ -+ -+void -+grub_qsort (void *const pbase, grub_size_t total_elems, grub_size_t size, -+ grub_compar_d_fn_t cmp, void *arg) -+{ -+ char *base_ptr = (char *) pbase; -+ -+ const grub_size_t max_thresh = MAX_THRESH * size; -+ -+ if (total_elems == 0) -+ /* Avoid lossage with unsigned arithmetic below. */ -+ return; -+ -+ if (total_elems > MAX_THRESH) -+ { -+ char *lo = base_ptr; -+ char *hi = &lo[size * (total_elems - 1)]; -+ stack_node stack[STACK_SIZE]; -+ stack_node *top = stack; -+ -+ PUSH (NULL, NULL); -+ -+ while (STACK_NOT_EMPTY) -+ { -+ char *left_ptr; -+ char *right_ptr; -+ -+ /* Select median value from among LO, MID, and HI. Rearrange -+ LO and HI so the three values are sorted. This lowers the -+ probability of picking a pathological pivot value and -+ skips a comparison for both the LEFT_PTR and RIGHT_PTR in -+ the while loops. */ -+ -+ char *mid = lo + size * ((hi - lo) / size >> 1); -+ -+ if ((*cmp) ((void *) mid, (void *) lo, arg) < 0) -+ SWAP (mid, lo, size); -+ if ((*cmp) ((void *) hi, (void *) mid, arg) < 0) -+ SWAP (mid, hi, size); -+ else -+ goto jump_over; -+ if ((*cmp) ((void *) mid, (void *) lo, arg) < 0) -+ SWAP (mid, lo, size); -+ jump_over:; -+ -+ left_ptr = lo + size; -+ right_ptr = hi - size; -+ -+ /* Here's the famous ``collapse the walls'' section of quicksort. -+ Gotta like those tight inner loops! They are the main reason -+ that this algorithm runs much faster than others. */ -+ do -+ { -+ while ((*cmp) ((void *) left_ptr, (void *) mid, arg) < 0) -+ left_ptr += size; -+ -+ while ((*cmp) ((void *) mid, (void *) right_ptr, arg) < 0) -+ right_ptr -= size; -+ -+ if (left_ptr < right_ptr) -+ { -+ SWAP (left_ptr, right_ptr, size); -+ if (mid == left_ptr) -+ mid = right_ptr; -+ else if (mid == right_ptr) -+ mid = left_ptr; -+ left_ptr += size; -+ right_ptr -= size; -+ } -+ else if (left_ptr == right_ptr) -+ { -+ left_ptr += size; -+ right_ptr -= size; -+ break; -+ } -+ } -+ while (left_ptr <= right_ptr); -+ -+ /* Set up pointers for next iteration. First determine whether -+ left and right partitions are below the threshold size. If so, -+ ignore one or both. Otherwise, push the larger partition's -+ bounds on the stack and continue sorting the smaller one. */ -+ -+ if ((grub_size_t) (right_ptr - lo) <= max_thresh) -+ { -+ if ((grub_size_t) (hi - left_ptr) <= max_thresh) -+ /* Ignore both small partitions. */ -+ POP (lo, hi); -+ else -+ /* Ignore small left partition. */ -+ lo = left_ptr; -+ } -+ else if ((grub_size_t) (hi - left_ptr) <= max_thresh) -+ /* Ignore small right partition. */ -+ hi = right_ptr; -+ else if ((right_ptr - lo) > (hi - left_ptr)) -+ { -+ /* Push larger left partition indices. */ -+ PUSH (lo, right_ptr); -+ lo = left_ptr; -+ } -+ else -+ { -+ /* Push larger right partition indices. */ -+ PUSH (left_ptr, hi); -+ hi = right_ptr; -+ } -+ } -+ } -+ -+ /* Once the BASE_PTR array is partially sorted by quicksort the rest -+ is completely sorted using insertion sort, since this is efficient -+ for partitions below MAX_THRESH size. BASE_PTR points to the beginning -+ of the array to sort, and END_PTR points at the very last element in -+ the array (*not* one beyond it!). */ -+ -+#define min(x, y) ((x) < (y) ? (x) : (y)) -+ -+ { -+ char *const end_ptr = &base_ptr[size * (total_elems - 1)]; -+ char *tmp_ptr = base_ptr; -+ char *thresh = min(end_ptr, base_ptr + max_thresh); -+ char *run_ptr; -+ -+ /* Find smallest element in first threshold and place it at the -+ array's beginning. This is the smallest array element, -+ and the operation speeds up insertion sort's inner loop. */ -+ -+ for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) -+ if ((*cmp) ((void *) run_ptr, (void *) tmp_ptr, arg) < 0) -+ tmp_ptr = run_ptr; -+ -+ if (tmp_ptr != base_ptr) -+ SWAP (tmp_ptr, base_ptr, size); -+ -+ /* Insertion sort, running from left-hand-side up to right-hand-side. */ -+ -+ run_ptr = base_ptr + size; -+ while ((run_ptr += size) <= end_ptr) -+ { -+ tmp_ptr = run_ptr - size; -+ while ((*cmp) ((void *) run_ptr, (void *) tmp_ptr, arg) < 0) -+ tmp_ptr -= size; -+ -+ tmp_ptr += size; -+ if (tmp_ptr != run_ptr) -+ { -+ char *trav; -+ -+ trav = run_ptr + size; -+ while (--trav >= run_ptr) -+ { -+ char c = *trav; -+ char *hi, *lo; -+ -+ for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) -+ *hi = *lo; -+ *hi = c; -+ } -+ } -+ } -+ } -+} -+ -+void * -+grub_bsearch (const void *key, const void *base, grub_size_t nmemb, grub_size_t size, -+ grub_compar_d_fn_t compar, void *state) -+{ -+ grub_size_t l, u, idx; -+ const void *p; -+ int comparison; -+ -+ l = 0; -+ u = nmemb; -+ while (l < u) -+ { -+ idx = (l + u) / 2; -+ p = (void *) (((const char *) base) + (idx * size)); -+ comparison = (*compar) (key, p, state); -+ if (comparison < 0) -+ u = idx; -+ else if (comparison > 0) -+ l = idx + 1; -+ else -+ return (void *) p; -+ } -+ -+ return NULL; -+} -diff --git a/include/grub/misc.h b/include/grub/misc.h -index fcaf1201e39..cbfae75a1b4 100644 ---- a/include/grub/misc.h -+++ b/include/grub/misc.h -@@ -507,4 +507,19 @@ void EXPORT_FUNC(grub_real_boot_time) (const char *file, - #define grub_max(a, b) (((a) > (b)) ? (a) : (b)) - #define grub_min(a, b) (((a) < (b)) ? (a) : (b)) - -+typedef int (*grub_compar_d_fn_t) (const void *p0, const void *p1, void *state); -+ -+void *EXPORT_FUNC(grub_bsearch) (const void *key, -+ const void *base, -+ grub_size_t nmemb, -+ grub_size_t size, -+ grub_compar_d_fn_t compar, -+ void *state); -+ -+void EXPORT_FUNC(grub_qsort) (void *const pbase, -+ grub_size_t total_elems, -+ grub_size_t size, -+ grub_compar_d_fn_t cmp, -+ void *state); -+ - #endif /* ! GRUB_MISC_HEADER */ diff --git a/0164-Use-xid-to-match-DHCP-replies.patch b/0110-Use-xid-to-match-DHCP-replies.patch similarity index 100% rename from 0164-Use-xid-to-match-DHCP-replies.patch rename to 0110-Use-xid-to-match-DHCP-replies.patch diff --git a/0111-Add-blscfg-command-support-to-parse-BootLoaderSpec-c.patch b/0111-Add-blscfg-command-support-to-parse-BootLoaderSpec-c.patch deleted file mode 100644 index 63b0529..0000000 --- a/0111-Add-blscfg-command-support-to-parse-BootLoaderSpec-c.patch +++ /dev/null @@ -1,1157 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 9 Dec 2016 15:40:58 -0500 -Subject: [PATCH] Add blscfg command support to parse BootLoaderSpec config - fragments - -The BootLoaderSpec (BLS) defines a scheme where different bootloaders can -share a format for boot items and a configuration directory that accepts -these common configurations as drop-in files. - -GRUB2 already has a blscfg modle that can parse the config snippets using -the bls_import command, change it to blscfg and improve the BLS support. ---- - grub-core/Makefile.core.def | 4 +- - grub-core/commands/blscfg.c | 796 ++++++++++++++++++++++++++++++++++++++++--- - grub-core/commands/loadenv.c | 77 +---- - grub-core/commands/loadenv.h | 93 +++++ - include/grub/compiler.h | 2 + - 5 files changed, 840 insertions(+), 132 deletions(-) - create mode 100644 grub-core/commands/loadenv.h - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 27563743ba9..96ccb402125 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -129,6 +129,7 @@ kernel = { - common = kern/rescue_parser.c; - common = kern/rescue_reader.c; - common = kern/term.c; -+ common = kern/qsort.c; - - noemu = kern/compiler-rt.c; - noemu = kern/mm.c; -@@ -774,8 +775,7 @@ module = { - module = { - name = blscfg; - common = commands/blscfg.c; -- enable = i386_efi; -- enable = x86_64_efi; -+ enable = efi; - enable = i386_pc; - }; - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 4274aca5a9d..86796c8cd83 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -30,32 +30,405 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -+#include "loadenv.h" -+ -+#define GRUB_BLS_CONFIG_PATH "/loader/entries/" -+#define GRUB_BOOT_DEVICE "($root)" - #ifdef GRUB_MACHINE_EFI - #define GRUB_LINUX_CMD "linuxefi" - #define GRUB_INITRD_CMD "initrdefi" --#define GRUB_BLS_CONFIG_PATH "/EFI/fedora/loader/entries/" --#define GRUB_BOOT_DEVICE "($boot)" - #else - #define GRUB_LINUX_CMD "linux" - #define GRUB_INITRD_CMD "initrd" --#define GRUB_BLS_CONFIG_PATH "/loader/entries/" --#define GRUB_BOOT_DEVICE "($root)" - #endif - --static int parse_entry ( -+#define grub_free(x) ({grub_dprintf("blscfg", "%s freeing %p\n", __func__, x); grub_free(x); }) -+ -+struct keyval -+{ -+ const char *key; -+ char *val; -+}; -+ -+struct bls_entry -+{ -+ struct keyval **keyvals; -+ int nkeyvals; -+}; -+ -+static struct bls_entry **entries; -+static int nentries; -+ -+static struct bls_entry *bls_new_entry(void) -+{ -+ struct bls_entry **new_entries; -+ struct bls_entry *entry; -+ int new_n = nentries + 1; -+ -+ new_entries = grub_realloc (entries, new_n * sizeof (struct bls_entry *)); -+ if (!new_entries) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ "couldn't find space for BLS entry list"); -+ return NULL; -+ } -+ -+ entries = new_entries; -+ -+ entry = grub_malloc (sizeof (*entry)); -+ if (!entry) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ "couldn't find space for BLS entry list"); -+ return NULL; -+ } -+ -+ grub_memset (entry, 0, sizeof (*entry)); -+ entries[nentries] = entry; -+ -+ nentries = new_n; -+ -+ return entry; -+} -+ -+static int bls_add_keyval(struct bls_entry *entry, char *key, char *val) -+{ -+ char *k, *v; -+ struct keyval **kvs, *kv; -+ int new_n = entry->nkeyvals + 1; -+ -+ kvs = grub_realloc (entry->keyvals, new_n * sizeof (struct keyval *)); -+ if (!kvs) -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ "couldn't find space for BLS entry"); -+ entry->keyvals = kvs; -+ -+ kv = grub_malloc (sizeof (struct keyval)); -+ if (!kv) -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ "couldn't find space for BLS entry"); -+ -+ k = grub_strdup (key); -+ if (!k) -+ { -+ grub_free (kv); -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ "couldn't find space for BLS entry"); -+ } -+ -+ v = grub_strdup (val); -+ if (!v) -+ { -+ grub_free (k); -+ grub_free (kv); -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ "couldn't find space for BLS entry"); -+ } -+ -+ kv->key = k; -+ kv->val = v; -+ -+ entry->keyvals[entry->nkeyvals] = kv; -+ grub_dprintf("blscfg", "new keyval at %p:%p:%p\n", entry->keyvals[entry->nkeyvals], k, v); -+ entry->nkeyvals = new_n; -+ -+ return 0; -+} -+ -+static void bls_free_entry(struct bls_entry *entry) -+{ -+ int i; -+ -+ grub_dprintf("blscfg", "%s got here\n", __func__); -+ for (i = 0; i < entry->nkeyvals; i++) -+ { -+ struct keyval *kv = entry->keyvals[i]; -+ grub_free ((void *)kv->key); -+ grub_free (kv->val); -+ grub_free (kv); -+ } -+ -+ grub_free (entry->keyvals); -+ grub_memset (entry, 0, sizeof (*entry)); -+ grub_free (entry); -+} -+ -+static int keyval_cmp (const void *p0, const void *p1, -+ void *state UNUSED) -+{ -+ const struct keyval *kv0 = *(struct keyval * const *)p0; -+ const struct keyval *kv1 = *(struct keyval * const *)p1; -+ int rc; -+ -+ rc = grub_strcmp(kv0->key, kv1->key); -+ -+ return rc; -+} -+ -+/* Find they value of the key named by keyname. If there are allowed to be -+ * more than one, pass a pointer to an int set to -1 the first time, and pass -+ * the same pointer through each time after, and it'll return them in sorted -+ * order. */ -+static char *bls_get_val(struct bls_entry *entry, const char *keyname, int *last) -+{ -+ char *foo = (char *)""; -+ struct keyval *kv = NULL, **kvp, key = {keyname, foo}, *keyp = &key; -+ -+ /* if we've already found an entry that matches, just iterate */ -+ if (last && *last >= 0) -+ { -+ int next = ++last[0]; -+ -+ if (next == entry->nkeyvals) -+ { -+done: -+ *last = -1; -+ return NULL; -+ } -+ -+ kv = entry->keyvals[next]; -+ if (grub_strcmp (keyname, kv->key)) -+ goto done; -+ -+ return kv->val; -+ } -+ -+ kvp = grub_bsearch(&keyp, &entry->keyvals[0], entry->nkeyvals, -+ sizeof (struct keyval *), keyval_cmp, NULL); -+ if (kvp) -+ kv = *kvp; -+ -+ if (kv) -+ { -+ /* if we've got uninitialized but present state, track back until we find -+ * the first match */ -+ if (last) -+ { -+ grub_dprintf("blscfg", "%s trying to find another entry because last was set\n", __func__); -+ /* figure out the position of this entry in the array */ -+ int idx; -+ for (idx = 0 ; idx < entry->nkeyvals; idx++) -+ if (entry->keyvals[idx] == kv) -+ break; -+ *last = idx; -+ -+ while (idx > 0) -+ { -+ struct keyval *kvtmp = entry->keyvals[idx-1]; -+ if (idx == 0 || grub_strcmp (keyname, kvtmp->key)) -+ { -+ /* if we're at the start, or if the previous entry doesn't -+ * match, then we're done */ -+ *last = idx; -+ break; -+ } -+ else -+ /* but if it does match, keep going backwards */ -+ idx--; -+ } -+ } -+ -+ return kv->val; -+ } -+ return NULL; -+} -+ -+#define goto_return(x) ({ ret = (x); goto finish; }) -+ -+/* compare alpha and numeric segments of two versions */ -+/* return 1: a is newer than b */ -+/* 0: a and b are the same version */ -+/* -1: b is newer than a */ -+static int vercmp(const char * a, const char * b) -+{ -+ char oldch1, oldch2; -+ char *abuf, *bbuf; -+ char *str1, *str2; -+ char * one, * two; -+ int rc; -+ int isnum; -+ int ret = 0; -+ -+ grub_dprintf("blscfg", "%s got here\n", __func__); -+ if (!grub_strcmp(a, b)) -+ return 0; -+ -+ abuf = grub_malloc(grub_strlen(a) + 1); -+ bbuf = grub_malloc(grub_strlen(b) + 1); -+ str1 = abuf; -+ str2 = bbuf; -+ grub_strcpy(str1, a); -+ grub_strcpy(str2, b); -+ -+ one = str1; -+ two = str2; -+ -+ /* loop through each version segment of str1 and str2 and compare them */ -+ while (*one || *two) { -+ while (*one && !grub_isalnum(*one) && *one != '~') one++; -+ while (*two && !grub_isalnum(*two) && *two != '~') two++; -+ -+ /* handle the tilde separator, it sorts before everything else */ -+ if (*one == '~' || *two == '~') { -+ if (*one != '~') goto_return (1); -+ if (*two != '~') goto_return (-1); -+ one++; -+ two++; -+ continue; -+ } -+ -+ /* If we ran to the end of either, we are finished with the loop */ -+ if (!(*one && *two)) break; -+ -+ str1 = one; -+ str2 = two; -+ -+ /* grab first completely alpha or completely numeric segment */ -+ /* leave one and two pointing to the start of the alpha or numeric */ -+ /* segment and walk str1 and str2 to end of segment */ -+ if (grub_isdigit(*str1)) { -+ while (*str1 && grub_isdigit(*str1)) str1++; -+ while (*str2 && grub_isdigit(*str2)) str2++; -+ isnum = 1; -+ } else { -+ while (*str1 && grub_isalpha(*str1)) str1++; -+ while (*str2 && grub_isalpha(*str2)) str2++; -+ isnum = 0; -+ } -+ -+ /* save character at the end of the alpha or numeric segment */ -+ /* so that they can be restored after the comparison */ -+ oldch1 = *str1; -+ *str1 = '\0'; -+ oldch2 = *str2; -+ *str2 = '\0'; -+ -+ /* this cannot happen, as we previously tested to make sure that */ -+ /* the first string has a non-null segment */ -+ if (one == str1) goto_return(-1); /* arbitrary */ -+ -+ /* take care of the case where the two version segments are */ -+ /* different types: one numeric, the other alpha (i.e. empty) */ -+ /* numeric segments are always newer than alpha segments */ -+ /* XXX See patch #60884 (and details) from bugzilla #50977. */ -+ if (two == str2) goto_return (isnum ? 1 : -1); -+ -+ if (isnum) { -+ grub_size_t onelen, twolen; -+ /* this used to be done by converting the digit segments */ -+ /* to ints using atoi() - it's changed because long */ -+ /* digit segments can overflow an int - this should fix that. */ -+ -+ /* throw away any leading zeros - it's a number, right? */ -+ while (*one == '0') one++; -+ while (*two == '0') two++; -+ -+ /* whichever number has more digits wins */ -+ onelen = grub_strlen(one); -+ twolen = grub_strlen(two); -+ if (onelen > twolen) goto_return (1); -+ if (twolen > onelen) goto_return (-1); -+ } -+ -+ /* grub_strcmp will return which one is greater - even if the two */ -+ /* segments are alpha or if they are numeric. don't return */ -+ /* if they are equal because there might be more segments to */ -+ /* compare */ -+ rc = grub_strcmp(one, two); -+ if (rc) goto_return (rc < 1 ? -1 : 1); -+ -+ /* restore character that was replaced by null above */ -+ *str1 = oldch1; -+ one = str1; -+ *str2 = oldch2; -+ two = str2; -+ } -+ -+ /* this catches the case where all numeric and alpha segments have */ -+ /* compared identically but the segment sepparating characters were */ -+ /* different */ -+ if ((!*one) && (!*two)) goto_return (0); -+ -+ /* whichever version still has characters left over wins */ -+ if (!*one) goto_return (-1); else goto_return (1); -+ -+finish: -+ grub_free (abuf); -+ grub_free (bbuf); -+ return ret; -+} -+ -+typedef int (*void_cmp_t)(void *, void *); -+ -+static int nulcmp(char *s0, char *s1, void_cmp_t cmp) -+{ -+ grub_dprintf("blscfg", "%s got here\n", __func__); -+ if (s1 && !s0) -+ return 1; -+ if (s0 && !s1) -+ return -1; -+ if (!s0 && !s1) -+ return 0; -+ if (cmp) -+ return cmp(s0, s1); -+ return grub_strcmp(s0, s1); -+} -+ -+static int -+bls_keyval_cmp(struct bls_entry *e0, struct bls_entry *e1, const char *keyname) -+{ -+ char *val0, *val1; -+ -+ val0 = bls_get_val (e0, keyname, NULL); -+ val1 = bls_get_val (e1, keyname, NULL); -+ -+ if (val1 && !val0) -+ return 1; -+ -+ if (val0 && !val1) -+ return -1; -+ -+ if (!val0 && !val1) -+ return 0; -+ -+ return nulcmp(val0, val1, (void_cmp_t)vercmp); -+} -+ -+static int bls_cmp(const void *p0, const void *p1, void *state UNUSED) -+{ -+ struct bls_entry * e0 = *(struct bls_entry **)p0; -+ struct bls_entry * e1 = *(struct bls_entry **)p1; -+ int rc = 0; -+ -+ rc = bls_keyval_cmp (e0, e1, "id"); -+ -+ if (rc == 0) -+ rc = bls_keyval_cmp (e0, e1, "title"); -+ -+ if (rc == 0) -+ rc = bls_keyval_cmp (e0, e1, "linux"); -+ -+ return rc; -+} -+ -+static int read_entry ( - const char *filename, -- const struct grub_dirhook_info *info __attribute__ ((unused)), -- void *data __attribute__ ((unused))) -+ const struct grub_dirhook_info *info UNUSED, -+ void *data) - { - grub_size_t n; - char *p; - grub_file_t f = NULL; - grub_off_t sz; -- char *title = NULL, *options = NULL, *clinux = NULL, *initrd = NULL, *src = NULL; -- const char *args[2] = { NULL, NULL }; -+ struct bls_entry *entry; -+ const char *dirname= (const char *)data; -+ const char *devid = grub_env_get ("boot"); -+ -+ grub_dprintf ("blscfg", "filename: \"%s\"\n", filename); - - if (filename[0] == '.') - return 0; -@@ -67,7 +440,7 @@ static int parse_entry ( - if (grub_strcmp (filename + n - 5, ".conf") != 0) - return 0; - -- p = grub_xasprintf (GRUB_BLS_CONFIG_PATH "%s", filename); -+ p = grub_xasprintf ("(%s)%s/%s", devid, dirname, filename); - - f = grub_file_open (p); - if (!f) -@@ -77,54 +450,169 @@ static int parse_entry ( - if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024) - goto finish; - -+ entry = bls_new_entry(); -+ if (!entry) -+ goto finish; -+ - for (;;) - { - char *buf; -+ char *separator; -+ int rc; - - buf = grub_file_getline (f); - if (!buf) - break; - -- if (grub_strncmp (buf, "title ", 6) == 0) -- { -- grub_free (title); -- title = grub_strdup (buf + 6); -- if (!title) -- goto finish; -- } -- else if (grub_strncmp (buf, "options ", 8) == 0) -- { -- grub_free (options); -- options = grub_strdup (buf + 8); -- if (!options) -- goto finish; -- } -- else if (grub_strncmp (buf, "linux ", 6) == 0) -- { -- grub_free (clinux); -- clinux = grub_strdup (buf + 6); -- if (!clinux) -- goto finish; -- } -- else if (grub_strncmp (buf, "initrd ", 7) == 0) -+ while (buf && buf[0] && (buf[0] == ' ' || buf[0] == '\t')) -+ buf++; -+ if (buf[0] == '#') -+ continue; -+ -+ separator = grub_strchr (buf, ' '); -+ -+ if (!separator) -+ separator = grub_strchr (buf, '\t'); -+ -+ if (!separator || separator[1] == '\0') - { -- grub_free (initrd); -- initrd = grub_strdup (buf + 7); -- if (!initrd) -- goto finish; -+ grub_free (buf); -+ break; - } - -- grub_free(buf); -+ separator[0] = '\0'; -+ -+ rc = bls_add_keyval (entry, buf, separator+1); -+ grub_free (buf); -+ if (rc < 0) -+ break; -+ } -+ -+ grub_qsort(&entry->keyvals[0], entry->nkeyvals, sizeof (struct keyval *), -+ keyval_cmp, NULL); -+ -+finish: -+ grub_free (p); -+ -+ if (f) -+ grub_file_close (f); -+ -+ return 0; -+} -+ -+static grub_envblk_t saved_env = NULL; -+ -+static int -+save_var (const char *name, const char *value, void *whitelist UNUSED) -+{ -+ const char *val = grub_env_get (name); -+ grub_dprintf("blscfg", "saving \"%s\"\n", name); -+ -+ if (val) -+ grub_envblk_set (saved_env, name, value); -+ -+ return 0; -+} -+ -+static int -+unset_var (const char *name, const char *value UNUSED, void *whitelist) -+{ -+ grub_dprintf("blscfg", "restoring \"%s\"\n", name); -+ if (! whitelist) -+ { -+ grub_env_unset (name); -+ return 0; - } - -- if (!linux) -+ if (test_whitelist_membership (name, -+ (const grub_env_whitelist_t *) whitelist)) -+ grub_env_unset (name); -+ -+ return 0; -+} -+ -+static char **bls_make_list (struct bls_entry *entry, const char *key, int *num) -+{ -+ int last = -1; -+ char *val; -+ -+ int nlist = 0; -+ char **list = NULL; -+ -+ list = grub_malloc (sizeof (char *)); -+ if (!list) -+ return NULL; -+ list[0] = NULL; -+ -+ while (1) -+ { -+ char **new; -+ -+ val = bls_get_val (entry, key, &last); -+ if (!val) -+ break; -+ -+ new = grub_realloc (list, (nlist + 2) * sizeof (char *)); -+ if (!new) -+ break; -+ -+ list = new; -+ list[nlist++] = val; -+ list[nlist] = NULL; -+ } -+ -+ if (num) -+ *num = nlist; -+ -+ return list; -+} -+ -+static void create_entry (struct bls_entry *entry, const char *cfgfile) -+{ -+ int argc = 0; -+ const char **argv = NULL; -+ -+ char *title = NULL; -+ char *clinux = NULL; -+ char *options = NULL; -+ char *initrd = NULL; -+ char *id = NULL; -+ char *hotkey = NULL; -+ -+ char *users = NULL; -+ char **classes = NULL; -+ -+ char **args = NULL; -+ -+ char *src = NULL; -+ int i; -+ -+ grub_dprintf("blscfg", "%s got here\n", __func__); -+ clinux = bls_get_val (entry, "linux", NULL); -+ if (!clinux) - { -- grub_printf ("Skipping file %s with no 'linux' key.", p); -+ grub_dprintf ("blscfg", "Skipping file %s with no 'linux' key.\n", cfgfile); - goto finish; - } - -- args[0] = title ? title : filename; -+ title = bls_get_val (entry, "title", NULL); -+ options = bls_get_val (entry, "options", NULL); -+ initrd = bls_get_val (entry, "initrd", NULL); -+ id = bls_get_val (entry, "id", NULL); - -+ hotkey = bls_get_val (entry, "grub_hotkey", NULL); -+ users = bls_get_val (entry, "grub_users", NULL); -+ classes = bls_make_list (entry, "grub_class", NULL); -+ args = bls_make_list (entry, "grub_arg", &argc); -+ -+ argc += 1; -+ argv = grub_malloc ((argc + 1) * sizeof (char *)); -+ argv[0] = title ? title : clinux; -+ for (i = 1; i < argc; i++) -+ argv[i] = args[i-1]; -+ argv[argc] = NULL; -+ -+ grub_dprintf("blscfg", "adding menu entry for \"%s\"\n", title); - src = grub_xasprintf ("load_video\n" - "set gfx_payload=keep\n" - "insmod gzio\n" -@@ -133,40 +621,219 @@ static int parse_entry ( - GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", - initrd ? GRUB_INITRD_CMD " " : "", initrd ? GRUB_BOOT_DEVICE : "", initrd ? initrd : "", initrd ? "\n" : ""); - -- grub_normal_add_menu_entry (1, args, NULL, NULL, "bls", NULL, NULL, src, 0); -+ grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0); - - finish: -- grub_free (p); -- grub_free (title); -- grub_free (options); -- grub_free (clinux); -- grub_free (initrd); -- grub_free (src); -+ if (classes) -+ grub_free (classes); -+ grub_dprintf("blscfg", "%s got here\n", __func__); -+ if (args) -+ grub_free (args); -+ -+ if (argv) -+ grub_free (argv); -+ -+ if (src) -+ grub_free (src); -+ grub_dprintf("blscfg", "%s got here\n", __func__); -+} -+ -+struct find_entry_info { -+ grub_device_t dev; -+ grub_fs_t fs; -+ int efi; -+}; -+ -+/* -+ * filename: if the directory is /EFI/something/ , filename is "something" -+ * info: unused -+ * data: the filesystem object the file is on. -+ */ -+static int find_entry (const char *filename, -+ const struct grub_dirhook_info *dirhook_info UNUSED, -+ void *data) -+{ -+ struct find_entry_info *info = (struct find_entry_info *)data; -+ grub_file_t f = NULL; -+ char *grubenv_path = NULL; -+ grub_envblk_t env = NULL; -+ char *default_blsdir = NULL; -+ const char *blsdir = NULL; -+ char *saved_env_buf = NULL; -+ int r = 0; -+ const char *devid = grub_env_get ("boot"); -+ -+ grub_dprintf("blscfg", "%s got here\n", __func__); -+ if (!grub_strcmp (filename, ".") || -+ !grub_strcmp (filename, "..")) -+ return 0; -+ -+ if (info->efi && !grub_strcasecmp (filename, "boot")) -+ return 0; -+ -+ saved_env_buf = grub_malloc (512); -+ -+ // set a default blsdir -+ if (info->efi) -+ default_blsdir = grub_xasprintf ("/EFI/%s%s", filename, -+ GRUB_BLS_CONFIG_PATH); -+ else -+ default_blsdir = grub_xasprintf ("%s", GRUB_BLS_CONFIG_PATH); -+ -+ grub_env_set ("blsdir", default_blsdir); -+ grub_dprintf ("blscfg", "default_blsdir: \"%s\"\n", default_blsdir); -+ -+ /* -+ * try to load a grubenv from /EFI/wherever/grubenv -+ */ -+ if (info->efi) -+ grubenv_path = grub_xasprintf ("(%s)/EFI/%s/grubenv", devid, filename); -+ else -+ grubenv_path = grub_xasprintf ("(%s)/grub2/grubenv", devid); -+ -+ grub_dprintf ("blscfg", "looking for \"%s\"\n", grubenv_path); -+ f = grub_file_open (grubenv_path); -+ -+ grub_dprintf ("blscfg", "%s it\n", f ? "found" : "did not find"); -+ grub_free (grubenv_path); -+ if (f) -+ { -+ grub_off_t sz; -+ -+ grub_dprintf ("blscfg", "getting size\n"); -+ sz = grub_file_size (f); -+ if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024) -+ goto finish; -+ -+ grub_dprintf ("blscfg", "reading env\n"); -+ env = read_envblk_file (f); -+ if (!env) -+ goto finish; -+ grub_dprintf ("blscfg", "read env file\n"); -+ -+ grub_memset (saved_env_buf, '#', 512); -+ grub_memcpy (saved_env_buf, GRUB_ENVBLK_SIGNATURE, -+ sizeof (GRUB_ENVBLK_SIGNATURE)); -+ grub_dprintf ("blscfg", "saving env\n"); -+ saved_env = grub_envblk_open (saved_env_buf, 512); -+ if (!saved_env) -+ goto finish; -+ -+ // save everything listed in "env" with values from our existing grub env -+ grub_envblk_iterate (env, NULL, save_var); -+ // set everything from our loaded grubenv into the real grub env -+ grub_envblk_iterate (env, NULL, set_var); -+ } -+ else -+ { -+ grub_err_t e; -+ grub_dprintf ("blscfg", "no such file\n"); -+ do -+ { -+ e = grub_error_pop(); -+ } while (e); -+ -+ } -+ -+ blsdir = grub_env_get ("blsdir"); -+ if (!blsdir) -+ goto finish; -+ -+ grub_dprintf ("blscfg", "blsdir: \"%s\"\n", blsdir); -+ if (blsdir[0] != '/' && info->efi) -+ blsdir = grub_xasprintf ("/EFI/%s/%s/", filename, blsdir); -+ else -+ blsdir = grub_strdup (blsdir); -+ -+ if (!blsdir) -+ goto finish; -+ -+ grub_dprintf ("blscfg", "blsdir: \"%s\"\n", blsdir); -+ r = info->fs->dir (info->dev, blsdir, read_entry, (char *)blsdir); -+ if (r != 0) { -+ grub_dprintf ("blscfg", "read_entry returned error\n"); -+ grub_err_t e; -+ do -+ { -+ e = grub_error_pop(); -+ } while (e); -+ } -+ -+ grub_dprintf ("blscfg", "Sorting %d entries\n", nentries); -+ grub_qsort(&entries[0], nentries, sizeof (struct bls_entry *), bls_cmp, NULL); -+ -+ grub_dprintf ("blscfg", "%s Creating %d entries from bls\n", __func__, nentries); -+ for (r = nentries - 1; r >= 0; r--) -+ create_entry(entries[r], filename); -+ -+ for (r = 0; r < nentries; r++) -+ bls_free_entry (entries[r]); -+finish: -+ nentries = 0; -+ -+ grub_free (entries); -+ entries = NULL; -+ -+ grub_free ((char *)blsdir); -+ -+ grub_env_unset ("blsdir"); -+ -+ if (saved_env) -+ { -+ // remove everything from the real environment that's defined in env -+ grub_envblk_iterate (env, NULL, unset_var); -+ -+ // re-set the things from our original environment -+ grub_envblk_iterate (saved_env, NULL, set_var); -+ grub_envblk_close (saved_env); -+ saved_env = NULL; -+ } -+ else if (saved_env_buf) -+ { -+ // if we have a saved environment, grub_envblk_close() freed this. -+ grub_free (saved_env_buf); -+ } -+ -+ if (env) -+ grub_envblk_close (env); - - if (f) - grub_file_close (f); - -+ grub_free (default_blsdir); -+ - return 0; - } - - static grub_err_t --grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)), -- int argc __attribute__ ((unused)), -- char **args __attribute__ ((unused))) -+grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, -+ int argc UNUSED, -+ char **args UNUSED) - { - grub_fs_t fs; - grub_device_t dev; - static grub_err_t r; - const char *devid; -+ struct find_entry_info info = -+ { -+ .dev = NULL, -+ .fs = NULL, -+ .efi = 0, -+ }; - -- devid = grub_env_get ("root"); -+ -+ grub_dprintf ("blscfg", "finding boot\n"); -+ devid = grub_env_get ("boot"); - if (!devid) -- return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "root"); -+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, -+ N_("variable `%s' isn't set"), "boot"); - -+ grub_dprintf ("blscfg", "opening %s\n", devid); - dev = grub_device_open (devid); - if (!dev) - return grub_errno; - -+ grub_dprintf ("blscfg", "probing fs\n"); - fs = grub_fs_probe (dev); - if (!fs) - { -@@ -174,7 +841,17 @@ grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)), - goto finish; - } - -- r = fs->dir (dev, GRUB_BLS_CONFIG_PATH, parse_entry, NULL); -+ info.dev = dev; -+ info.fs = fs; -+#ifdef GRUB_MACHINE_EFI -+ info.efi = 1; -+ grub_dprintf ("blscfg", "scanning /EFI/\n"); -+ r = fs->dir (dev, "/EFI/", find_entry, &info); -+#else -+ info.efi = 0; -+ grub_dprintf ("blscfg", "scanning %s\n", GRUB_BLS_CONFIG_PATH); -+ r = fs->dir (dev, "/", find_entry, &info); -+#endif - - finish: - if (dev) -@@ -184,18 +861,27 @@ finish: - } - - static grub_extcmd_t cmd; -+static grub_extcmd_t oldcmd; - - GRUB_MOD_INIT(bls) - { -- cmd = grub_register_extcmd ("bls_import", -- grub_cmd_bls_import, -+ grub_dprintf("blscfg", "%s got here\n", __func__); -+ cmd = grub_register_extcmd ("blscfg", -+ grub_cmd_blscfg, - 0, - NULL, - N_("Import Boot Loader Specification snippets."), - NULL); -+ oldcmd = grub_register_extcmd ("bls_import", -+ grub_cmd_blscfg, -+ 0, -+ NULL, -+ N_("Import Boot Loader Specification snippets."), -+ NULL); - } - - GRUB_MOD_FINI(bls) - { - grub_unregister_extcmd (cmd); -+ grub_unregister_extcmd (oldcmd); - } -diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c -index acd93d123ed..91c99456091 100644 ---- a/grub-core/commands/loadenv.c -+++ b/grub-core/commands/loadenv.c -@@ -28,6 +28,8 @@ - #include - #include - -+#include "loadenv.h" -+ - GRUB_MOD_LICENSE ("GPLv3+"); - - static const struct grub_arg_option options[] = -@@ -84,81 +86,6 @@ open_envblk_file (char *filename, int untrusted) - return file; - } - --static grub_envblk_t --read_envblk_file (grub_file_t file) --{ -- grub_off_t offset = 0; -- char *buf; -- grub_size_t size = grub_file_size (file); -- grub_envblk_t envblk; -- -- buf = grub_malloc (size); -- if (! buf) -- return 0; -- -- while (size > 0) -- { -- grub_ssize_t ret; -- -- ret = grub_file_read (file, buf + offset, size); -- if (ret <= 0) -- { -- grub_free (buf); -- return 0; -- } -- -- size -= ret; -- offset += ret; -- } -- -- envblk = grub_envblk_open (buf, offset); -- if (! envblk) -- { -- grub_free (buf); -- grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid environment block"); -- return 0; -- } -- -- return envblk; --} -- --struct grub_env_whitelist --{ -- grub_size_t len; -- char **list; --}; --typedef struct grub_env_whitelist grub_env_whitelist_t; -- --static int --test_whitelist_membership (const char* name, -- const grub_env_whitelist_t* whitelist) --{ -- grub_size_t i; -- -- for (i = 0; i < whitelist->len; i++) -- if (grub_strcmp (name, whitelist->list[i]) == 0) -- return 1; /* found it */ -- -- return 0; /* not found */ --} -- --/* Helper for grub_cmd_load_env. */ --static int --set_var (const char *name, const char *value, void *whitelist) --{ -- if (! whitelist) -- { -- grub_env_set (name, value); -- return 0; -- } -- -- if (test_whitelist_membership (name, -- (const grub_env_whitelist_t *) whitelist)) -- grub_env_set (name, value); -- -- return 0; --} -- - static grub_err_t - grub_cmd_load_env (grub_extcmd_context_t ctxt, int argc, char **args) - { -diff --git a/grub-core/commands/loadenv.h b/grub-core/commands/loadenv.h -new file mode 100644 -index 00000000000..952f46121bd ---- /dev/null -+++ b/grub-core/commands/loadenv.h -@@ -0,0 +1,93 @@ -+/* loadenv.c - command to load/save environment variable. */ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2008,2009,2010 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+static grub_envblk_t UNUSED -+read_envblk_file (grub_file_t file) -+{ -+ grub_off_t offset = 0; -+ char *buf; -+ grub_size_t size = grub_file_size (file); -+ grub_envblk_t envblk; -+ -+ buf = grub_malloc (size); -+ if (! buf) -+ return 0; -+ -+ while (size > 0) -+ { -+ grub_ssize_t ret; -+ -+ ret = grub_file_read (file, buf + offset, size); -+ if (ret <= 0) -+ { -+ grub_free (buf); -+ return 0; -+ } -+ -+ size -= ret; -+ offset += ret; -+ } -+ -+ envblk = grub_envblk_open (buf, offset); -+ if (! envblk) -+ { -+ grub_free (buf); -+ grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid environment block"); -+ return 0; -+ } -+ -+ return envblk; -+} -+ -+struct grub_env_whitelist -+{ -+ grub_size_t len; -+ char **list; -+}; -+typedef struct grub_env_whitelist grub_env_whitelist_t; -+ -+static int UNUSED -+test_whitelist_membership (const char* name, -+ const grub_env_whitelist_t* whitelist) -+{ -+ grub_size_t i; -+ -+ for (i = 0; i < whitelist->len; i++) -+ if (grub_strcmp (name, whitelist->list[i]) == 0) -+ return 1; /* found it */ -+ -+ return 0; /* not found */ -+} -+ -+/* Helper for grub_cmd_load_env. */ -+static int UNUSED -+set_var (const char *name, const char *value, void *whitelist) -+{ -+ if (! whitelist) -+ { -+ grub_env_set (name, value); -+ return 0; -+ } -+ -+ if (test_whitelist_membership (name, -+ (const grub_env_whitelist_t *) whitelist)) -+ grub_env_set (name, value); -+ -+ return 0; -+} -diff --git a/include/grub/compiler.h b/include/grub/compiler.h -index c9e1d7a73dc..9859ff4cc79 100644 ---- a/include/grub/compiler.h -+++ b/include/grub/compiler.h -@@ -48,4 +48,6 @@ - # define WARN_UNUSED_RESULT - #endif - -+#define UNUSED __attribute__((__unused__)) -+ - #endif /* ! GRUB_COMPILER_HEADER */ diff --git a/0165-Add-support-for-non-Ethernet-network-cards.patch b/0111-Add-support-for-non-Ethernet-network-cards.patch similarity index 98% rename from 0165-Add-support-for-non-Ethernet-network-cards.patch rename to 0111-Add-support-for-non-Ethernet-network-cards.patch index 9a83fe6..f1b7656 100644 --- a/0165-Add-support-for-non-Ethernet-network-cards.patch +++ b/0111-Add-support-for-non-Ethernet-network-cards.patch @@ -20,9 +20,8 @@ then chaddr field in BOOTP it will be set to 0 as per rfc4390. Resolves: rhbz#1370642 Signed-off-by: Andrzej Kacprowski - -Conflicts: - grub-core/net/ip.c +[msalter: Fix max string calculation in grub_net_hwaddr_to_str] +Signed-off-by: Mark Salter --- grub-core/net/arp.c | 155 ++++++++++++++++++++++----------- grub-core/net/bootp.c | 14 ++- @@ -34,9 +33,9 @@ Conflicts: grub-core/net/ethernet.c | 88 +++++++++---------- grub-core/net/icmp6.c | 15 ++-- grub-core/net/ip.c | 4 +- - grub-core/net/net.c | 48 +++++----- + grub-core/net/net.c | 50 ++++++----- include/grub/net.h | 19 ++-- - 12 files changed, 216 insertions(+), 152 deletions(-) + 12 files changed, 218 insertions(+), 152 deletions(-) diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c index 54306e3b16d..67b409a8acc 100644 @@ -627,7 +626,7 @@ index 8411e0ecca3..b2ca74b6eb1 100644 grub_net_process_dhcp (nb, inf->card); grub_netbuff_free (nb); diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index fa3e2912643..9b8944292c7 100644 +index fa3e2912643..9700e2d09a2 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -128,8 +128,9 @@ grub_net_link_layer_resolve (struct grub_net_network_level_interface *inf, @@ -650,7 +649,7 @@ index fa3e2912643..9b8944292c7 100644 hw_addr->mac[0] = 0x33; hw_addr->mac[1] = 0x33; hw_addr->mac[2] = ((grub_be_to_cpu64 (proto_addr->ipv6[1]) >> 24) & 0xff); -@@ -757,23 +759,21 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target, char *buf) +@@ -757,23 +759,23 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target, char *buf) void grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str) { @@ -658,6 +657,7 @@ index fa3e2912643..9b8944292c7 100644 - switch (addr->type) + char *ptr; + unsigned i; ++ int maxstr; + + if (addr->len > GRUB_NET_MAX_LINK_ADDRESS_SIZE) { @@ -678,16 +678,17 @@ index fa3e2912643..9b8944292c7 100644 + addr->type, addr->len); + return; + } ++ maxstr = addr->len * grub_strlen ("XX:"); + for (ptr = str, i = 0; i < addr->len; i++) + { -+ ptr += grub_snprintf (ptr, GRUB_NET_MAX_STR_HWADDR_LEN - (ptr - str), ++ ptr += grub_snprintf (ptr, maxstr - (ptr - str), + "%02x:", addr->mac[i] & 0xff); } - grub_printf (_("Unsupported hw address type %d\n"), addr->type); } int -@@ -784,13 +784,17 @@ grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a, +@@ -784,13 +786,17 @@ grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a, return -1; if (a->type > b->type) return +1; diff --git a/0112-Add-BLS-support-to-grub-mkconfig.patch b/0112-Add-BLS-support-to-grub-mkconfig.patch deleted file mode 100644 index 75698fd..0000000 --- a/0112-Add-BLS-support-to-grub-mkconfig.patch +++ /dev/null @@ -1,167 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 9 Dec 2016 15:40:29 -0500 -Subject: [PATCH] Add BLS support to grub-mkconfig - -GRUB now has BootLoaderSpec support, the user can choose to use this by -setting GRUB_ENABLE_BLSCFG to true in /etc/default/grub. On this setup, -the boot menu entries are not added to the grub.cfg, instead BLS config -files are parsed by blscfg command and the entries created dynamically. ---- - util/grub-mkconfig.in | 3 ++- - util/grub-mkconfig_lib.in | 29 +++++++++++++++++++---------- - util/grub.d/10_linux.in | 37 +++++++++++++++++++++++++++++++++++-- - 3 files changed, 56 insertions(+), 13 deletions(-) - -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 4248b9341ab..c20171919d9 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -259,7 +259,8 @@ export GRUB_DEFAULT \ - GRUB_OS_PROBER_SKIP_LIST \ - GRUB_DISABLE_SUBMENU \ - GRUB_DEFAULT_DTB \ -- SUSE_BTRFS_SNAPSHOT_BOOTING -+ SUSE_BTRFS_SNAPSHOT_BOOTING \ -+ GRUB_ENABLE_BLSCFG - - if test "x${grub_cfg}" != "x"; then - rm -f "${grub_cfg}.new" -diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index b3aae534ddc..1acc1d01c39 100644 ---- a/util/grub-mkconfig_lib.in -+++ b/util/grub-mkconfig_lib.in -@@ -30,6 +30,9 @@ fi - if test "x$grub_file" = x; then - grub_file="${bindir}/@grub_file@" - fi -+if test "x$grub_editenv" = x; then -+ grub_editenv="${bindir}/@grub_editenv@" -+fi - if test "x$grub_mkrelpath" = x; then - grub_mkrelpath="${bindir}/@grub_mkrelpath@" - fi -@@ -127,10 +130,16 @@ EOF - - prepare_grub_to_access_device () - { -+ local device=$1 && shift -+ if [ "$#" -gt 0 ]; then -+ local variable=$1 && shift -+ else -+ local variable=root -+ fi - old_ifs="$IFS" - IFS=' - ' -- partmap="`"${grub_probe}" --device $@ --target=partmap`" -+ partmap="`"${grub_probe}" --device ${device} --target=partmap`" - for module in ${partmap} ; do - case "${module}" in - netbsd | openbsd) -@@ -141,34 +150,34 @@ prepare_grub_to_access_device () - done - - # Abstraction modules aren't auto-loaded. -- abstraction="`"${grub_probe}" --device $@ --target=abstraction`" -+ abstraction="`"${grub_probe}" --device ${device} --target=abstraction`" - for module in ${abstraction} ; do - echo "insmod ${module}" - done - -- fs="`"${grub_probe}" --device $@ --target=fs`" -+ fs="`"${grub_probe}" --device ${device} --target=fs`" - for module in ${fs} ; do - echo "insmod ${module}" - done - - if [ x$GRUB_ENABLE_CRYPTODISK = xy ]; then -- for uuid in `"${grub_probe}" --device $@ --target=cryptodisk_uuid`; do -+ for uuid in `"${grub_probe}" --device ${device} --target=cryptodisk_uuid`; do - echo "cryptomount -u $uuid" - done - fi - - # If there's a filesystem UUID that GRUB is capable of identifying, use it; - # otherwise set root as per value in device.map. -- fs_hint="`"${grub_probe}" --device $@ --target=compatibility_hint`" -+ fs_hint="`"${grub_probe}" --device ${device} --target=compatibility_hint`" - if [ "x$fs_hint" != x ]; then -- echo "set root='$fs_hint'" -+ echo "set ${variable}='$fs_hint'" - fi -- if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then -- hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints= -+ if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then -+ hints="`"${grub_probe}" --device ${device} --target=hints_string 2> /dev/null`" || hints= - echo "if [ x\$feature_platform_search_hint = xy ]; then" -- echo " search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}" -+ echo " search --no-floppy --fs-uuid --set=${variable} ${hints} ${fs_uuid}" - echo "else" -- echo " search --no-floppy --fs-uuid --set=root ${fs_uuid}" -+ echo " search --no-floppy --fs-uuid --set=${variable} ${fs_uuid}" - echo "fi" - fi - IFS="$old_ifs" -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index d9a05937e46..839f1fdb655 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -121,6 +121,34 @@ linux_entry () - if [ -z "$boot_device_id" ]; then - boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" - fi -+ -+ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then -+ if [ x$dirname = x/ ]; then -+ if [ -z "${prepare_root_cache}" ]; then -+ prepare_grub_to_access_device ${GRUB_DEVICE} -+ fi -+ else -+ if [ -z "${prepare_boot_cache}" ]; then -+ prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} -+ fi -+ fi -+ -+ bootefi_device="`${grub_probe} --target=device /boot/efi/`" -+ prepare_grub_to_access_device ${bootefi_device} boot -+ -+ cat << EOF -+insmod blscfg -+blscfg -+if [ -s \$prefix/grubenv ]; then -+ load_env -+fi -+EOF -+ -+ ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" -+ -+ exit 0 -+ fi -+ - if [ x$type != xsimple ] ; then - title=$(mktitle "$type" "$version") - if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then -@@ -223,7 +251,10 @@ submenu_indentation="" - is_top_level=true - while [ "x$list" != "x" ] ; do - linux=`version_find_latest $list` -- gettext_printf "Found linux image: %s\n" "$linux" >&2 -+ if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then -+ gettext_printf "Found linux image: %s\n" "$linux" >&2 -+ fi -+ - basename=`basename $linux` - dirname=`dirname $linux` - rel_dirname=`make_system_path_relative_to_its_root $dirname` -@@ -262,7 +293,9 @@ while [ "x$list" != "x" ] ; do - for i in ${initrd}; do - initrd_display="${initrd_display} ${dirname}/${i}" - done -- gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 -+ if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then -+ gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 -+ fi - fi - - fdt= diff --git a/0166-misc-fix-invalid-character-recongition-in-strto-l.patch b/0112-misc-fix-invalid-character-recongition-in-strto-l.patch similarity index 100% rename from 0166-misc-fix-invalid-character-recongition-in-strto-l.patch rename to 0112-misc-fix-invalid-character-recongition-in-strto-l.patch diff --git a/0113-Remove-duplicated-grub_exit-definition-for-grub-emu-.patch b/0113-Remove-duplicated-grub_exit-definition-for-grub-emu-.patch deleted file mode 100644 index 53bf22e..0000000 --- a/0113-Remove-duplicated-grub_exit-definition-for-grub-emu-.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 6 Feb 2018 11:02:09 +0100 -Subject: [PATCH] Remove duplicated grub_exit() definition for grub-emu - platform - -The grub_exit() function signature was changed on all platforms to take a -return code, but latter on a following commit the grub_exit() for the emu -platform was duplicated. It causes a build error so remove the duplicated -function definition. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/kern/emu/main.c | 6 ------ - 1 file changed, 6 deletions(-) - -diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c -index 7e47ec81263..55ea5a11ccd 100644 ---- a/grub-core/kern/emu/main.c -+++ b/grub-core/kern/emu/main.c -@@ -72,12 +72,6 @@ grub_exit (int retval __attribute__((unused))) - grub_reboot (); - } - --void --grub_exit (int retval __attribute__((unused))) --{ -- grub_reboot (); --} -- - void - grub_machine_init (void) - { diff --git a/0167-net-read-bracketed-ipv6-addrs-and-port-numbers.patch b/0113-net-read-bracketed-ipv6-addrs-and-port-numbers.patch similarity index 73% rename from 0167-net-read-bracketed-ipv6-addrs-and-port-numbers.patch rename to 0113-net-read-bracketed-ipv6-addrs-and-port-numbers.patch index 4f68187..9199fe8 100644 --- a/0167-net-read-bracketed-ipv6-addrs-and-port-numbers.patch +++ b/0113-net-read-bracketed-ipv6-addrs-and-port-numbers.patch @@ -6,18 +6,33 @@ Subject: [PATCH] net: read bracketed ipv6 addrs and port numbers Allow specifying port numbers for http and tftp paths, and allow ipv6 addresses to be recognized with brackets around them, which is required to specify a port number + +Signed-off-by: Aaron Miller +[pjones: various bug fixes] +Signed-off-by: Peter Jones --- - grub-core/net/http.c | 21 +++++++++++--- - grub-core/net/net.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ - grub-core/net/tftp.c | 8 ++++-- + grub-core/net/http.c | 27 ++++++++++++---- + grub-core/net/net.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++--- + grub-core/net/tftp.c | 8 +++-- include/grub/net.h | 1 + - 4 files changed, 101 insertions(+), 6 deletions(-) + 4 files changed, 110 insertions(+), 13 deletions(-) diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index 5aa4ad3befc..f182d7b871d 100644 +index 5aa4ad3befc..00737c52750 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c -@@ -312,12 +312,14 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) +@@ -289,7 +289,9 @@ http_receive (grub_net_tcp_socket_t sock __attribute__ ((unused)), + nb2 = grub_netbuff_alloc (data->chunk_rem); + if (!nb2) + return grub_errno; +- grub_netbuff_put (nb2, data->chunk_rem); ++ err = grub_netbuff_put (nb2, data->chunk_rem); ++ if (err) ++ return grub_errno; + grub_memcpy (nb2->data, nb->data, data->chunk_rem); + if (file->device->net->packs.count >= 20) + { +@@ -312,12 +314,14 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) int i; struct grub_net_buff *nb; grub_err_t err; @@ -33,7 +48,7 @@ index 5aa4ad3befc..f182d7b871d 100644 + sizeof ("\r\nUser-Agent: " PACKAGE_STRING "\r\n") - 1 + sizeof ("Range: bytes=XXXXXXXXXXXXXXXXXXXX" -@@ -356,7 +358,7 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) +@@ -356,7 +360,7 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) sizeof (" HTTP/1.1\r\nHost: ") - 1); ptr = nb->tail; @@ -42,7 +57,7 @@ index 5aa4ad3befc..f182d7b871d 100644 if (err) { grub_netbuff_free (nb); -@@ -365,6 +367,15 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) +@@ -365,6 +369,15 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) grub_memcpy (ptr, file->device->net->server, grub_strlen (file->device->net->server)); @@ -58,47 +73,49 @@ index 5aa4ad3befc..f182d7b871d 100644 ptr = nb->tail; err = grub_netbuff_put (nb, sizeof ("\r\nUser-Agent: " PACKAGE_STRING "\r\n") -@@ -390,8 +401,10 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) +@@ -390,9 +403,11 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) grub_netbuff_put (nb, 2); grub_memcpy (ptr, "\r\n", 2); - data->sock = grub_net_tcp_open (file->device->net->server, - HTTP_PORT, http_receive, +- http_err, http_err, + grub_dprintf ("http", "opening path %s on host %s TCP port %d\n", + data->filename, server, port ? port : HTTP_PORT); + data->sock = grub_net_tcp_open (server, + port ? port : HTTP_PORT, http_receive, - http_err, http_err, ++ http_err, NULL, file); if (!data->sock) + { diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 9b8944292c7..1f887d44b32 100644 +index 9700e2d09a2..191e8e41bd6 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c -@@ -439,6 +439,12 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) +@@ -439,6 +439,13 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) grub_uint16_t newip[8]; const char *ptr = val; int word, quaddot = -1; + int bracketed = 0; + -+ if (ptr[0] == '[') { -+ bracketed = 1; -+ ptr++; -+ } ++ if (ptr[0] == '[') ++ { ++ bracketed = 1; ++ ptr++; ++ } if (ptr[0] == ':' && ptr[1] != ':') return 0; -@@ -477,6 +483,9 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) +@@ -477,6 +484,8 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) grub_memset (&newip[quaddot], 0, (7 - word) * sizeof (newip[0])); } grub_memcpy (ip, newip, 16); -+ if (bracketed && *ptr == ']') { ++ if (bracketed && *ptr == ']') + ptr++; -+ } if (rest) *rest = ptr; return 1; -@@ -1336,8 +1345,10 @@ grub_net_open_real (const char *name) +@@ -1338,8 +1347,10 @@ grub_net_open_real (const char *name) { grub_net_app_level_t proto; const char *protname, *server; @@ -109,14 +126,14 @@ index 9b8944292c7..1f887d44b32 100644 if (grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) == 0) { -@@ -1375,6 +1386,72 @@ grub_net_open_real (const char *name) +@@ -1377,6 +1388,72 @@ grub_net_open_real (const char *name) return NULL; } + char* port_start; + /* ipv6 or port specified? */ + if ((port_start = grub_strchr (server, ':'))) -+ { ++ { + char* ipv6_begin; + if((ipv6_begin = grub_strchr (server, '['))) + { @@ -182,6 +199,33 @@ index 9b8944292c7..1f887d44b32 100644 for (try = 0; try < 2; try++) { FOR_NET_APP_LEVEL (proto) +@@ -1386,14 +1463,13 @@ grub_net_open_real (const char *name) + { + grub_net_t ret = grub_zalloc (sizeof (*ret)); + if (!ret) +- return NULL; +- ret->protocol = proto; +- ret->server = grub_strdup (server); +- if (!ret->server) + { +- grub_free (ret); ++ grub_free (host); + return NULL; + } ++ ret->protocol = proto; ++ ret->port = port; ++ ret->server = host; + ret->fs = &grub_net_fs; + return ret; + } +@@ -1468,6 +1544,7 @@ grub_net_open_real (const char *name) + grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' not found"), + name); + ++ grub_free (host); + return NULL; + } + diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c index f90071353ad..e267af354f4 100644 --- a/grub-core/net/tftp.c diff --git a/0169-bootp-New-net_bootp6-command.patch b/0114-bootp-New-net_bootp6-command.patch similarity index 98% rename from 0169-bootp-New-net_bootp6-command.patch rename to 0114-bootp-New-net_bootp6-command.patch index 04a4dcc..ae02563 100644 --- a/0169-bootp-New-net_bootp6-command.patch +++ b/0114-bootp-New-net_bootp6-command.patch @@ -8,16 +8,18 @@ DHCPv6 protocol (RFC3315). Signed-off-by: Michael Chang Signed-off-by: Ken Lin +[pjones: Put back our code to add a local route] +Signed-off-by: Peter Jones --- - grub-core/net/bootp.c | 1048 ++++++++++++++++++++++++++++++------ + grub-core/net/bootp.c | 1053 ++++++++++++++++++++++++++++++------ grub-core/net/drivers/efi/efinet.c | 20 +- grub-core/net/ip.c | 39 ++ include/grub/efi/api.h | 2 +- include/grub/net.h | 91 ++-- - 5 files changed, 994 insertions(+), 206 deletions(-) + 5 files changed, 999 insertions(+), 206 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 4e55adc557b..ff1d7776e7f 100644 +index 4e55adc557b..242cd1f4cbd 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -25,6 +25,98 @@ @@ -119,7 +121,7 @@ index 4e55adc557b..ff1d7776e7f 100644 static char * grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)), -@@ -345,178 +437,578 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -345,178 +437,583 @@ grub_net_configure_by_dhcp_ack (const char *name, return inter; } @@ -588,7 +590,10 @@ index 4e55adc557b..ff1d7776e7f 100644 + grub_errno = GRUB_ERR_NONE; + t = 0; + } -+ + +- if (inter) +- grub_net_add_ipv6_local (inter, mask); +- return inter; + se->iface = iface; + se->iaid = iaid; + se->transaction_id = t; @@ -599,8 +604,8 @@ index 4e55adc557b..ff1d7776e7f 100644 + se->adv = NULL; + se->reply = NULL; + grub_list_push (GRUB_AS_LIST_P (&grub_dhcp6_sessions), GRUB_AS_LIST (se)); -+} -+ + } + +static void +grub_dhcp6_session_remove (grub_dhcp6_session_t se) +{ @@ -628,10 +633,7 @@ index 4e55adc557b..ff1d7776e7f 100644 +grub_dhcp6_session_configure_network (grub_dhcp6_session_t se) +{ + char *name; - -- if (inter) -- grub_net_add_ipv6_local (inter, mask); -- return inter; ++ + name = grub_xasprintf ("%s:dhcp6", se->iface->card->name); + if (!name) + return grub_errno; @@ -640,8 +642,8 @@ index 4e55adc557b..ff1d7776e7f 100644 + grub_free (name); + + return GRUB_ERR_NONE; - } - ++} ++ +static grub_err_t +grub_dhcp6_session_send_request (grub_dhcp6_session_t se) +{ @@ -818,6 +820,7 @@ index 4e55adc557b..ff1d7776e7f 100644 +{ + struct grub_net_network_level_interface *inf; + grub_dhcp6_options_t dhcp6; ++ int mask = -1; + + dhcp6 = grub_dhcp6_options_get (v6h, size); + if (!dhcp6) @@ -849,12 +852,16 @@ index 4e55adc557b..ff1d7776e7f 100644 + } + + grub_dhcp6_options_free (dhcp6); ++ ++ if (inf) ++ grub_net_add_ipv6_local (inf, mask); ++ + return inf; +} void grub_net_process_dhcp (struct grub_net_buff *nb, -@@ -550,6 +1042,77 @@ grub_net_process_dhcp (struct grub_net_buff *nb, +@@ -550,6 +1047,77 @@ grub_net_process_dhcp (struct grub_net_buff *nb, } } @@ -932,7 +939,7 @@ index 4e55adc557b..ff1d7776e7f 100644 static grub_err_t grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), int argc, char **args) -@@ -824,7 +1387,174 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), +@@ -824,7 +1392,174 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), return err; } @@ -1108,7 +1115,7 @@ index 4e55adc557b..ff1d7776e7f 100644 void grub_bootp_init (void) -@@ -835,6 +1565,9 @@ grub_bootp_init (void) +@@ -835,6 +1570,9 @@ grub_bootp_init (void) cmd_getdhcp = grub_register_command ("net_get_dhcp_option", grub_cmd_dhcpopt, N_("VAR INTERFACE NUMBER DESCRIPTION"), N_("retrieve DHCP option and save it into VAR. If VAR is - then print the value.")); @@ -1118,7 +1125,7 @@ index 4e55adc557b..ff1d7776e7f 100644 } void -@@ -842,4 +1575,5 @@ grub_bootp_fini (void) +@@ -842,4 +1580,5 @@ grub_bootp_fini (void) { grub_unregister_command (cmd_getdhcp); grub_unregister_command (cmd_bootp); diff --git a/0115-Enable-blscfg-command-for-the-emu-platform.patch b/0115-Enable-blscfg-command-for-the-emu-platform.patch deleted file mode 100644 index 5a2f7b7..0000000 --- a/0115-Enable-blscfg-command-for-the-emu-platform.patch +++ /dev/null @@ -1,164 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 2 Feb 2018 11:36:29 +0100 -Subject: [PATCH] Enable blscfg command for the emu platform - -Allow grub-emu to call a blscfg command. This may be useful for platforms -that don't support GRUB, so grub-emu can be used to parse the BLS configs -and kexec a new kernel using that information. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/Makefile.core.def | 1 + - grub-core/commands/blscfg.c | 46 +++++++++++++++++++++++++++++++++++---------- - 2 files changed, 37 insertions(+), 10 deletions(-) - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 96ccb402125..e52d776887a 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -777,6 +777,7 @@ module = { - common = commands/blscfg.c; - enable = efi; - enable = i386_pc; -+ enable = emu; - }; - - module = { -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 86796c8cd83..e0b65534af4 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -37,7 +37,12 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #include "loadenv.h" - - #define GRUB_BLS_CONFIG_PATH "/loader/entries/" -+#ifdef GRUB_MACHINE_EMU -+#define GRUB_BOOT_DEVICE "/boot" -+#else - #define GRUB_BOOT_DEVICE "($root)" -+#endif -+ - #ifdef GRUB_MACHINE_EFI - #define GRUB_LINUX_CMD "linuxefi" - #define GRUB_INITRD_CMD "initrdefi" -@@ -46,6 +51,13 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #define GRUB_INITRD_CMD "initrd" - #endif - -+enum -+ { -+ PLATFORM_EFI, -+ PLATFORM_EMU, -+ PLATFORM_BIOS, -+ }; -+ - #define grub_free(x) ({grub_dprintf("blscfg", "%s freeing %p\n", __func__, x); grub_free(x); }) - - struct keyval -@@ -641,7 +653,7 @@ finish: - struct find_entry_info { - grub_device_t dev; - grub_fs_t fs; -- int efi; -+ int platform; - }; - - /* -@@ -668,13 +680,16 @@ static int find_entry (const char *filename, - !grub_strcmp (filename, "..")) - return 0; - -- if (info->efi && !grub_strcasecmp (filename, "boot")) -+ if (info->platform == PLATFORM_EFI && !grub_strcasecmp (filename, "boot")) - return 0; - - saved_env_buf = grub_malloc (512); - - // set a default blsdir -- if (info->efi) -+ if (info->platform == PLATFORM_EMU) -+ default_blsdir = grub_xasprintf ("%s%s", GRUB_BOOT_DEVICE, -+ GRUB_BLS_CONFIG_PATH); -+ else if (info->platform == PLATFORM_EFI) - default_blsdir = grub_xasprintf ("/EFI/%s%s", filename, - GRUB_BLS_CONFIG_PATH); - else -@@ -686,7 +701,7 @@ static int find_entry (const char *filename, - /* - * try to load a grubenv from /EFI/wherever/grubenv - */ -- if (info->efi) -+ if (info->platform == PLATFORM_EFI) - grubenv_path = grub_xasprintf ("(%s)/EFI/%s/grubenv", devid, filename); - else - grubenv_path = grub_xasprintf ("(%s)/grub2/grubenv", devid); -@@ -740,7 +755,7 @@ static int find_entry (const char *filename, - goto finish; - - grub_dprintf ("blscfg", "blsdir: \"%s\"\n", blsdir); -- if (blsdir[0] != '/' && info->efi) -+ if (blsdir[0] != '/' && info->platform == PLATFORM_EFI) - blsdir = grub_xasprintf ("/EFI/%s/%s/", filename, blsdir); - else - blsdir = grub_strdup (blsdir); -@@ -818,15 +833,21 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - { - .dev = NULL, - .fs = NULL, -- .efi = 0, -+ .platform = PLATFORM_BIOS, - }; - - - grub_dprintf ("blscfg", "finding boot\n"); -+ -+#ifdef GRUB_MACHINE_EMU -+ devid = "host"; -+ grub_env_set ("boot", devid); -+#else - devid = grub_env_get ("boot"); - if (!devid) - return grub_error (GRUB_ERR_FILE_NOT_FOUND, - N_("variable `%s' isn't set"), "boot"); -+#endif - - grub_dprintf ("blscfg", "opening %s\n", devid); - dev = grub_device_open (devid); -@@ -844,11 +865,16 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - info.dev = dev; - info.fs = fs; - #ifdef GRUB_MACHINE_EFI -- info.efi = 1; -+ info.platform = PLATFORM_EFI; - grub_dprintf ("blscfg", "scanning /EFI/\n"); - r = fs->dir (dev, "/EFI/", find_entry, &info); -+#elif GRUB_MACHINE_EMU -+ info.platform = PLATFORM_EMU; -+ grub_dprintf ("blscfg", "scanning %s%s\n", GRUB_BOOT_DEVICE, -+ GRUB_BLS_CONFIG_PATH); -+ r = fs->dir (dev, "/boot/loader/", -+ find_entry, &info); - #else -- info.efi = 0; - grub_dprintf ("blscfg", "scanning %s\n", GRUB_BLS_CONFIG_PATH); - r = fs->dir (dev, "/", find_entry, &info); - #endif -@@ -863,7 +889,7 @@ finish: - static grub_extcmd_t cmd; - static grub_extcmd_t oldcmd; - --GRUB_MOD_INIT(bls) -+GRUB_MOD_INIT(blscfg) - { - grub_dprintf("blscfg", "%s got here\n", __func__); - cmd = grub_register_extcmd ("blscfg", -@@ -880,7 +906,7 @@ GRUB_MOD_INIT(bls) - NULL); - } - --GRUB_MOD_FINI(bls) -+GRUB_MOD_FINI(blscfg) - { - grub_unregister_extcmd (cmd); - grub_unregister_extcmd (oldcmd); diff --git a/0171-efinet-UEFI-IPv6-PXE-support.patch b/0115-efinet-UEFI-IPv6-PXE-support.patch similarity index 100% rename from 0171-efinet-UEFI-IPv6-PXE-support.patch rename to 0115-efinet-UEFI-IPv6-PXE-support.patch diff --git a/0172-grub.texi-Add-net_bootp6-doument.patch b/0116-grub.texi-Add-net_bootp6-doument.patch similarity index 100% rename from 0172-grub.texi-Add-net_bootp6-doument.patch rename to 0116-grub.texi-Add-net_bootp6-doument.patch diff --git a/0117-Fix-the-efidir-in-grub-setpassword.patch b/0117-Fix-the-efidir-in-grub-setpassword.patch deleted file mode 100644 index 2d815e2..0000000 --- a/0117-Fix-the-efidir-in-grub-setpassword.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 15 Mar 2018 14:12:54 -0400 -Subject: [PATCH] Fix the efidir in grub-setpassword - -Signed-off-by: Peter Jones ---- - util/grub-setpassword.in | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in -index d7924af5192..cf70257eed6 100644 ---- a/util/grub-setpassword.in -+++ b/util/grub-setpassword.in -@@ -1,7 +1,8 @@ - #!/bin/sh -e - -+EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') - if [ -d /sys/firmware/efi/efivars/ ]; then -- grubdir=`echo "/@bootdirname@/efi/EFI/redhat/" | sed 's,//*,/,g'` -+ grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'` - else - grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'` - fi diff --git a/0173-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch b/0117-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch similarity index 100% rename from 0173-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch rename to 0117-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch diff --git a/0174-efinet-Setting-network-from-UEFI-device-path.patch b/0118-efinet-Setting-network-from-UEFI-device-path.patch similarity index 100% rename from 0174-efinet-Setting-network-from-UEFI-device-path.patch rename to 0118-efinet-Setting-network-from-UEFI-device-path.patch diff --git a/0175-efinet-Setting-DNS-server-from-UEFI-protocol.patch b/0119-efinet-Setting-DNS-server-from-UEFI-protocol.patch similarity index 100% rename from 0175-efinet-Setting-DNS-server-from-UEFI-protocol.patch rename to 0119-efinet-Setting-DNS-server-from-UEFI-protocol.patch diff --git a/0176-Fix-one-more-coverity-complaint.patch b/0120-Fix-one-more-coverity-complaint.patch similarity index 100% rename from 0176-Fix-one-more-coverity-complaint.patch rename to 0120-Fix-one-more-coverity-complaint.patch diff --git a/0178-Support-UEFI-networking-protocols.patch b/0121-Support-UEFI-networking-protocols.patch similarity index 99% rename from 0178-Support-UEFI-networking-protocols.patch rename to 0121-Support-UEFI-networking-protocols.patch index 6973854..6675e2c 100644 --- a/0178-Support-UEFI-networking-protocols.patch +++ b/0121-Support-UEFI-networking-protocols.patch @@ -22,8 +22,12 @@ V3: * Use HEAD request method to test before GET * Finish HTTP transaction in one go * Fix bsc#1076132 + +Signed-off-by: Michael Chang +[pjones: make efi_netfs not duplicate symbols from efinet] +Signed-off-by: Peter Jones --- - grub-core/Makefile.core.def | 18 + + grub-core/Makefile.core.def | 12 + grub-core/io/bufio.c | 2 +- grub-core/kern/efi/efi.c | 96 ++- grub-core/net/drivers/efi/efinet.c | 27 + @@ -40,7 +44,7 @@ V3: include/grub/efi/dhcp.h | 343 +++++++++ include/grub/efi/http.h | 215 ++++++ include/grub/net/efi.h | 144 ++++ - 17 files changed, 4626 insertions(+), 41 deletions(-) + 17 files changed, 4620 insertions(+), 41 deletions(-) create mode 100644 grub-core/net/efi/dhcp.c create mode 100644 grub-core/net/efi/efi_netfs.c create mode 100644 grub-core/net/efi/http.c @@ -53,29 +57,23 @@ V3: create mode 100644 include/grub/net/efi.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 420831bc89e..2851437e098 100644 +index 3be42a95195..4168ec5d3ff 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -2181,6 +2181,18 @@ module = { +@@ -2182,6 +2182,12 @@ module = { common = hook/datehook.c; }; +module = { + name = efi_netfs; + common = net/efi/efi_netfs.c; -+ common = net/efi/net.c; -+ common = net/efi/http.c; -+ common = net/efi/pxe.c; -+ common = net/efi/ip4_config.c; -+ common = net/efi/ip6_config.c; -+ common = net/efi/dhcp.c; + enable = efi; +}; + module = { name = net; common = net/net.c; -@@ -2195,6 +2207,12 @@ module = { +@@ -2196,6 +2202,12 @@ module = { common = net/arp.c; common = net/netbuff.c; common = net/url.c; diff --git a/0179-AUDIT-0-http-boot-tracker-bug.patch b/0122-AUDIT-0-http-boot-tracker-bug.patch similarity index 100% rename from 0179-AUDIT-0-http-boot-tracker-bug.patch rename to 0122-AUDIT-0-http-boot-tracker-bug.patch diff --git a/0180-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch b/0123-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch similarity index 100% rename from 0180-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch rename to 0123-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch diff --git a/0181-efi-uga-use-64-bit-for-fb_base.patch b/0124-efi-uga-use-64-bit-for-fb_base.patch similarity index 100% rename from 0181-efi-uga-use-64-bit-for-fb_base.patch rename to 0124-efi-uga-use-64-bit-for-fb_base.patch diff --git a/0182-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch b/0125-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch similarity index 100% rename from 0182-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch rename to 0125-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch diff --git a/0183-EFI-console-Add-grub_console_read_key_stroke-helper-.patch b/0126-EFI-console-Add-grub_console_read_key_stroke-helper-.patch similarity index 100% rename from 0183-EFI-console-Add-grub_console_read_key_stroke-helper-.patch rename to 0126-EFI-console-Add-grub_console_read_key_stroke-helper-.patch diff --git a/0126-Only-attempt-to-scan-different-BLS-directories-on-EF.patch b/0126-Only-attempt-to-scan-different-BLS-directories-on-EF.patch deleted file mode 100644 index 52a1085..0000000 --- a/0126-Only-attempt-to-scan-different-BLS-directories-on-EF.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 3 Apr 2018 15:42:47 +0200 -Subject: [PATCH] Only attempt to scan different BLS directories on EFI - machines - -Current BLS support attempted to scan for BLS directories, but this only -makes sense on EFI, where BLS fragments are in /loader/$vendor/entries. - -For BIOS, only either the default /loader/entries path should be scanned -or the BLS directory defined in the blsdir GRUB 2 environment variable. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index e0b65534af4..e775c6b8794 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -676,8 +676,8 @@ static int find_entry (const char *filename, - const char *devid = grub_env_get ("boot"); - - grub_dprintf("blscfg", "%s got here\n", __func__); -- if (!grub_strcmp (filename, ".") || -- !grub_strcmp (filename, "..")) -+ if (filename && (!grub_strcmp (filename, ".") || -+ !grub_strcmp (filename, ".."))) - return 0; - - if (info->platform == PLATFORM_EFI && !grub_strcasecmp (filename, "boot")) -@@ -872,11 +872,10 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - info.platform = PLATFORM_EMU; - grub_dprintf ("blscfg", "scanning %s%s\n", GRUB_BOOT_DEVICE, - GRUB_BLS_CONFIG_PATH); -- r = fs->dir (dev, "/boot/loader/", -- find_entry, &info); -+ find_entry(NULL, NULL, &info); - #else - grub_dprintf ("blscfg", "scanning %s\n", GRUB_BLS_CONFIG_PATH); -- r = fs->dir (dev, "/", find_entry, &info); -+ find_entry(NULL, NULL, &info); - #endif - - finish: diff --git a/0184-EFI-console-Implement-getkeystatus-support.patch b/0127-EFI-console-Implement-getkeystatus-support.patch similarity index 100% rename from 0184-EFI-console-Implement-getkeystatus-support.patch rename to 0127-EFI-console-Implement-getkeystatus-support.patch diff --git a/0185-Make-grub_getkeystatus-helper-funtion-available-ever.patch b/0128-Make-grub_getkeystatus-helper-funtion-available-ever.patch similarity index 100% rename from 0185-Make-grub_getkeystatus-helper-funtion-available-ever.patch rename to 0128-Make-grub_getkeystatus-helper-funtion-available-ever.patch diff --git a/0128-Measure-kernel-initrd.patch b/0128-Measure-kernel-initrd.patch deleted file mode 100644 index ff1f10b..0000000 --- a/0128-Measure-kernel-initrd.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Thu, 16 Jul 2015 15:22:34 -0700 -Subject: [PATCH] Measure kernel + initrd - -Measure the kernel and initrd when loaded on UEFI systems ---- - grub-core/loader/i386/efi/linux.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 800c3e54022..d837249b4a1 100644 ---- a/grub-core/loader/i386/efi/linux.c -+++ b/grub-core/loader/i386/efi/linux.c -@@ -27,6 +27,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -131,6 +132,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - argv[i]); - goto fail; - } -+ grub_tpm_measure (ptr, cursize, GRUB_INITRD_PCR, "UEFI Linux initrd"); - ptr += cursize; - grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); - ptr += ALIGN_UP_OVERHEAD (cursize, 4); -@@ -195,6 +197,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -+ grub_tpm_measure (kernel, filelen, GRUB_KERNEL_PCR, "UEFI Linux kernel"); -+ - rc = grub_linuxefi_secure_validate (kernel, filelen); - if (rc < 0) - { diff --git a/0186-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch b/0129-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch similarity index 100% rename from 0186-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch rename to 0129-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch diff --git a/0129-Add-BIOS-boot-measurement.patch b/0129-Add-BIOS-boot-measurement.patch deleted file mode 100644 index a428d32..0000000 --- a/0129-Add-BIOS-boot-measurement.patch +++ /dev/null @@ -1,176 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Sun, 9 Aug 2015 15:48:51 -0700 -Subject: [PATCH] Add BIOS boot measurement - -Measure the on-disk grub core on BIOS systems - unlike UEFI, the firmware -can't do this stage for us. ---- - grub-core/boot/i386/pc/boot.S | 30 +++++++++++++++++++++++++- - grub-core/boot/i386/pc/diskboot.S | 44 +++++++++++++++++++++++++++++++++++++++ - 2 files changed, 73 insertions(+), 1 deletion(-) - -diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S -index ea167fe1206..c1df86dec0b 100644 ---- a/grub-core/boot/i386/pc/boot.S -+++ b/grub-core/boot/i386/pc/boot.S -@@ -24,11 +24,14 @@ - * defines for the code go here - */ - -+#define TPM 1 -+ - /* Print message string */ - #define MSG(x) movw $x, %si; call LOCAL(message) - #define ERR(x) movw $x, %si; jmp LOCAL(error_message) - - .macro floppy -+#ifndef TPM - part_start: - - LOCAL(probe_values): -@@ -85,6 +88,7 @@ fd_probe_error_string: .asciz "Floppy" - movb MACRO_DOLLAR(79), %ch - - jmp LOCAL(final_init) -+#endif - .endm - - .macro scratch -@@ -252,6 +256,7 @@ real_start: - /* set %si to the disk address packet */ - movw $disk_address_packet, %si - -+#ifndef TPM - /* check if LBA is supported */ - movb $0x41, %ah - movw $0x55aa, %bx -@@ -271,6 +276,7 @@ real_start: - - andw $1, %cx - jz LOCAL(chs_mode) -+#endif - - LOCAL(lba_mode): - xorw %ax, %ax -@@ -314,6 +320,9 @@ LOCAL(lba_mode): - jmp LOCAL(copy_buffer) - - LOCAL(chs_mode): -+#ifdef TPM -+ jmp LOCAL(general_error) -+#else - /* - * Determine the hard disk geometry from the BIOS! - * We do this first, so that LS-120 IDE floppies work correctly. -@@ -425,7 +434,7 @@ setup_sectors: - jc LOCAL(read_error) - - movw %es, %bx -- -+#endif /* TPM */ - LOCAL(copy_buffer): - /* - * We need to save %cx and %si because the startup code in -@@ -448,6 +457,25 @@ LOCAL(copy_buffer): - popw %ds - popa - -+#ifdef TPM -+ pusha -+ -+ movw $0xBB00, %ax /* TCG_StatusCheck */ -+ int $0x1A -+ test %eax, %eax -+ jnz boot /* No TPM or TPM deactivated */ -+ -+ movw $0xBB07, %ax /* TCG_CompactHashLogExtendEvent */ -+ movw $GRUB_BOOT_MACHINE_KERNEL_ADDR, %di -+ xorl %esi, %esi -+ movl $0x41504354, %ebx /* TCPA */ -+ movl $0x200, %ecx /* Measure 512 bytes */ -+ movl $0x8, %edx /* PCR 8 */ -+ int $0x1A -+ -+ popa -+#endif -+boot: - /* boot kernel */ - jmp *(LOCAL(kernel_address)) - -diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S -index 68d31de0c4c..f4744ec6fcb 100644 ---- a/grub-core/boot/i386/pc/diskboot.S -+++ b/grub-core/boot/i386/pc/diskboot.S -@@ -19,6 +19,8 @@ - #include - #include - -+#define TPM 1 -+ - /* - * defines for the code go here - */ -@@ -53,6 +55,21 @@ _start: - /* this sets up for the first run through "bootloop" */ - movw $LOCAL(firstlist), %di - -+#ifdef TPM -+ /* clear EAX to remove potential garbage */ -+ xorl %eax, %eax -+ /* 8(%di) = number of sectors to read */ -+ movw 8(%di), %ax -+ -+ /* Multiply number of sectors to read with 512 bytes. EAX is 32bit -+ * which is large enough to hold values of up to 4GB. I doubt there -+ * will ever be a core.img larger than that. ;-) */ -+ shll $9, %eax -+ -+ /* write result to bytes_to_measure var */ -+ movl %eax, bytes_to_measure -+#endif -+ - /* save the sector number of the second sector in %ebp */ - movl (%di), %ebp - -@@ -290,6 +307,29 @@ LOCAL(copy_buffer): - /* END OF MAIN LOOP */ - - LOCAL(bootit): -+#ifdef TPM -+ pusha -+ movw $0xBB07, %ax /* TCG_CompactHashLogExtendEvent */ -+ -+ movw $0x0, %bx -+ movw %bx, %es -+ -+ /* We've already measured the first 512 bytes, now measure the rest */ -+ xorl %edi, %edi -+ movw $(GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200), %di -+ -+ movl $0x41504354, %ebx /* EBX = "TCPA" */ -+ -+ /* %ecx = The length, in bytes, of the buffer to measure */ -+ movl $bytes_to_measure, %esi -+ movl (%esi), %ecx -+ xorl %esi, %esi -+ movl $0x9, %edx /* PCR 9 */ -+ -+ int $0x1A -+ -+ popa -+#endif - /* print a newline */ - MSG(notification_done) - popw %dx /* this makes sure %dl is our "boot" drive */ -@@ -324,6 +364,10 @@ geometry_error_string: .asciz "Geom" - read_error_string: .asciz "Read" - general_error_string: .asciz " Error" - -+#ifdef TPM -+bytes_to_measure: .long 0 -+#endif -+ - /* - * message: write the string pointed to by %si - * diff --git a/0130-Measure-kernel-and-initrd-on-BIOS-systems.patch b/0130-Measure-kernel-and-initrd-on-BIOS-systems.patch deleted file mode 100644 index 69d58fb..0000000 --- a/0130-Measure-kernel-and-initrd-on-BIOS-systems.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Sun, 9 Aug 2015 16:28:29 -0700 -Subject: [PATCH] Measure kernel and initrd on BIOS systems - -Measure the kernel and initrd when loaded on BIOS systems ---- - grub-core/loader/i386/linux.c | 5 +++++ - grub-core/loader/i386/pc/linux.c | 3 +++ - grub-core/loader/linux.c | 2 ++ - 3 files changed, 10 insertions(+) - -diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index c84747ea857..94526966e8a 100644 ---- a/grub-core/loader/i386/linux.c -+++ b/grub-core/loader/i386/linux.c -@@ -36,6 +36,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -724,7 +725,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -+ grub_tpm_measure (kernel, len, GRUB_KERNEL_PCR, "Linux Kernel"); -+ - grub_memcpy (&lh, kernel, sizeof (lh)); -+ - kernel_offset = sizeof (lh); - - if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) -@@ -1038,6 +1042,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - len = prot_file_size; - grub_memcpy (prot_mode_mem, kernel + kernel_offset, len); -+ kernel_offset += len; - - if (grub_errno == GRUB_ERR_NONE) - { -diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index 783a3cd93bc..15544230763 100644 ---- a/grub-core/loader/i386/pc/linux.c -+++ b/grub-core/loader/i386/pc/linux.c -@@ -36,6 +36,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -161,6 +162,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -+ grub_tpm_measure (kernel, len, GRUB_KERNEL_PCR, "BIOS Linux Kernel"); -+ - grub_memcpy (&lh, kernel, sizeof (lh)); - kernel_offset = sizeof (lh); - -diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c -index be6fa0f4d45..3005c0d19c9 100644 ---- a/grub-core/loader/linux.c -+++ b/grub-core/loader/linux.c -@@ -4,6 +4,7 @@ - #include - #include - #include -+#include - - struct newc_head - { -@@ -288,6 +289,7 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, - grub_initrd_close (initrd_ctx); - return grub_errno; - } -+ grub_tpm_measure (ptr, cursize, GRUB_INITRD_PCR, "Linux Initrd"); - ptr += cursize; - } - if (newc) diff --git a/0187-grub-editenv-Add-incr-command-to-increment-integer-v.patch b/0130-grub-editenv-Add-incr-command-to-increment-integer-v.patch similarity index 100% rename from 0187-grub-editenv-Add-incr-command-to-increment-integer-v.patch rename to 0130-grub-editenv-Add-incr-command-to-increment-integer-v.patch diff --git a/0188-Add-auto-hide-menu-support.patch b/0131-Add-auto-hide-menu-support.patch similarity index 91% rename from 0188-Add-auto-hide-menu-support.patch rename to 0131-Add-auto-hide-menu-support.patch index efbc9eb..06ca8da 100644 --- a/0188-Add-auto-hide-menu-support.patch +++ b/0131-Add-auto-hide-menu-support.patch @@ -43,13 +43,13 @@ Changes in v2: the fwsetup by doing "systemctl reboot --firmware" --- Makefile.util.def | 6 +++++ - util/grub.d/00_menu_auto_hide.in | 50 ++++++++++++++++++++++++++++++++++++++++ + util/grub.d/01_menu_auto_hide.in | 48 ++++++++++++++++++++++++++++++++++++++++ util/grub.d/30_os-prober.in | 18 +++++++++++++++ - 3 files changed, 74 insertions(+) - create mode 100644 util/grub.d/00_menu_auto_hide.in + 3 files changed, 72 insertions(+) + create mode 100644 util/grub.d/01_menu_auto_hide.in diff --git a/Makefile.util.def b/Makefile.util.def -index cbd661d6348..0fdfdd91fb0 100644 +index 4e722ab766b..8b376d6e740 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -448,6 +448,12 @@ script = { @@ -57,20 +57,20 @@ index cbd661d6348..0fdfdd91fb0 100644 }; +script = { -+ name = '00_menu_auto_hide'; -+ common = util/grub.d/00_menu_auto_hide.in; ++ name = '01_menu_auto_hide'; ++ common = util/grub.d/01_menu_auto_hide.in; + installdir = grubconf; +}; + script = { name = '01_users'; common = util/grub.d/01_users.in; -diff --git a/util/grub.d/00_menu_auto_hide.in b/util/grub.d/00_menu_auto_hide.in +diff --git a/util/grub.d/01_menu_auto_hide.in b/util/grub.d/01_menu_auto_hide.in new file mode 100644 -index 00000000000..a10fe45bb2c +index 00000000000..ad175870a54 --- /dev/null -+++ b/util/grub.d/00_menu_auto_hide.in -@@ -0,0 +1,50 @@ ++++ b/util/grub.d/01_menu_auto_hide.in +@@ -0,0 +1,48 @@ +#! /bin/sh + +# Disable / skip generating menu-auto-hide config parts on serial terminals @@ -92,21 +92,19 @@ index 00000000000..a10fe45bb2c +# Reset boot_indeterminate after a successful boot +if [ "\${boot_success}" = "1" ] ; then + set boot_indeterminate=0 -+ save_env boot_indeterminate +# Avoid boot_indeterminate causing the menu to be hidden more then once +elif [ "\${boot_indeterminate}" = "1" ]; then + set boot_indeterminate=2 -+ save_env boot_indeterminate +fi +set boot_success=0 -+save_env boot_success ++save_env boot_success boot_indeterminate + +if [ x\$feature_timeout_style = xy ] ; then + if [ "\${menu_show_once}" ]; then + unset menu_show_once + save_env menu_show_once + set timeout_style=menu -+ unset timeout ++ set timeout=60 + elif [ "\${menu_auto_hide}" -a "\${last_boot_ok}" = "1" ]; then + set orig_timeout_style=\${timeout_style} + set orig_timeout=\${timeout} diff --git a/0131-Measure-the-kernel-commandline.patch b/0131-Measure-the-kernel-commandline.patch deleted file mode 100644 index 7fe2809..0000000 --- a/0131-Measure-the-kernel-commandline.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Sun, 9 Aug 2015 16:32:29 -0700 -Subject: [PATCH] Measure the kernel commandline - -Measure the kernel commandline to ensure that it hasn't been modified ---- - grub-core/lib/cmdline.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c -index 970ea868c14..6b56304d4a7 100644 ---- a/grub-core/lib/cmdline.c -+++ b/grub-core/lib/cmdline.c -@@ -19,6 +19,7 @@ - - #include - #include -+#include - - static int - is_hex(char c) -@@ -79,7 +80,7 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, - { - int i, space; - unsigned int arg_size; -- char *c; -+ char *c, *orig = buf; - - for (i = 0; i < argc; i++) - { -@@ -125,5 +126,8 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, - - *buf = 0; - -+ grub_tpm_measure ((void *)orig, grub_strlen (orig), GRUB_CMDLINE_PCR, -+ "Kernel Commandline"); -+ - return i; - } diff --git a/0132-Measure-commands.patch b/0132-Measure-commands.patch deleted file mode 100644 index bac4c8d..0000000 --- a/0132-Measure-commands.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Mon, 10 Aug 2015 15:27:12 -0700 -Subject: [PATCH] Measure commands - -Measure each command executed by grub, which includes script execution. ---- - grub-core/script/execute.c | 25 +++++++++++++++++++++++-- - include/grub/tpm.h | 1 + - 2 files changed, 24 insertions(+), 2 deletions(-) - -diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index cf6cd6601d6..9ae04a05160 100644 ---- a/grub-core/script/execute.c -+++ b/grub-core/script/execute.c -@@ -30,6 +30,7 @@ - #ifdef GRUB_MACHINE_IEEE1275 - #include - #endif -+#include - - /* Max digits for a char is 3 (0xFF is 255), similarly for an int it - is sizeof (int) * 3, and one extra for a possible -ve sign. */ -@@ -967,8 +968,9 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) - grub_err_t ret = 0; - grub_script_function_t func = 0; - char errnobuf[18]; -- char *cmdname; -- int argc; -+ char *cmdname, *cmdstring; -+ int argc, offset = 0, cmdlen = 0; -+ unsigned int i; - char **args; - int invert; - struct grub_script_argv argv = { 0, 0, 0 }; -@@ -977,6 +979,25 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) - if (grub_script_arglist_to_argv (cmdline->arglist, &argv) || ! argv.args[0]) - return grub_errno; - -+ for (i = 0; i < argv.argc; i++) { -+ cmdlen += grub_strlen (argv.args[i]) + 1; -+ } -+ -+ cmdstring = grub_malloc (cmdlen); -+ if (!cmdstring) -+ { -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ N_("cannot allocate command buffer")); -+ } -+ -+ for (i = 0; i < argv.argc; i++) { -+ offset += grub_snprintf (cmdstring + offset, cmdlen - offset, "%s ", -+ argv.args[i]); -+ } -+ cmdstring[cmdlen-1]= '\0'; -+ grub_tpm_measure ((unsigned char *)cmdstring, cmdlen, GRUB_COMMAND_PCR, -+ cmdstring); -+ grub_free(cmdstring); - invert = 0; - argc = argv.argc - 1; - args = argv.args + 1; -diff --git a/include/grub/tpm.h b/include/grub/tpm.h -index 40d3cf65ba6..7fc9d77d277 100644 ---- a/include/grub/tpm.h -+++ b/include/grub/tpm.h -@@ -30,6 +30,7 @@ - #define GRUB_KERNEL_PCR 10 - #define GRUB_INITRD_PCR 11 - #define GRUB_CMDLINE_PCR 12 -+#define GRUB_COMMAND_PCR 13 - - #define TPM_TAG_RQU_COMMAND 0x00C1 - #define TPM_ORD_Extend 0x14 diff --git a/0189-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch b/0132-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch similarity index 91% rename from 0189-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch rename to 0132-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch index 4daefdb..b0215a4 100644 --- a/0189-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch +++ b/0132-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch @@ -15,6 +15,7 @@ According to: https://git.launchpad.net/~ubuntu-core-dev/grub/+git/ubuntu/tree/debian/copyright The patch is licensed under GPL-3+ +[hdegoede: fix use with /sys/firmware/efi/efivars] Signed-off-by: Hans de Goede --- Makefile.util.def | 6 ++++++ @@ -23,10 +24,10 @@ Signed-off-by: Hans de Goede create mode 100644 util/grub.d/30_uefi-firmware.in diff --git a/Makefile.util.def b/Makefile.util.def -index 0fdfdd91fb0..5a8c390a1da 100644 +index 8b376d6e740..56bf1159a42 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -529,6 +529,12 @@ script = { +@@ -536,6 +536,12 @@ script = { installdir = grubconf; }; @@ -41,7 +42,7 @@ index 0fdfdd91fb0..5a8c390a1da 100644 common = util/grub.d/40_custom.in; diff --git a/util/grub.d/30_uefi-firmware.in b/util/grub.d/30_uefi-firmware.in new file mode 100644 -index 00000000000..3c9f533d8c6 +index 00000000000..93ececffea7 --- /dev/null +++ b/util/grub.d/30_uefi-firmware.in @@ -0,0 +1,46 @@ @@ -73,12 +74,12 @@ index 00000000000..3c9f533d8c6 + +. "@datadir@/@PACKAGE@/grub-mkconfig_lib" + -+efi_vars_dir=/sys/firmware/efi/vars ++efi_vars_dir=/sys/firmware/efi/efivars +EFI_GLOBAL_VARIABLE=8be4df61-93ca-11d2-aa0d-00e098032b8c -+OsIndications="$efi_vars_dir/OsIndicationsSupported-$EFI_GLOBAL_VARIABLE/data" ++OsIndications="$efi_vars_dir/OsIndicationsSupported-$EFI_GLOBAL_VARIABLE" + +if [ -e "$OsIndications" ] && \ -+ [ "$(( $(printf 0x%x \'"$(cat $OsIndications | cut -b1)") & 1 ))" = 1 ]; then ++ [ "$(( $(printf 0x%x \'"$(cat $OsIndications | cut -b5)") & 1 ))" = 1 ]; then + LABEL="System setup" + + gettext_printf "Adding boot menu entry for EFI firmware configuration\n" >&2 diff --git a/0190-Add-grub-set-bootflag-utility.patch b/0133-Add-grub-set-bootflag-utility.patch similarity index 78% rename from 0190-Add-grub-set-bootflag-utility.patch rename to 0133-Add-grub-set-bootflag-utility.patch index 9adc1c0..2b4174e 100644 --- a/0190-Add-grub-set-bootflag-utility.patch +++ b/0133-Add-grub-set-bootflag-utility.patch @@ -8,50 +8,48 @@ to set known bootflags in the grubenv: boot_success or menu_show_once. grub-set-bootflag is different from grub-editenv in 2 ways: -1) It is intended to be executed by regular users through pkexec, so -running as root if the polkit policy allows this. As such it is written -to not use any existing grubenv related code for easy auditing. +1) It is intended to be executed by regular users so must be installed +as suid root. As such it is written to not use any existing grubenv +related code for easy auditing. + +It can't be executed through pkexec because we want to call it under gdm +and pkexec does not work under gdm due the gdm user having /sbin/nologin +as shell. 2) Since it can be executed by regular users it only allows setting (assigning a value of 1 to) bootflags which it knows about. Currently those are just boot_success and menu_show_once. -This commit also adds a couple of example systemd and polkit files which -show how this can be used to set boot_success from a user-session: +This commit also adds a couple of example systemd and files which show +how this can be used to set boot_success from a user-session: docs/grub-boot-success.service docs/grub-boot-success.timer -docs/org.gnu.grub.policy The 2 grub-boot-success.systemd files should be placed in /lib/systemd/user and a symlink to grub-boot-success.timer should be added to /lib/systemd/user/timers.target.wants. -The org.gnu.grub.policy polkit file should be placed in -/usr/share/polkit-1/actions. - Signed-off-by: Hans de Goede --- Makefile.util.def | 7 ++ - util/grub-set-bootflag.c | 158 +++++++++++++++++++++++++++++++++++++++++ + util/grub-set-bootflag.c | 160 +++++++++++++++++++++++++++++++++++++++++ .gitignore | 2 + conf/Makefile.extra-dist | 3 + docs/grub-boot-success.service | 6 ++ - docs/grub-boot-success.timer | 5 ++ - docs/org.gnu.grub.policy | 20 ++++++ + docs/grub-boot-success.timer | 6 ++ util/grub-set-bootflag.1 | 20 ++++++ - 8 files changed, 221 insertions(+) + 7 files changed, 204 insertions(+) create mode 100644 util/grub-set-bootflag.c create mode 100644 docs/grub-boot-success.service create mode 100644 docs/grub-boot-success.timer - create mode 100644 docs/org.gnu.grub.policy create mode 100644 util/grub-set-bootflag.1 diff --git a/Makefile.util.def b/Makefile.util.def -index 5a8c390a1da..5da55393291 100644 +index 56bf1159a42..08cc98ddb8b 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -1435,3 +1435,10 @@ program = { +@@ -1442,3 +1442,10 @@ program = { ldadd = grub-core/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -64,10 +62,10 @@ index 5a8c390a1da..5da55393291 100644 +}; diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c new file mode 100644 -index 00000000000..f8dc310909a +index 00000000000..bb198f02351 --- /dev/null +++ b/util/grub-set-bootflag.c -@@ -0,0 +1,158 @@ +@@ -0,0 +1,160 @@ +/* grub-set-bootflag.c - tool to set boot-flags in the grubenv. */ +/* + * GRUB -- GRand Unified Bootloader @@ -96,6 +94,7 @@ index 00000000000..f8dc310909a +#include /* For *_DIR_NAME defines */ +#include +#include /* For GRUB_ENVBLK_DEFCFG define */ ++#include +#include +#include +#include @@ -156,6 +155,7 @@ index 00000000000..f8dc310909a + fclose (f); + if (ret != GRUBENV_SIZE) + { ++ errno = EINVAL; + perror ("Error reading from " GRUBENV); + return 1; + } @@ -227,7 +227,7 @@ index 00000000000..f8dc310909a + return 0; +} diff --git a/.gitignore b/.gitignore -index 42475592123..6c4cfc53781 100644 +index 7aaae594d51..a999024652e 100644 --- a/.gitignore +++ b/.gitignore @@ -111,6 +111,8 @@ grub-*.tar.* @@ -238,7 +238,7 @@ index 42475592123..6c4cfc53781 100644 +/grub*-set-bootflag.1 /grub*-set-default /grub*-set-default.8 - /grub*-setsetpassword + /grub*-set-password diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index 39eb94bded6..5946ec24a65 100644 --- a/conf/Makefile.extra-dist @@ -255,7 +255,7 @@ index 39eb94bded6..5946ec24a65 100644 diff --git a/docs/grub-boot-success.service b/docs/grub-boot-success.service new file mode 100644 -index 00000000000..c8c91c34d49 +index 00000000000..80e79584c91 --- /dev/null +++ b/docs/grub-boot-success.service @@ -0,0 +1,6 @@ @@ -264,44 +264,19 @@ index 00000000000..c8c91c34d49 + +[Service] +Type=oneshot -+ExecStart=/usr/bin/pkexec /usr/sbin/grub2-set-bootflag boot_success ++ExecStart=/usr/sbin/grub2-set-bootflag boot_success diff --git a/docs/grub-boot-success.timer b/docs/grub-boot-success.timer new file mode 100644 -index 00000000000..221b532781b +index 00000000000..5d8fcba21aa --- /dev/null +++ b/docs/grub-boot-success.timer -@@ -0,0 +1,5 @@ +@@ -0,0 +1,6 @@ +[Unit] +Description=Mark boot as successful after the user session has run 2 minutes ++ConditionUser=!@system + +[Timer] +OnActiveSec=2min -diff --git a/docs/org.gnu.grub.policy b/docs/org.gnu.grub.policy -new file mode 100644 -index 00000000000..18391efc8e7 ---- /dev/null -+++ b/docs/org.gnu.grub.policy -@@ -0,0 +1,20 @@ -+ -+ -+ -+ GNU GRUB -+ https://www.gnu.org/software/grub/ -+ -+ -+ Set GRUB bootflags -+ Authentication is required to modify the bootloaders bootflags -+ -+ no -+ no -+ yes -+ -+ /usr/sbin/grub2-set-bootflag -+ -+ diff --git a/util/grub-set-bootflag.1 b/util/grub-set-bootflag.1 new file mode 100644 index 00000000000..57801da22a0 diff --git a/0133-Measure-multiboot-images-and-modules.patch b/0133-Measure-multiboot-images-and-modules.patch deleted file mode 100644 index 0c19d8d..0000000 --- a/0133-Measure-multiboot-images-and-modules.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Tue, 1 Sep 2015 16:02:55 -0700 -Subject: [PATCH] Measure multiboot images and modules - ---- - grub-core/loader/i386/multiboot_mbi.c | 3 +++ - grub-core/loader/multiboot.c | 2 ++ - grub-core/loader/multiboot_mbi2.c | 4 +++- - 3 files changed, 8 insertions(+), 1 deletion(-) - -diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c -index dc98dbcae25..1c5b0ac25ce 100644 ---- a/grub-core/loader/i386/multiboot_mbi.c -+++ b/grub-core/loader/i386/multiboot_mbi.c -@@ -36,6 +36,7 @@ - #include - #include - #include -+#include - - #ifdef GRUB_MACHINE_EFI - #include -@@ -173,6 +174,8 @@ grub_multiboot_load (grub_file_t file, const char *filename) - return grub_errno; - } - -+ grub_tpm_measure((unsigned char*)buffer, len, GRUB_KERNEL_PCR, filename); -+ - header = find_header (buffer, len); - - if (header == 0) -diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c -index 26df46a4161..93e026c53db 100644 ---- a/grub-core/loader/multiboot.c -+++ b/grub-core/loader/multiboot.c -@@ -51,6 +51,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -440,6 +441,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), - } - - grub_file_close (file); -+ grub_tpm_measure (module, size, GRUB_KERNEL_PCR, argv[0]); - return GRUB_ERR_NONE; - } - -diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c -index 4df6595954d..d5ad02a33a1 100644 ---- a/grub-core/loader/multiboot_mbi2.c -+++ b/grub-core/loader/multiboot_mbi2.c -@@ -36,6 +36,7 @@ - #include - #include - #include -+#include - - #if defined (GRUB_MACHINE_EFI) - #include -@@ -131,8 +132,9 @@ grub_multiboot2_load (grub_file_t file, const char *filename) - - COMPILE_TIME_ASSERT (MULTIBOOT_HEADER_ALIGN % 4 == 0); - -+ grub_tpm_measure ((unsigned char *)buffer, len, GRUB_KERNEL_PCR, filename); -+ - header = find_header (mld.buffer, len); -- - if (header == 0) - { - grub_free (mld.buffer); diff --git a/0134-Fix-boot-when-there-s-no-TPM.patch b/0134-Fix-boot-when-there-s-no-TPM.patch deleted file mode 100644 index 60efb93..0000000 --- a/0134-Fix-boot-when-there-s-no-TPM.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Wed, 23 Mar 2016 16:49:42 -0700 -Subject: [PATCH] Fix boot when there's no TPM - -If the firmware has TPM support but has no TPM, we're jumping to core.img -without popping the registers back onto the stack. Fix that. - -(cherry picked from commit c2eee36ec08f8ed0cd25b8030276347680be4843) ---- - grub-core/boot/i386/pc/boot.S | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S -index c1df86dec0b..acab37369ae 100644 ---- a/grub-core/boot/i386/pc/boot.S -+++ b/grub-core/boot/i386/pc/boot.S -@@ -473,9 +473,9 @@ LOCAL(copy_buffer): - movl $0x8, %edx /* PCR 8 */ - int $0x1A - -- popa --#endif - boot: -+ popa -+#endif - /* boot kernel */ - jmp *(LOCAL(kernel_address)) - diff --git a/0193-docs-Add-grub-boot-indeterminate.service-example.patch b/0134-docs-Add-grub-boot-indeterminate.service-example.patch similarity index 100% rename from 0193-docs-Add-grub-boot-indeterminate.service-example.patch rename to 0134-docs-Add-grub-boot-indeterminate.service-example.patch diff --git a/0135-Rework-TPM-measurements.patch b/0135-Rework-TPM-measurements.patch deleted file mode 100644 index eb18094..0000000 --- a/0135-Rework-TPM-measurements.patch +++ /dev/null @@ -1,216 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Wed, 23 Mar 2016 17:03:43 -0700 -Subject: [PATCH] Rework TPM measurements - -Rework TPM measurements to use fewer PCRs. After discussion with upstream, -it's preferable to avoid using so many PCRs. Instead, measure into PCRs 8 -and 9 but use a prefix in the event log to indicate which subsystem carried -out the measurements. - -(cherry picked from commit bb3473d7c8741ad5ef7cf8aafbbcf094df08bfc9) ---- - grub-core/kern/dl.c | 2 +- - grub-core/kern/tpm.c | 10 ++++++++-- - grub-core/lib/cmdline.c | 4 ++-- - grub-core/loader/i386/efi/linux.c | 4 ++-- - grub-core/loader/i386/linux.c | 2 +- - grub-core/loader/i386/multiboot_mbi.c | 2 +- - grub-core/loader/i386/pc/linux.c | 2 +- - grub-core/loader/linux.c | 2 +- - grub-core/loader/multiboot.c | 2 +- - grub-core/loader/multiboot_mbi2.c | 2 +- - grub-core/script/execute.c | 4 ++-- - include/grub/tpm.h | 9 +++------ - 12 files changed, 24 insertions(+), 21 deletions(-) - -diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 387d1e6446d..d0989573866 100644 ---- a/grub-core/kern/dl.c -+++ b/grub-core/kern/dl.c -@@ -830,7 +830,7 @@ grub_dl_load_file (const char *filename) - opens of the same device. */ - grub_file_close (file); - -- grub_tpm_measure(core, size, GRUB_TPM_PCR, filename); -+ grub_tpm_measure(core, size, GRUB_BINARY_PCR, "grub_module", filename); - - mod = grub_dl_load_core (core, size); - grub_free (core); -diff --git a/grub-core/kern/tpm.c b/grub-core/kern/tpm.c -index 1a991876c83..cb5a812035d 100644 ---- a/grub-core/kern/tpm.c -+++ b/grub-core/kern/tpm.c -@@ -7,7 +7,13 @@ - - grub_err_t - grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, -- const char *description) -+ const char *kind, const char *description) - { -- return grub_tpm_log_event(buf, size, pcr, description); -+ grub_err_t ret; -+ char *desc = grub_xasprintf("%s %s", kind, description); -+ if (!desc) -+ return GRUB_ERR_OUT_OF_MEMORY; -+ ret = grub_tpm_log_event(buf, size, pcr, description); -+ grub_free(desc); -+ return ret; - } -diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c -index 6b56304d4a7..178f7382f07 100644 ---- a/grub-core/lib/cmdline.c -+++ b/grub-core/lib/cmdline.c -@@ -126,8 +126,8 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, - - *buf = 0; - -- grub_tpm_measure ((void *)orig, grub_strlen (orig), GRUB_CMDLINE_PCR, -- "Kernel Commandline"); -+ grub_tpm_measure ((void *)orig, grub_strlen (orig), GRUB_ASCII_PCR, -+ "grub_kernel_cmdline", orig); - - return i; - } -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index d837249b4a1..074dbd6513e 100644 ---- a/grub-core/loader/i386/efi/linux.c -+++ b/grub-core/loader/i386/efi/linux.c -@@ -132,7 +132,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - argv[i]); - goto fail; - } -- grub_tpm_measure (ptr, cursize, GRUB_INITRD_PCR, "UEFI Linux initrd"); -+ grub_tpm_measure (ptr, cursize, GRUB_BINARY_PCR, "grub_linuxefi", "Initrd"); - ptr += cursize; - grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); - ptr += ALIGN_UP_OVERHEAD (cursize, 4); -@@ -197,7 +197,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- grub_tpm_measure (kernel, filelen, GRUB_KERNEL_PCR, "UEFI Linux kernel"); -+ grub_tpm_measure (kernel, filelen, GRUB_BINARY_PCR, "grub_linuxefi", "Kernel"); - - rc = grub_linuxefi_secure_validate (kernel, filelen); - if (rc < 0) -diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index 94526966e8a..273f48a6c88 100644 ---- a/grub-core/loader/i386/linux.c -+++ b/grub-core/loader/i386/linux.c -@@ -725,7 +725,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- grub_tpm_measure (kernel, len, GRUB_KERNEL_PCR, "Linux Kernel"); -+ grub_tpm_measure (kernel, len, GRUB_BINARY_PCR, "grub_linux", "Kernel"); - - grub_memcpy (&lh, kernel, sizeof (lh)); - -diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c -index 1c5b0ac25ce..2ce424a997b 100644 ---- a/grub-core/loader/i386/multiboot_mbi.c -+++ b/grub-core/loader/i386/multiboot_mbi.c -@@ -174,7 +174,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) - return grub_errno; - } - -- grub_tpm_measure((unsigned char*)buffer, len, GRUB_KERNEL_PCR, filename); -+ grub_tpm_measure((unsigned char*)buffer, len, GRUB_BINARY_PCR, "grub_multiboot", filename); - - header = find_header (buffer, len); - -diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index 15544230763..4f8c02288ec 100644 ---- a/grub-core/loader/i386/pc/linux.c -+++ b/grub-core/loader/i386/pc/linux.c -@@ -162,7 +162,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- grub_tpm_measure (kernel, len, GRUB_KERNEL_PCR, "BIOS Linux Kernel"); -+ grub_tpm_measure (kernel, len, GRUB_BINARY_PCR, "grub_linux16", "Kernel"); - - grub_memcpy (&lh, kernel, sizeof (lh)); - kernel_offset = sizeof (lh); -diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c -index 3005c0d19c9..78c41e33416 100644 ---- a/grub-core/loader/linux.c -+++ b/grub-core/loader/linux.c -@@ -289,7 +289,7 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, - grub_initrd_close (initrd_ctx); - return grub_errno; - } -- grub_tpm_measure (ptr, cursize, GRUB_INITRD_PCR, "Linux Initrd"); -+ grub_tpm_measure (ptr, cursize, GRUB_BINARY_PCR, "grub_initrd", "Initrd"); - ptr += cursize; - } - if (newc) -diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c -index 93e026c53db..3b87dc4fab3 100644 ---- a/grub-core/loader/multiboot.c -+++ b/grub-core/loader/multiboot.c -@@ -441,7 +441,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), - } - - grub_file_close (file); -- grub_tpm_measure (module, size, GRUB_KERNEL_PCR, argv[0]); -+ grub_tpm_measure (module, size, GRUB_BINARY_PCR, "grub_multiboot", argv[0]); - return GRUB_ERR_NONE; - } - -diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c -index d5ad02a33a1..60ae4606fda 100644 ---- a/grub-core/loader/multiboot_mbi2.c -+++ b/grub-core/loader/multiboot_mbi2.c -@@ -132,7 +132,7 @@ grub_multiboot2_load (grub_file_t file, const char *filename) - - COMPILE_TIME_ASSERT (MULTIBOOT_HEADER_ALIGN % 4 == 0); - -- grub_tpm_measure ((unsigned char *)buffer, len, GRUB_KERNEL_PCR, filename); -+ grub_tpm_measure ((unsigned char *)mld.buffer, len, GRUB_BINARY_PCR, "grub_multiboot", filename); - - header = find_header (mld.buffer, len); - if (header == 0) -diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index 9ae04a05160..976643c47b0 100644 ---- a/grub-core/script/execute.c -+++ b/grub-core/script/execute.c -@@ -995,8 +995,8 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) - argv.args[i]); - } - cmdstring[cmdlen-1]= '\0'; -- grub_tpm_measure ((unsigned char *)cmdstring, cmdlen, GRUB_COMMAND_PCR, -- cmdstring); -+ grub_tpm_measure ((unsigned char *)cmdstring, cmdlen, GRUB_ASCII_PCR, -+ "grub_cmd", cmdstring); - grub_free(cmdstring); - invert = 0; - argc = argv.argc - 1; -diff --git a/include/grub/tpm.h b/include/grub/tpm.h -index 7fc9d77d277..ecb2d09ff5d 100644 ---- a/include/grub/tpm.h -+++ b/include/grub/tpm.h -@@ -26,11 +26,8 @@ - #define TPM_AUTHFAIL (TPM_BASE + 0x1) - #define TPM_BADINDEX (TPM_BASE + 0x2) - --#define GRUB_TPM_PCR 9 --#define GRUB_KERNEL_PCR 10 --#define GRUB_INITRD_PCR 11 --#define GRUB_CMDLINE_PCR 12 --#define GRUB_COMMAND_PCR 13 -+#define GRUB_ASCII_PCR 8 -+#define GRUB_BINARY_PCR 9 - - #define TPM_TAG_RQU_COMMAND 0x00C1 - #define TPM_ORD_Extend 0x14 -@@ -70,7 +67,7 @@ typedef struct { - } GRUB_PACKED ExtendOutgoing; - - grub_err_t EXPORT_FUNC(grub_tpm_measure) (unsigned char *buf, grub_size_t size, -- grub_uint8_t pcr, -+ grub_uint8_t pcr, const char *kind, - const char *description); - #if defined (GRUB_MACHINE_EFI) || defined (GRUB_MACHINE_PCBIOS) - grub_err_t grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, diff --git a/0197-gentpl-add-disable-support.patch b/0135-gentpl-add-disable-support.patch similarity index 100% rename from 0197-gentpl-add-disable-support.patch rename to 0135-gentpl-add-disable-support.patch diff --git a/0136-Fix-event-log-prefix.patch b/0136-Fix-event-log-prefix.patch deleted file mode 100644 index 7b98f9a..0000000 --- a/0136-Fix-event-log-prefix.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Tue, 29 Mar 2016 15:36:49 -0700 -Subject: [PATCH] Fix event log prefix - -We're not passing the prefixed version of the description to the event log. -Fix that. - -(cherry picked from commit aab446306b8a78c741e229861c4988738cfc6426) ---- - grub-core/kern/tpm.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/kern/tpm.c b/grub-core/kern/tpm.c -index cb5a812035d..e5e8fced624 100644 ---- a/grub-core/kern/tpm.c -+++ b/grub-core/kern/tpm.c -@@ -13,7 +13,7 @@ grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, - char *desc = grub_xasprintf("%s %s", kind, description); - if (!desc) - return GRUB_ERR_OUT_OF_MEMORY; -- ret = grub_tpm_log_event(buf, size, pcr, description); -+ ret = grub_tpm_log_event(buf, size, pcr, desc); - grub_free(desc); - return ret; - } diff --git a/0198-gentpl-add-pc-firmware-type.patch b/0136-gentpl-add-pc-firmware-type.patch similarity index 100% rename from 0198-gentpl-add-pc-firmware-type.patch rename to 0136-gentpl-add-pc-firmware-type.patch diff --git a/0137-Set-the-first-boot-menu-entry-as-default-when-using-.patch b/0137-Set-the-first-boot-menu-entry-as-default-when-using-.patch deleted file mode 100644 index 1e8e73f..0000000 --- a/0137-Set-the-first-boot-menu-entry-as-default-when-using-.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 6 Apr 2018 14:08:36 +0200 -Subject: [PATCH] Set the first boot menu entry as default when using BLS - fragments - -When BootLoaderSpec configuration files are used, the default boot menu -entry is always set to the first entry as sorted by the blscfg command. - -Suggested-by: Peter Jones -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 839f1fdb655..89cd71d852d 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -144,6 +144,7 @@ if [ -s \$prefix/grubenv ]; then - fi - EOF - -+ ${grub_editenv} - set saved_entry=0 - ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" - - exit 0 diff --git a/0214-efinet-also-use-the-firmware-acceleration-for-http.patch b/0137-efinet-also-use-the-firmware-acceleration-for-http.patch similarity index 100% rename from 0214-efinet-also-use-the-firmware-acceleration-for-http.patch rename to 0137-efinet-also-use-the-firmware-acceleration-for-http.patch diff --git a/0215-efi-http-Make-root_url-reflect-the-protocol-hostname.patch b/0138-efi-http-Make-root_url-reflect-the-protocol-hostname.patch similarity index 100% rename from 0215-efi-http-Make-root_url-reflect-the-protocol-hostname.patch rename to 0138-efi-http-Make-root_url-reflect-the-protocol-hostname.patch diff --git a/0138-tpm-fix-warnings-when-compiling-for-platforms-other-.patch b/0138-tpm-fix-warnings-when-compiling-for-platforms-other-.patch deleted file mode 100644 index 9f9373f..0000000 --- a/0138-tpm-fix-warnings-when-compiling-for-platforms-other-.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Michael Marineau -Date: Sun, 21 Aug 2016 18:24:58 -0700 -Subject: [PATCH] tpm: fix warnings when compiling for platforms other than pc - and efi - ---- - include/grub/tpm.h | 17 +++++++++++------ - 1 file changed, 11 insertions(+), 6 deletions(-) - -diff --git a/include/grub/tpm.h b/include/grub/tpm.h -index ecb2d09ff5d..972a5edc836 100644 ---- a/include/grub/tpm.h -+++ b/include/grub/tpm.h -@@ -75,12 +75,17 @@ grub_err_t grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, - grub_err_t grub_tpm_log_event(unsigned char *buf, grub_size_t size, - grub_uint8_t pcr, const char *description); - #else --static inline grub_err_t grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, -- PassThroughToTPM_OutputParamBlock *outbuf) { return 0; }; --static inline grub_err_t grub_tpm_log_event(unsigned char *buf, -- grub_size_t size, -- grub_uint8_t pcr, -- const char *description) -+static inline grub_err_t grub_tpm_execute( -+ PassThroughToTPM_InputParamBlock *inbuf __attribute__ ((unused)), -+ PassThroughToTPM_OutputParamBlock *outbuf __attribute__ ((unused))) -+{ -+ return 0; -+}; -+static inline grub_err_t grub_tpm_log_event( -+ unsigned char *buf __attribute__ ((unused)), -+ grub_size_t size __attribute__ ((unused)), -+ grub_uint8_t pcr __attribute__ ((unused)), -+ const char *description __attribute__ ((unused))) - { - return 0; - }; diff --git a/0217-Force-everything-to-use-python3.patch b/0139-Force-everything-to-use-python3.patch similarity index 100% rename from 0217-Force-everything-to-use-python3.patch rename to 0139-Force-everything-to-use-python3.patch diff --git a/0139-Make-TPM-errors-less-fatal.patch b/0139-Make-TPM-errors-less-fatal.patch deleted file mode 100644 index bcee8a1..0000000 --- a/0139-Make-TPM-errors-less-fatal.patch +++ /dev/null @@ -1,208 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Thu, 13 Oct 2016 13:55:26 -0700 -Subject: [PATCH] Make TPM errors less fatal - -Handle TPM errors, and stop trying to use the TPM once we hit one. ---- - grub-core/kern/dl.c | 1 + - grub-core/kern/i386/pc/tpm.c | 21 +++++++++++++++++---- - grub-core/lib/cmdline.c | 1 + - grub-core/loader/i386/efi/linux.c | 2 ++ - grub-core/loader/i386/linux.c | 1 + - grub-core/loader/i386/multiboot_mbi.c | 1 + - grub-core/loader/i386/pc/linux.c | 1 + - grub-core/loader/linux.c | 2 ++ - grub-core/loader/multiboot.c | 1 + - grub-core/loader/multiboot_mbi2.c | 1 + - grub-core/script/execute.c | 1 + - 11 files changed, 29 insertions(+), 4 deletions(-) - -diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index d0989573866..91105bc4677 100644 ---- a/grub-core/kern/dl.c -+++ b/grub-core/kern/dl.c -@@ -831,6 +831,7 @@ grub_dl_load_file (const char *filename) - grub_file_close (file); - - grub_tpm_measure(core, size, GRUB_BINARY_PCR, "grub_module", filename); -+ grub_print_error(); - - mod = grub_dl_load_core (core, size); - grub_free (core); -diff --git a/grub-core/kern/i386/pc/tpm.c b/grub-core/kern/i386/pc/tpm.c -index 8c6c1e6ece2..f6f264aff2e 100644 ---- a/grub-core/kern/i386/pc/tpm.c -+++ b/grub-core/kern/i386/pc/tpm.c -@@ -7,21 +7,28 @@ - - #define TCPA_MAGIC 0x41504354 - -+static int tpm_presence = -1; -+ - int tpm_present(void); - - int tpm_present(void) - { - struct grub_bios_int_registers regs; - -+ if (tpm_presence != -1) -+ return tpm_presence; -+ - regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; - regs.eax = 0xbb00; - regs.ebx = TCPA_MAGIC; - grub_bios_interrupt (0x1a, ®s); - - if (regs.eax == 0) -- return 1; -+ tpm_presence = 1; -+ else -+ tpm_presence = 0; - -- return 0; -+ return tpm_presence; - } - - grub_err_t -@@ -49,7 +56,10 @@ grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, - grub_bios_interrupt (0x1a, ®s); - - if (regs.eax) -- return grub_error (GRUB_ERR_IO, N_("TPM error %x\n"), regs.eax); -+ { -+ tpm_presence = 0; -+ return grub_error (GRUB_ERR_IO, N_("TPM error %x, disabling TPM"), regs.eax); -+ } - - return 0; - } -@@ -126,7 +136,10 @@ grub_tpm_log_event(unsigned char *buf, grub_size_t size, grub_uint8_t pcr, - grub_free(event); - - if (regs.eax) -- return grub_error (GRUB_ERR_IO, N_("TPM error %x\n"), regs.eax); -+ { -+ tpm_presence = 0; -+ return grub_error (GRUB_ERR_IO, N_("TPM error %x, disabling TPM"), regs.eax); -+ } - - return 0; - } -diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c -index 178f7382f07..d5c12957cad 100644 ---- a/grub-core/lib/cmdline.c -+++ b/grub-core/lib/cmdline.c -@@ -128,6 +128,7 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, - - grub_tpm_measure ((void *)orig, grub_strlen (orig), GRUB_ASCII_PCR, - "grub_kernel_cmdline", orig); -+ grub_print_error(); - - return i; - } -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 074dbd6513e..ea9f5134e67 100644 ---- a/grub-core/loader/i386/efi/linux.c -+++ b/grub-core/loader/i386/efi/linux.c -@@ -133,6 +133,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - grub_tpm_measure (ptr, cursize, GRUB_BINARY_PCR, "grub_linuxefi", "Initrd"); -+ grub_print_error(); - ptr += cursize; - grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); - ptr += ALIGN_UP_OVERHEAD (cursize, 4); -@@ -198,6 +199,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - } - - grub_tpm_measure (kernel, filelen, GRUB_BINARY_PCR, "grub_linuxefi", "Kernel"); -+ grub_print_error(); - - rc = grub_linuxefi_secure_validate (kernel, filelen); - if (rc < 0) -diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index 273f48a6c88..76304f05700 100644 ---- a/grub-core/loader/i386/linux.c -+++ b/grub-core/loader/i386/linux.c -@@ -726,6 +726,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - } - - grub_tpm_measure (kernel, len, GRUB_BINARY_PCR, "grub_linux", "Kernel"); -+ grub_print_error(); - - grub_memcpy (&lh, kernel, sizeof (lh)); - -diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c -index 2ce424a997b..ca85358f771 100644 ---- a/grub-core/loader/i386/multiboot_mbi.c -+++ b/grub-core/loader/i386/multiboot_mbi.c -@@ -175,6 +175,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) - } - - grub_tpm_measure((unsigned char*)buffer, len, GRUB_BINARY_PCR, "grub_multiboot", filename); -+ grub_print_error(); - - header = find_header (buffer, len); - -diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index 4f8c02288ec..cfff25c21b5 100644 ---- a/grub-core/loader/i386/pc/linux.c -+++ b/grub-core/loader/i386/pc/linux.c -@@ -163,6 +163,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - } - - grub_tpm_measure (kernel, len, GRUB_BINARY_PCR, "grub_linux16", "Kernel"); -+ grub_print_error(); - - grub_memcpy (&lh, kernel, sizeof (lh)); - kernel_offset = sizeof (lh); -diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c -index 78c41e33416..c2c7cfcd0fd 100644 ---- a/grub-core/loader/linux.c -+++ b/grub-core/loader/linux.c -@@ -290,6 +290,8 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, - return grub_errno; - } - grub_tpm_measure (ptr, cursize, GRUB_BINARY_PCR, "grub_initrd", "Initrd"); -+ grub_print_error(); -+ - ptr += cursize; - } - if (newc) -diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c -index 3b87dc4fab3..9a8dae5565b 100644 ---- a/grub-core/loader/multiboot.c -+++ b/grub-core/loader/multiboot.c -@@ -442,6 +442,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), - - grub_file_close (file); - grub_tpm_measure (module, size, GRUB_BINARY_PCR, "grub_multiboot", argv[0]); -+ grub_print_error(); - return GRUB_ERR_NONE; - } - -diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c -index 60ae4606fda..54078455e2f 100644 ---- a/grub-core/loader/multiboot_mbi2.c -+++ b/grub-core/loader/multiboot_mbi2.c -@@ -133,6 +133,7 @@ grub_multiboot2_load (grub_file_t file, const char *filename) - COMPILE_TIME_ASSERT (MULTIBOOT_HEADER_ALIGN % 4 == 0); - - grub_tpm_measure ((unsigned char *)mld.buffer, len, GRUB_BINARY_PCR, "grub_multiboot", filename); -+ grub_print_error(); - - header = find_header (mld.buffer, len); - if (header == 0) -diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index 976643c47b0..93965777138 100644 ---- a/grub-core/script/execute.c -+++ b/grub-core/script/execute.c -@@ -997,6 +997,7 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) - cmdstring[cmdlen-1]= '\0'; - grub_tpm_measure ((unsigned char *)cmdstring, cmdlen, GRUB_ASCII_PCR, - "grub_cmd", cmdstring); -+ grub_print_error(); - grub_free(cmdstring); - invert = 0; - argc = argv.argc - 1; diff --git a/0218-Fix-an-8-year-old-typo.patch b/0140-Fix-an-8-year-old-typo.patch similarity index 100% rename from 0218-Fix-an-8-year-old-typo.patch rename to 0140-Fix-an-8-year-old-typo.patch diff --git a/0140-blscfg-handle-multiple-initramfs-images.patch b/0140-blscfg-handle-multiple-initramfs-images.patch deleted file mode 100644 index 2050ffa..0000000 --- a/0140-blscfg-handle-multiple-initramfs-images.patch +++ /dev/null @@ -1,104 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 11 Apr 2018 13:44:29 -0400 -Subject: [PATCH] blscfg: handle multiple initramfs images. - -Signed-off-by: Peter Jones ---- - grub-core/commands/blscfg.c | 54 ++++++++++++++++++++++++++++++++++++--------- - 1 file changed, 44 insertions(+), 10 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index e775c6b8794..6ab85df6b3a 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -587,6 +587,7 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - char *title = NULL; - char *clinux = NULL; - char *options = NULL; -+ char **initrds = NULL; - char *initrd = NULL; - char *id = NULL; - char *hotkey = NULL; -@@ -609,7 +610,7 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - - title = bls_get_val (entry, "title", NULL); - options = bls_get_val (entry, "options", NULL); -- initrd = bls_get_val (entry, "initrd", NULL); -+ initrds = bls_make_list (entry, "initrd", NULL); - id = bls_get_val (entry, "id", NULL); - - hotkey = bls_get_val (entry, "grub_hotkey", NULL); -@@ -624,30 +625,63 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - argv[i] = args[i-1]; - argv[argc] = NULL; - -- grub_dprintf("blscfg", "adding menu entry for \"%s\"\n", title); -+ grub_dprintf ("blscfg", "adding menu entry for \"%s\"\n", title); -+ if (initrds) -+ { -+ int initrd_size = sizeof (GRUB_INITRD_CMD); -+ char *tmp; -+ -+ for (i = 0; initrds != NULL && initrds[i] != NULL; i++) -+ initrd_size += sizeof (" " GRUB_BOOT_DEVICE) \ -+ + grub_strlen (initrds[i]) + 1; -+ initrd_size += 1; -+ -+ initrd = grub_malloc (initrd_size); -+ if (!initrd) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -+ goto finish; -+ } -+ -+ -+ tmp = grub_stpcpy(initrd, GRUB_INITRD_CMD); -+ for (i = 0; initrds != NULL && initrds[i] != NULL; i++) -+ { -+ grub_dprintf ("blscfg", "adding initrd %s\n", initrds[i]); -+ tmp = grub_stpcpy (tmp, " " GRUB_BOOT_DEVICE); -+ tmp = grub_stpcpy (tmp, initrds[i]); -+ } -+ tmp = grub_stpcpy (tmp, "\n"); -+ } -+ - src = grub_xasprintf ("load_video\n" - "set gfx_payload=keep\n" - "insmod gzio\n" - GRUB_LINUX_CMD " %s%s%s%s\n" -- "%s%s%s%s", -+ "%s", - GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", -- initrd ? GRUB_INITRD_CMD " " : "", initrd ? GRUB_BOOT_DEVICE : "", initrd ? initrd : "", initrd ? "\n" : ""); -+ initrd ? initrd : ""); - - grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0); - - finish: -+ if (initrd) -+ grub_free (initrd); -+ -+ if (initrds) -+ grub_free (initrds); -+ - if (classes) -- grub_free (classes); -- grub_dprintf("blscfg", "%s got here\n", __func__); -+ grub_free (classes); -+ - if (args) -- grub_free (args); -+ grub_free (args); - - if (argv) -- grub_free (argv); -+ grub_free (argv); - - if (src) -- grub_free (src); -- grub_dprintf("blscfg", "%s got here\n", __func__); -+ grub_free (src); - } - - struct find_entry_info { diff --git a/0141-BLS-Fix-grub2-switch-to-blscfg-on-non-EFI-machines.patch b/0141-BLS-Fix-grub2-switch-to-blscfg-on-non-EFI-machines.patch deleted file mode 100644 index a045646..0000000 --- a/0141-BLS-Fix-grub2-switch-to-blscfg-on-non-EFI-machines.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jan Hlavac -Date: Tue, 10 Apr 2018 16:07:36 +0200 -Subject: [PATCH] BLS: Fix grub2-switch-to-blscfg on non-EFI machines - -On the non-EFI machines the grub2-switch-to-blscfg script places the BLS -snippets into the /boot directory. But the right location is -/boot/loader/entries. ---- - util/grub-switch-to-blscfg.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 3ae5e4ea8d0..f740b8f4d03 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -44,7 +44,7 @@ if [ -d /sys/firmware/efi/efivars/ ]; then - else - startlink=/etc/grub2.cfg - grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'` -- blsdir=`echo "/@bootdirname@" | sed 's,//*,/,g'` -+ blsdir=`echo "/@bootdirname@/loader/entries" | sed 's,//*,/,g'` - fi - - backupsuffix=.bak diff --git a/0219-autogen-don-t-run-autoreconf-in-the-topdir.patch b/0141-autogen-don-t-run-autoreconf-in-the-topdir.patch similarity index 100% rename from 0219-autogen-don-t-run-autoreconf-in-the-topdir.patch rename to 0141-autogen-don-t-run-autoreconf-in-the-topdir.patch diff --git a/0142-BLS-Use-etcdefaultgrub-instead-of-etc.patch b/0142-BLS-Use-etcdefaultgrub-instead-of-etc.patch deleted file mode 100644 index db97410..0000000 --- a/0142-BLS-Use-etcdefaultgrub-instead-of-etc.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jan Hlavac -Date: Tue, 10 Apr 2018 16:56:28 +0200 -Subject: [PATCH] BLS: Use ${etcdefaultgrub} instead of /etc/... - -Inside the grub-switch-to-blscfg script the ${etcdefaultgrub} variable -is used. So replace the hardcoded /etc/default/grub with it. ---- - util/grub-switch-to-blscfg.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index f740b8f4d03..eae3c379e4a 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -252,7 +252,7 @@ if [[ "${GENERATE}" -eq 1 ]] ; then - cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}" - sed -i"${backupsuffix}" \ - -e 's,^GRUB_ENABLE_BLSCFG=.*,GRUB_ENABLE_BLSCFG=false,' \ -- /etc/default/grub -+ "${etcdefaultgrub}" - gettext_printf "Updating %s failed\n" "${GRUB_CONFIG_FILE}" - exit 1 - fi diff --git a/0220-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch b/0142-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch similarity index 100% rename from 0220-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch rename to 0142-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch diff --git a/0143-Add-missing-options-to-grub2-switch-to-blscfg-man-pa.patch b/0143-Add-missing-options-to-grub2-switch-to-blscfg-man-pa.patch deleted file mode 100644 index 16ab928..0000000 --- a/0143-Add-missing-options-to-grub2-switch-to-blscfg-man-pa.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 11 Apr 2018 11:36:43 +0200 -Subject: [PATCH] Add missing options to grub2-switch-to-blscfg man page - -The script --bls-directory and --backup-suffix options were not documented -in the man page, add them as well so users can know what these are about. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.8 | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/util/grub-switch-to-blscfg.8 b/util/grub-switch-to-blscfg.8 -index 134dfc62a7b..7d99de2d2f9 100644 ---- a/util/grub-switch-to-blscfg.8 -+++ b/util/grub-switch-to-blscfg.8 -@@ -21,5 +21,13 @@ The grub config file to use. The default value is \fI/etc/grub2-efi.cfg\fR on U - --grub-defaults=\fIFILE\fR - The defaults file for grub-mkconfig. The default value is \fI/etc/default/grub\fR. - -+.TP -+--bls-directory=\fIDIR\fR -+Create BootLoaderSpec fragments in \fIDIR\fR. The default value is \fI/boot/loader/entries\fR on BIOS machines and \fI/boot/efi/EFI/\fBVENDOR\fI/loader/entries\fR on UEFI machines. -+ -+.TP -+--backup-suffix=\fSUFFIX\fR -+The suffix to use for saved backup files. The default value is \fI.bak\fR. -+ - .SH SEE ALSO - .BR "info grub" diff --git a/0221-module-verifier-make-it-possible-to-run-checkers-on-.patch b/0143-module-verifier-make-it-possible-to-run-checkers-on-.patch similarity index 100% rename from 0221-module-verifier-make-it-possible-to-run-checkers-on-.patch rename to 0143-module-verifier-make-it-possible-to-run-checkers-on-.patch diff --git a/0144-Make-grub2-switch-to-blscfg-to-generate-debug-BLS-wh.patch b/0144-Make-grub2-switch-to-blscfg-to-generate-debug-BLS-wh.patch deleted file mode 100644 index 5e47f2d..0000000 --- a/0144-Make-grub2-switch-to-blscfg-to-generate-debug-BLS-wh.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 11 Apr 2018 11:49:24 +0200 -Subject: [PATCH] Make grub2-switch-to-blscfg to generate debug BLS when - MAKEDEBUG is set - -If MAKEDEBUG=yes in /etc/sysconfig/kernel, then a debug menu entry should -be created. So for BLS, a debug configuration file has to be created that -contains additional debug kernel command line parameters. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 15 +++++++++++++++ - 1 file changed, 15 insertions(+) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index eae3c379e4a..c59299ffa6a 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -21,6 +21,7 @@ - # Initialize some variables. - prefix=@prefix@ - exec_prefix=@exec_prefix@ -+sbindir=@sbindir@ - bindir=@bindir@ - sysconfdir="@sysconfdir@" - PACKAGE_NAME=@PACKAGE_NAME@ -@@ -33,9 +34,12 @@ fi - - self=`basename $0` - -+grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@" - grub_editenv=${bindir}/@grub_editenv@ - etcdefaultgrub=/etc/default/grub - -+eval "$("${grub_get_kernel_settings}")" || true -+ - EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') - if [ -d /sys/firmware/efi/efivars/ ]; then - startlink=/etc/grub2-efi.cfg -@@ -226,6 +230,17 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \ - >"${bls_target}" - fi -+ -+ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -+ arch="$(uname -m)" -+ bls_debug="$(echo ${bls_target} | sed -e "s/\.${arch}/-debug.${arch}/")" -+ cp -aT "${bls_target}" "${bls_debug}" -+ title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')" -+ blsid="$(grep '^id[ \t]' "${bls_debug}" | sed -e "s/\.${ARCH}/-debug.${arch}/")" -+ sed -i -e "s/^title.*/title ${title}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${bls_debug}" -+ sed -i -e "s/^id.*/${blsid}/" "${bls_debug}" -+ sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${bls_debug}" -+ fi - done - - GENERATE=0 diff --git a/0222-grub-module-verifier-report-the-filename-or-modname-.patch b/0144-grub-module-verifier-report-the-filename-or-modname-.patch similarity index 100% rename from 0222-grub-module-verifier-report-the-filename-or-modname-.patch rename to 0144-grub-module-verifier-report-the-filename-or-modname-.patch diff --git a/0145-Make-grub2-switch-to-blscfg-to-generate-BLS-fragment.patch b/0145-Make-grub2-switch-to-blscfg-to-generate-BLS-fragment.patch deleted file mode 100644 index eb1726b..0000000 --- a/0145-Make-grub2-switch-to-blscfg-to-generate-BLS-fragment.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 11 Apr 2018 12:39:59 +0200 -Subject: [PATCH] Make grub2-switch-to-blscfg to generate BLS fragment for - rescue kernel - -If a rescue image is available, it should have a BootLoaderSpec fragment. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index c59299ffa6a..bc28053cd30 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -243,6 +243,10 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - fi - done - -+if [[ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]]; then -+ mkbls "0-rescue-${MACHINE_ID}" "0" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" -+fi -+ - GENERATE=0 - if grep '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" \ - | grep -vq '^GRUB_ENABLE_BLSCFG="*true"*\s*$' ; then diff --git a/0224-Rework-how-the-fdt-command-builds.patch b/0145-Rework-how-the-fdt-command-builds.patch similarity index 95% rename from 0224-Rework-how-the-fdt-command-builds.patch rename to 0145-Rework-how-the-fdt-command-builds.patch index 5f66a7a..34b2d3c 100644 --- a/0224-Rework-how-the-fdt-command-builds.patch +++ b/0145-Rework-how-the-fdt-command-builds.patch @@ -22,10 +22,10 @@ Signed-off-by: Peter Jones 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 715d3a3ec02..203584fb00b 100644 +index 4168ec5d3ff..144734e39e1 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -166,7 +166,6 @@ kernel = { +@@ -165,7 +165,6 @@ kernel = { arm_coreboot = kern/arm/coreboot/init.c; arm_coreboot = kern/arm/coreboot/timer.c; arm_coreboot = kern/arm/coreboot/coreboot.S; @@ -33,7 +33,7 @@ index 715d3a3ec02..203584fb00b 100644 arm_coreboot = bus/fdt.c; arm_coreboot = term/ps2.c; arm_coreboot = term/arm/pl050.c; -@@ -317,6 +316,8 @@ kernel = { +@@ -315,6 +314,8 @@ kernel = { arm64 = kern/arm64/dl.c; arm64 = kern/arm64/dl_helper.c; @@ -42,7 +42,7 @@ index 715d3a3ec02..203584fb00b 100644 emu = disk/host.c; emu = kern/emu/cache_s.S; emu = kern/emu/hostdisk.c; -@@ -1714,7 +1715,6 @@ module = { +@@ -1713,7 +1714,6 @@ module = { arm_uboot = loader/arm/linux.c; arm64 = loader/arm64/linux.c; emu = loader/emu/linux.c; @@ -50,7 +50,7 @@ index 715d3a3ec02..203584fb00b 100644 common = loader/linux.c; common = lib/cmdline.c; -@@ -1725,7 +1725,6 @@ module = { +@@ -1724,7 +1724,6 @@ module = { module = { name = fdt; efi = loader/efi/fdt.c; diff --git a/0225-Disable-non-wordsize-allocations-on-arm.patch b/0146-Disable-non-wordsize-allocations-on-arm.patch similarity index 100% rename from 0225-Disable-non-wordsize-allocations-on-arm.patch rename to 0146-Disable-non-wordsize-allocations-on-arm.patch diff --git a/0146-Only-attempt-to-query-dev-mounted-in-boot-efi-as-boo.patch b/0146-Only-attempt-to-query-dev-mounted-in-boot-efi-as-boo.patch deleted file mode 100644 index 84b0167..0000000 --- a/0146-Only-attempt-to-query-dev-mounted-in-boot-efi-as-boo.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 24 Apr 2018 02:16:38 +0200 -Subject: [PATCH] Only attempt to query dev mounted in /boot/efi as boot dev on - EFI machines - -The 10_linux script calls grub2-probe to probe the information for the dev -mounted in /boot/efi, but this directory may not exist on non-EFI machines -which leads to the following error when generating the grub2 config file: - -/usr/sbin/grub2-probe: error: failed to get canonical path of `/boot/efi/' - -Instead query for the device mounted in /boot and use that as the boot dev -for non-EFI machines. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 89cd71d852d..61d0664fb5c 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -133,8 +133,13 @@ linux_entry () - fi - fi - -- bootefi_device="`${grub_probe} --target=device /boot/efi/`" -- prepare_grub_to_access_device ${bootefi_device} boot -+ if [ -d /sys/firmware/efi ]; then -+ bootefi_device="`${grub_probe} --target=device /boot/efi/`" -+ prepare_grub_to_access_device ${bootefi_device} boot -+ else -+ boot_device="`${grub_probe} --target=device /boot/`" -+ prepare_grub_to_access_device ${boot_device} boot -+ fi - - cat << EOF - insmod blscfg diff --git a/0147-Include-OSTree-path-when-searching-kernels-images-if.patch b/0147-Include-OSTree-path-when-searching-kernels-images-if.patch deleted file mode 100644 index 70b33b3..0000000 --- a/0147-Include-OSTree-path-when-searching-kernels-images-if.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 24 Apr 2018 02:28:04 +0200 -Subject: [PATCH] Include OSTree path when searching kernels images if BLS - config is enabled - -The OSTree based distros (i.e: Fedora Atomic) don't install kernel images -in the /boot directory, but in /boot/ostree. So the 10_linux script isn't -able to include these kernels in its list, so the linux_entry() function -is never called. - -This isn't a problem since the 10_linux script isn't used to populate the -menu entries anyways, but instead a custom 15_ostree script is used. But -for BLS we want the 10_linux script to generate the minimal grub.cfg that -calls the blscfg command, so add the OSTree kernel images to the list. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 61d0664fb5c..9682e97b7f5 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -237,6 +237,12 @@ case "x$machine" in - done ;; - esac - -+if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then -+ for i in /boot/ostree/*/vmlinuz-* ; do -+ if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi -+ done -+fi -+ - case "$machine" in - i?86) GENKERNEL_ARCH="x86" ;; - mips|mips64) GENKERNEL_ARCH="mips" ;; diff --git a/0226-strip-R-.note.gnu.property-at-more-places.patch b/0147-strip-R-.note.gnu.property-at-more-places.patch similarity index 100% rename from 0226-strip-R-.note.gnu.property-at-more-places.patch rename to 0147-strip-R-.note.gnu.property-at-more-places.patch diff --git a/0227-Prepend-prefix-when-HTTP-path-is-relative.patch b/0148-Prepend-prefix-when-HTTP-path-is-relative.patch similarity index 89% rename from 0227-Prepend-prefix-when-HTTP-path-is-relative.patch rename to 0148-Prepend-prefix-when-HTTP-path-is-relative.patch index 9e90636..1b1af53 100644 --- a/0227-Prepend-prefix-when-HTTP-path-is-relative.patch +++ b/0148-Prepend-prefix-when-HTTP-path-is-relative.patch @@ -39,7 +39,7 @@ index da47b18b50e..dcf48726d54 100644 } } diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c -index 243acbaa35b..2a9624dacc4 100644 +index 243acbaa35b..de351b2cd03 100644 --- a/grub-core/net/efi/http.c +++ b/grub-core/net/efi/http.c @@ -9,10 +9,52 @@ @@ -56,7 +56,7 @@ index 243acbaa35b..2a9624dacc4 100644 + const char *rest, *http_server, *http_path = NULL; + + http_server = grub_env_get ("root"); -+ https = grub_strncmp (http_server, "https", 5) ? 1 : 0; ++ https = (grub_strncmp (http_server, "https", 5) == 0) ? 1 : 0; + + /* extract http server + port */ + if (http_server) @@ -102,16 +102,12 @@ index 243acbaa35b..2a9624dacc4 100644 - char *root_url; - grub_efi_ipv6_address_t address; - const char *rest; -+ char *file_name; ++ char *file_name = NULL; + const char *http_path; - if (grub_efi_string_to_ip6_address (file->device->net->server, &address, &rest) && *rest == 0) - root_url = grub_xasprintf ("%s://[%s]", type ? "https" : "http", file->device->net->server); -+ /* If path is relative, prepend http_path */ -+ http_path = grub_env_get ("http_path"); -+ if (http_path && file->device->net->name[0] != '/') -+ file_name = grub_xasprintf ("%s/%s", http_path, file->device->net->name); - else +- else - root_url = grub_xasprintf ("%s://%s", type ? "https" : "http", file->device->net->server); - if (root_url) - { @@ -121,15 +117,18 @@ index 243acbaa35b..2a9624dacc4 100644 - } - else - { -- return grub_errno; ++ /* If path is relative, prepend http_path */ ++ http_path = grub_env_get ("http_path"); ++ if (http_path && file->device->net->name[0] != '/') { ++ file_name = grub_xasprintf ("%s/%s", http_path, file->device->net->name); ++ if (!file_name) + return grub_errno; - } -+ file_name = grub_strdup (file->device->net->name); ++ } - err = efihttp_request (dev->http, file->device->net->server, file->device->net->name, type, 1, 0); -+ if (!file_name) -+ return grub_errno; -+ -+ err = efihttp_request (dev->http, file->device->net->server, file_name, type, 1, 0); ++ err = efihttp_request (dev->http, file->device->net->server, ++ file_name ? file_name : file->device->net->name, type, 1, 0); if (err != GRUB_ERR_NONE) - return err; + { @@ -138,7 +137,8 @@ index 243acbaa35b..2a9624dacc4 100644 + } - err = efihttp_request (dev->http, file->device->net->server, file->device->net->name, type, 0, &size); -+ err = efihttp_request (dev->http, file->device->net->server, file_name, type, 0, &size); ++ err = efihttp_request (dev->http, file->device->net->server, ++ file_name ? file_name : file->device->net->name, type, 0, &size); + grub_free (file_name); if (err != GRUB_ERR_NONE) - return err; diff --git a/0148-Use-BLS-version-field-to-compare-entries-if-id-field.patch b/0148-Use-BLS-version-field-to-compare-entries-if-id-field.patch deleted file mode 100644 index 0d76ad8..0000000 --- a/0148-Use-BLS-version-field-to-compare-entries-if-id-field.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 27 Apr 2018 17:53:41 +0200 -Subject: [PATCH] Use BLS version field to compare entries if id field isn't - defined - -The BootLoaderSpec fragments generated by OSTree don't have the id field, -so grub2 will attempt to sort the entries by using the title field which -may not be correct. The entries do have a version field though so use it. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 6ab85df6b3a..c52d2b2e05a 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -418,6 +418,9 @@ static int bls_cmp(const void *p0, const void *p1, void *state UNUSED) - - rc = bls_keyval_cmp (e0, e1, "id"); - -+ if (rc == 0) -+ rc = bls_keyval_cmp (e0, e1, "version"); -+ - if (rc == 0) - rc = bls_keyval_cmp (e0, e1, "title"); - diff --git a/0149-Add-version-field-to-BLS-generated-by-grub2-switch-t.patch b/0149-Add-version-field-to-BLS-generated-by-grub2-switch-t.patch deleted file mode 100644 index 27e0a17..0000000 --- a/0149-Add-version-field-to-BLS-generated-by-grub2-switch-t.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 10 May 2018 10:52:11 +0200 -Subject: [PATCH] Add version field to BLS generated by grub2-switch-to-blscfg - -The version field is present in the BLS fragments that are shipped in the -kernel packages, so add it to the BLS generated by grub2-switch-to-blscfg -for consistency. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index bc28053cd30..89487ad611c 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -190,12 +190,14 @@ mkbls() { - local datetime=$1 && shift - - local debugname="" -+ local debugid="" - local flavor="" - - if [[ "$kernelver" == *\+* ]] ; then - local flavor=-"${kernelver##*+}" - if [[ "${flavor}" == "-debug" ]]; then - local debugname=" with debugging" -+ local debugid="-debug" - fi - fi - ( -@@ -203,6 +205,7 @@ mkbls() { - - cat < -Date: Fri, 11 May 2018 23:47:31 +0200 -Subject: [PATCH] Simplify BLS entry key val pairs lookup - -The pairs found in the BLS are being sorted but this isn't -really needed and it makes the implementation complex and error prone. - -For example, the current implementation has the following issues: - -1) Fields not present in the grub2 menu entry - - linux /linuz - initrd /foo - initrd /bar - - load_video - set gfx_payload=keep - insmod gzio - linux /boot/linuz - initrd /boot/bar - -2) Fields present but in the wrong order - - title Fedora (4.16.6-300.fc28.x86_64-tuned) 28 (Twenty Eight) - version 4.16.6-300.fc28.x86_64 - linux /vmlinuz-4.16.6-300.fc28.x86_64 - initrd /foo.img - initrd /bar.img - options $kernelopts - id fedora-20180430150025-4.16.6-300.fc28.x86_64 - - load_video - set gfx_payload=keep - insmod gzio - linux /boot/vmlinuz-4.16.6-300.fc28.x86_64 $kernelopts - initrd /boot/bar.img /boot/foo.img - -It's important to preserve the order in which fields have been defined -in the BLS fragment since for some of the fields the order has meaning. -For example, initramfs images have to be passed to the kernel in order -that were defined in the BLS fragment. - -This patch simplifies the pairs storage and lookup. Rather -than sorting and attempt to later figure out what's the expected order, -just store it in the same order as they were defined in the BLS config -file and return in that same order to callers when these look them up. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 88 ++++++++++----------------------------------- - 1 file changed, 18 insertions(+), 70 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index c52d2b2e05a..fb08d8e4c12 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -169,84 +169,35 @@ static void bls_free_entry(struct bls_entry *entry) - grub_free (entry); - } - --static int keyval_cmp (const void *p0, const void *p1, -- void *state UNUSED) --{ -- const struct keyval *kv0 = *(struct keyval * const *)p0; -- const struct keyval *kv1 = *(struct keyval * const *)p1; -- int rc; -- -- rc = grub_strcmp(kv0->key, kv1->key); -- -- return rc; --} -- - /* Find they value of the key named by keyname. If there are allowed to be - * more than one, pass a pointer to an int set to -1 the first time, and pass - * the same pointer through each time after, and it'll return them in sorted -- * order. */ -+ * order as defined in the BLS fragment file */ - static char *bls_get_val(struct bls_entry *entry, const char *keyname, int *last) - { -- char *foo = (char *)""; -- struct keyval *kv = NULL, **kvp, key = {keyname, foo}, *keyp = &key; -+ int idx, start = 0; -+ struct keyval *kv = NULL; - -- /* if we've already found an entry that matches, just iterate */ -- if (last && *last >= 0) -- { -- int next = ++last[0]; -+ if (last) -+ start = *last + 1; - -- if (next == entry->nkeyvals) -- { --done: -- *last = -1; -- return NULL; -- } -+ for (idx = start; idx < entry->nkeyvals; idx++) { -+ kv = entry->keyvals[idx]; - -- kv = entry->keyvals[next]; -- if (grub_strcmp (keyname, kv->key)) -- goto done; -+ if (!grub_strcmp (keyname, kv->key)) -+ break; -+ } - -- return kv->val; -- } -+ if (idx == entry->nkeyvals) { -+ if (last) -+ *last = -1; -+ return NULL; -+ } - -- kvp = grub_bsearch(&keyp, &entry->keyvals[0], entry->nkeyvals, -- sizeof (struct keyval *), keyval_cmp, NULL); -- if (kvp) -- kv = *kvp; -+ if (last) -+ *last = idx; - -- if (kv) -- { -- /* if we've got uninitialized but present state, track back until we find -- * the first match */ -- if (last) -- { -- grub_dprintf("blscfg", "%s trying to find another entry because last was set\n", __func__); -- /* figure out the position of this entry in the array */ -- int idx; -- for (idx = 0 ; idx < entry->nkeyvals; idx++) -- if (entry->keyvals[idx] == kv) -- break; -- *last = idx; -- -- while (idx > 0) -- { -- struct keyval *kvtmp = entry->keyvals[idx-1]; -- if (idx == 0 || grub_strcmp (keyname, kvtmp->key)) -- { -- /* if we're at the start, or if the previous entry doesn't -- * match, then we're done */ -- *last = idx; -- break; -- } -- else -- /* but if it does match, keep going backwards */ -- idx--; -- } -- } -- -- return kv->val; -- } -- return NULL; -+ return kv->val; - } - - #define goto_return(x) ({ ret = (x); goto finish; }) -@@ -503,9 +454,6 @@ static int read_entry ( - break; - } - -- grub_qsort(&entry->keyvals[0], entry->nkeyvals, sizeof (struct keyval *), -- keyval_cmp, NULL); -- - finish: - grub_free (p); - diff --git a/0233-Add-a-version-command.patch b/0153-Add-a-version-command.patch similarity index 98% rename from 0233-Add-a-version-command.patch rename to 0153-Add-a-version-command.patch index f7398b9..47da68f 100644 --- a/0233-Add-a-version-command.patch +++ b/0153-Add-a-version-command.patch @@ -41,10 +41,10 @@ index 9323c125469..61c4683cb76 100644 have_with_bootdir=n AC_ARG_WITH([bootdir], diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 203584fb00b..701e5d32fa2 100644 +index 144734e39e1..59ead422028 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -537,6 +537,11 @@ image = { +@@ -535,6 +535,11 @@ image = { enable = mips_loongson; }; diff --git a/0153-Add-relative-path-to-the-kernel-and-initrds-BLS-fiel.patch b/0153-Add-relative-path-to-the-kernel-and-initrds-BLS-fiel.patch deleted file mode 100644 index 5a5a77d..0000000 --- a/0153-Add-relative-path-to-the-kernel-and-initrds-BLS-fiel.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 4 Jun 2018 16:10:22 +0200 -Subject: [PATCH] Add relative path to the kernel and initrds BLS fields if - needed - -The static BLS config file shipped with the kernel package assumes that -the /boot directory is a mount point, and that the kernel and initramfs -images relative path is to the root of a boot partition. - -But there are cases in which this isn't true, for example if a user has -its /boot in a btrfs subvolume or if /boot isn't a mount point at all. - -So instead of always using the BLS fragment file as distributed by the -package, check the relative path that GRUB 2 has to use for the images. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 20 +++++++++++++++++--- - 1 file changed, 17 insertions(+), 3 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 89487ad611c..2482483a437 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -188,6 +188,7 @@ fi - mkbls() { - local kernelver=$1 && shift - local datetime=$1 && shift -+ local bootprefix=$1 && shift - - local debugname="" - local debugid="" -@@ -206,8 +207,8 @@ mkbls() { - cat <"${bls_target}" - fi - -+ linux="$(grep '^linux[ \t]' "${bls_target}" | sed -e 's,^linux[ \t]*,,')" -+ initrd="$(grep '^initrd[ \t]' "${bls_target}" | sed -e 's,^initrd[ \t]*,,')" -+ linux_relpath="$("${grub_mkrelpath}" /boot/$linux)" -+ initrd_relpath="$("${grub_mkrelpath}" /boot/$initrd)" -+ -+ if [[ $linux != $linux_relpath ]]; then -+ sed -i -e "s,^linux.*,linux ${linux_relpath},g" "${bls_target}" -+ sed -i -e "s,^initrd.*,initrd ${initrd_relpath},g" "${bls_target}" -+ fi -+ - if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then - arch="$(uname -m)" - bls_debug="$(echo ${bls_target} | sed -e "s/\.${arch}/-debug.${arch}/")" -@@ -247,7 +258,10 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - done - - if [[ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]]; then -- mkbls "0-rescue-${MACHINE_ID}" "0" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" -+ if [[ $linux != $linux_relpath ]]; then -+ bootprefix="$(dirname ${linux_relpath})" -+ fi -+ mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" - fi - - GENERATE=0 diff --git a/0234-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch b/0154-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch similarity index 100% rename from 0234-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch rename to 0154-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch diff --git a/0154-Skip-leading-spaces-on-BLS-field-values.patch b/0154-Skip-leading-spaces-on-BLS-field-values.patch deleted file mode 100644 index df80edf..0000000 --- a/0154-Skip-leading-spaces-on-BLS-field-values.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 7 Jun 2018 00:44:51 +0200 -Subject: [PATCH] Skip leading spaces on BLS field values - -The GRUB 2 blscfg command doesn't parse correctly the BLS fields if these -have extra spaces before the field values. For example, the following BLS -fragment generates a wrong menu entry due using spaces to tabulate values: - -title Fedora 28 (Twenty Eight) -version 4.16.13-300.fc28.x86_64 -machine-id e5c131dfee3249cbb9891c2641d8e350 -linux /vmlinuz-4.16.13-300.fc28.x86_64 -initrd /initramfs-4.16.13-300.fc28.x86_64.img -options root=/dev/mapper/fedora-root ro - -Wrong generated menu entry: - -load_video -set gfx_payload=keep -insmod gzio -linux ($root) /vmlinuz-4.16.13-300.fc28.x86_64 root=/dev/mapper/fedora-root ro -initrd ($root) /initramfs-4.16.13-300.fc28.x86_64.img - -Correct menu entry after the fix: - -load_video -set gfx_payload=keep -insmod gzio -linux ($root)/vmlinuz-4.16.13-300.fc28.x86_64 root=/dev/mapper/fedora-root ro -initrd ($root)/initramfs-4.16.13-300.fc28.x86_64.img - -Resolves: rhbz#1588184 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index fb08d8e4c12..831cdcaccdf 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -448,7 +448,11 @@ static int read_entry ( - - separator[0] = '\0'; - -- rc = bls_add_keyval (entry, buf, separator+1); -+ do { -+ separator++; -+ } while (*separator == ' ' || *separator == '\t'); -+ -+ rc = bls_add_keyval (entry, buf, separator); - grub_free (buf); - if (rc < 0) - break; diff --git a/0235-arm-arm64-loader-Better-memory-allocation-and-error-.patch b/0155-arm-arm64-loader-Better-memory-allocation-and-error-.patch similarity index 100% rename from 0235-arm-arm64-loader-Better-memory-allocation-and-error-.patch rename to 0155-arm-arm64-loader-Better-memory-allocation-and-error-.patch diff --git a/0156-TPM-Fix-hash_log_extend_event-function-prototype.patch b/0156-TPM-Fix-hash_log_extend_event-function-prototype.patch deleted file mode 100644 index 56cd169..0000000 --- a/0156-TPM-Fix-hash_log_extend_event-function-prototype.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Fri, 15 Jun 2018 09:25:00 +0200 -Subject: [PATCH] TPM: Fix hash_log_extend_event function prototype - -The DataToHash argument is a efi_physical_address, not a *pointer* to -a efi_physical_address. - -This distinction is important for 32 bits builds, where the pointer is -only 32 bits where as an efi_physical_address is 64 bits. - -Fixing this fixes the tpm code not working with 32 bits build and grub -showing multiple: - -error: Invalid parameter - -Messages during boot, followed by a "press any key to continue" message. - -Signed-off-by: Hans de Goede ---- - grub-core/kern/efi/tpm.c | 2 +- - include/grub/efi/tpm.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/kern/efi/tpm.c b/grub-core/kern/efi/tpm.c -index c9fb3c133f3..36e1f69df16 100644 ---- a/grub-core/kern/efi/tpm.c -+++ b/grub-core/kern/efi/tpm.c -@@ -245,7 +245,7 @@ grub_tpm2_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf, - event->Size = sizeof(*event) - sizeof(event->Event) + grub_strlen(description) + 1; - grub_memcpy(event->Event, description, grub_strlen(description) + 1); - -- status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, buf, -+ status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (unsigned long) buf, - (grub_uint64_t) size, event); - - switch (status) { -diff --git a/include/grub/efi/tpm.h b/include/grub/efi/tpm.h -index e2aff4a3c22..63d8a0fe714 100644 ---- a/include/grub/efi/tpm.h -+++ b/include/grub/efi/tpm.h -@@ -129,7 +129,7 @@ struct grub_efi_tpm2_protocol - grub_efi_boolean_t *EventLogTruncated); - grub_efi_status_t (*hash_log_extend_event) (struct grub_efi_tpm2_protocol *this, - grub_efi_uint64_t Flags, -- grub_efi_physical_address_t *DataToHash, -+ grub_efi_physical_address_t DataToHash, - grub_efi_uint64_t DataToHashLen, - EFI_TCG2_EVENT *EfiTcgEvent); - grub_efi_status_t (*submit_command) (struct grub_efi_tpm2_protocol *this, diff --git a/0236-Try-to-pick-better-locations-for-kernel-and-initrd.patch b/0156-Try-to-pick-better-locations-for-kernel-and-initrd.patch similarity index 100% rename from 0236-Try-to-pick-better-locations-for-kernel-and-initrd.patch rename to 0156-Try-to-pick-better-locations-for-kernel-and-initrd.patch diff --git a/0237-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch b/0157-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch similarity index 100% rename from 0237-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch rename to 0157-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch diff --git a/0157-TPM-Fix-compiler-warnings.patch b/0157-TPM-Fix-compiler-warnings.patch deleted file mode 100644 index b19d484..0000000 --- a/0157-TPM-Fix-compiler-warnings.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Fri, 15 Jun 2018 09:58:50 +0200 -Subject: [PATCH] TPM: Fix compiler warnings - -Stop defining our own Event type in tpm.c instead use the one from -the header, so that it matches the function prototype. -Note this requires some further code changes to go from all lowercaps -of the private Event type to the CamelCaps from the header. - -Also cast buf, which gets passed as a efi_physicall_address_t to an -integer, to avoid the compiler complaining about passing a pointer as -an integer. - -Signed-off-by: Hans de Goede ---- - grub-core/kern/efi/tpm.c | 24 ++++++++---------------- - 1 file changed, 8 insertions(+), 16 deletions(-) - -diff --git a/grub-core/kern/efi/tpm.c b/grub-core/kern/efi/tpm.c -index 36e1f69df16..0d3ebe22e57 100644 ---- a/grub-core/kern/efi/tpm.c -+++ b/grub-core/kern/efi/tpm.c -@@ -161,21 +161,12 @@ grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, - } - } - --typedef struct { -- grub_uint32_t pcrindex; -- grub_uint32_t eventtype; -- grub_uint8_t digest[20]; -- grub_uint32_t eventsize; -- grub_uint8_t event[1]; --} Event; -- -- - static grub_err_t - grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf, - grub_size_t size, grub_uint8_t pcr, - const char *description) - { -- Event *event; -+ TCG_PCR_EVENT *event; - grub_efi_status_t status; - grub_efi_tpm_protocol_t *tpm; - grub_efi_physical_address_t lastevent; -@@ -188,18 +179,19 @@ grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf, - if (!grub_tpm_present(tpm)) - return 0; - -- event = grub_zalloc(sizeof (Event) + grub_strlen(description) + 1); -+ event = grub_zalloc(sizeof (TCG_PCR_EVENT) + grub_strlen(description) + 1); - if (!event) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, - N_("cannot allocate TPM event buffer")); - -- event->pcrindex = pcr; -- event->eventtype = EV_IPL; -- event->eventsize = grub_strlen(description) + 1; -- grub_memcpy(event->event, description, event->eventsize); -+ event->PCRIndex = pcr; -+ event->EventType = EV_IPL; -+ event->EventSize = grub_strlen(description) + 1; -+ grub_memcpy(event->Event, description, event->EventSize); - - algorithm = TCG_ALG_SHA; -- status = efi_call_7 (tpm->log_extend_event, tpm, buf, (grub_uint64_t) size, -+ status = efi_call_7 (tpm->log_extend_event, tpm, -+ (unsigned long) buf, (grub_uint64_t) size, - algorithm, event, &eventnum, &lastevent); - - switch (status) { diff --git a/0238-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch b/0158-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch similarity index 100% rename from 0238-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch rename to 0158-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch diff --git a/0158-grub-switch-to-blscfg.in-get-rid-of-a-bunch-of-bashi.patch b/0158-grub-switch-to-blscfg.in-get-rid-of-a-bunch-of-bashi.patch deleted file mode 100644 index 54c4322..0000000 --- a/0158-grub-switch-to-blscfg.in-get-rid-of-a-bunch-of-bashi.patch +++ /dev/null @@ -1,113 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 22 Jun 2018 14:01:06 -0400 -Subject: [PATCH] grub-switch-to-blscfg.in: get rid of a bunch of bashisms - -Since this says /bin/sh at the top, it should work with dash. - -Signed-off-by: Peter Jones ---- - util/grub-switch-to-blscfg.in | 30 +++++++++++++++--------------- - 1 file changed, 15 insertions(+), 15 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 2482483a437..dac41e73836 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -151,18 +151,18 @@ done - - find_grub_cfg() { - local candidate="" -- while [[ -e "${candidate}" || $# -gt 0 ]] -+ while [ -e "${candidate}" -o $# -gt 0 ] - do -- if [[ ! -e "${candidate}" ]] ; then -+ if [ ! -e "${candidate}" ] ; then - candidate="$1" - shift - fi - -- if [[ -L "${candidate}" ]]; then -+ if [ -L "${candidate}" ]; then - candidate="$(realpath "${candidate}")" - fi - -- if [[ -f "${candidate}" ]]; then -+ if [ -f "${candidate}" ]; then - export GRUB_CONFIG_FILE="${candidate}" - return 0 - fi -@@ -175,11 +175,11 @@ if ! find_grub_cfg ${startlink} ${grubdir}/grub.cfg ; then - exit 1 - fi - --if [[ ! -d "${blsdir}" ]]; then -+if [ ! -d "${blsdir}" ]; then - install -m 700 -d "${blsdir}" - fi - --if [[ -f /etc/machine-id ]]; then -+if [ -f /etc/machine-id ]; then - MACHINE_ID=$(cat /etc/machine-id) - else - MACHINE_ID=$(dmesg | sha256sum) -@@ -194,9 +194,9 @@ mkbls() { - local debugid="" - local flavor="" - -- if [[ "$kernelver" == *\+* ]] ; then -+ if [ "$kernelver" == *\+* ] ; then - local flavor=-"${kernelver##*+}" -- if [[ "${flavor}" == "-debug" ]]; then -+ if [ "${flavor}" == "-debug" ]; then - local debugname=" with debugging" - local debugid="-debug" - fi -@@ -219,15 +219,15 @@ EOF - } - - for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do -- if [[ ! -d "/lib/modules/${kernelver}" ]] ; then -+ if [ ! -d "/lib/modules/${kernelver}" ] ; then - continue - fi -- if [[ ! -f "/boot/vmlinuz-${kernelver}" ]]; then -+ if [ ! -f "/boot/vmlinuz-${kernelver}" ]; then - continue - fi - bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf" - kernel_dir="/lib/modules/${kernelver}" -- if [[ -f "${kernel_dir}/bls.conf" ]]; then -+ if [ -f "${kernel_dir}/bls.conf" ]; then - cp -af "${kernel_dir}/bls.conf" "${bls_target}" - else - mkbls "${kernelver}" \ -@@ -240,7 +240,7 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - linux_relpath="$("${grub_mkrelpath}" /boot/$linux)" - initrd_relpath="$("${grub_mkrelpath}" /boot/$initrd)" - -- if [[ $linux != $linux_relpath ]]; then -+ if [ $linux != $linux_relpath ] ; then - sed -i -e "s,^linux.*,linux ${linux_relpath},g" "${bls_target}" - sed -i -e "s,^initrd.*,initrd ${initrd_relpath},g" "${bls_target}" - fi -@@ -257,8 +257,8 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - fi - done - --if [[ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]]; then -- if [[ $linux != $linux_relpath ]]; then -+if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then -+ if [ $linux != $linux_relpath ]; then - bootprefix="$(dirname ${linux_relpath})" - fi - mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" -@@ -282,7 +282,7 @@ elif ! grep -q '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" ; then - GENERATE=1 - fi - --if [[ "${GENERATE}" -eq 1 ]] ; then -+if [ "${GENERATE}" -eq 1 ] ; then - cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}" - if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then - cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}" diff --git a/0159-grub-switch-to-blscfg.in-Better-boot-prefix-checking.patch b/0159-grub-switch-to-blscfg.in-Better-boot-prefix-checking.patch deleted file mode 100644 index 8437c68..0000000 --- a/0159-grub-switch-to-blscfg.in-Better-boot-prefix-checking.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 22 Jun 2018 14:04:28 -0400 -Subject: [PATCH] grub-switch-to-blscfg.in: Better boot prefix checking - -Signed-off-by: Peter Jones ---- - util/grub-switch-to-blscfg.in | 36 +++++++++++++++++------------------- - 1 file changed, 17 insertions(+), 19 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index dac41e73836..884cf45b1e1 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -219,30 +219,31 @@ EOF - } - - for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do -- if [ ! -d "/lib/modules/${kernelver}" ] ; then -- continue -- fi -- if [ ! -f "/boot/vmlinuz-${kernelver}" ]; then -- continue -- fi - bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf" -+ linux="$(grep '^linux[ \t]' "${bls_target}" | sed -e 's,^linux[ \t]+,,')" - kernel_dir="/lib/modules/${kernelver}" -- if [ -f "${kernel_dir}/bls.conf" ]; then -+ -+ if [ ! -d "${kernel_dir}" ] ; then -+ continue -+ fi -+ if [ ! -f "${linux_path}" ]; then -+ continue -+ fi -+ -+ linux_relpath="$("${grub_mkrelpath}" "${linux}")" -+ bootprefix="${linux%%"${linux_relpath}"}" -+ -+ if [ -f "${kernel_dir}/bls.conf" ] ; then - cp -af "${kernel_dir}/bls.conf" "${bls_target}" - else - mkbls "${kernelver}" \ - "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \ -+ "${bootprefix}" \ - >"${bls_target}" - fi - -- linux="$(grep '^linux[ \t]' "${bls_target}" | sed -e 's,^linux[ \t]*,,')" -- initrd="$(grep '^initrd[ \t]' "${bls_target}" | sed -e 's,^initrd[ \t]*,,')" -- linux_relpath="$("${grub_mkrelpath}" /boot/$linux)" -- initrd_relpath="$("${grub_mkrelpath}" /boot/$initrd)" -- -- if [ $linux != $linux_relpath ] ; then -- sed -i -e "s,^linux.*,linux ${linux_relpath},g" "${bls_target}" -- sed -i -e "s,^initrd.*,initrd ${initrd_relpath},g" "${bls_target}" -+ if [ -n "${bootprefix}" ]; then -+ sed -i -e "s,\([ \t]\)${bootprefix},\1,g" "${bls_target}" - fi - - if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -@@ -257,10 +258,7 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - fi - done - --if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then -- if [ $linux != $linux_relpath ]; then -- bootprefix="$(dirname ${linux_relpath})" -- fi -+if [ -n "${bootprefix}" -a -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then - mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" - fi - diff --git a/0240-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch b/0159-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch similarity index 100% rename from 0240-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch rename to 0159-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch diff --git a/0160-Use-boot-loader-entries-as-BLS-directory-path-also-o.patch b/0160-Use-boot-loader-entries-as-BLS-directory-path-also-o.patch deleted file mode 100644 index 88b9bc2..0000000 --- a/0160-Use-boot-loader-entries-as-BLS-directory-path-also-o.patch +++ /dev/null @@ -1,152 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 25 Jun 2018 11:45:33 +0200 -Subject: [PATCH] Use /boot/loader/entries as BLS directory path also on EFI - systems - -For EFI systems, the BLS fragments were stored in the EFI System Partition -(ESP) while in non-EFI systems it was stored in /boot. - -For consistency, it's better to always store the BLS fragments in the same -path regardless of the firmware interface used. - -Also change the grub2-switch-to-blscfg script default BLS directory. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 48 ++++++++++++++++++++++++++++++++----------- - util/grub-switch-to-blscfg.in | 4 ++-- - 2 files changed, 38 insertions(+), 14 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 831cdcaccdf..70939a81826 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -381,9 +381,14 @@ static int bls_cmp(const void *p0, const void *p1, void *state UNUSED) - return rc; - } - -+struct read_entry_info { -+ const char *devid; -+ const char *dirname; -+}; -+ - static int read_entry ( - const char *filename, -- const struct grub_dirhook_info *info UNUSED, -+ const struct grub_dirhook_info *dirhook_info UNUSED, - void *data) - { - grub_size_t n; -@@ -391,8 +396,7 @@ static int read_entry ( - grub_file_t f = NULL; - grub_off_t sz; - struct bls_entry *entry; -- const char *dirname= (const char *)data; -- const char *devid = grub_env_get ("boot"); -+ struct read_entry_info *info = (struct read_entry_info *)data; - - grub_dprintf ("blscfg", "filename: \"%s\"\n", filename); - -@@ -406,7 +410,7 @@ static int read_entry ( - if (grub_strcmp (filename + n - 5, ".conf") != 0) - return 0; - -- p = grub_xasprintf ("(%s)%s/%s", devid, dirname, filename); -+ p = grub_xasprintf ("(%s)%s/%s", info->devid, info->dirname, filename); - - f = grub_file_open (p); - if (!f) -@@ -655,10 +659,13 @@ static int find_entry (const char *filename, - void *data) - { - struct find_entry_info *info = (struct find_entry_info *)data; -+ struct read_entry_info read_entry_info; - grub_file_t f = NULL; - char *grubenv_path = NULL; - grub_envblk_t env = NULL; - char *default_blsdir = NULL; -+ grub_fs_t blsdir_fs = NULL; -+ grub_device_t blsdir_dev = NULL; - const char *blsdir = NULL; - char *saved_env_buf = NULL; - int r = 0; -@@ -678,9 +685,6 @@ static int find_entry (const char *filename, - if (info->platform == PLATFORM_EMU) - default_blsdir = grub_xasprintf ("%s%s", GRUB_BOOT_DEVICE, - GRUB_BLS_CONFIG_PATH); -- else if (info->platform == PLATFORM_EFI) -- default_blsdir = grub_xasprintf ("/EFI/%s%s", filename, -- GRUB_BLS_CONFIG_PATH); - else - default_blsdir = grub_xasprintf ("%s", GRUB_BLS_CONFIG_PATH); - -@@ -744,16 +748,33 @@ static int find_entry (const char *filename, - goto finish; - - grub_dprintf ("blscfg", "blsdir: \"%s\"\n", blsdir); -- if (blsdir[0] != '/' && info->platform == PLATFORM_EFI) -- blsdir = grub_xasprintf ("/EFI/%s/%s/", filename, blsdir); -- else -- blsdir = grub_strdup (blsdir); -+ blsdir = grub_strdup (blsdir); - - if (!blsdir) - goto finish; - - grub_dprintf ("blscfg", "blsdir: \"%s\"\n", blsdir); -- r = info->fs->dir (info->dev, blsdir, read_entry, (char *)blsdir); -+ if (info->platform == PLATFORM_EFI) { -+ read_entry_info.devid = grub_env_get ("root"); -+ if (!read_entry_info.devid) -+ goto finish; -+ -+ blsdir_dev = grub_device_open (read_entry_info.devid); -+ if (!blsdir_dev) -+ goto finish; -+ -+ blsdir_fs = grub_fs_probe (blsdir_dev); -+ if (!blsdir_fs) -+ goto finish; -+ -+ } else { -+ read_entry_info.devid = devid; -+ blsdir_dev = info->dev; -+ blsdir_fs = info->fs; -+ } -+ read_entry_info.dirname = blsdir; -+ -+ r = blsdir_fs->dir (blsdir_dev, blsdir, read_entry, &read_entry_info); - if (r != 0) { - grub_dprintf ("blscfg", "read_entry returned error\n"); - grub_err_t e; -@@ -773,6 +794,9 @@ static int find_entry (const char *filename, - for (r = 0; r < nentries; r++) - bls_free_entry (entries[r]); - finish: -+ if (info->platform == PLATFORM_EFI && blsdir_dev) -+ grub_device_close (blsdir_dev); -+ - nentries = 0; - - grub_free (entries); -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 884cf45b1e1..2f37a1f740b 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -44,13 +44,13 @@ EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') - if [ -d /sys/firmware/efi/efivars/ ]; then - startlink=/etc/grub2-efi.cfg - grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'` -- blsdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/loader/entries" | sed 's,//*,/,g'` - else - startlink=/etc/grub2.cfg - grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'` -- blsdir=`echo "/@bootdirname@/loader/entries" | sed 's,//*,/,g'` - fi - -+blsdir=`echo "/@bootdirname@/loader/entries" | sed 's,//*,/,g'` -+ - backupsuffix=.bak - - export TEXTDOMAIN=@PACKAGE@ diff --git a/0241-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch b/0160-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch similarity index 100% rename from 0241-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch rename to 0160-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch diff --git a/0161-Use-BLS-fragment-filename-as-menu-entry-id-and-for-c.patch b/0161-Use-BLS-fragment-filename-as-menu-entry-id-and-for-c.patch deleted file mode 100644 index 7f765e7..0000000 --- a/0161-Use-BLS-fragment-filename-as-menu-entry-id-and-for-c.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 26 Jun 2018 14:01:26 +0200 -Subject: [PATCH] Use BLS fragment filename as menu entry id and for criteria - to sort - -The BLS config filenames are guaranteed to be unique, so they can be -used as GRUB2 entry id and can also be used to sort the menu entries. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 62 +++++++++------------------------------------ - 1 file changed, 12 insertions(+), 50 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 70939a81826..cd8659384e4 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -70,6 +70,7 @@ struct bls_entry - { - struct keyval **keyvals; - int nkeyvals; -+ char *filename; - }; - - static struct bls_entry **entries; -@@ -166,6 +167,7 @@ static void bls_free_entry(struct bls_entry *entry) - - grub_free (entry->keyvals); - grub_memset (entry, 0, sizeof (*entry)); -+ grub_free (entry->filename); - grub_free (entry); - } - -@@ -327,58 +329,12 @@ finish: - - typedef int (*void_cmp_t)(void *, void *); - --static int nulcmp(char *s0, char *s1, void_cmp_t cmp) --{ -- grub_dprintf("blscfg", "%s got here\n", __func__); -- if (s1 && !s0) -- return 1; -- if (s0 && !s1) -- return -1; -- if (!s0 && !s1) -- return 0; -- if (cmp) -- return cmp(s0, s1); -- return grub_strcmp(s0, s1); --} -- --static int --bls_keyval_cmp(struct bls_entry *e0, struct bls_entry *e1, const char *keyname) --{ -- char *val0, *val1; -- -- val0 = bls_get_val (e0, keyname, NULL); -- val1 = bls_get_val (e1, keyname, NULL); -- -- if (val1 && !val0) -- return 1; -- -- if (val0 && !val1) -- return -1; -- -- if (!val0 && !val1) -- return 0; -- -- return nulcmp(val0, val1, (void_cmp_t)vercmp); --} -- - static int bls_cmp(const void *p0, const void *p1, void *state UNUSED) - { - struct bls_entry * e0 = *(struct bls_entry **)p0; - struct bls_entry * e1 = *(struct bls_entry **)p1; -- int rc = 0; - -- rc = bls_keyval_cmp (e0, e1, "id"); -- -- if (rc == 0) -- rc = bls_keyval_cmp (e0, e1, "version"); -- -- if (rc == 0) -- rc = bls_keyval_cmp (e0, e1, "title"); -- -- if (rc == 0) -- rc = bls_keyval_cmp (e0, e1, "linux"); -- -- return rc; -+ return vercmp(e0->filename, e1->filename); - } - - struct read_entry_info { -@@ -424,6 +380,12 @@ static int read_entry ( - if (!entry) - goto finish; - -+ entry->filename = grub_strndup(filename, n - 5); -+ if (!entry->filename) -+ goto finish; -+ -+ entry->filename[n - 5] = '\0'; -+ - for (;;) - { - char *buf; -@@ -548,7 +510,7 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - char *options = NULL; - char **initrds = NULL; - char *initrd = NULL; -- char *id = NULL; -+ char *id = entry->filename; - char *hotkey = NULL; - - char *users = NULL; -@@ -570,7 +532,6 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - title = bls_get_val (entry, "title", NULL); - options = bls_get_val (entry, "options", NULL); - initrds = bls_make_list (entry, "initrd", NULL); -- id = bls_get_val (entry, "id", NULL); - - hotkey = bls_get_val (entry, "grub_hotkey", NULL); - users = bls_get_val (entry, "grub_users", NULL); -@@ -584,7 +545,8 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - argv[i] = args[i-1]; - argv[argc] = NULL; - -- grub_dprintf ("blscfg", "adding menu entry for \"%s\"\n", title); -+ grub_dprintf ("blscfg", "adding menu entry for \"%s\" with id \"%s\"\n", -+ title, id); - if (initrds) - { - int initrd_size = sizeof (GRUB_INITRD_CMD); diff --git a/0242-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch b/0161-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch similarity index 100% rename from 0242-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch rename to 0161-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch diff --git a/0162-Fix-grub-switch-to-blscfg-boot-prefix-handling.patch b/0162-Fix-grub-switch-to-blscfg-boot-prefix-handling.patch deleted file mode 100644 index be7d1a3..0000000 --- a/0162-Fix-grub-switch-to-blscfg-boot-prefix-handling.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 9 Jul 2018 12:19:03 +0200 -Subject: [PATCH] Fix grub-switch-to-blscfg boot prefix handling - -Commit b3ac18e3265f ("grub-switch-to-blscfg.in: Better boot prefix checking") -simplified the boot prefix checking, but unfortunately introduced a couple of -regressions on the script. Fix them. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 12 +++++++----- - 1 file changed, 7 insertions(+), 5 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 2f37a1f740b..40612e00686 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -220,7 +220,8 @@ EOF - - for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf" -- linux="$(grep '^linux[ \t]' "${bls_target}" | sed -e 's,^linux[ \t]+,,')" -+ linux="/vmlinuz-${kernelver}" -+ linux_path="/boot${linux}" - kernel_dir="/lib/modules/${kernelver}" - - if [ ! -d "${kernel_dir}" ] ; then -@@ -230,8 +231,8 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - continue - fi - -- linux_relpath="$("${grub_mkrelpath}" "${linux}")" -- bootprefix="${linux%%"${linux_relpath}"}" -+ linux_relpath="$("${grub_mkrelpath}" "${linux_path}")" -+ bootprefix="${linux_relpath%%"${linux}"}" - - if [ -f "${kernel_dir}/bls.conf" ] ; then - cp -af "${kernel_dir}/bls.conf" "${bls_target}" -@@ -243,7 +244,8 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - fi - - if [ -n "${bootprefix}" ]; then -- sed -i -e "s,\([ \t]\)${bootprefix},\1,g" "${bls_target}" -+ sed -i -e "s,^\(linux[^ \t]*[ \t]\+\).*,\1${bootprefix}${linux},g" "${bls_target}" -+ sed -i -e "/^initrd/ s,\([ \t]\+\)\([^ \t]\+\),\1${bootprefix}\2,g" "${bls_target}" - fi - - if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -@@ -258,7 +260,7 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - fi - done - --if [ -n "${bootprefix}" -a -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then -+if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then - mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" - fi - diff --git a/0243-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch b/0162-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch similarity index 100% rename from 0243-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch rename to 0162-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch diff --git a/0249-Fix-getroot.c-s-trampolines.patch b/0163-Fix-getroot.c-s-trampolines.patch similarity index 100% rename from 0249-Fix-getroot.c-s-trampolines.patch rename to 0163-Fix-getroot.c-s-trampolines.patch diff --git a/0163-Revert-trim-arp-packets-with-abnormal-size.patch b/0163-Revert-trim-arp-packets-with-abnormal-size.patch deleted file mode 100644 index 5a169d7..0000000 --- a/0163-Revert-trim-arp-packets-with-abnormal-size.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 18 May 2017 14:25:45 -0400 -Subject: [PATCH] Revert "trim arp packets with abnormal size" - -This reverts commit d11b2eb425d2125f67dd8d8e9b11d9be7d6f3f11. ---- - grub-core/net/arp.c | 6 ------ - 1 file changed, 6 deletions(-) - -diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c -index d1c69ed2b55..54306e3b16d 100644 ---- a/grub-core/net/arp.c -+++ b/grub-core/net/arp.c -@@ -150,12 +150,6 @@ grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card, - if (grub_net_addr_cmp (&inf->address, &target_addr) == 0 - && arp_packet->op == grub_cpu_to_be16_compile_time (ARP_REQUEST)) - { -- if ((nb->tail - nb->data) > 50) -- { -- grub_dprintf ("net", "arp packet with abnormal size (%ld bytes).\n", -- nb->tail - nb->data); -- nb->tail = nb->data + 50; -- } - grub_net_link_level_address_t target; - struct grub_net_buff nb_reply; - struct arppkt *arp_reply; diff --git a/0250-Do-not-allow-stack-trampolines-anywhere.patch b/0164-Do-not-allow-stack-trampolines-anywhere.patch similarity index 100% rename from 0250-Do-not-allow-stack-trampolines-anywhere.patch rename to 0164-Do-not-allow-stack-trampolines-anywhere.patch diff --git a/0251-Reimplement-boot_counter.patch b/0165-Reimplement-boot_counter.patch similarity index 82% rename from 0251-Reimplement-boot_counter.patch rename to 0165-Reimplement-boot_counter.patch index c0a3b84..032dded 100644 --- a/0251-Reimplement-boot_counter.patch +++ b/0165-Reimplement-boot_counter.patch @@ -11,17 +11,19 @@ Apparently, this *really* wasn't tested well enough. Resolves: rhbz#1614637 Signed-off-by: Peter Jones +[lorbus: add comments and revert logic changes in 01_fallback_counting] +Signed-off-by: Christian Glombek --- Makefile.util.def | 6 +++ grub-core/Makefile.core.def | 5 ++ grub-core/commands/increment.c | 105 ++++++++++++++++++++++++++++++++++++ - util/grub.d/01_fallback_counting.in | 15 ++++++ - 4 files changed, 131 insertions(+) + util/grub.d/01_fallback_counting.in | 22 ++++++++ + 4 files changed, 138 insertions(+) create mode 100644 grub-core/commands/increment.c create mode 100644 util/grub.d/01_fallback_counting.in diff --git a/Makefile.util.def b/Makefile.util.def -index cba4d500198..c8cb91308d9 100644 +index 08cc98ddb8b..eca3dfa753f 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -448,6 +448,12 @@ script = { @@ -38,7 +40,7 @@ index cba4d500198..c8cb91308d9 100644 name = '01_menu_auto_hide'; common = util/grub.d/01_menu_auto_hide.in; diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 30c2ac8f3c8..826e27af900 100644 +index 59ead422028..ceb6fc677a0 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -362,6 +362,11 @@ kernel = { @@ -166,22 +168,29 @@ index 00000000000..79cf137656c +} diff --git a/util/grub.d/01_fallback_counting.in b/util/grub.d/01_fallback_counting.in new file mode 100644 -index 00000000000..6ca13da03df +index 00000000000..be0e770ea82 --- /dev/null +++ b/util/grub.d/01_fallback_counting.in -@@ -0,0 +1,15 @@ +@@ -0,0 +1,22 @@ +#! /bin/sh -e + +# Boot Counting ++# The boot_counter env var can be used to count down boot attempts after an ++# OSTree upgrade and choose the rollback deployment when 0 is reached. Both ++# boot_counter and boot_success need to be (re-)set from userspace. +cat << EOF +insmod increment -+if [ -z "\${boot_counter}" ]; then -+ set boot_counter=0 -+elif [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then -+ increment default -+ set boot_counter=-1 -+else -+ decrement boot_counter ++# Check if boot_counter exists and boot_success=0 to activate this behaviour. ++if [ -n "\${boot_counter}" -a "\${boot_success}" = "0" ]; then ++ # if countdown has ended, choose to boot rollback deployment (default=1 on ++ # OSTree-based systems) ++ if [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then ++ set default=1 ++ set boot_counter=-1 ++ # otherwise decrement boot_counter ++ else ++ decrement boot_counter ++ fi ++ save_env boot_counter +fi -+save_env boot_counter +EOF diff --git a/0262-Make-grub_strtoul-end-pointer-have-the-right-constif.patch b/0166-Make-grub_strtoul-end-pointer-have-the-right-constif.patch similarity index 100% rename from 0262-Make-grub_strtoul-end-pointer-have-the-right-constif.patch rename to 0166-Make-grub_strtoul-end-pointer-have-the-right-constif.patch diff --git a/0263-Fix-menu-entry-selection-based-on-ID-and-title.patch b/0167-Fix-menu-entry-selection-based-on-ID-and-title.patch similarity index 88% rename from 0263-Fix-menu-entry-selection-based-on-ID-and-title.patch rename to 0167-Fix-menu-entry-selection-based-on-ID-and-title.patch index 065765c..9de7cc5 100644 --- a/0263-Fix-menu-entry-selection-based-on-ID-and-title.patch +++ b/0167-Fix-menu-entry-selection-based-on-ID-and-title.patch @@ -15,12 +15,16 @@ ID as a numeral. In that case, we also require that the entire string is numeric, not merely a string with leading numeric characters. Resolves: rhbz#1640979 + +Signed-off-by: Peter Jones +[javierm: fix menu entry selection based on title] +Signed-off-by: Javier Martinez Canillas --- - grub-core/normal/menu.c | 146 +++++++++++++++++++++++++----------------------- - 1 file changed, 75 insertions(+), 71 deletions(-) + grub-core/normal/menu.c | 143 ++++++++++++++++++++++++------------------------ + 1 file changed, 72 insertions(+), 71 deletions(-) diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index 6cb2a071490..95f7abaf2fd 100644 +index 6cb2a071490..7e32c498aa8 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -164,12 +164,12 @@ grub_menu_set_timeout (int timeout) @@ -51,7 +55,7 @@ index 6cb2a071490..95f7abaf2fd 100644 if (*ptr1 == 0) return ptr1 - id; ptr1++; -@@ -187,6 +191,61 @@ menuentry_eq (const char *id, const char *spec) +@@ -187,6 +191,58 @@ menuentry_eq (const char *id, const char *spec) return 0; } @@ -81,14 +85,11 @@ index 6cb2a071490..95f7abaf2fd 100644 + + for (i = 0, e = menu->entry_list; e; i++) + { -+ int l = 0; -+ while (val[l] && !grub_isspace(val[l])) -+ l++; + -+ if (menuentry_eq (e->title, val, l)) ++ if (menuentry_eq (e->title, val, -1)) + { + if (tail) -+ *tail = val + l; ++ *tail = NULL; + return i; + } + e = e->next; @@ -113,7 +114,7 @@ index 6cb2a071490..95f7abaf2fd 100644 /* Get the first entry number from the value of the environment variable NAME, which is a space-separated list of non-negative integers. The entry number which is returned is stripped from the value of NAME. If no entry number -@@ -195,9 +254,8 @@ static int +@@ -195,9 +251,8 @@ static int get_and_remove_first_entry_number (grub_menu_t menu, const char *name) { const char *val; @@ -124,7 +125,7 @@ index 6cb2a071490..95f7abaf2fd 100644 val = grub_env_get (name); if (! val) -@@ -205,50 +263,24 @@ get_and_remove_first_entry_number (grub_menu_t menu, const char *name) +@@ -205,50 +260,24 @@ get_and_remove_first_entry_number (grub_menu_t menu, const char *name) grub_error_push (); @@ -183,7 +184,7 @@ index 6cb2a071490..95f7abaf2fd 100644 } grub_error_pop (); -@@ -525,6 +557,7 @@ static int +@@ -525,6 +554,7 @@ static int get_entry_number (grub_menu_t menu, const char *name) { const char *val; @@ -191,7 +192,7 @@ index 6cb2a071490..95f7abaf2fd 100644 int entry; val = grub_env_get (name); -@@ -532,38 +565,9 @@ get_entry_number (grub_menu_t menu, const char *name) +@@ -532,38 +562,9 @@ get_entry_number (grub_menu_t menu, const char *name) return -1; grub_error_push (); @@ -228,7 +229,7 @@ index 6cb2a071490..95f7abaf2fd 100644 - } - + entry = get_entry_number_helper(menu, val, &tail); -+ if (*tail != '\0') ++ if (tail && *tail != '\0') + entry = -1; grub_error_pop (); diff --git a/0267-Make-the-menu-entry-users-option-argument-to-be-opti.patch b/0168-Make-the-menu-entry-users-option-argument-to-be-opti.patch similarity index 94% rename from 0267-Make-the-menu-entry-users-option-argument-to-be-opti.patch rename to 0168-Make-the-menu-entry-users-option-argument-to-be-opti.patch index 50479ce..d560ec9 100644 --- a/0267-Make-the-menu-entry-users-option-argument-to-be-opti.patch +++ b/0168-Make-the-menu-entry-users-option-argument-to-be-opti.patch @@ -23,7 +23,7 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c -index 8d242b0187e..7004e08ce78 100644 +index 9faf2be0f64..29736f5cd03 100644 --- a/grub-core/commands/menuentry.c +++ b/grub-core/commands/menuentry.c @@ -29,7 +29,7 @@ static const struct grub_arg_option options[] = @@ -35,7 +35,7 @@ index 8d242b0187e..7004e08ce78 100644 N_("List of users allowed to boot this entry."), N_("USERNAME[,USERNAME]"), ARG_TYPE_STRING}, {"hotkey", 3, 0, -@@ -280,7 +280,7 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args) +@@ -281,7 +281,7 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args) if (! ctxt->state[3].set && ! ctxt->script) return grub_error (GRUB_ERR_BAD_ARGUMENT, "no menuentry definition"); diff --git a/0168-net-read-bracketed-ipv6-addrs-and-port-numbers-pjone.patch b/0168-net-read-bracketed-ipv6-addrs-and-port-numbers-pjone.patch deleted file mode 100644 index a0f3859..0000000 --- a/0168-net-read-bracketed-ipv6-addrs-and-port-numbers-pjone.patch +++ /dev/null @@ -1,105 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aaron Miller -Date: Fri, 29 Jul 2016 17:41:38 +0800 -Subject: [PATCH] net: read bracketed ipv6 addrs and port numbers (pjones - fixup) - -Various bug fixes related to previous patch. - -Signed-off-by: Peter Jones ---- - grub-core/net/http.c | 6 ++++-- - grub-core/net/net.c | 24 ++++++++++++------------ - 2 files changed, 16 insertions(+), 14 deletions(-) - -diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index f182d7b871d..00737c52750 100644 ---- a/grub-core/net/http.c -+++ b/grub-core/net/http.c -@@ -289,7 +289,9 @@ http_receive (grub_net_tcp_socket_t sock __attribute__ ((unused)), - nb2 = grub_netbuff_alloc (data->chunk_rem); - if (!nb2) - return grub_errno; -- grub_netbuff_put (nb2, data->chunk_rem); -+ err = grub_netbuff_put (nb2, data->chunk_rem); -+ if (err) -+ return grub_errno; - grub_memcpy (nb2->data, nb->data, data->chunk_rem); - if (file->device->net->packs.count >= 20) - { -@@ -405,7 +407,7 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) - data->filename, server, port ? port : HTTP_PORT); - data->sock = grub_net_tcp_open (server, - port ? port : HTTP_PORT, http_receive, -- http_err, http_err, -+ http_err, NULL, - file); - if (!data->sock) - { -diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 1f887d44b32..a0f4d00f0be 100644 ---- a/grub-core/net/net.c -+++ b/grub-core/net/net.c -@@ -441,10 +441,11 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) - int word, quaddot = -1; - int bracketed = 0; - -- if (ptr[0] == '[') { -- bracketed = 1; -- ptr++; -- } -+ if (ptr[0] == '[') -+ { -+ bracketed = 1; -+ ptr++; -+ } - - if (ptr[0] == ':' && ptr[1] != ':') - return 0; -@@ -483,9 +484,8 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) - grub_memset (&newip[quaddot], 0, (7 - word) * sizeof (newip[0])); - } - grub_memcpy (ip, newip, 16); -- if (bracketed && *ptr == ']') { -+ if (bracketed && *ptr == ']') - ptr++; -- } - if (rest) - *rest = ptr; - return 1; -@@ -1389,7 +1389,7 @@ grub_net_open_real (const char *name) - char* port_start; - /* ipv6 or port specified? */ - if ((port_start = grub_strchr (server, ':'))) -- { -+ { - char* ipv6_begin; - if((ipv6_begin = grub_strchr (server, '['))) - { -@@ -1461,14 +1461,13 @@ grub_net_open_real (const char *name) - { - grub_net_t ret = grub_zalloc (sizeof (*ret)); - if (!ret) -- return NULL; -- ret->protocol = proto; -- ret->server = grub_strdup (server); -- if (!ret->server) - { -- grub_free (ret); -+ grub_free (host); - return NULL; - } -+ ret->protocol = proto; -+ ret->port = port; -+ ret->server = host; - ret->fs = &grub_net_fs; - return ret; - } -@@ -1543,6 +1542,7 @@ grub_net_open_real (const char *name) - grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' not found"), - name); - -+ grub_free (host); - return NULL; - } - diff --git a/0273-Add-efi-export-env-and-efi-load-env-commands.patch b/0169-Add-efi-export-env-and-efi-load-env-commands.patch similarity index 99% rename from 0273-Add-efi-export-env-and-efi-load-env-commands.patch rename to 0169-Add-efi-export-env-and-efi-load-env-commands.patch index 58e8e1e..0e35e0b 100644 --- a/0273-Add-efi-export-env-and-efi-load-env-commands.patch +++ b/0169-Add-efi-export-env-and-efi-load-env-commands.patch @@ -22,7 +22,7 @@ Signed-off-by: Peter Jones create mode 100644 grub-core/commands/efi/env.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 826e27af900..017080bd599 100644 +index ceb6fc677a0..b662312ca6f 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -776,6 +776,12 @@ module = { @@ -310,7 +310,7 @@ index 41bc7cb1c9a..844a14d90da 100644 grub_util_create_envblk_file (const char *name) { diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c -index f8dc310909a..20062fe802b 100644 +index bb198f02351..6a79ee67444 100644 --- a/util/grub-set-bootflag.c +++ b/util/grub-set-bootflag.c @@ -25,6 +25,7 @@ @@ -319,8 +319,8 @@ index f8dc310909a..20062fe802b 100644 #include +#include #include /* For GRUB_ENVBLK_DEFCFG define */ + #include #include - #include diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 570a69361a5..2778b95df17 100644 --- a/include/grub/efi/efi.h diff --git a/0274-Make-it-possible-to-subtract-conditions-from-debug.patch b/0170-Make-it-possible-to-subtract-conditions-from-debug.patch similarity index 100% rename from 0274-Make-it-possible-to-subtract-conditions-from-debug.patch rename to 0170-Make-it-possible-to-subtract-conditions-from-debug.patch diff --git a/0170-Put-back-our-code-to-add-a-local-route.patch b/0170-Put-back-our-code-to-add-a-local-route.patch deleted file mode 100644 index e8da589..0000000 --- a/0170-Put-back-our-code-to-add-a-local-route.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 21 Jun 2018 18:32:26 -0400 -Subject: [PATCH] Put back our code to add a local route. - -This was removed by the previous patch. - -Signed-off-by: Peter Jones ---- - grub-core/net/bootp.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index ff1d7776e7f..242cd1f4cbd 100644 ---- a/grub-core/net/bootp.c -+++ b/grub-core/net/bootp.c -@@ -976,6 +976,7 @@ grub_net_configure_by_dhcpv6_reply (const char *name, - { - struct grub_net_network_level_interface *inf; - grub_dhcp6_options_t dhcp6; -+ int mask = -1; - - dhcp6 = grub_dhcp6_options_get (v6h, size); - if (!dhcp6) -@@ -1007,6 +1008,10 @@ grub_net_configure_by_dhcpv6_reply (const char *name, - } - - grub_dhcp6_options_free (dhcp6); -+ -+ if (inf) -+ grub_net_add_ipv6_local (inf, mask); -+ - return inf; - } - diff --git a/0275-Export-all-variables-from-the-initial-context-when-c.patch b/0171-Export-all-variables-from-the-initial-context-when-c.patch similarity index 100% rename from 0275-Export-all-variables-from-the-initial-context-when-c.patch rename to 0171-Export-all-variables-from-the-initial-context-when-c.patch diff --git a/0279-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch b/0172-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch similarity index 100% rename from 0279-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch rename to 0172-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch diff --git a/0280-Try-to-set-fPIE-and-friends-on-libgnu.a.patch b/0173-Try-to-set-fPIE-and-friends-on-libgnu.a.patch similarity index 100% rename from 0280-Try-to-set-fPIE-and-friends-on-libgnu.a.patch rename to 0173-Try-to-set-fPIE-and-friends-on-libgnu.a.patch diff --git a/0281-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch b/0174-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch similarity index 100% rename from 0281-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch rename to 0174-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch diff --git a/0287-Fix-the-type-of-grub_efi_status_t.patch b/0175-Fix-the-type-of-grub_efi_status_t.patch similarity index 100% rename from 0287-Fix-the-type-of-grub_efi_status_t.patch rename to 0175-Fix-the-type-of-grub_efi_status_t.patch diff --git a/0289-mkimage-Use-EFI32_HEADER_SIZE-define-in-arm-efi-case.patch b/0176-mkimage-Use-EFI32_HEADER_SIZE-define-in-arm-efi-case.patch similarity index 100% rename from 0289-mkimage-Use-EFI32_HEADER_SIZE-define-in-arm-efi-case.patch rename to 0176-mkimage-Use-EFI32_HEADER_SIZE-define-in-arm-efi-case.patch diff --git a/0177-Fix-grub_net_hwaddr_to_str.patch b/0177-Fix-grub_net_hwaddr_to_str.patch deleted file mode 100644 index 6c17a32..0000000 --- a/0177-Fix-grub_net_hwaddr_to_str.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Mark Salter -Date: Tue, 22 Aug 2017 12:21:12 -0400 -Subject: [PATCH] Fix grub_net_hwaddr_to_str - -commit 5c3b78c92f8 introduced support for larger network hw addresses. -However, grub_net_hwaddr_to_str() relies on GRUB_NET_MAX_STR_ADDRESS_SIZE -to prevent a spurious ':' at the end of the string. So now, if actual -hwaddr size is less than max, an extra ':' appears at the end of the -string. So calculate max string size based on actual hwaddr length to -fix the problem. - -Signed-off-by: Mark Salter ---- - grub-core/net/net.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index a0f4d00f0be..191e8e41bd6 100644 ---- a/grub-core/net/net.c -+++ b/grub-core/net/net.c -@@ -770,6 +770,7 @@ grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str) - { - char *ptr; - unsigned i; -+ int maxstr; - - if (addr->len > GRUB_NET_MAX_LINK_ADDRESS_SIZE) - { -@@ -778,9 +779,10 @@ grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str) - addr->type, addr->len); - return; - } -+ maxstr = addr->len * grub_strlen ("XX:"); - for (ptr = str, i = 0; i < addr->len; i++) - { -- ptr += grub_snprintf (ptr, GRUB_NET_MAX_STR_HWADDR_LEN - (ptr - str), -+ ptr += grub_snprintf (ptr, maxstr - (ptr - str), - "%02x:", addr->mac[i] & 0xff); - } - } diff --git a/0290-mkimage-Align-efi-sections-on-4k-boundary.patch b/0177-mkimage-Align-efi-sections-on-4k-boundary.patch similarity index 100% rename from 0290-mkimage-Align-efi-sections-on-4k-boundary.patch rename to 0177-mkimage-Align-efi-sections-on-4k-boundary.patch diff --git a/0291-mkimage-Clarify-file-alignment-in-efi-case.patch b/0178-mkimage-Clarify-file-alignment-in-efi-case.patch similarity index 100% rename from 0291-mkimage-Clarify-file-alignment-in-efi-case.patch rename to 0178-mkimage-Clarify-file-alignment-in-efi-case.patch diff --git a/0293-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch b/0179-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch similarity index 92% rename from 0293-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch rename to 0179-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch index 691380d..82df575 100644 --- a/0293-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch +++ b/0179-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch @@ -8,17 +8,17 @@ Also rename fallback and menu auto hide script to be executed before and after boot success reset script. In menu auto hide script, rename last_boot_ok var to menu_hide_ok --- - Makefile.util.def | 8 +++---- + Makefile.util.def | 14 ++++++++---- ...allback_counting.in => 08_fallback_counting.in} | 14 ++++++------ util/grub.d/10_reset_boot_success.in | 25 ++++++++++++++++++++++ .../{01_menu_auto_hide.in => 12_menu_auto_hide.in} | 23 +++++--------------- - 4 files changed, 42 insertions(+), 28 deletions(-) + 4 files changed, 48 insertions(+), 28 deletions(-) rename util/grub.d/{01_fallback_counting.in => 08_fallback_counting.in} (65%) create mode 100644 util/grub.d/10_reset_boot_success.in rename util/grub.d/{01_menu_auto_hide.in => 12_menu_auto_hide.in} (58%) diff --git a/Makefile.util.def b/Makefile.util.def -index eca3dfa753f..cae6002d2e3 100644 +index eca3dfa753f..5062a0e50fa 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -449,14 +449,14 @@ script = { @@ -40,6 +40,19 @@ index eca3dfa753f..cae6002d2e3 100644 installdir = grubconf; }; +@@ -515,6 +515,12 @@ script = { + condition = COND_HOST_LINUX; + }; + ++script = { ++ name = '10_reset_boot_success'; ++ common = util/grub.d/10_reset_boot_success.in; ++ installdir = grubconf; ++}; ++ + script = { + name = '10_xnu'; + common = util/grub.d/10_xnu.in; diff --git a/util/grub.d/01_fallback_counting.in b/util/grub.d/08_fallback_counting.in similarity index 65% rename from util/grub.d/01_fallback_counting.in diff --git a/0295-Fix-systemctl-kexec-exit-status-check.patch b/0180-Fix-systemctl-kexec-exit-status-check.patch similarity index 100% rename from 0295-Fix-systemctl-kexec-exit-status-check.patch rename to 0180-Fix-systemctl-kexec-exit-status-check.patch diff --git a/0296-Print-grub-emu-linux-loader-messages-as-debug.patch b/0181-Print-grub-emu-linux-loader-messages-as-debug.patch similarity index 100% rename from 0296-Print-grub-emu-linux-loader-messages-as-debug.patch rename to 0181-Print-grub-emu-linux-loader-messages-as-debug.patch diff --git a/0297-Don-t-assume-that-boot-commands-will-only-return-on-.patch b/0182-Don-t-assume-that-boot-commands-will-only-return-on-.patch similarity index 100% rename from 0297-Don-t-assume-that-boot-commands-will-only-return-on-.patch rename to 0182-Don-t-assume-that-boot-commands-will-only-return-on-.patch diff --git a/0299-Fix-undefined-references-for-fdt-when-building-with-.patch b/0183-Fix-undefined-references-for-fdt-when-building-with-.patch similarity index 100% rename from 0299-Fix-undefined-references-for-fdt-when-building-with-.patch rename to 0183-Fix-undefined-references-for-fdt-when-building-with-.patch diff --git a/0309-arm-Move-trampolines-into-code-section.patch b/0184-arm-Move-trampolines-into-code-section.patch similarity index 100% rename from 0309-arm-Move-trampolines-into-code-section.patch rename to 0184-arm-Move-trampolines-into-code-section.patch diff --git a/0310-arm-Align-section-alignment-with-manual-relocation-o.patch b/0185-arm-Align-section-alignment-with-manual-relocation-o.patch similarity index 100% rename from 0310-arm-Align-section-alignment-with-manual-relocation-o.patch rename to 0185-arm-Align-section-alignment-with-manual-relocation-o.patch diff --git a/0311-grub-core-loader-efi-fdt.c-Do-not-copy-random-memory.patch b/0186-grub-core-loader-efi-fdt.c-Do-not-copy-random-memory.patch similarity index 100% rename from 0311-grub-core-loader-efi-fdt.c-Do-not-copy-random-memory.patch rename to 0186-grub-core-loader-efi-fdt.c-Do-not-copy-random-memory.patch diff --git a/0312-linux-efi-arm-fdt-break-FDT-extra-allocation-space-o.patch b/0187-linux-efi-arm-fdt-break-FDT-extra-allocation-space-o.patch similarity index 100% rename from 0312-linux-efi-arm-fdt-break-FDT-extra-allocation-space-o.patch rename to 0187-linux-efi-arm-fdt-break-FDT-extra-allocation-space-o.patch diff --git a/0191-Fix-grub-setpassword-o-s-output-path.patch b/0191-Fix-grub-setpassword-o-s-output-path.patch deleted file mode 100644 index f26da57..0000000 --- a/0191-Fix-grub-setpassword-o-s-output-path.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Andy Lutomirski -Date: Sun, 11 Jun 2017 19:17:40 -0400 -Subject: [PATCH] Fix grub-setpassword -o's output path - -The output path is set up in the command line parsing, but completely ignored -in the code that actually writes the files. This patch fixes that. - -Signed-off-by: Peter Jones ---- - util/grub-setpassword.in | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in -index cf70257eed6..5ebf50576d6 100644 ---- a/util/grub-setpassword.in -+++ b/util/grub-setpassword.in -@@ -118,11 +118,11 @@ fi - - # on the ESP, these will fail to set the permissions, but it's okay because - # the directory is protected. --install -m 0600 /dev/null "${grubdir}/user.cfg" 2>/dev/null || : --chmod 0600 "${grubdir}/user.cfg" 2>/dev/null || : --echo "GRUB2_PASSWORD=${MYPASS}" > "${grubdir}/user.cfg" -+install -m 0600 /dev/null "${OUTPUT_PATH}/user.cfg" 2>/dev/null || : -+chmod 0600 "${OUTPUT_PATH}/user.cfg" 2>/dev/null || : -+echo "GRUB2_PASSWORD=${MYPASS}" > "${OUTPUT_PATH}/user.cfg" - --if ! grep -q "^### BEGIN /etc/grub.d/01_users ###$" "${grubdir}/grub.cfg"; then -+if ! grep -q "^### BEGIN /etc/grub.d/01_users ###$" "${OUTPUT_PATH}/grub.cfg"; then - echo "WARNING: The current configuration lacks password support!" - echo "Update your configuration with @grub_mkconfig@ to support this feature." - fi diff --git a/0192-Make-grub-set-password-be-named-like-all-the-other-g.patch b/0192-Make-grub-set-password-be-named-like-all-the-other-g.patch deleted file mode 100644 index 678b3ad..0000000 --- a/0192-Make-grub-set-password-be-named-like-all-the-other-g.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Sat, 23 Jun 2018 13:19:15 -0400 -Subject: [PATCH] Make grub-set-password be named like all the other grub - utilities - -Signed-off-by: Peter Jones ---- - configure.ac | 2 +- - Makefile.util.def | 4 ++-- - .gitignore | 4 ++-- - util/{grub-setpassword.8 => grub-set-password.8} | 8 ++++---- - util/{grub-setpassword.in => grub-set-password.in} | 0 - 5 files changed, 9 insertions(+), 9 deletions(-) - rename util/{grub-setpassword.8 => grub-set-password.8} (50%) - rename util/{grub-setpassword.in => grub-set-password.in} (100%) - -diff --git a/configure.ac b/configure.ac -index 359cac3c26b..5f47a9265f3 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -66,7 +66,7 @@ grub_TRANSFORM([grub-mkrelpath]) - grub_TRANSFORM([grub-mkrescue]) - grub_TRANSFORM([grub-probe]) - grub_TRANSFORM([grub-reboot]) --grub_TRANSFORM([grub-setpassword]) -+grub_TRANSFORM([grub-set-password]) - grub_TRANSFORM([grub-rpm-sort]) - grub_TRANSFORM([grub-script-check]) - grub_TRANSFORM([grub-set-default]) -diff --git a/Makefile.util.def b/Makefile.util.def -index 5da55393291..97cd8bdebd9 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -756,8 +756,8 @@ script = { - }; - - script = { -- name = grub-setpassword; -- common = util/grub-setpassword.in; -+ name = grub-set-password; -+ common = util/grub-set-password.in; - mansection = 8; - installdir = sbin; - }; -diff --git a/.gitignore b/.gitignore -index 6c4cfc53781..a999024652e 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -115,8 +115,8 @@ grub-*.tar.* - /grub*-set-bootflag.1 - /grub*-set-default - /grub*-set-default.8 --/grub*-setsetpassword --/grub*-setsetpassword.8 -+/grub*-set-password -+/grub*-set-password.8 - /grub*-shell - /grub*-shell-tester - /grub*-sparc64-setup -diff --git a/util/grub-setpassword.8 b/util/grub-set-password.8 -similarity index 50% -rename from util/grub-setpassword.8 -rename to util/grub-set-password.8 -index dc91dd6697b..9646546e43d 100644 ---- a/util/grub-setpassword.8 -+++ b/util/grub-set-password.8 -@@ -1,12 +1,12 @@ --.TH GRUB-SETPASSWORD 3 "Thu Jun 25 2015" -+.TH GRUB-SET-PASSWORD 3 "Thu Jun 25 2015" - .SH NAME --\fBgrub-setpassword\fR \(em Generate the user.cfg file containing the hashed grub bootloader password. -+\fBgrub-set-password\fR \(em Generate the user.cfg file containing the hashed grub bootloader password. - - .SH SYNOPSIS --\fBgrub-setpassword\fR [OPTION] -+\fBgrub-set-password\fR [OPTION] - - .SH DESCRIPTION --\fBgrub-setpassword\fR outputs the user.cfg file which contains the hashed GRUB bootloader password. This utility only supports configurations where there is a single root user. -+\fBgrub-set-password\fR outputs the user.cfg file which contains the hashed GRUB bootloader password. This utility only supports configurations where there is a single root user. - - The file has the format: - GRUB2_PASSWORD=<\fIhashed password\fR>. -diff --git a/util/grub-setpassword.in b/util/grub-set-password.in -similarity index 100% -rename from util/grub-setpassword.in -rename to util/grub-set-password.in diff --git a/0194-00_menu_auto_hide-Use-a-timeout-of-60s-for-menu_show.patch b/0194-00_menu_auto_hide-Use-a-timeout-of-60s-for-menu_show.patch deleted file mode 100644 index 367fc6c..0000000 --- a/0194-00_menu_auto_hide-Use-a-timeout-of-60s-for-menu_show.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Tue, 26 Jun 2018 12:44:29 +0200 -Subject: [PATCH] 00_menu_auto_hide: Use a timeout of 60s for menu_show_once, - rather then no timeout - -On some UEFI systems with fastboot enabled (USB) keyboards don't work at -all, not even when explictly asking for keyboard input. - -So lets change the timeout from not set (no timeout) to 60 seconds, so -that on such systems if the menu was requested we continue with the -default choice after 60 seconds. - -Signed-off-by: Hans de Goede ---- - util/grub.d/00_menu_auto_hide.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub.d/00_menu_auto_hide.in b/util/grub.d/00_menu_auto_hide.in -index a10fe45bb2c..ca95c0d1c9f 100644 ---- a/util/grub.d/00_menu_auto_hide.in -+++ b/util/grub.d/00_menu_auto_hide.in -@@ -33,7 +33,7 @@ if [ x\$feature_timeout_style = xy ] ; then - unset menu_show_once - save_env menu_show_once - set timeout_style=menu -- unset timeout -+ set timeout=60 - elif [ "\${menu_auto_hide}" -a "\${last_boot_ok}" = "1" ]; then - set orig_timeout_style=\${timeout_style} - set orig_timeout=\${timeout} diff --git a/0195-00_menu_auto_hide-Reduce-number-of-save_env-calls.patch b/0195-00_menu_auto_hide-Reduce-number-of-save_env-calls.patch deleted file mode 100644 index 6993508..0000000 --- a/0195-00_menu_auto_hide-Reduce-number-of-save_env-calls.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Wed, 27 Jun 2018 13:33:43 +0200 -Subject: [PATCH] 00_menu_auto_hide: Reduce number of save_env calls - -Normally boot_success will be 1 on every boot (as normally the -previous boot will have been successful). This means that we end -up in the code-path to set boot_indeterminate to 0 every boot. - -So we do 2 separate save_env calls each boot, one for boot_indeterminate -and one for boot_success. This results in 2 writes to the disk. - -This commit makes us save both boot_success and boot_indeterminate -in a single call, reducing the number of writes, this reducing wear -and tear on the underlying storage. - -Signed-off-by: Hans de Goede ---- - util/grub.d/00_menu_auto_hide.in | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) - -diff --git a/util/grub.d/00_menu_auto_hide.in b/util/grub.d/00_menu_auto_hide.in -index ca95c0d1c9f..ad175870a54 100644 ---- a/util/grub.d/00_menu_auto_hide.in -+++ b/util/grub.d/00_menu_auto_hide.in -@@ -19,14 +19,12 @@ fi - # Reset boot_indeterminate after a successful boot - if [ "\${boot_success}" = "1" ] ; then - set boot_indeterminate=0 -- save_env boot_indeterminate - # Avoid boot_indeterminate causing the menu to be hidden more then once - elif [ "\${boot_indeterminate}" = "1" ]; then - set boot_indeterminate=2 -- save_env boot_indeterminate - fi - set boot_success=0 --save_env boot_success -+save_env boot_success boot_indeterminate - - if [ x\$feature_timeout_style = xy ] ; then - if [ "\${menu_show_once}" ]; then diff --git a/0196-30_uefi-firmware-fix-use-with-sys-firmware-efi-efiva.patch b/0196-30_uefi-firmware-fix-use-with-sys-firmware-efi-efiva.patch deleted file mode 100644 index e713d69..0000000 --- a/0196-30_uefi-firmware-fix-use-with-sys-firmware-efi-efiva.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Fri, 29 Jun 2018 10:08:22 +0200 -Subject: [PATCH] 30_uefi-firmware: fix use with /sys/firmware/efi/efivars - -Fix 30_uefi-firmware checking for the obsolete /sys/firmware/efi/vars -instead of for the new efivarfs mounted at /sys/firmware/efi/efivars. - -Which goes to show that I really should have tested this before blindly -importing it from Ubuntu. - -Signed-off-by: Hans de Goede ---- - util/grub.d/30_uefi-firmware.in | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/util/grub.d/30_uefi-firmware.in b/util/grub.d/30_uefi-firmware.in -index 3c9f533d8c6..93ececffea7 100644 ---- a/util/grub.d/30_uefi-firmware.in -+++ b/util/grub.d/30_uefi-firmware.in -@@ -26,12 +26,12 @@ export TEXTDOMAINDIR="@localedir@" - - . "@datadir@/@PACKAGE@/grub-mkconfig_lib" - --efi_vars_dir=/sys/firmware/efi/vars -+efi_vars_dir=/sys/firmware/efi/efivars - EFI_GLOBAL_VARIABLE=8be4df61-93ca-11d2-aa0d-00e098032b8c --OsIndications="$efi_vars_dir/OsIndicationsSupported-$EFI_GLOBAL_VARIABLE/data" -+OsIndications="$efi_vars_dir/OsIndicationsSupported-$EFI_GLOBAL_VARIABLE" - - if [ -e "$OsIndications" ] && \ -- [ "$(( $(printf 0x%x \'"$(cat $OsIndications | cut -b1)") & 1 ))" = 1 ]; then -+ [ "$(( $(printf 0x%x \'"$(cat $OsIndications | cut -b5)") & 1 ))" = 1 ]; then - LABEL="System setup" - - gettext_printf "Adding boot menu entry for EFI firmware configuration\n" >&2 diff --git a/0199-blscfg-remove-unused-typedef.patch b/0199-blscfg-remove-unused-typedef.patch deleted file mode 100644 index 819a144..0000000 --- a/0199-blscfg-remove-unused-typedef.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Wed, 11 Jul 2018 14:59:52 +0100 -Subject: [PATCH] blscfg: remove unused typedef -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This is unused since ‘Use BLS fragment filename as menu entry id and for -criteria to sort’. - -Signed-off-by: Will Thompson ---- - grub-core/commands/blscfg.c | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index cd8659384e4..82fb6cdd182 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -327,8 +327,6 @@ finish: - return ret; - } - --typedef int (*void_cmp_t)(void *, void *); -- - static int bls_cmp(const void *p0, const void *p1, void *state UNUSED) - { - struct bls_entry * e0 = *(struct bls_entry **)p0; diff --git a/0200-blscfg-don-t-dynamically-allocate-default_blsdir.patch b/0200-blscfg-don-t-dynamically-allocate-default_blsdir.patch deleted file mode 100644 index ab076ec..0000000 --- a/0200-blscfg-don-t-dynamically-allocate-default_blsdir.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Wed, 11 Jul 2018 15:01:45 +0100 -Subject: [PATCH] blscfg: don't dynamically allocate default_blsdir - -Signed-off-by: Will Thompson ---- - grub-core/commands/blscfg.c | 9 +++------ - 1 file changed, 3 insertions(+), 6 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 82fb6cdd182..b61dddb7f43 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -623,7 +623,7 @@ static int find_entry (const char *filename, - grub_file_t f = NULL; - char *grubenv_path = NULL; - grub_envblk_t env = NULL; -- char *default_blsdir = NULL; -+ const char *default_blsdir = NULL; - grub_fs_t blsdir_fs = NULL; - grub_device_t blsdir_dev = NULL; - const char *blsdir = NULL; -@@ -643,10 +643,9 @@ static int find_entry (const char *filename, - - // set a default blsdir - if (info->platform == PLATFORM_EMU) -- default_blsdir = grub_xasprintf ("%s%s", GRUB_BOOT_DEVICE, -- GRUB_BLS_CONFIG_PATH); -+ default_blsdir = GRUB_BOOT_DEVICE GRUB_BLS_CONFIG_PATH; - else -- default_blsdir = grub_xasprintf ("%s", GRUB_BLS_CONFIG_PATH); -+ default_blsdir = GRUB_BLS_CONFIG_PATH; - - grub_env_set ("blsdir", default_blsdir); - grub_dprintf ("blscfg", "default_blsdir: \"%s\"\n", default_blsdir); -@@ -788,8 +787,6 @@ finish: - if (f) - grub_file_close (f); - -- grub_free (default_blsdir); -- - return 0; - } - diff --git a/0201-blscfg-sort-BLS-entries-by-version-field.patch b/0201-blscfg-sort-BLS-entries-by-version-field.patch deleted file mode 100644 index 0ee94af..0000000 --- a/0201-blscfg-sort-BLS-entries-by-version-field.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Wed, 11 Jul 2018 15:41:09 +0100 -Subject: [PATCH] blscfg: sort BLS entries by 'version' field -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This partially reverts ‘Use BLS fragment filename as menu entry id and -for criteria to sort’. Sorting by filename only gives the correct order -if the BLS entries are generated by a version of ostree after this patch -https://github.com/ostreedev/ostree/commit/9f48e212a3bf9ed418fb3216e4f834d581bc520e -to use the version (higher is newer) in the filename. Older ostrees, -including all releases at the time of writing, use the index (lower is -newer) in the filename, so sorting by filename produces the reverse -order. - -Sorting by 'version' field matches libostree's own -compare_boot_loader_configs(), so I think it's more correct than relying -on the filename, particularly since we've already gone to the trouble of -parsing all the fields in the file. - -Signed-off-by: Will Thompson ---- - grub-core/commands/blscfg.c | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index b61dddb7f43..9c928dda470 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -327,10 +327,26 @@ finish: - return ret; - } - -+/* return 1: p0 is newer than p1 */ -+/* 0: p0 and p1 are the same version */ -+/* -1: p1 is newer than p0 */ - static int bls_cmp(const void *p0, const void *p1, void *state UNUSED) - { - struct bls_entry * e0 = *(struct bls_entry **)p0; - struct bls_entry * e1 = *(struct bls_entry **)p1; -+ const char *v0, *v1; -+ int r; -+ -+ v0 = bls_get_val(e0, "version", NULL); -+ v1 = bls_get_val(e1, "version", NULL); -+ -+ if (v0 && !v1) -+ return -1; -+ if (!v0 && v1) -+ return 1; -+ -+ if ((r = vercmp(v0, v1)) != 0) -+ return r; - - return vercmp(e0->filename, e1->filename); - } diff --git a/0202-blscfg-remove-NULL-guards-around-grub_free.patch b/0202-blscfg-remove-NULL-guards-around-grub_free.patch deleted file mode 100644 index add1766..0000000 --- a/0202-blscfg-remove-NULL-guards-around-grub_free.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Thu, 12 Jul 2018 10:14:43 +0100 -Subject: [PATCH] blscfg: remove NULL guards around grub_free() - -The internal implementation of grub_free() is NULL-safe. In emu builds, -it just delegates to the host's free(), which is specified by ANSI C to -be NULL-safe. - -Signed-off-by: Will Thompson ---- - grub-core/commands/blscfg.c | 23 ++++++----------------- - 1 file changed, 6 insertions(+), 17 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 9c928dda470..bd78559ef68 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -600,23 +600,12 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0); - - finish: -- if (initrd) -- grub_free (initrd); -- -- if (initrds) -- grub_free (initrds); -- -- if (classes) -- grub_free (classes); -- -- if (args) -- grub_free (args); -- -- if (argv) -- grub_free (argv); -- -- if (src) -- grub_free (src); -+ grub_free (initrd); -+ grub_free (initrds); -+ grub_free (classes); -+ grub_free (args); -+ grub_free (argv); -+ grub_free (src); - } - - struct find_entry_info { diff --git a/0203-blscfg-fix-filename-in-no-linux-key-error.patch b/0203-blscfg-fix-filename-in-no-linux-key-error.patch deleted file mode 100644 index 37795f6..0000000 --- a/0203-blscfg-fix-filename-in-no-linux-key-error.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Thu, 12 Jul 2018 10:38:27 +0100 -Subject: [PATCH] blscfg: fix filename in "no 'linux' key" error - -In find_entry(), 'filename' is either NULL or a directory in the ESP. -But previously it was passed to create_entry(), which uses it in an -error message as if it's the filename of the BLS entry in question. - -Since bls_entry now has a 'filename' field, just use that. - -Signed-off-by: Will Thompson ---- - grub-core/commands/blscfg.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index bd78559ef68..a45f40fe67e 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -514,7 +514,7 @@ static char **bls_make_list (struct bls_entry *entry, const char *key, int *num) - return list; - } - --static void create_entry (struct bls_entry *entry, const char *cfgfile) -+static void create_entry (struct bls_entry *entry) - { - int argc = 0; - const char **argv = NULL; -@@ -539,7 +539,7 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - clinux = bls_get_val (entry, "linux", NULL); - if (!clinux) - { -- grub_dprintf ("blscfg", "Skipping file %s with no 'linux' key.\n", cfgfile); -+ grub_dprintf ("blscfg", "Skipping file %s with no 'linux' key.\n", entry->filename); - goto finish; - } - -@@ -753,7 +753,7 @@ static int find_entry (const char *filename, - - grub_dprintf ("blscfg", "%s Creating %d entries from bls\n", __func__, nentries); - for (r = nentries - 1; r >= 0; r--) -- create_entry(entries[r], filename); -+ create_entry(entries[r]); - - for (r = 0; r < nentries; r++) - bls_free_entry (entries[r]); diff --git a/0204-blscfg-don-t-leak-bls_entry.filename.patch b/0204-blscfg-don-t-leak-bls_entry.filename.patch deleted file mode 100644 index 5080e2e..0000000 --- a/0204-blscfg-don-t-leak-bls_entry.filename.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Thu, 12 Jul 2018 10:59:10 +0100 -Subject: [PATCH] blscfg: don't leak bls_entry.filename - -Zeroing the bls_entry struct before calling grub_free() on one of its -fields is not going to work too well. - -Signed-off-by: Will Thompson ---- - grub-core/commands/blscfg.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index a45f40fe67e..11a356de81a 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -166,8 +166,8 @@ static void bls_free_entry(struct bls_entry *entry) - } - - grub_free (entry->keyvals); -- grub_memset (entry, 0, sizeof (*entry)); - grub_free (entry->filename); -+ grub_memset (entry, 0, sizeof (*entry)); - grub_free (entry); - } - diff --git a/0205-blscfg-fix-compilation-on-EFI-and-EMU.patch b/0205-blscfg-fix-compilation-on-EFI-and-EMU.patch deleted file mode 100644 index 04aadc3..0000000 --- a/0205-blscfg-fix-compilation-on-EFI-and-EMU.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Thu, 12 Jul 2018 19:00:42 +0100 -Subject: [PATCH] blscfg: fix compilation on !EFI and !EMU -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Neither GRUB_MACHINE_EFI nor GRUB_MACHINE_EMU are defined when compiling -for (eg) i386-pc. In this case, #elif GRUB_MACHINE_EMU is an error: - - commands/blscfg.c: In function ‘grub_cmd_blscfg’: - commands/blscfg.c:835:7: error: "GRUB_MACHINE_EMU" is not defined [-Werror=undef] - #elif GRUB_MACHINE_EMU - ^~~~~~~~~~~~~~~~ - -Signed-off-by: Will Thompson ---- - grub-core/commands/blscfg.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 11a356de81a..53676576ba5 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -843,7 +843,7 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - info.platform = PLATFORM_EFI; - grub_dprintf ("blscfg", "scanning /EFI/\n"); - r = fs->dir (dev, "/EFI/", find_entry, &info); --#elif GRUB_MACHINE_EMU -+#elif defined(GRUB_MACHINE_EMU) - info.platform = PLATFORM_EMU; - grub_dprintf ("blscfg", "scanning %s%s\n", GRUB_BOOT_DEVICE, - GRUB_BLS_CONFIG_PATH); diff --git a/0206-Add-loadenv-to-blscfg-and-loadenv-source-file-list.patch b/0206-Add-loadenv-to-blscfg-and-loadenv-source-file-list.patch deleted file mode 100644 index 76df19c..0000000 --- a/0206-Add-loadenv-to-blscfg-and-loadenv-source-file-list.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Fri, 13 Jul 2018 05:51:54 +0100 -Subject: [PATCH] Add loadenv to blscfg and loadenv source file list -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Without this, `make distcheck` fails because loadenv.h is not included -in the source tarball. - -This broke in ‘Add blscfg command support to parse BootLoaderSpec config -fragments’. - -Signed-off-by: Will Thompson ---- - grub-core/Makefile.core.def | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 2851437e098..aa44d66aca4 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -781,6 +781,7 @@ module = { - module = { - name = blscfg; - common = commands/blscfg.c; -+ common = commands/loadenv.h; - enable = efi; - enable = i386_pc; - enable = emu; -@@ -947,6 +948,7 @@ module = { - module = { - name = loadenv; - common = commands/loadenv.c; -+ common = commands/loadenv.h; - common = lib/envblk.c; - }; - diff --git a/0207-blscfg-Get-rid-of-the-linuxefi-linux16-linux-distinc.patch b/0207-blscfg-Get-rid-of-the-linuxefi-linux16-linux-distinc.patch deleted file mode 100644 index df63ac6..0000000 --- a/0207-blscfg-Get-rid-of-the-linuxefi-linux16-linux-distinc.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 16 Jul 2018 11:00:50 -0400 -Subject: [PATCH] blscfg: Get rid of the linuxefi/linux16/linux distinction - -Signed-off-by: Peter Jones ---- - grub-core/commands/blscfg.c | 14 +++----------- - 1 file changed, 3 insertions(+), 11 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 53676576ba5..c6addc4dc12 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -43,14 +43,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #define GRUB_BOOT_DEVICE "($root)" - #endif - --#ifdef GRUB_MACHINE_EFI --#define GRUB_LINUX_CMD "linuxefi" --#define GRUB_INITRD_CMD "initrdefi" --#else --#define GRUB_LINUX_CMD "linux" --#define GRUB_INITRD_CMD "initrd" --#endif -- - enum - { - PLATFORM_EFI, -@@ -563,7 +555,7 @@ static void create_entry (struct bls_entry *entry) - title, id); - if (initrds) - { -- int initrd_size = sizeof (GRUB_INITRD_CMD); -+ int initrd_size = sizeof ("initrd"); - char *tmp; - - for (i = 0; initrds != NULL && initrds[i] != NULL; i++) -@@ -579,7 +571,7 @@ static void create_entry (struct bls_entry *entry) - } - - -- tmp = grub_stpcpy(initrd, GRUB_INITRD_CMD); -+ tmp = grub_stpcpy(initrd, "initrd "); - for (i = 0; initrds != NULL && initrds[i] != NULL; i++) - { - grub_dprintf ("blscfg", "adding initrd %s\n", initrds[i]); -@@ -592,7 +584,7 @@ static void create_entry (struct bls_entry *entry) - src = grub_xasprintf ("load_video\n" - "set gfx_payload=keep\n" - "insmod gzio\n" -- GRUB_LINUX_CMD " %s%s%s%s\n" -+ "linux %s%s%s%s\n" - "%s", - GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", - initrd ? initrd : ""); diff --git a/0208-grub-switch-to-blscfg-Only-fix-boot-prefix-for-non-g.patch b/0208-grub-switch-to-blscfg-Only-fix-boot-prefix-for-non-g.patch deleted file mode 100644 index 9b996bc..0000000 --- a/0208-grub-switch-to-blscfg-Only-fix-boot-prefix-for-non-g.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 18 Jul 2018 08:07:37 +0200 -Subject: [PATCH] grub-switch-to-blscfg: Only fix boot prefix for non-generated - BLS files - -The BLS files are either copied from /lib/modules/$kernelver/bls.conf or -generated if this file doesn't exist. The shipped bls.conf default path -for the kernel and initramfs is relative to the boot partition. - -But in some setups /boot may not be a mount point so in that case the -boot prefix has to be added to the BLS. But we already provide this -prefix for generated BLS files so attempting to add a boot prefix will -lead to a path that contains the boot prefix twice (i.e: /boot/boot). - -Reported-by: Hans de Goede -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 40612e00686..9cf64f8e725 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -236,6 +236,10 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - - if [ -f "${kernel_dir}/bls.conf" ] ; then - cp -af "${kernel_dir}/bls.conf" "${bls_target}" -+ if [ -n "${bootprefix}" ]; then -+ sed -i -e "s,^\(linux[^ \t]*[ \t]\+\).*,\1${bootprefix}${linux},g" "${bls_target}" -+ sed -i -e "/^initrd/ s,\([ \t]\+\)\([^ \t]\+\),\1${bootprefix}\2,g" "${bls_target}" -+ fi - else - mkbls "${kernelver}" \ - "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \ -@@ -243,11 +247,6 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - >"${bls_target}" - fi - -- if [ -n "${bootprefix}" ]; then -- sed -i -e "s,^\(linux[^ \t]*[ \t]\+\).*,\1${bootprefix}${linux},g" "${bls_target}" -- sed -i -e "/^initrd/ s,\([ \t]\+\)\([^ \t]\+\),\1${bootprefix}\2,g" "${bls_target}" -- fi -- - if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then - arch="$(uname -m)" - bls_debug="$(echo ${bls_target} | sed -e "s/\.${arch}/-debug.${arch}/")" diff --git a/0209-blscfg-Expand-the-BLS-options-field-instead-of-showi.patch b/0209-blscfg-Expand-the-BLS-options-field-instead-of-showi.patch deleted file mode 100644 index 3dca942..0000000 --- a/0209-blscfg-Expand-the-BLS-options-field-instead-of-showi.patch +++ /dev/null @@ -1,130 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 18 Jul 2018 08:08:02 +0200 -Subject: [PATCH] blscfg: Expand the BLS options field instead of showing its - variables - -The values of the BLS fragment fields can either be string literals or -grub2 environment variables, the latter will be expanded by grub2 when -the boot entry is selected. - -But from a usability point of view, is much more convenient if the BLS -parse code expand any variables that are present in the options field. - -That will allow users to select an entry in the menu by pressing the e -key and edit the kernel command line parameters. So for example instead -of showing the following: - -kernel /boot/vmlinuz-4.17.0 $kernelopts - -It would show something like the following: - -kernel /boot/vmlinuz-4.17.0 root=UUID=cec677c9-c890-4103-b94a-bcc191642935 - -Suggested-by: Hans de Goede -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 69 ++++++++++++++++++++++++++++++++++++++++++++- - 1 file changed, 68 insertions(+), 1 deletion(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index c6addc4dc12..80d8814fc3f 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -32,6 +32,8 @@ - #include - #include - -+#include -+ - GRUB_MOD_LICENSE ("GPLv3+"); - - #include "loadenv.h" -@@ -506,6 +508,70 @@ static char **bls_make_list (struct bls_entry *entry, const char *key, int *num) - return list; - } - -+static char *field_append(bool is_var, char *buffer, char *start, char *end) -+{ -+ char *temp = grub_strndup(start, end - start + 1); -+ const char *field = temp; -+ -+ if (is_var) { -+ field = grub_env_get (temp); -+ if (!field) -+ return buffer; -+ } -+ -+ if (!buffer) { -+ buffer = grub_strdup(field); -+ if (!buffer) -+ return NULL; -+ } else { -+ buffer = grub_realloc (buffer, grub_strlen(buffer) + grub_strlen(field)); -+ if (!buffer) -+ return NULL; -+ -+ grub_stpcpy (buffer + grub_strlen(buffer), field); -+ } -+ -+ return buffer; -+} -+ -+static char *expand_val(char *value) -+{ -+ char *buffer = NULL; -+ char *start = value; -+ char *end = value; -+ bool is_var = false; -+ -+ while (*value) { -+ if (*value == '$') { -+ if (start != end) { -+ buffer = field_append(is_var, buffer, start, end); -+ if (!buffer) -+ return NULL; -+ } -+ -+ is_var = true; -+ start = value + 1; -+ } else if (is_var) { -+ if (!grub_isalnum(*value) && *value != '_') { -+ buffer = field_append(is_var, buffer, start, end); -+ is_var = false; -+ start = value; -+ } -+ } -+ -+ end = value; -+ value++; -+ } -+ -+ if (start != end) { -+ buffer = field_append(is_var, buffer, start, end); -+ if (!buffer) -+ return NULL; -+ } -+ -+ return buffer; -+} -+ - static void create_entry (struct bls_entry *entry) - { - int argc = 0; -@@ -536,7 +602,7 @@ static void create_entry (struct bls_entry *entry) - } - - title = bls_get_val (entry, "title", NULL); -- options = bls_get_val (entry, "options", NULL); -+ options = expand_val (bls_get_val (entry, "options", NULL)); - initrds = bls_make_list (entry, "initrd", NULL); - - hotkey = bls_get_val (entry, "grub_hotkey", NULL); -@@ -594,6 +660,7 @@ static void create_entry (struct bls_entry *entry) - finish: - grub_free (initrd); - grub_free (initrds); -+ grub_free (options); - grub_free (classes); - grub_free (args); - grub_free (argv); diff --git a/0210-blscfg-Fallback-to-search-BLS-snippets-in-boot-loade.patch b/0210-blscfg-Fallback-to-search-BLS-snippets-in-boot-loade.patch deleted file mode 100644 index d04928f..0000000 --- a/0210-blscfg-Fallback-to-search-BLS-snippets-in-boot-loade.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 18 Jul 2018 08:08:06 +0200 -Subject: [PATCH] blscfg: Fallback to search BLS snippets in - /boot/loader/entries - -The default path to search the BLS snippets is /loader/entries, this is -only a correct assumption if $root ($root) is a boot partition but it's -not true if /boot isn't a mount point. - -A user can set a blsdir grub environment variable to choose a different -path, but instead of failing when /boot is a directory inside the root -partition fallback to search the BLS in /boot/loader/entries to cover -that case as well. - -Reported-by: Hans de Goede -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 13 ++++++++++++- - 1 file changed, 12 insertions(+), 1 deletion(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 80d8814fc3f..321c93069f2 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -692,6 +692,7 @@ static int find_entry (const char *filename, - grub_device_t blsdir_dev = NULL; - const char *blsdir = NULL; - char *saved_env_buf = NULL; -+ int fallback = 0; - int r = 0; - const char *devid = grub_env_get ("boot"); - -@@ -797,7 +798,9 @@ static int find_entry (const char *filename, - } - read_entry_info.dirname = blsdir; - -- r = blsdir_fs->dir (blsdir_dev, blsdir, read_entry, &read_entry_info); -+read_fallback: -+ r = blsdir_fs->dir (blsdir_dev, read_entry_info.dirname, read_entry, -+ &read_entry_info); - if (r != 0) { - grub_dprintf ("blscfg", "read_entry returned error\n"); - grub_err_t e; -@@ -807,6 +810,14 @@ static int find_entry (const char *filename, - } while (e); - } - -+ if (!nentries && !fallback && info->platform != PLATFORM_EMU) { -+ read_entry_info.dirname = "/boot" GRUB_BLS_CONFIG_PATH; -+ grub_dprintf ("blscfg", "Entries weren't found in %s, fallback to %s\n", -+ blsdir, read_entry_info.dirname); -+ fallback = 1; -+ goto read_fallback; -+ } -+ - grub_dprintf ("blscfg", "Sorting %d entries\n", nentries); - grub_qsort(&entries[0], nentries, sizeof (struct bls_entry *), bls_cmp, NULL); - diff --git a/0211-blscfg-Don-t-attempt-to-sort-by-version-if-not-prese.patch b/0211-blscfg-Don-t-attempt-to-sort-by-version-if-not-prese.patch deleted file mode 100644 index 60b609d..0000000 --- a/0211-blscfg-Don-t-attempt-to-sort-by-version-if-not-prese.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 18 Jul 2018 00:58:44 +0200 -Subject: [PATCH] blscfg: Don't attempt to sort by version if not present in - all BLS files - -Commit a16805341cc ("blscfg: sort BLS entries by 'version' field") made to -sort by the version field take precedence over the BLS fragment file name. - -But it also uses the lack of the version field in one BLS fragment as sort -criterion, which means that entries could be wrongly sorted if one of them -doesn't have a version field and others do. - -So only sort by version if all the BLS entries have this field defined, -otherwise just fallback to sorting by the BLS file name. - -Reported-by: Hans de Goede -Suggested-by: Will Thompson -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 27 ++++++++++++++++----------- - 1 file changed, 16 insertions(+), 11 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 321c93069f2..69bfb5db295 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -324,23 +324,21 @@ finish: - /* return 1: p0 is newer than p1 */ - /* 0: p0 and p1 are the same version */ - /* -1: p1 is newer than p0 */ --static int bls_cmp(const void *p0, const void *p1, void *state UNUSED) -+static int bls_cmp(const void *p0, const void *p1, void *state) - { - struct bls_entry * e0 = *(struct bls_entry **)p0; - struct bls_entry * e1 = *(struct bls_entry **)p1; -+ bool use_version = *(bool *)state; - const char *v0, *v1; - int r; - -- v0 = bls_get_val(e0, "version", NULL); -- v1 = bls_get_val(e1, "version", NULL); -+ if (use_version) { -+ v0 = bls_get_val(e0, "version", NULL); -+ v1 = bls_get_val(e1, "version", NULL); - -- if (v0 && !v1) -- return -1; -- if (!v0 && v1) -- return 1; -- -- if ((r = vercmp(v0, v1)) != 0) -- return r; -+ if ((r = vercmp(v0, v1)) != 0) -+ return r; -+ } - - return vercmp(e0->filename, e1->filename); - } -@@ -692,6 +690,7 @@ static int find_entry (const char *filename, - grub_device_t blsdir_dev = NULL; - const char *blsdir = NULL; - char *saved_env_buf = NULL; -+ bool use_version = true; - int fallback = 0; - int r = 0; - const char *devid = grub_env_get ("boot"); -@@ -819,7 +818,13 @@ read_fallback: - } - - grub_dprintf ("blscfg", "Sorting %d entries\n", nentries); -- grub_qsort(&entries[0], nentries, sizeof (struct bls_entry *), bls_cmp, NULL); -+ -+ for (r = 0; r < nentries && use_version; r++) { -+ if (!bls_get_val(entries[r], "version", NULL)) -+ use_version = false; -+ } -+ -+ grub_qsort(&entries[0], nentries, sizeof (struct bls_entry *), bls_cmp, &use_version); - - grub_dprintf ("blscfg", "%s Creating %d entries from bls\n", __func__, nentries); - for (r = nentries - 1; r >= 0; r--) diff --git a/0212-blscfg-remove-logic-to-read-the-grubenv-file-and-set.patch b/0212-blscfg-remove-logic-to-read-the-grubenv-file-and-set.patch deleted file mode 100644 index f32b620..0000000 --- a/0212-blscfg-remove-logic-to-read-the-grubenv-file-and-set.patch +++ /dev/null @@ -1,292 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Sat, 28 Jul 2018 23:57:15 +0200 -Subject: [PATCH] blscfg: remove logic to read the grubenv file and set the - blsdir variable - -The BLS grub2 support has a blsdir environment variable that can be set by -users to override the BLS fragment default path. - -Currently the BLS parsing code reads the grubenv file and sets the blsdir -variable, but it shouldn't be the responsability of the blscfg module to -do this and instead just use it if the variable has been set (either from -the grub.cfg file or the grub shell). - -This makes the find_entry() function much simpler and consistent for EFI, -BIOS and grub-emu. It also fixes a bug that caused having menu entries to -be repeated for each sub-directory that existed under the /EFI directory. - -So for example having three different operating systems sharing the ESP, -would lead to the boot menu entries being repeated three times for grub. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 179 ++++---------------------------------------- - 1 file changed, 16 insertions(+), 163 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 69bfb5db295..bdb1c5a95aa 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -45,13 +45,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #define GRUB_BOOT_DEVICE "($root)" - #endif - --enum -- { -- PLATFORM_EFI, -- PLATFORM_EMU, -- PLATFORM_BIOS, -- }; -- - #define grub_free(x) ({grub_dprintf("blscfg", "%s freeing %p\n", __func__, x); grub_free(x); }) - - struct keyval -@@ -666,137 +659,37 @@ finish: - } - - struct find_entry_info { -+ const char *devid; - grub_device_t dev; - grub_fs_t fs; - int platform; - }; - - /* -- * filename: if the directory is /EFI/something/ , filename is "something" -- * info: unused -- * data: the filesystem object the file is on. -+ * info: the filesystem object the file is on. - */ --static int find_entry (const char *filename, -- const struct grub_dirhook_info *dirhook_info UNUSED, -- void *data) -+static int find_entry (struct find_entry_info *info) - { -- struct find_entry_info *info = (struct find_entry_info *)data; - struct read_entry_info read_entry_info; -- grub_file_t f = NULL; -- char *grubenv_path = NULL; -- grub_envblk_t env = NULL; -- const char *default_blsdir = NULL; - grub_fs_t blsdir_fs = NULL; - grub_device_t blsdir_dev = NULL; - const char *blsdir = NULL; -- char *saved_env_buf = NULL; - bool use_version = true; - int fallback = 0; - int r = 0; -- const char *devid = grub_env_get ("boot"); -- -- grub_dprintf("blscfg", "%s got here\n", __func__); -- if (filename && (!grub_strcmp (filename, ".") || -- !grub_strcmp (filename, ".."))) -- return 0; -- -- if (info->platform == PLATFORM_EFI && !grub_strcasecmp (filename, "boot")) -- return 0; -- -- saved_env_buf = grub_malloc (512); -- -- // set a default blsdir -- if (info->platform == PLATFORM_EMU) -- default_blsdir = GRUB_BOOT_DEVICE GRUB_BLS_CONFIG_PATH; -- else -- default_blsdir = GRUB_BLS_CONFIG_PATH; -- -- grub_env_set ("blsdir", default_blsdir); -- grub_dprintf ("blscfg", "default_blsdir: \"%s\"\n", default_blsdir); -- -- /* -- * try to load a grubenv from /EFI/wherever/grubenv -- */ -- if (info->platform == PLATFORM_EFI) -- grubenv_path = grub_xasprintf ("(%s)/EFI/%s/grubenv", devid, filename); -- else -- grubenv_path = grub_xasprintf ("(%s)/grub2/grubenv", devid); -- -- grub_dprintf ("blscfg", "looking for \"%s\"\n", grubenv_path); -- f = grub_file_open (grubenv_path); -- -- grub_dprintf ("blscfg", "%s it\n", f ? "found" : "did not find"); -- grub_free (grubenv_path); -- if (f) -- { -- grub_off_t sz; -- -- grub_dprintf ("blscfg", "getting size\n"); -- sz = grub_file_size (f); -- if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024) -- goto finish; -- -- grub_dprintf ("blscfg", "reading env\n"); -- env = read_envblk_file (f); -- if (!env) -- goto finish; -- grub_dprintf ("blscfg", "read env file\n"); -- -- grub_memset (saved_env_buf, '#', 512); -- grub_memcpy (saved_env_buf, GRUB_ENVBLK_SIGNATURE, -- sizeof (GRUB_ENVBLK_SIGNATURE)); -- grub_dprintf ("blscfg", "saving env\n"); -- saved_env = grub_envblk_open (saved_env_buf, 512); -- if (!saved_env) -- goto finish; -- -- // save everything listed in "env" with values from our existing grub env -- grub_envblk_iterate (env, NULL, save_var); -- // set everything from our loaded grubenv into the real grub env -- grub_envblk_iterate (env, NULL, set_var); -- } -- else -- { -- grub_err_t e; -- grub_dprintf ("blscfg", "no such file\n"); -- do -- { -- e = grub_error_pop(); -- } while (e); -- -- } - - blsdir = grub_env_get ("blsdir"); - if (!blsdir) -- goto finish; -+ blsdir = GRUB_BLS_CONFIG_PATH; - -- grub_dprintf ("blscfg", "blsdir: \"%s\"\n", blsdir); -- blsdir = grub_strdup (blsdir); -- -- if (!blsdir) -- goto finish; -- -- grub_dprintf ("blscfg", "blsdir: \"%s\"\n", blsdir); -- if (info->platform == PLATFORM_EFI) { -- read_entry_info.devid = grub_env_get ("root"); -- if (!read_entry_info.devid) -- goto finish; -- -- blsdir_dev = grub_device_open (read_entry_info.devid); -- if (!blsdir_dev) -- goto finish; -- -- blsdir_fs = grub_fs_probe (blsdir_dev); -- if (!blsdir_fs) -- goto finish; -- -- } else { -- read_entry_info.devid = devid; -- blsdir_dev = info->dev; -- blsdir_fs = info->fs; -- } - read_entry_info.dirname = blsdir; - -+ grub_dprintf ("blscfg", "scanning blsdir: %s\n", GRUB_BLS_CONFIG_PATH); -+ -+ blsdir_dev = info->dev; -+ blsdir_fs = info->fs; -+ read_entry_info.devid = info->devid; -+ - read_fallback: - r = blsdir_fs->dir (blsdir_dev, read_entry_info.dirname, read_entry, - &read_entry_info); -@@ -809,7 +702,7 @@ read_fallback: - } while (e); - } - -- if (!nentries && !fallback && info->platform != PLATFORM_EMU) { -+ if (!nentries && !fallback) { - read_entry_info.dirname = "/boot" GRUB_BLS_CONFIG_PATH; - grub_dprintf ("blscfg", "Entries weren't found in %s, fallback to %s\n", - blsdir, read_entry_info.dirname); -@@ -832,41 +725,12 @@ read_fallback: - - for (r = 0; r < nentries; r++) - bls_free_entry (entries[r]); --finish: -- if (info->platform == PLATFORM_EFI && blsdir_dev) -- grub_device_close (blsdir_dev); - - nentries = 0; - - grub_free (entries); - entries = NULL; - -- grub_free ((char *)blsdir); -- -- grub_env_unset ("blsdir"); -- -- if (saved_env) -- { -- // remove everything from the real environment that's defined in env -- grub_envblk_iterate (env, NULL, unset_var); -- -- // re-set the things from our original environment -- grub_envblk_iterate (saved_env, NULL, set_var); -- grub_envblk_close (saved_env); -- saved_env = NULL; -- } -- else if (saved_env_buf) -- { -- // if we have a saved environment, grub_envblk_close() freed this. -- grub_free (saved_env_buf); -- } -- -- if (env) -- grub_envblk_close (env); -- -- if (f) -- grub_file_close (f); -- - return 0; - } - -@@ -883,7 +747,6 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - { - .dev = NULL, - .fs = NULL, -- .platform = PLATFORM_BIOS, - }; - - -@@ -891,13 +754,14 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - - #ifdef GRUB_MACHINE_EMU - devid = "host"; -- grub_env_set ("boot", devid); -+#elif defined(GRUB_MACHINE_EFI) -+ devid = grub_env_get ("root"); - #else - devid = grub_env_get ("boot"); -+#endif - if (!devid) - return grub_error (GRUB_ERR_FILE_NOT_FOUND, - N_("variable `%s' isn't set"), "boot"); --#endif - - grub_dprintf ("blscfg", "opening %s\n", devid); - dev = grub_device_open (devid); -@@ -912,21 +776,10 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - goto finish; - } - -+ info.devid = devid; - info.dev = dev; - info.fs = fs; --#ifdef GRUB_MACHINE_EFI -- info.platform = PLATFORM_EFI; -- grub_dprintf ("blscfg", "scanning /EFI/\n"); -- r = fs->dir (dev, "/EFI/", find_entry, &info); --#elif defined(GRUB_MACHINE_EMU) -- info.platform = PLATFORM_EMU; -- grub_dprintf ("blscfg", "scanning %s%s\n", GRUB_BOOT_DEVICE, -- GRUB_BLS_CONFIG_PATH); -- find_entry(NULL, NULL, &info); --#else -- grub_dprintf ("blscfg", "scanning %s\n", GRUB_BLS_CONFIG_PATH); -- find_entry(NULL, NULL, &info); --#endif -+ find_entry(&info); - - finish: - if (dev) diff --git a/0213-Rename-00_menu_auto_hide.in-to-01_menu_auto_hide.in.patch b/0213-Rename-00_menu_auto_hide.in-to-01_menu_auto_hide.in.patch deleted file mode 100644 index 14cc004..0000000 --- a/0213-Rename-00_menu_auto_hide.in-to-01_menu_auto_hide.in.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Christian Glombek -Date: Tue, 31 Jul 2018 11:11:01 +0200 -Subject: [PATCH] Rename 00_menu_auto_hide.in to 01_menu_auto_hide.in - -This is necessary to accommodate the fallback counting script which -needs to run before this one because the menu auto hide script sets -boot_success = 0, which will be used by the boot counting script ---- - Makefile.util.def | 4 ++-- - util/grub.d/{00_menu_auto_hide.in => 01_menu_auto_hide.in} | 0 - 2 files changed, 2 insertions(+), 2 deletions(-) - rename util/grub.d/{00_menu_auto_hide.in => 01_menu_auto_hide.in} (100%) - -diff --git a/Makefile.util.def b/Makefile.util.def -index 97cd8bdebd9..cba4d500198 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -449,8 +449,8 @@ script = { - }; - - script = { -- name = '00_menu_auto_hide'; -- common = util/grub.d/00_menu_auto_hide.in; -+ name = '01_menu_auto_hide'; -+ common = util/grub.d/01_menu_auto_hide.in; - installdir = grubconf; - }; - -diff --git a/util/grub.d/00_menu_auto_hide.in b/util/grub.d/01_menu_auto_hide.in -similarity index 100% -rename from util/grub.d/00_menu_auto_hide.in -rename to util/grub.d/01_menu_auto_hide.in diff --git a/0216-Disable-multiboot-multiboot2-and-linux16-modules-on-.patch b/0216-Disable-multiboot-multiboot2-and-linux16-modules-on-.patch deleted file mode 100644 index 9dccf5a..0000000 --- a/0216-Disable-multiboot-multiboot2-and-linux16-modules-on-.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 11 Jul 2018 13:48:48 -0400 -Subject: [PATCH] Disable multiboot, multiboot2, and linux16 modules on EFI - builds. - -Signed-off-by: Peter Jones ---- - grub-core/Makefile.core.def | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index aa44d66aca4..d3e3bfd4d7a 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -1680,7 +1680,7 @@ module = { - - common = loader/multiboot.c; - common = loader/multiboot_mbi2.c; -- enable = x86; -+ enable = i386_pc; - enable = mips; - }; - -@@ -1689,7 +1689,7 @@ module = { - common = loader/multiboot.c; - x86 = loader/i386/multiboot_mbi.c; - extra_dist = loader/multiboot_elfxx.c; -- enable = x86; -+ enable = i386_pc; - }; - - module = { diff --git a/0223-Make-efi_netfs-not-duplicate-symbols-from-efinet.patch b/0223-Make-efi_netfs-not-duplicate-symbols-from-efinet.patch deleted file mode 100644 index e1b9bb4..0000000 --- a/0223-Make-efi_netfs-not-duplicate-symbols-from-efinet.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 11 Jul 2018 13:50:00 -0400 -Subject: [PATCH] Make efi_netfs not duplicate symbols from efinet - -Signed-off-by: Peter Jones ---- - grub-core/Makefile.core.def | 6 ------ - 1 file changed, 6 deletions(-) - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index d3e3bfd4d7a..715d3a3ec02 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -2186,12 +2186,6 @@ module = { - module = { - name = efi_netfs; - common = net/efi/efi_netfs.c; -- common = net/efi/net.c; -- common = net/efi/http.c; -- common = net/efi/pxe.c; -- common = net/efi/ip4_config.c; -- common = net/efi/ip6_config.c; -- common = net/efi/dhcp.c; - enable = efi; - }; - diff --git a/0229-Mark-some-unused-stuff-unused.patch b/0229-Mark-some-unused-stuff-unused.patch deleted file mode 100644 index 2561754..0000000 --- a/0229-Mark-some-unused-stuff-unused.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 27 Aug 2018 13:10:08 -0400 -Subject: [PATCH] Mark some unused stuff unused - -Signed-off-by: Peter Jones ---- - grub-core/commands/blscfg.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index bdb1c5a95aa..abd6f00d0de 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -434,7 +434,7 @@ finish: - - static grub_envblk_t saved_env = NULL; - --static int -+static int UNUSED - save_var (const char *name, const char *value, void *whitelist UNUSED) - { - const char *val = grub_env_get (name); -@@ -446,7 +446,7 @@ save_var (const char *name, const char *value, void *whitelist UNUSED) - return 0; - } - --static int -+static int UNUSED - unset_var (const char *name, const char *value UNUSED, void *whitelist) - { - grub_dprintf("blscfg", "restoring \"%s\"\n", name); diff --git a/0239-grub-boot-success.timer-Add-a-few-Conditions-for-run.patch b/0239-grub-boot-success.timer-Add-a-few-Conditions-for-run.patch deleted file mode 100644 index 4f82ba2..0000000 --- a/0239-grub-boot-success.timer-Add-a-few-Conditions-for-run.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Mon, 3 Sep 2018 13:01:58 +0200 -Subject: [PATCH] grub-boot-success.timer: Add a few Conditions for running the - timer - -Add 2 Conditions for running the boot-success timer / service: - -1) Do not run it for system users, this fixes errors about gdm not being -allowed to use pkexec when the greeter session lasts for more then 2 minutes: -https://bugzilla.redhat.com/show_bug.cgi?id=1592201#c6 - -2) Do not run the timer when pkexec is not available (on minimal installs) -since then it will just lead to a bunch of errors without doing anything: -https://bugzilla.redhat.com/show_bug.cgi?id=1619445 - -Signed-off-by: Hans de Goede ---- - docs/grub-boot-success.timer | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/docs/grub-boot-success.timer b/docs/grub-boot-success.timer -index 221b532781b..67bd829b795 100644 ---- a/docs/grub-boot-success.timer -+++ b/docs/grub-boot-success.timer -@@ -1,5 +1,7 @@ - [Unit] - Description=Mark boot as successful after the user session has run 2 minutes -+ConditionUser=!@system -+ConditionPathExists=/usr/bin/pkexec - - [Timer] - OnActiveSec=2min diff --git a/0244-docs-Stop-using-polkit-pkexec-for-grub-boot-success..patch b/0244-docs-Stop-using-polkit-pkexec-for-grub-boot-success..patch deleted file mode 100644 index bf4ad27..0000000 --- a/0244-docs-Stop-using-polkit-pkexec-for-grub-boot-success..patch +++ /dev/null @@ -1,69 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Fri, 14 Sep 2018 16:39:40 +0200 -Subject: [PATCH] docs: Stop using polkit / pkexec for grub-boot-success.timer - / service - -We also want to call grub2-set-bootflag under gdm and pkexec does not -work under gdm because the gdm user has /sbin/nologin as shell. - -So instead we are going to install grub2-set-bootflag as suid root, -grub2-set-bootflag was written with this usage in mind, so is safe -to be made suid root. - -Signed-off-by: Hans de Goede ---- - docs/grub-boot-success.service | 2 +- - docs/grub-boot-success.timer | 1 - - docs/org.gnu.grub.policy | 20 -------------------- - 3 files changed, 1 insertion(+), 22 deletions(-) - delete mode 100644 docs/org.gnu.grub.policy - -diff --git a/docs/grub-boot-success.service b/docs/grub-boot-success.service -index c8c91c34d49..80e79584c91 100644 ---- a/docs/grub-boot-success.service -+++ b/docs/grub-boot-success.service -@@ -3,4 +3,4 @@ Description=Mark boot as successful - - [Service] - Type=oneshot --ExecStart=/usr/bin/pkexec /usr/sbin/grub2-set-bootflag boot_success -+ExecStart=/usr/sbin/grub2-set-bootflag boot_success -diff --git a/docs/grub-boot-success.timer b/docs/grub-boot-success.timer -index 67bd829b795..5d8fcba21aa 100644 ---- a/docs/grub-boot-success.timer -+++ b/docs/grub-boot-success.timer -@@ -1,7 +1,6 @@ - [Unit] - Description=Mark boot as successful after the user session has run 2 minutes - ConditionUser=!@system --ConditionPathExists=/usr/bin/pkexec - - [Timer] - OnActiveSec=2min -diff --git a/docs/org.gnu.grub.policy b/docs/org.gnu.grub.policy -deleted file mode 100644 -index 18391efc8e7..00000000000 ---- a/docs/org.gnu.grub.policy -+++ /dev/null -@@ -1,20 +0,0 @@ -- -- -- -- GNU GRUB -- https://www.gnu.org/software/grub/ -- -- -- Set GRUB bootflags -- Authentication is required to modify the bootloaders bootflags -- -- no -- no -- yes -- -- /usr/sbin/grub2-set-bootflag -- -- diff --git a/0245-drop-TPM-support-for-legacy-BIOS.patch b/0245-drop-TPM-support-for-legacy-BIOS.patch deleted file mode 100644 index 6de6f60..0000000 --- a/0245-drop-TPM-support-for-legacy-BIOS.patch +++ /dev/null @@ -1,401 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 21 Sep 2018 17:51:16 +0200 -Subject: [PATCH] drop TPM support for legacy BIOS - -Currently there's TPM support for both EFI and legacy BIOS. - -A software interrupt call interface is used in legacy BIOS to communicate -with the TPM chips. But with some BIOS firmwares, the machine just hangs -after doing a BIOS interrupt call for the TCG_HashLogExtendEvent command. - -It's hard to know what exactly is causing this, but the Trousers project -mentions in their docs that they don't use TCG_HashLogExtendEvent [0] due -the command not working reliable on some BIOS. - -The TCG_CompactHashLogExtendEvent is less fragile, since it has a simpler -interface, doesn't require to setup any data structure and doesn't return -anything. So it could be used to do measurements and logs events instead. - -But even when using this command can be a workaround on some systems, it -doesn't guarantee that could not fail on others. So since the TPM support -for some legacy BIOS don't work and can lead to machines failing to boot, -let's just drop it and only support TPM for EFI. - -[0]: http://trousers.sourceforge.net/grub.html - -Resolves: rhbz#1579835 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/Makefile.core.def | 1 - - grub-core/kern/i386/pc/tpm.c | 145 -------------------------------------- - grub-core/loader/i386/pc/linux.c | 4 -- - include/grub/tpm.h | 2 +- - grub-core/boot/i386/pc/boot.S | 30 +------- - grub-core/boot/i386/pc/diskboot.S | 44 ------------ - 6 files changed, 2 insertions(+), 224 deletions(-) - delete mode 100644 grub-core/kern/i386/pc/tpm.c - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 701e5d32fa2..f33ff332079 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -246,7 +246,6 @@ kernel = { - - i386_pc = kern/i386/pc/init.c; - i386_pc = kern/i386/pc/mmap.c; -- i386_pc = kern/i386/pc/tpm.c; - i386_pc = term/i386/pc/console.c; - - i386_qemu = bus/pci.c; -diff --git a/grub-core/kern/i386/pc/tpm.c b/grub-core/kern/i386/pc/tpm.c -deleted file mode 100644 -index f6f264aff2e..00000000000 ---- a/grub-core/kern/i386/pc/tpm.c -+++ /dev/null -@@ -1,145 +0,0 @@ --#include --#include --#include --#include --#include --#include -- --#define TCPA_MAGIC 0x41504354 -- --static int tpm_presence = -1; -- --int tpm_present(void); -- --int tpm_present(void) --{ -- struct grub_bios_int_registers regs; -- -- if (tpm_presence != -1) -- return tpm_presence; -- -- regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; -- regs.eax = 0xbb00; -- regs.ebx = TCPA_MAGIC; -- grub_bios_interrupt (0x1a, ®s); -- -- if (regs.eax == 0) -- tpm_presence = 1; -- else -- tpm_presence = 0; -- -- return tpm_presence; --} -- --grub_err_t --grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, -- PassThroughToTPM_OutputParamBlock *outbuf) --{ -- struct grub_bios_int_registers regs; -- grub_addr_t inaddr, outaddr; -- -- if (!tpm_present()) -- return 0; -- -- inaddr = (grub_addr_t) inbuf; -- outaddr = (grub_addr_t) outbuf; -- regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; -- regs.eax = 0xbb02; -- regs.ebx = TCPA_MAGIC; -- regs.ecx = 0; -- regs.edx = 0; -- regs.es = (inaddr & 0xffff0000) >> 4; -- regs.edi = inaddr & 0xffff; -- regs.ds = outaddr >> 4; -- regs.esi = outaddr & 0xf; -- -- grub_bios_interrupt (0x1a, ®s); -- -- if (regs.eax) -- { -- tpm_presence = 0; -- return grub_error (GRUB_ERR_IO, N_("TPM error %x, disabling TPM"), regs.eax); -- } -- -- return 0; --} -- --typedef struct { -- grub_uint32_t pcrindex; -- grub_uint32_t eventtype; -- grub_uint8_t digest[20]; -- grub_uint32_t eventdatasize; -- grub_uint8_t event[0]; --} GRUB_PACKED Event; -- --typedef struct { -- grub_uint16_t ipblength; -- grub_uint16_t reserved; -- grub_uint32_t hashdataptr; -- grub_uint32_t hashdatalen; -- grub_uint32_t pcr; -- grub_uint32_t reserved2; -- grub_uint32_t logdataptr; -- grub_uint32_t logdatalen; --} GRUB_PACKED EventIncoming; -- --typedef struct { -- grub_uint16_t opblength; -- grub_uint16_t reserved; -- grub_uint32_t eventnum; -- grub_uint8_t hashvalue[20]; --} GRUB_PACKED EventOutgoing; -- --grub_err_t --grub_tpm_log_event(unsigned char *buf, grub_size_t size, grub_uint8_t pcr, -- const char *description) --{ -- struct grub_bios_int_registers regs; -- EventIncoming incoming; -- EventOutgoing outgoing; -- Event *event; -- grub_uint32_t datalength; -- -- if (!tpm_present()) -- return 0; -- -- datalength = grub_strlen(description); -- event = grub_zalloc(datalength + sizeof(Event)); -- if (!event) -- return grub_error (GRUB_ERR_OUT_OF_MEMORY, -- N_("cannot allocate TPM event buffer")); -- -- event->pcrindex = pcr; -- event->eventtype = 0x0d; -- event->eventdatasize = grub_strlen(description); -- grub_memcpy(event->event, description, datalength); -- -- incoming.ipblength = sizeof(incoming); -- incoming.hashdataptr = (grub_uint32_t)buf; -- incoming.hashdatalen = size; -- incoming.pcr = pcr; -- incoming.logdataptr = (grub_uint32_t)event; -- incoming.logdatalen = datalength + sizeof(Event); -- -- regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; -- regs.eax = 0xbb01; -- regs.ebx = TCPA_MAGIC; -- regs.ecx = 0; -- regs.edx = 0; -- regs.es = (((grub_addr_t) &incoming) & 0xffff0000) >> 4; -- regs.edi = ((grub_addr_t) &incoming) & 0xffff; -- regs.ds = (((grub_addr_t) &outgoing) & 0xffff0000) >> 4; -- regs.esi = ((grub_addr_t) &outgoing) & 0xffff; -- -- grub_bios_interrupt (0x1a, ®s); -- -- grub_free(event); -- -- if (regs.eax) -- { -- tpm_presence = 0; -- return grub_error (GRUB_ERR_IO, N_("TPM error %x, disabling TPM"), regs.eax); -- } -- -- return 0; --} -diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index cfff25c21b5..783a3cd93bc 100644 ---- a/grub-core/loader/i386/pc/linux.c -+++ b/grub-core/loader/i386/pc/linux.c -@@ -36,7 +36,6 @@ - #include - #include - #include --#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -162,9 +161,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- grub_tpm_measure (kernel, len, GRUB_BINARY_PCR, "grub_linux16", "Kernel"); -- grub_print_error(); -- - grub_memcpy (&lh, kernel, sizeof (lh)); - kernel_offset = sizeof (lh); - -diff --git a/include/grub/tpm.h b/include/grub/tpm.h -index 972a5edc836..ce52be4ff7f 100644 ---- a/include/grub/tpm.h -+++ b/include/grub/tpm.h -@@ -69,7 +69,7 @@ typedef struct { - grub_err_t EXPORT_FUNC(grub_tpm_measure) (unsigned char *buf, grub_size_t size, - grub_uint8_t pcr, const char *kind, - const char *description); --#if defined (GRUB_MACHINE_EFI) || defined (GRUB_MACHINE_PCBIOS) -+#if defined (GRUB_MACHINE_EFI) - grub_err_t grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, - PassThroughToTPM_OutputParamBlock *outbuf); - grub_err_t grub_tpm_log_event(unsigned char *buf, grub_size_t size, -diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S -index acab37369ae..ea167fe1206 100644 ---- a/grub-core/boot/i386/pc/boot.S -+++ b/grub-core/boot/i386/pc/boot.S -@@ -24,14 +24,11 @@ - * defines for the code go here - */ - --#define TPM 1 -- - /* Print message string */ - #define MSG(x) movw $x, %si; call LOCAL(message) - #define ERR(x) movw $x, %si; jmp LOCAL(error_message) - - .macro floppy --#ifndef TPM - part_start: - - LOCAL(probe_values): -@@ -88,7 +85,6 @@ fd_probe_error_string: .asciz "Floppy" - movb MACRO_DOLLAR(79), %ch - - jmp LOCAL(final_init) --#endif - .endm - - .macro scratch -@@ -256,7 +252,6 @@ real_start: - /* set %si to the disk address packet */ - movw $disk_address_packet, %si - --#ifndef TPM - /* check if LBA is supported */ - movb $0x41, %ah - movw $0x55aa, %bx -@@ -276,7 +271,6 @@ real_start: - - andw $1, %cx - jz LOCAL(chs_mode) --#endif - - LOCAL(lba_mode): - xorw %ax, %ax -@@ -320,9 +314,6 @@ LOCAL(lba_mode): - jmp LOCAL(copy_buffer) - - LOCAL(chs_mode): --#ifdef TPM -- jmp LOCAL(general_error) --#else - /* - * Determine the hard disk geometry from the BIOS! - * We do this first, so that LS-120 IDE floppies work correctly. -@@ -434,7 +425,7 @@ setup_sectors: - jc LOCAL(read_error) - - movw %es, %bx --#endif /* TPM */ -+ - LOCAL(copy_buffer): - /* - * We need to save %cx and %si because the startup code in -@@ -457,25 +448,6 @@ LOCAL(copy_buffer): - popw %ds - popa - --#ifdef TPM -- pusha -- -- movw $0xBB00, %ax /* TCG_StatusCheck */ -- int $0x1A -- test %eax, %eax -- jnz boot /* No TPM or TPM deactivated */ -- -- movw $0xBB07, %ax /* TCG_CompactHashLogExtendEvent */ -- movw $GRUB_BOOT_MACHINE_KERNEL_ADDR, %di -- xorl %esi, %esi -- movl $0x41504354, %ebx /* TCPA */ -- movl $0x200, %ecx /* Measure 512 bytes */ -- movl $0x8, %edx /* PCR 8 */ -- int $0x1A -- --boot: -- popa --#endif - /* boot kernel */ - jmp *(LOCAL(kernel_address)) - -diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S -index f4744ec6fcb..68d31de0c4c 100644 ---- a/grub-core/boot/i386/pc/diskboot.S -+++ b/grub-core/boot/i386/pc/diskboot.S -@@ -19,8 +19,6 @@ - #include - #include - --#define TPM 1 -- - /* - * defines for the code go here - */ -@@ -55,21 +53,6 @@ _start: - /* this sets up for the first run through "bootloop" */ - movw $LOCAL(firstlist), %di - --#ifdef TPM -- /* clear EAX to remove potential garbage */ -- xorl %eax, %eax -- /* 8(%di) = number of sectors to read */ -- movw 8(%di), %ax -- -- /* Multiply number of sectors to read with 512 bytes. EAX is 32bit -- * which is large enough to hold values of up to 4GB. I doubt there -- * will ever be a core.img larger than that. ;-) */ -- shll $9, %eax -- -- /* write result to bytes_to_measure var */ -- movl %eax, bytes_to_measure --#endif -- - /* save the sector number of the second sector in %ebp */ - movl (%di), %ebp - -@@ -307,29 +290,6 @@ LOCAL(copy_buffer): - /* END OF MAIN LOOP */ - - LOCAL(bootit): --#ifdef TPM -- pusha -- movw $0xBB07, %ax /* TCG_CompactHashLogExtendEvent */ -- -- movw $0x0, %bx -- movw %bx, %es -- -- /* We've already measured the first 512 bytes, now measure the rest */ -- xorl %edi, %edi -- movw $(GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200), %di -- -- movl $0x41504354, %ebx /* EBX = "TCPA" */ -- -- /* %ecx = The length, in bytes, of the buffer to measure */ -- movl $bytes_to_measure, %esi -- movl (%esi), %ecx -- xorl %esi, %esi -- movl $0x9, %edx /* PCR 9 */ -- -- int $0x1A -- -- popa --#endif - /* print a newline */ - MSG(notification_done) - popw %dx /* this makes sure %dl is our "boot" drive */ -@@ -364,10 +324,6 @@ geometry_error_string: .asciz "Geom" - read_error_string: .asciz "Read" - general_error_string: .asciz " Error" - --#ifdef TPM --bytes_to_measure: .long 0 --#endif -- - /* - * message: write the string pointed to by %si - * diff --git a/0246-Move-quicksort-function-from-kernel.exec-to-the-blsc.patch b/0246-Move-quicksort-function-from-kernel.exec-to-the-blsc.patch deleted file mode 100644 index b4db698..0000000 --- a/0246-Move-quicksort-function-from-kernel.exec-to-the-blsc.patch +++ /dev/null @@ -1,146 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 27 Sep 2018 10:49:14 +0200 -Subject: [PATCH] Move quicksort function from kernel.exec to the blscfg module - -The qsort function is defined in the grub2 kernel and exported for modules -to use. But this prevents the blscfg.mod to be loaded by old grub2 kernels -that don't export this symbol. - -Loading the latest blscfg module might be useful on legacy BIOS systems to -avoid updating the first and second stage grub2 images in the boot device. - -Since the only caller of the qsort function is the blscfg module, move the -qsort function out of the grub2 kernel and only have it in the blscfg.mod. - -While being there, also remove the grub_bsearch() function that is unused. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/Makefile.core.def | 2 +- - grub-core/commands/blscfg.c | 3 ++- - grub-core/{kern/qsort.c => commands/bls_qsort.h} | 30 +++--------------------- - include/grub/misc.h | 15 ------------ - 4 files changed, 6 insertions(+), 44 deletions(-) - rename grub-core/{kern/qsort.c => commands/bls_qsort.h} (93%) - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index f33ff332079..18d4ec20cdf 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -129,7 +129,6 @@ kernel = { - common = kern/rescue_parser.c; - common = kern/rescue_reader.c; - common = kern/term.c; -- common = kern/qsort.c; - common = kern/backtrace.c; - common = kern/tpm.c; - -@@ -786,6 +785,7 @@ module = { - module = { - name = blscfg; - common = commands/blscfg.c; -+ common = commands/bls_qsort.h; - common = commands/loadenv.h; - enable = efi; - enable = i386_pc; -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index abd6f00d0de..bec5a9ffe3e 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -36,6 +36,7 @@ - - GRUB_MOD_LICENSE ("GPLv3+"); - -+#include "bls_qsort.h" - #include "loadenv.h" - - #define GRUB_BLS_CONFIG_PATH "/loader/entries/" -@@ -717,7 +718,7 @@ read_fallback: - use_version = false; - } - -- grub_qsort(&entries[0], nentries, sizeof (struct bls_entry *), bls_cmp, &use_version); -+ bls_qsort(&entries[0], nentries, sizeof (struct bls_entry *), bls_cmp, &use_version); - - grub_dprintf ("blscfg", "%s Creating %d entries from bls\n", __func__, nentries); - for (r = nentries - 1; r >= 0; r--) -diff --git a/grub-core/kern/qsort.c b/grub-core/commands/bls_qsort.h -similarity index 93% -rename from grub-core/kern/qsort.c -rename to grub-core/commands/bls_qsort.h -index 7f3fc9ffdae..572765fa3f2 100644 ---- a/grub-core/kern/qsort.c -+++ b/grub-core/commands/bls_qsort.h -@@ -64,6 +64,7 @@ typedef struct - #define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) - #define STACK_NOT_EMPTY (stack < top) - -+typedef int (*grub_compar_d_fn_t) (const void *p0, const void *p1, void *state); - - /* Order size using quicksort. This implementation incorporates - four optimizations discussed in Sedgewick: -@@ -89,8 +90,8 @@ typedef struct - smaller partition. This *guarantees* no more than log (total_elems) - stack size is needed (actually O(1) in this case)! */ - --void --grub_qsort (void *const pbase, grub_size_t total_elems, grub_size_t size, -+static inline void UNUSED -+bls_qsort (void *const pbase, grub_size_t total_elems, grub_size_t size, - grub_compar_d_fn_t cmp, void *arg) - { - char *base_ptr = (char *) pbase; -@@ -252,28 +253,3 @@ grub_qsort (void *const pbase, grub_size_t total_elems, grub_size_t size, - } - } - --void * --grub_bsearch (const void *key, const void *base, grub_size_t nmemb, grub_size_t size, -- grub_compar_d_fn_t compar, void *state) --{ -- grub_size_t l, u, idx; -- const void *p; -- int comparison; -- -- l = 0; -- u = nmemb; -- while (l < u) -- { -- idx = (l + u) / 2; -- p = (void *) (((const char *) base) + (idx * size)); -- comparison = (*compar) (key, p, state); -- if (comparison < 0) -- u = idx; -- else if (comparison > 0) -- l = idx + 1; -- else -- return (void *) p; -- } -- -- return NULL; --} -diff --git a/include/grub/misc.h b/include/grub/misc.h -index 5f1c1c1be4e..de9016ab709 100644 ---- a/include/grub/misc.h -+++ b/include/grub/misc.h -@@ -510,19 +510,4 @@ void EXPORT_FUNC(grub_real_boot_time) (const char *file, - #define grub_max(a, b) (((a) > (b)) ? (a) : (b)) - #define grub_min(a, b) (((a) < (b)) ? (a) : (b)) - --typedef int (*grub_compar_d_fn_t) (const void *p0, const void *p1, void *state); -- --void *EXPORT_FUNC(grub_bsearch) (const void *key, -- const void *base, -- grub_size_t nmemb, -- grub_size_t size, -- grub_compar_d_fn_t compar, -- void *state); -- --void EXPORT_FUNC(grub_qsort) (void *const pbase, -- grub_size_t total_elems, -- grub_size_t size, -- grub_compar_d_fn_t cmp, -- void *state); -- - #endif /* ! GRUB_MISC_HEADER */ diff --git a/0247-Include-blscfg-module-for-powerpc-ieee1275.patch b/0247-Include-blscfg-module-for-powerpc-ieee1275.patch deleted file mode 100644 index 9df5926..0000000 --- a/0247-Include-blscfg-module-for-powerpc-ieee1275.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 27 Sep 2018 19:03:43 +0200 -Subject: [PATCH] Include blscfg module for powerpc ieee1275 - -The blscfg module is currently not built for powerpc ieee1275, but this -is still needed when the machine is not booted in bare metal with OPAL. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/Makefile.core.def | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 18d4ec20cdf..30c2ac8f3c8 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -787,6 +787,7 @@ module = { - common = commands/blscfg.c; - common = commands/bls_qsort.h; - common = commands/loadenv.h; -+ enable = powerpc_ieee1275; - enable = efi; - enable = i386_pc; - enable = emu; diff --git a/0248-grub-switch-to-blscfg-copy-blscfg-module-for-legacy-.patch b/0248-grub-switch-to-blscfg-copy-blscfg-module-for-legacy-.patch deleted file mode 100644 index f4f391e..0000000 --- a/0248-grub-switch-to-blscfg-copy-blscfg-module-for-legacy-.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 28 Sep 2018 10:35:38 +0200 -Subject: [PATCH] grub-switch-to-blscfg: copy blscfg module for legacy BIOS and - ppc ieee1275 - -On platforms that load the blscfg module the latest version should be used, -so copy the module to the boot directory to make sure that the grub2 kernel -will load the latest version of the BLS parsing code. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 13 ++++++++++++- - 1 file changed, 12 insertions(+), 1 deletion(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 9cf64f8e725..1c6bd1882a7 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -53,6 +53,8 @@ blsdir=`echo "/@bootdirname@/loader/entries" | sed 's,//*,/,g'` - - backupsuffix=.bak - -+arch="$(uname -m)" -+ - export TEXTDOMAIN=@PACKAGE@ - export TEXTDOMAINDIR="@localedir@" - -@@ -248,7 +250,6 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - fi - - if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -- arch="$(uname -m)" - bls_debug="$(echo ${bls_target} | sed -e "s/\.${arch}/-debug.${arch}/")" - cp -aT "${bls_target}" "${bls_debug}" - title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')" -@@ -282,6 +283,16 @@ elif ! grep -q '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" ; then - fi - - if [ "${GENERATE}" -eq 1 ] ; then -+ if [ $arch = "x86_64" ] && [ ! -d /sys/firmware/efi ]; then -+ if ! cp ${prefix}/lib/grub//i386-pc/blscfg.mod ${grubdir}/i386-pc/ ; then -+ exit 1 -+ fi -+ elif [ $arch = "ppc64" -o $arch = "ppc64le" ] && [ ! -d /sys/firmware/opal ]; then -+ if ! cp ${prefix}/lib/grub/powerpc-ieee1275/blscfg.mod ${grubdir}/powerpc-ieee1275/ ; then -+ exit 1 -+ fi -+ fi -+ - cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}" - if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then - cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}" diff --git a/0252-blscfg-don-t-include-.conf-at-the-end-of-our-id.patch b/0252-blscfg-don-t-include-.conf-at-the-end-of-our-id.patch deleted file mode 100644 index 59adb84..0000000 --- a/0252-blscfg-don-t-include-.conf-at-the-end-of-our-id.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 11 Oct 2018 15:30:13 -0400 -Subject: [PATCH] blscfg: don't include ".conf" at the end of our "id". - -Related: rhbz#1638117 - -Signed-off-by: Peter Jones ---- - grub-core/commands/blscfg.c | 11 +++++++++++ - 1 file changed, 11 insertions(+) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index bec5a9ffe3e..3847572dabd 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -575,6 +575,7 @@ static void create_entry (struct bls_entry *entry) - char **initrds = NULL; - char *initrd = NULL; - char *id = entry->filename; -+ char *dotconf = id; - char *hotkey = NULL; - - char *users = NULL; -@@ -593,6 +594,16 @@ static void create_entry (struct bls_entry *entry) - goto finish; - } - -+ /* -+ * strip the ".conf" off the end before we make it our "id" field. -+ */ -+ do -+ { -+ dotconf = grub_strstr(dotconf, ".conf"); -+ } while (dotconf != NULL && dotconf[5] != '\0'); -+ if (dotconf) -+ dotconf[0] = '\0'; -+ - title = bls_get_val (entry, "title", NULL); - options = expand_val (bls_get_val (entry, "options", NULL)); - initrds = bls_make_list (entry, "initrd", NULL); diff --git a/0253-grub-get-kernel-settings-expose-some-more-config-var.patch b/0253-grub-get-kernel-settings-expose-some-more-config-var.patch deleted file mode 100644 index 2471e5f..0000000 --- a/0253-grub-get-kernel-settings-expose-some-more-config-var.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 11 Oct 2018 15:31:04 -0400 -Subject: [PATCH] grub-get-kernel-settings: expose some more config variables - -This exposes MAKEDEFAULT as GRUB_UPDATE_DEFAULT_KERNEL and DEFAULTDEBUG as -GRUB_DEFAULT_TO_DEBUG - -Related: rhbz#1638117 -Signed-off-by: Peter Jones ---- - util/grub-get-kernel-settings.in | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/util/grub-get-kernel-settings.in b/util/grub-get-kernel-settings.in -index 12046219878..7e87dfccc0e 100644 ---- a/util/grub-get-kernel-settings.in -+++ b/util/grub-get-kernel-settings.in -@@ -76,3 +76,13 @@ if [ "$MAKEDEBUG" = "yes" ]; then - echo GRUB_LINUX_DEBUG_TITLE_POSTFIX=\" with debugging\" - echo export GRUB_LINUX_DEBUG_TITLE_POSTFIX - fi -+if [ "$DEFAULTDEBUG" = "yes" ]; then -+ echo GRUB_DEFAULT_TO_DEBUG=true -+else -+ echo GRUB_DEFAULT_TO_DEBUG=false -+fi -+echo export GRUB_DEFAULT_TO_DEBUG -+if [ "$UPDATEDEFAULT" = "yes" ]; then -+ echo GRUB_UPDATE_DEFAULT_KERNEL=true -+ echo export GRUB_UPDATE_DEFAULT_KERNEL -+fi diff --git a/0254-Reimplement-boot_counter.patch b/0254-Reimplement-boot_counter.patch deleted file mode 100644 index 9091c9e..0000000 --- a/0254-Reimplement-boot_counter.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 4 Oct 2018 14:22:09 -0400 -Subject: [PATCH] Reimplement boot_counter - -This adds "increment" and "decrement" commands, and uses them to maintain our -variables in 01_fallback_counter. It also simplifies the counter logic, so -that there are no nested tests that conflict with each other. - -Apparently, this *really* wasn't tested well enough. - -Resolves: rhbz#1614637 -Signed-off-by: Peter Jones ---- - util/grub.d/01_fallback_counting.in | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/util/grub.d/01_fallback_counting.in b/util/grub.d/01_fallback_counting.in -index 6ca13da03df..1a0b5fbecfc 100644 ---- a/util/grub.d/01_fallback_counting.in -+++ b/util/grub.d/01_fallback_counting.in -@@ -1,5 +1,9 @@ - #! /bin/sh -e - -+if ! systemctl -q is-enabled greenboot.service >/dev/null 2>&1 ; then -+ exit 0 -+fi -+ - # Boot Counting - cat << EOF - insmod increment diff --git a/0256-Only-set-kernelopts-in-grubenv-if-it-wasn-t-set-befo.patch b/0256-Only-set-kernelopts-in-grubenv-if-it-wasn-t-set-befo.patch deleted file mode 100644 index be3c867..0000000 --- a/0256-Only-set-kernelopts-in-grubenv-if-it-wasn-t-set-befo.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 5 Oct 2018 16:29:47 +0200 -Subject: [PATCH] Only set kernelopts in grubenv if it wasn't set before - -Users may want to use a different command line parameters, so if there's -a kernelopts var set in grubenv, grub2-mkconfig shouldn't reset it. - -While being there, print a warning so users know that they shouldn't edit -the grub config file and instead edit the BootLoaderSpec config files. - -Resolves: rhbz#1636466 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 20 +++++++++++++++++++- - util/grub.d/10_linux_bls.in | 4 +++- - 2 files changed, 22 insertions(+), 2 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 9682e97b7f5..01e66e5fc74 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -82,6 +82,20 @@ case x"$GRUB_FS" in - ;; - esac - -+populate_header_warn() -+{ -+cat < -Date: Mon, 15 Oct 2018 15:08:33 -0400 -Subject: [PATCH] blscfg: sort everything with rpm *package* comparison - -This makes comparisons use the n-v-r tuple, and compare name with name, -version with version, and release with release. - -Related: rhbz#1638103 - -Signed-off-by: Peter Jones ---- - grub-core/commands/blscfg.c | 118 ++++++++++++++++++++++++++++++++++++++++---- - 1 file changed, 108 insertions(+), 10 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 3847572dabd..347128c9ddd 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -206,7 +206,7 @@ static int vercmp(const char * a, const char * b) - int isnum; - int ret = 0; - -- grub_dprintf("blscfg", "%s got here\n", __func__); -+ grub_dprintf("blscfg", "%s got here\n", __func__); - if (!grub_strcmp(a, b)) - return 0; - -@@ -315,6 +315,81 @@ finish: - return ret; - } - -+/* returns name/version/release */ -+/* NULL string pointer returned if nothing found */ -+static void -+split_package_string (char *package_string, char **name, -+ char **version, char **release) -+{ -+ char *package_version, *package_release; -+ -+ /* Release */ -+ package_release = grub_strrchr (package_string, '-'); -+ -+ if (package_release != NULL) -+ *package_release++ = '\0'; -+ -+ *release = package_release; -+ -+ if (name == NULL) -+ { -+ *version = package_string; -+ } -+ else -+ { -+ /* Version */ -+ package_version = grub_strrchr(package_string, '-'); -+ -+ if (package_version != NULL) -+ *package_version++ = '\0'; -+ -+ *version = package_version; -+ /* Name */ -+ *name = package_string; -+ } -+ -+ /* Bubble up non-null values from release to name */ -+ if (name != NULL && *name == NULL) -+ { -+ *name = (*version == NULL ? *release : *version); -+ *version = *release; -+ *release = NULL; -+ } -+ if (*version == NULL) -+ { -+ *version = *release; -+ *release = NULL; -+ } -+} -+ -+static int -+split_cmp(char *nvr0, char *nvr1, int has_name) -+{ -+ int ret = 0; -+ char *name0, *version0, *release0; -+ char *name1, *version1, *release1; -+ -+ split_package_string(nvr0, has_name ? &name0 : NULL, &version0, &release0); -+ split_package_string(nvr1, has_name ? &name1 : NULL, &version1, &release1); -+ -+ if (has_name) -+ { -+ ret = vercmp(name0 == NULL ? "" : name0, -+ name1 == NULL ? "" : name1); -+ if (ret != 0) -+ return ret; -+ } -+ -+ ret = vercmp(version0 == NULL ? "" : version0, -+ version1 == NULL ? "" : version1); -+ if (ret != 0) -+ return ret; -+ -+ ret = vercmp(release0 == NULL ? "" : release0, -+ release1 == NULL ? "" : release1); -+ return ret; -+} -+ - /* return 1: p0 is newer than p1 */ - /* 0: p0 and p1 are the same version */ - /* -1: p1 is newer than p0 */ -@@ -323,18 +398,41 @@ static int bls_cmp(const void *p0, const void *p1, void *state) - struct bls_entry * e0 = *(struct bls_entry **)p0; - struct bls_entry * e1 = *(struct bls_entry **)p1; - bool use_version = *(bool *)state; -- const char *v0, *v1; -- int r; -+ char *v0, *v1; -+ char *id0, *id1; -+ int l, r; - -- if (use_version) { -- v0 = bls_get_val(e0, "version", NULL); -- v1 = bls_get_val(e1, "version", NULL); -+ if (use_version) -+ { -+ v0 = grub_strdup(bls_get_val(e0, "version", NULL)); -+ v1 = grub_strdup(bls_get_val(e1, "version", NULL)); - -- if ((r = vercmp(v0, v1)) != 0) -- return r; -- } -+ r = split_cmp(v0, v1, 0); - -- return vercmp(e0->filename, e1->filename); -+ grub_free(v0); -+ grub_free(v1); -+ -+ if (r != 0) -+ return r; -+ } -+ -+ id0 = grub_strdup(e0->filename); -+ id1 = grub_strdup(e1->filename); -+ -+ l = grub_strlen(id0); -+ if (l > 5 && grub_strcmp(id0 + l - 5, ".conf")) -+ id0[l-5] = '\0'; -+ -+ l = grub_strlen(id1); -+ if (l > 5 && grub_strcmp(id1 + l - 5, ".conf")) -+ id1[l-5] = '\0'; -+ -+ r = split_cmp(id0, id1, 1); -+ -+ grub_free(id0); -+ grub_free(id1); -+ -+ return r; - } - - struct read_entry_info { diff --git a/0258-10_linux_bls-use-grub2-rpm-sort-instead-of-ls-vr-to-.patch b/0258-10_linux_bls-use-grub2-rpm-sort-instead-of-ls-vr-to-.patch deleted file mode 100644 index f23cd47..0000000 --- a/0258-10_linux_bls-use-grub2-rpm-sort-instead-of-ls-vr-to-.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 16 Oct 2018 15:48:15 +0200 -Subject: [PATCH] 10_linux_bls: use grub2-rpm-sort instead of ls -vr to sort - entries - -Using ls -vr is wrong since it's not the same than the RPM sort algorithm. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux_bls.in | 18 +++++++++++++++--- - 1 file changed, 15 insertions(+), 3 deletions(-) - -diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in -index 8a3379578bd..1bc97f29898 100644 ---- a/util/grub.d/10_linux_bls.in -+++ b/util/grub.d/10_linux_bls.in -@@ -151,10 +151,22 @@ read_config() - - populate_menu() - { -- entries_path="/boot/loader/entries" -+ blsdir="/boot/loader/entries" -+ local -a files -+ local IFS=$'\n' - gettext_printf "Generating boot entries from BLS files...\n" >&2 -- for config in $(ls -v -r $entries_path/*.conf); do -- read_config ${config} -+ -+ files=($(for bls in ${blsdir}/*.conf ; do -+ if ! [[ -e "${bls}" ]] ; then -+ continue -+ fi -+ bls="${bls%.conf}" -+ bls="${bls##*/}" -+ echo "${bls}" -+ done | ${kernel_sort} | tac)) || : -+ -+ for bls in "${files[@]}" ; do -+ read_config "${blsdir}/${bls}.conf" - menu="${menu}menuentry '${title}' {\n" - menu="${menu}\t linux ${linux} ${options}\n" - if [ -n "${initrd}" ] ; then diff --git a/0259-don-t-set-saved_entry-on-grub2-mkconfig.patch b/0259-don-t-set-saved_entry-on-grub2-mkconfig.patch deleted file mode 100644 index 8e3ea47..0000000 --- a/0259-don-t-set-saved_entry-on-grub2-mkconfig.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 19 Oct 2018 14:42:41 +0200 -Subject: [PATCH] don't set saved_entry on grub2-mkconfig - -The original plan was for grub2 to rely on the BLS sort criteria to choose -the default entry to boot, to avoid modifying any files when a new kernel -was installed. But that was changed and now 20-grub.install changes the -default, so 10_linux{,bls} shouldn't overwrite this. - -Resolves: rhbz#1636466 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 1 - - util/grub.d/10_linux_bls.in | 1 - - 2 files changed, 2 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 01e66e5fc74..b54d2774a7d 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -165,7 +165,6 @@ if [ -s \$prefix/grubenv ]; then - fi - EOF - -- ${grub_editenv} - set saved_entry=0 - if ! grub2-editenv - list | grep -q kernelopts; then - ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" - fi -diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in -index 1bc97f29898..8745e598d0e 100644 ---- a/util/grub.d/10_linux_bls.in -+++ b/util/grub.d/10_linux_bls.in -@@ -212,7 +212,6 @@ linux_entry () - populate_header_warn - populate_menu - -- ${grub_editenv} - set saved_entry=0 - if ! grub2-editenv - list | grep -q kernelopts; then - ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" - fi diff --git a/0260-grub-switch-to-blscfg-use-debug-instead-of-debug-as-.patch b/0260-grub-switch-to-blscfg-use-debug-instead-of-debug-as-.patch deleted file mode 100644 index 9256c23..0000000 --- a/0260-grub-switch-to-blscfg-use-debug-instead-of-debug-as-.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 19 Oct 2018 18:48:27 +0200 -Subject: [PATCH] grub-switch-to-blscfg: use ~debug instead of -debug as suffix - to sort correctly - -For the debug BLS entries a -debug suffix was added so they are sorted after -the kernel entries, but that only works with version sort and not rpm sort. - -So instead use ~debug prefix so rpm sort algorithm could sort it correctly. - -Related: rhbz#1638103 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 1c6bd1882a7..60cd6ca63cc 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -250,7 +250,7 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - fi - - if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -- bls_debug="$(echo ${bls_target} | sed -e "s/\.${arch}/-debug.${arch}/")" -+ bls_debug="$(echo ${bls_target} | sed -e "s/${kernelver}/${kernelver}~debug/")" - cp -aT "${bls_target}" "${bls_debug}" - title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')" - blsid="$(grep '^id[ \t]' "${bls_debug}" | sed -e "s/\.${ARCH}/-debug.${arch}/")" diff --git a/0261-Make-blscfg-debug-messages-more-useful.patch b/0261-Make-blscfg-debug-messages-more-useful.patch deleted file mode 100644 index 9a05606..0000000 --- a/0261-Make-blscfg-debug-messages-more-useful.patch +++ /dev/null @@ -1,175 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 19 Oct 2018 10:03:28 -0400 -Subject: [PATCH] Make blscfg debug messages more useful - -Related: rhbz#1640979 -Signed-off-by: Peter Jones ---- - grub-core/commands/blscfg.c | 12 +++++------- - grub-core/commands/legacycfg.c | 4 ++-- - grub-core/commands/menuentry.c | 18 ++++++++++++++---- - include/grub/normal.h | 2 +- - 4 files changed, 22 insertions(+), 14 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 347128c9ddd..42892cbfd55 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -46,8 +46,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #define GRUB_BOOT_DEVICE "($root)" - #endif - --#define grub_free(x) ({grub_dprintf("blscfg", "%s freeing %p\n", __func__, x); grub_free(x); }) -- - struct keyval - { - const char *key; -@@ -134,7 +132,7 @@ static int bls_add_keyval(struct bls_entry *entry, char *key, char *val) - kv->val = v; - - entry->keyvals[entry->nkeyvals] = kv; -- grub_dprintf("blscfg", "new keyval at %p:%p:%p\n", entry->keyvals[entry->nkeyvals], k, v); -+ grub_dprintf("blscfg", "new keyval at %p:%s:%s\n", entry->keyvals[entry->nkeyvals], k, v); - entry->nkeyvals = new_n; - - return 0; -@@ -144,7 +142,6 @@ static void bls_free_entry(struct bls_entry *entry) - { - int i; - -- grub_dprintf("blscfg", "%s got here\n", __func__); - for (i = 0; i < entry->nkeyvals; i++) - { - struct keyval *kv = entry->keyvals[i]; -@@ -206,7 +203,7 @@ static int vercmp(const char * a, const char * b) - int isnum; - int ret = 0; - -- grub_dprintf("blscfg", "%s got here\n", __func__); -+ grub_dprintf("blscfg", "%s comparing %s and %s\n", __func__, a, b); - if (!grub_strcmp(a, b)) - return 0; - -@@ -682,7 +679,7 @@ static void create_entry (struct bls_entry *entry) - char **args = NULL; - - char *src = NULL; -- int i; -+ int i, index; - - grub_dprintf("blscfg", "%s got here\n", __func__); - clinux = bls_get_val (entry, "linux", NULL); -@@ -756,7 +753,8 @@ static void create_entry (struct bls_entry *entry) - GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", - initrd ? initrd : ""); - -- grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0); -+ grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0, &index); -+ grub_dprintf ("blscfg", "Added entry %d id:\"%s\"\n", index, id); - - finish: - grub_free (initrd); -diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c -index b32f3c74cb1..f9d7627bdc3 100644 ---- a/grub-core/commands/legacycfg.c -+++ b/grub-core/commands/legacycfg.c -@@ -133,7 +133,7 @@ legacy_file (const char *filename) - args[0] = oldname; - grub_normal_add_menu_entry (1, args, NULL, NULL, "legacy", - NULL, NULL, -- entrysrc, 0); -+ entrysrc, 0, NULL); - grub_free (args); - entrysrc[0] = 0; - grub_free (oldname); -@@ -186,7 +186,7 @@ legacy_file (const char *filename) - } - args[0] = entryname; - grub_normal_add_menu_entry (1, args, NULL, NULL, NULL, -- NULL, NULL, entrysrc, 0); -+ NULL, NULL, entrysrc, 0, NULL); - grub_free (args); - } - -diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c -index 2c5363da7f5..8d242b0187e 100644 ---- a/grub-core/commands/menuentry.c -+++ b/grub-core/commands/menuentry.c -@@ -78,7 +78,7 @@ grub_normal_add_menu_entry (int argc, const char **args, - char **classes, const char *id, - const char *users, const char *hotkey, - const char *prefix, const char *sourcecode, -- int submenu) -+ int submenu, int *index) - { - int menu_hotkey = 0; - char **menu_args = NULL; -@@ -149,9 +149,12 @@ grub_normal_add_menu_entry (int argc, const char **args, - if (! menu_title) - goto fail; - -+ grub_dprintf ("menu", "id:\"%s\"\n", id); -+ grub_dprintf ("menu", "title:\"%s\"\n", menu_title); - menu_id = grub_strdup (id ? : menu_title); - if (! menu_id) - goto fail; -+ grub_dprintf ("menu", "menu_id:\"%s\"\n", menu_id); - - /* Save argc, args to pass as parameters to block arg later. */ - menu_args = grub_malloc (sizeof (char*) * (argc + 1)); -@@ -170,8 +173,12 @@ grub_normal_add_menu_entry (int argc, const char **args, - } - - /* Add the menu entry at the end of the list. */ -+ int ind=0; - while (*last) -- last = &(*last)->next; -+ { -+ ind++; -+ last = &(*last)->next; -+ } - - *last = grub_zalloc (sizeof (**last)); - if (! *last) -@@ -190,6 +197,8 @@ grub_normal_add_menu_entry (int argc, const char **args, - (*last)->submenu = submenu; - - menu->size++; -+ if (index) -+ *index = ind; - return GRUB_ERR_NONE; - - fail: -@@ -286,7 +295,8 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args) - users, - ctxt->state[2].arg, 0, - ctxt->state[3].arg, -- ctxt->extcmd->cmd->name[0] == 's'); -+ ctxt->extcmd->cmd->name[0] == 's', -+ NULL); - - src = args[argc - 1]; - args[argc - 1] = NULL; -@@ -303,7 +313,7 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args) - ctxt->state[0].args, ctxt->state[4].arg, - users, - ctxt->state[2].arg, prefix, src + 1, -- ctxt->extcmd->cmd->name[0] == 's'); -+ ctxt->extcmd->cmd->name[0] == 's', NULL); - - src[len - 1] = ch; - args[argc - 1] = src; -diff --git a/include/grub/normal.h b/include/grub/normal.h -index 218cbabccaf..cb9901f41b3 100644 ---- a/include/grub/normal.h -+++ b/include/grub/normal.h -@@ -145,7 +145,7 @@ grub_normal_add_menu_entry (int argc, const char **args, char **classes, - const char *id, - const char *users, const char *hotkey, - const char *prefix, const char *sourcecode, -- int submenu); -+ int submenu, int *index); - - grub_err_t - grub_normal_set_password (const char *user, const char *password); diff --git a/0264-Add-comments-and-revert-logic-changes-in-01_fallback.patch b/0264-Add-comments-and-revert-logic-changes-in-01_fallback.patch deleted file mode 100644 index cc5f8a8..0000000 --- a/0264-Add-comments-and-revert-logic-changes-in-01_fallback.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Christian Glombek -Date: Mon, 8 Oct 2018 11:57:04 +0200 -Subject: [PATCH] Add comments and revert logic changes in 01_fallback_counting - ---- - util/grub.d/01_fallback_counting.in | 27 +++++++++++++++------------ - 1 file changed, 15 insertions(+), 12 deletions(-) - -diff --git a/util/grub.d/01_fallback_counting.in b/util/grub.d/01_fallback_counting.in -index 1a0b5fbecfc..be0e770ea82 100644 ---- a/util/grub.d/01_fallback_counting.in -+++ b/util/grub.d/01_fallback_counting.in -@@ -1,19 +1,22 @@ - #! /bin/sh -e - --if ! systemctl -q is-enabled greenboot.service >/dev/null 2>&1 ; then -- exit 0 --fi -- - # Boot Counting -+# The boot_counter env var can be used to count down boot attempts after an -+# OSTree upgrade and choose the rollback deployment when 0 is reached. Both -+# boot_counter and boot_success need to be (re-)set from userspace. - cat << EOF - insmod increment --if [ -z "\${boot_counter}" ]; then -- set boot_counter=0 --elif [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then -- increment default -- set boot_counter=-1 --else -- decrement boot_counter -+# Check if boot_counter exists and boot_success=0 to activate this behaviour. -+if [ -n "\${boot_counter}" -a "\${boot_success}" = "0" ]; then -+ # if countdown has ended, choose to boot rollback deployment (default=1 on -+ # OSTree-based systems) -+ if [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then -+ set default=1 -+ set boot_counter=-1 -+ # otherwise decrement boot_counter -+ else -+ decrement boot_counter -+ fi -+ save_env boot_counter - fi --save_env boot_counter - EOF diff --git a/0265-Remove-quotes-when-reading-ID-value-from-etc-os-rele.patch b/0265-Remove-quotes-when-reading-ID-value-from-etc-os-rele.patch deleted file mode 100644 index b81f46f..0000000 --- a/0265-Remove-quotes-when-reading-ID-value-from-etc-os-rele.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 21 Nov 2018 15:37:32 +0100 -Subject: [PATCH] Remove quotes when reading ID value from /etc/os-release - -The field is used to obtain the path to the GRUB directory in the ESP for -UEFI installs. But in some OS the ID value is quoted, which leads to some -of the scripts to fail: - - $ grub2-setpassword - /boot/efi/EFI/"redhat"/ does not exist. - Usage: /usr/sbin/grub2-setpassword [OPTION] - -Related: rhbz#1650706 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-set-password.in | 2 +- - util/grub-switch-to-blscfg.in | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/util/grub-set-password.in b/util/grub-set-password.in -index 5ebf50576d6..c0b5ebbfdc5 100644 ---- a/util/grub-set-password.in -+++ b/util/grub-set-password.in -@@ -1,6 +1,6 @@ - #!/bin/sh -e - --EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') -+EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/' -e 's/\"//g') - if [ -d /sys/firmware/efi/efivars/ ]; then - grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'` - else -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 60cd6ca63cc..d353370cc51 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -40,7 +40,7 @@ etcdefaultgrub=/etc/default/grub - - eval "$("${grub_get_kernel_settings}")" || true - --EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') -+EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/' -e 's/\"//g') - if [ -d /sys/firmware/efi/efivars/ ]; then - startlink=/etc/grub2-efi.cfg - grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'` diff --git a/0266-blscfg-expand-grub_users-before-passing-to-grub_norm.patch b/0266-blscfg-expand-grub_users-before-passing-to-grub_norm.patch deleted file mode 100644 index d5951b4..0000000 --- a/0266-blscfg-expand-grub_users-before-passing-to-grub_norm.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 21 Nov 2018 15:38:50 +0100 -Subject: [PATCH] blscfg: expand grub_users before passing to - grub_normal_add_menu_entry() - -The "grub_users" field from the BLS snippet file is used to specifcy the -users that are allowed to execute a given menu entry if the "superusers" -environment variable is set. - -If the "grub_users" isn't set, the menu entry is unrestricted and it can -be executed without any authentication and if is set then only the users -defined in "grub_users" can execute the menu entry after authentication. - -But this field can contain an environment variable so has to be expanded -or otherwise grub2 will wrongly assume that the user is "$var", and will -populate a menu entry that it's resctrited even when "$var" isn't set. - -Resolves: rhbz#1650706 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 42892cbfd55..c432c6ba27a 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -704,7 +704,7 @@ static void create_entry (struct bls_entry *entry) - initrds = bls_make_list (entry, "initrd", NULL); - - hotkey = bls_get_val (entry, "grub_hotkey", NULL); -- users = bls_get_val (entry, "grub_users", NULL); -+ users = expand_val (bls_get_val (entry, "grub_users", NULL)); - classes = bls_make_list (entry, "grub_class", NULL); - args = bls_make_list (entry, "grub_arg", &argc); - diff --git a/0268-10_linux_bls-add-missing-menu-entries-options.patch b/0268-10_linux_bls-add-missing-menu-entries-options.patch deleted file mode 100644 index 620c55d..0000000 --- a/0268-10_linux_bls-add-missing-menu-entries-options.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 22 Nov 2018 16:12:19 +0100 -Subject: [PATCH] 10_linux_bls: add missing menu entries options - -The script that generates menu entries in the grub.cfg from BLS snippets -wasn't filling some important options, like the --id, --class and --user -if these were defined in the BLS. - -Resolves: rhbz#1652434 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux_bls.in | 15 ++++++++++++++- - 1 file changed, 14 insertions(+), 1 deletion(-) - -diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in -index 8745e598d0e..8cff4c58ab5 100644 ---- a/util/grub.d/10_linux_bls.in -+++ b/util/grub.d/10_linux_bls.in -@@ -127,6 +127,9 @@ read_config() - initrd="" - options="" - linux="" -+ grub_users="" -+ grub_arg="" -+ grub_class="" - - while read -r line - do -@@ -145,6 +148,15 @@ read_config() - "options") - options=${value} - ;; -+ "grub_users") -+ grub_users=${value} -+ ;; -+ "grub_arg") -+ grub_arg=${value} -+ ;; -+ "grub_class") -+ grub_class=${value} -+ ;; - esac - done < ${config_file} - } -@@ -167,7 +179,8 @@ populate_menu() - - for bls in "${files[@]}" ; do - read_config "${blsdir}/${bls}.conf" -- menu="${menu}menuentry '${title}' {\n" -+ -+ menu="${menu}menuentry '${title}' --class ${grub_class} ${grub_arg} --users ${grub_users} --id ${bls} {\n" - menu="${menu}\t linux ${linux} ${options}\n" - if [ -n "${initrd}" ] ; then - menu="${menu}\t initrd ${boot_prefix}${initrd}\n" diff --git a/0269-Fix-menu-entry-selection-based-on-title.patch b/0269-Fix-menu-entry-selection-based-on-title.patch deleted file mode 100644 index 31825b0..0000000 --- a/0269-Fix-menu-entry-selection-based-on-title.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 30 Nov 2018 16:39:09 +0100 -Subject: [PATCH] Fix menu entry selection based on title - -The get_entry_number_helper() function assumes that there could be a set -of entries identifiers in a variable (i.e: as used in the fallback case) -so iterates over the string until it finds a space to get the first id. - -But this should only be done for indexes or entries id, since the title -can contain spaces. In the case of title, the complete string should be -used to select a given entry. - -Resolves: rhbz#1654936 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/normal/menu.c | 7 ++----- - 1 file changed, 2 insertions(+), 5 deletions(-) - -diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index 95f7abaf2fd..fc25c702f3c 100644 ---- a/grub-core/normal/menu.c -+++ b/grub-core/normal/menu.c -@@ -217,14 +217,11 @@ get_entry_number_helper(grub_menu_t menu, - - for (i = 0, e = menu->entry_list; e; i++) - { -- int l = 0; -- while (val[l] && !grub_isspace(val[l])) -- l++; - -- if (menuentry_eq (e->title, val, l)) -+ if (menuentry_eq (e->title, val, -1)) - { - if (tail) -- *tail = val + l; -+ *tail = NULL; - return i; - } - e = e->next; diff --git a/0270-BLS-files-should-only-be-copied-by-grub-switch-to-bl.patch b/0270-BLS-files-should-only-be-copied-by-grub-switch-to-bl.patch deleted file mode 100644 index 1fc6e2d..0000000 --- a/0270-BLS-files-should-only-be-copied-by-grub-switch-to-bl.patch +++ /dev/null @@ -1,120 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 4 Dec 2018 10:48:45 +0100 -Subject: [PATCH] BLS files should only be copied by grub-switch-to-blscfg if - BLS isn't set - -Currently the grub-switch-to-blscfg script doesn't update the grub.cfg if -GRUB_ENABLE_BLSCFG=true is already set in /etc/default/grub. But it still -copies the BLS files which may overwrite fields modified by the user. - -Related: rhbz#1638117 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 80 +++++++++++++++++++++++-------------------- - 1 file changed, 42 insertions(+), 38 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index d353370cc51..eeea1307706 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -220,49 +220,51 @@ EOF - ) | cat - } - --for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do -- bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf" -- linux="/vmlinuz-${kernelver}" -- linux_path="/boot${linux}" -- kernel_dir="/lib/modules/${kernelver}" -+copy_bls() { -+ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do -+ bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf" -+ linux="/vmlinuz-${kernelver}" -+ linux_path="/boot${linux}" -+ kernel_dir="/lib/modules/${kernelver}" - -- if [ ! -d "${kernel_dir}" ] ; then -- continue -- fi -- if [ ! -f "${linux_path}" ]; then -- continue -- fi -+ if [ ! -d "${kernel_dir}" ] ; then -+ continue -+ fi -+ if [ ! -f "${linux_path}" ]; then -+ continue -+ fi - -- linux_relpath="$("${grub_mkrelpath}" "${linux_path}")" -- bootprefix="${linux_relpath%%"${linux}"}" -+ linux_relpath="$("${grub_mkrelpath}" "${linux_path}")" -+ bootprefix="${linux_relpath%%"${linux}"}" - -- if [ -f "${kernel_dir}/bls.conf" ] ; then -- cp -af "${kernel_dir}/bls.conf" "${bls_target}" -- if [ -n "${bootprefix}" ]; then -- sed -i -e "s,^\(linux[^ \t]*[ \t]\+\).*,\1${bootprefix}${linux},g" "${bls_target}" -- sed -i -e "/^initrd/ s,\([ \t]\+\)\([^ \t]\+\),\1${bootprefix}\2,g" "${bls_target}" -- fi -- else -- mkbls "${kernelver}" \ -- "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \ -- "${bootprefix}" \ -- >"${bls_target}" -- fi -+ if [ -f "${kernel_dir}/bls.conf" ] ; then -+ cp -af "${kernel_dir}/bls.conf" "${bls_target}" -+ if [ -n "${bootprefix}" ]; then -+ sed -i -e "s,^\(linux[^ \t]*[ \t]\+\).*,\1${bootprefix}${linux},g" "${bls_target}" -+ sed -i -e "/^initrd/ s,\([ \t]\+\)\([^ \t]\+\),\1${bootprefix}\2,g" "${bls_target}" -+ fi -+ else -+ mkbls "${kernelver}" \ -+ "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \ -+ "${bootprefix}" \ -+ >"${bls_target}" -+ fi - -- if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -- bls_debug="$(echo ${bls_target} | sed -e "s/${kernelver}/${kernelver}~debug/")" -- cp -aT "${bls_target}" "${bls_debug}" -- title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')" -- blsid="$(grep '^id[ \t]' "${bls_debug}" | sed -e "s/\.${ARCH}/-debug.${arch}/")" -- sed -i -e "s/^title.*/title ${title}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${bls_debug}" -- sed -i -e "s/^id.*/${blsid}/" "${bls_debug}" -- sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${bls_debug}" -- fi --done -+ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -+ bls_debug="$(echo ${bls_target} | sed -e "s/${kernelver}/${kernelver}~debug/")" -+ cp -aT "${bls_target}" "${bls_debug}" -+ title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')" -+ blsid="$(grep '^id[ \t]' "${bls_debug}" | sed -e "s/\.${ARCH}/-debug.${arch}/")" -+ sed -i -e "s/^title.*/title ${title}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${bls_debug}" -+ sed -i -e "s/^id.*/${blsid}/" "${bls_debug}" -+ sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${bls_debug}" -+ fi -+ done - --if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then -- mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" --fi -+ if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then -+ mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" -+ fi -+} - - GENERATE=0 - if grep '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" \ -@@ -283,6 +285,8 @@ elif ! grep -q '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" ; then - fi - - if [ "${GENERATE}" -eq 1 ] ; then -+ copy_bls -+ - if [ $arch = "x86_64" ] && [ ! -d /sys/firmware/efi ]; then - if ! cp ${prefix}/lib/grub//i386-pc/blscfg.mod ${grubdir}/i386-pc/ ; then - exit 1 diff --git a/0271-Fix-get_entry_number-wrongly-dereferencing-the-tail-.patch b/0271-Fix-get_entry_number-wrongly-dereferencing-the-tail-.patch deleted file mode 100644 index f1667a1..0000000 --- a/0271-Fix-get_entry_number-wrongly-dereferencing-the-tail-.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 4 Dec 2018 10:53:49 +0100 -Subject: [PATCH] Fix get_entry_number() wrongly dereferencing the tail pointer - -The get_entry_number_helper() function attempts to lookup a boot entry by -either title or id matching the value of an environment variable. If they -are a substring of the variable, the tail pointer is set to the first char -of the remainder of the string. - -When get_entry_number() calls this function, it checks if this first char -is a NUL byte, to know if the variable matched correctly. But tail can be -set to NULL as well to indicate that there isn't a remainder in the string. - -Resolves: rhbz#1654936 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/normal/menu.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index fc25c702f3c..7e32c498aa8 100644 ---- a/grub-core/normal/menu.c -+++ b/grub-core/normal/menu.c -@@ -563,7 +563,7 @@ get_entry_number (grub_menu_t menu, const char *name) - - grub_error_push (); - entry = get_entry_number_helper(menu, val, &tail); -- if (*tail != '\0') -+ if (tail && *tail != '\0') - entry = -1; - grub_error_pop (); - diff --git a/0272-Make-grub2-mkconfig-to-honour-GRUB_CMDLINE_LINUX-in-.patch b/0272-Make-grub2-mkconfig-to-honour-GRUB_CMDLINE_LINUX-in-.patch deleted file mode 100644 index 71fbd51..0000000 --- a/0272-Make-grub2-mkconfig-to-honour-GRUB_CMDLINE_LINUX-in-.patch +++ /dev/null @@ -1,99 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 10 Dec 2018 13:11:58 +0100 -Subject: [PATCH] Make grub2-mkconfig to honour GRUB_CMDLINE_LINUX in - /etc/default/grub - -The kernelopts grub environment variable is set with the GRUB_CMDLINE_LINUX -value only if wasn't set before. This is because the kernel cmdline params -of the entries are not in the grub.cfg anymore so grub2-mkconfig shouldn't -have side effects on neither the entries nor their kernel cmdline params. - -But there's a lot of documentation pointing at modifying GRUB_CMDLINE_LINUX -to change the kernel cmdline params and users have built a muscle memory on -it, so the BLS support should be compatible. - -Make the grub2-mkconfig script update the $kernelopts environment variable -unless the --no-grubenv-update option is used. - -Resolves: rhbz#1637875 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-mkconfig.8 | 4 ++++ - util/grub-mkconfig.in | 6 ++++++ - util/grub.d/10_linux.in | 2 +- - util/grub.d/10_linux_bls.in | 2 +- - 4 files changed, 12 insertions(+), 2 deletions(-) - -diff --git a/util/grub-mkconfig.8 b/util/grub-mkconfig.8 -index a2d1f577b9b..434fa4deda4 100644 ---- a/util/grub-mkconfig.8 -+++ b/util/grub-mkconfig.8 -@@ -13,5 +13,9 @@ - \fB--output\fR=\fIFILE\fR - Write generated output to \fIFILE\fR. - -+.TP -+\fB--no-grubenv-update\fR -+Do not update variables in the grubenv file. -+ - .SH SEE ALSO - .BR "info grub" -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index c20171919d9..5e643e16973 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -50,6 +50,8 @@ grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@" - export TEXTDOMAIN=@PACKAGE@ - export TEXTDOMAINDIR="@localedir@" - -+export GRUB_GRUBENV_UPDATE="yes" -+ - . "${pkgdatadir}/grub-mkconfig_lib" - - # Usage: usage -@@ -59,6 +61,7 @@ usage () { - gettext "Generate a grub config file"; echo - echo - print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")" -+ print_option_help "--no-grubenv-update" "$(gettext "do not update variables in the grubenv file")" - print_option_help "-h, --help" "$(gettext "print this message and exit")" - print_option_help "-v, --version" "$(gettext "print the version information and exit")" - echo -@@ -94,6 +97,9 @@ do - --output=*) - grub_cfg=`echo "$option" | sed 's/--output=//'` - ;; -+ --no-grubenv-update) -+ GRUB_GRUBENV_UPDATE="no" -+ ;; - -*) - gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2 - usage -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index b54d2774a7d..da2992ac9f1 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -165,7 +165,7 @@ if [ -s \$prefix/grubenv ]; then - fi - EOF - -- if ! grub2-editenv - list | grep -q kernelopts; then -+ if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then - ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" - fi - -diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in -index 8cff4c58ab5..175bedd0763 100644 ---- a/util/grub.d/10_linux_bls.in -+++ b/util/grub.d/10_linux_bls.in -@@ -225,7 +225,7 @@ linux_entry () - populate_header_warn - populate_menu - -- if ! grub2-editenv - list | grep -q kernelopts; then -+ if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then - ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" - fi - diff --git a/0276-blscfg-store-the-BLS-entries-in-a-sorted-linked-list.patch b/0276-blscfg-store-the-BLS-entries-in-a-sorted-linked-list.patch deleted file mode 100644 index dfd0686..0000000 --- a/0276-blscfg-store-the-BLS-entries-in-a-sorted-linked-list.patch +++ /dev/null @@ -1,590 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 21 Jan 2019 17:33:13 +0100 -Subject: [PATCH] blscfg: store the BLS entries in a sorted linked list - -The parsed BLS entries are stored in an array, that it's sorted -using the quick sort algorithm before populating the boot menu. - -This works on the assumption that all BLS entries are parsed at -the same time and that are displayed just after being retrieved. - -But the support could be made more flexible, and have different -commands to load and display the entries. Keeping the BLS in a -sorted link simplify the code considerably, while not making it -much less efficient. - -While being there, mark entries that have been used to populate -the boot menu so multiple calls to the blscfg command don't add -duplicated entries. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/Makefile.core.def | 1 - - grub-core/commands/blscfg.c | 177 ++++++++++++---------------- - grub-core/commands/bls_qsort.h | 255 ----------------------------------------- - 3 files changed, 71 insertions(+), 362 deletions(-) - delete mode 100644 grub-core/commands/bls_qsort.h - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 017080bd599..8a00c6177e1 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -796,7 +796,6 @@ module = { - module = { - name = blscfg; - common = commands/blscfg.c; -- common = commands/bls_qsort.h; - common = commands/loadenv.h; - enable = powerpc_ieee1275; - enable = efi; -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index c432c6ba27a..304d73908ae 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -19,6 +19,7 @@ - * along with GRUB. If not, see . - */ - -+#include - #include - #include - #include -@@ -36,7 +37,6 @@ - - GRUB_MOD_LICENSE ("GPLv3+"); - --#include "bls_qsort.h" - #include "loadenv.h" - - #define GRUB_BLS_CONFIG_PATH "/loader/entries/" -@@ -54,45 +54,17 @@ struct keyval - - struct bls_entry - { -+ struct bls_entry *next; -+ struct bls_entry **prev; - struct keyval **keyvals; - int nkeyvals; - char *filename; -+ bool visible; - }; - --static struct bls_entry **entries; --static int nentries; -+static struct bls_entry *entries = NULL; - --static struct bls_entry *bls_new_entry(void) --{ -- struct bls_entry **new_entries; -- struct bls_entry *entry; -- int new_n = nentries + 1; -- -- new_entries = grub_realloc (entries, new_n * sizeof (struct bls_entry *)); -- if (!new_entries) -- { -- grub_error (GRUB_ERR_OUT_OF_MEMORY, -- "couldn't find space for BLS entry list"); -- return NULL; -- } -- -- entries = new_entries; -- -- entry = grub_malloc (sizeof (*entry)); -- if (!entry) -- { -- grub_error (GRUB_ERR_OUT_OF_MEMORY, -- "couldn't find space for BLS entry list"); -- return NULL; -- } -- -- grub_memset (entry, 0, sizeof (*entry)); -- entries[nentries] = entry; -- -- nentries = new_n; -- -- return entry; --} -+#define FOR_BLS_ENTRIES(var) FOR_LIST_ELEMENTS (var, entries) - - static int bls_add_keyval(struct bls_entry *entry, char *key, char *val) - { -@@ -138,24 +110,6 @@ static int bls_add_keyval(struct bls_entry *entry, char *key, char *val) - return 0; - } - --static void bls_free_entry(struct bls_entry *entry) --{ -- int i; -- -- for (i = 0; i < entry->nkeyvals; i++) -- { -- struct keyval *kv = entry->keyvals[i]; -- grub_free ((void *)kv->key); -- grub_free (kv->val); -- grub_free (kv); -- } -- -- grub_free (entry->keyvals); -- grub_free (entry->filename); -- grub_memset (entry, 0, sizeof (*entry)); -- grub_free (entry); --} -- - /* Find they value of the key named by keyname. If there are allowed to be - * more than one, pass a pointer to an int set to -1 the first time, and pass - * the same pointer through each time after, and it'll return them in sorted -@@ -387,43 +341,17 @@ split_cmp(char *nvr0, char *nvr1, int has_name) - return ret; - } - --/* return 1: p0 is newer than p1 */ --/* 0: p0 and p1 are the same version */ --/* -1: p1 is newer than p0 */ --static int bls_cmp(const void *p0, const void *p1, void *state) -+/* return 1: e0 is newer than e1 */ -+/* 0: e0 and e1 are the same version */ -+/* -1: e1 is newer than e0 */ -+static int bls_cmp(const struct bls_entry *e0, const struct bls_entry *e1) - { -- struct bls_entry * e0 = *(struct bls_entry **)p0; -- struct bls_entry * e1 = *(struct bls_entry **)p1; -- bool use_version = *(bool *)state; -- char *v0, *v1; - char *id0, *id1; -- int l, r; -- -- if (use_version) -- { -- v0 = grub_strdup(bls_get_val(e0, "version", NULL)); -- v1 = grub_strdup(bls_get_val(e1, "version", NULL)); -- -- r = split_cmp(v0, v1, 0); -- -- grub_free(v0); -- grub_free(v1); -- -- if (r != 0) -- return r; -- } -+ int r; - - id0 = grub_strdup(e0->filename); - id1 = grub_strdup(e1->filename); - -- l = grub_strlen(id0); -- if (l > 5 && grub_strcmp(id0 + l - 5, ".conf")) -- id0[l-5] = '\0'; -- -- l = grub_strlen(id1); -- if (l > 5 && grub_strcmp(id1 + l - 5, ".conf")) -- id1[l-5] = '\0'; -- - r = split_cmp(id0, id1, 1); - - grub_free(id0); -@@ -432,6 +360,53 @@ static int bls_cmp(const void *p0, const void *p1, void *state) - return r; - } - -+static void list_add_tail(grub_list_t head, grub_list_t item) -+{ -+ item->next = head; -+ if (head->prev) -+ (*head->prev)->next = item; -+ item->prev = head->prev; -+ head->prev = &item; -+} -+ -+static int bls_add_entry(struct bls_entry *entry) -+{ -+ struct bls_entry *e, *last = NULL; -+ int rc; -+ -+ if (!entries) { -+ grub_dprintf ("blscfg", "Add entry with id \"%s\"\n", entry->filename); -+ entries = entry; -+ return 0; -+ } -+ -+ FOR_BLS_ENTRIES(e) { -+ rc = bls_cmp(entry, e); -+ -+ if (!rc) -+ return GRUB_ERR_BAD_ARGUMENT; -+ -+ if (rc == 1) { -+ grub_dprintf ("blscfg", "Add entry with id \"%s\"\n", entry->filename); -+ list_add_tail (GRUB_AS_LIST (e), GRUB_AS_LIST (entry)); -+ if (e == entries) { -+ entries = entry; -+ entry->prev = NULL; -+ } -+ return 0; -+ } -+ last = e; -+ } -+ -+ if (last) { -+ grub_dprintf ("blscfg", "Add entry with id \"%s\"\n", entry->filename); -+ last->next = entry; -+ entry->prev = &last; -+ } -+ -+ return 0; -+} -+ - struct read_entry_info { - const char *devid; - const char *dirname; -@@ -442,6 +417,7 @@ static int read_entry ( - const struct grub_dirhook_info *dirhook_info UNUSED, - void *data) - { -+ int rc = 0; - grub_size_t n; - char *p; - grub_file_t f = NULL; -@@ -471,7 +447,7 @@ static int read_entry ( - if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024) - goto finish; - -- entry = bls_new_entry(); -+ entry = grub_zalloc (sizeof (*entry)); - if (!entry) - goto finish; - -@@ -485,7 +461,6 @@ static int read_entry ( - { - char *buf; - char *separator; -- int rc; - - buf = grub_file_getline (f); - if (!buf) -@@ -519,6 +494,9 @@ static int read_entry ( - break; - } - -+ if (!rc) -+ bls_add_entry(entry); -+ - finish: - grub_free (p); - -@@ -779,10 +757,10 @@ struct find_entry_info { - static int find_entry (struct find_entry_info *info) - { - struct read_entry_info read_entry_info; -+ struct bls_entry *entry = NULL; - grub_fs_t blsdir_fs = NULL; - grub_device_t blsdir_dev = NULL; - const char *blsdir = NULL; -- bool use_version = true; - int fallback = 0; - int r = 0; - -@@ -810,7 +788,7 @@ read_fallback: - } while (e); - } - -- if (!nentries && !fallback) { -+ if (!entries && !fallback) { - read_entry_info.dirname = "/boot" GRUB_BLS_CONFIG_PATH; - grub_dprintf ("blscfg", "Entries weren't found in %s, fallback to %s\n", - blsdir, read_entry_info.dirname); -@@ -818,27 +796,14 @@ read_fallback: - goto read_fallback; - } - -- grub_dprintf ("blscfg", "Sorting %d entries\n", nentries); -+ grub_dprintf ("blscfg", "%s Creating entries from bls\n", __func__); -+ FOR_BLS_ENTRIES(entry) { -+ if (entry->visible) -+ continue; - -- for (r = 0; r < nentries && use_version; r++) { -- if (!bls_get_val(entries[r], "version", NULL)) -- use_version = false; -+ create_entry(entry); -+ entry->visible = true; - } -- -- bls_qsort(&entries[0], nentries, sizeof (struct bls_entry *), bls_cmp, &use_version); -- -- grub_dprintf ("blscfg", "%s Creating %d entries from bls\n", __func__, nentries); -- for (r = nentries - 1; r >= 0; r--) -- create_entry(entries[r]); -- -- for (r = 0; r < nentries; r++) -- bls_free_entry (entries[r]); -- -- nentries = 0; -- -- grub_free (entries); -- entries = NULL; -- - return 0; - } - -diff --git a/grub-core/commands/bls_qsort.h b/grub-core/commands/bls_qsort.h -deleted file mode 100644 -index 572765fa3f2..00000000000 ---- a/grub-core/commands/bls_qsort.h -+++ /dev/null -@@ -1,255 +0,0 @@ --/* quicksort -- * This file from the GNU C Library. -- * Copyright (C) 1991-2016 Free Software Foundation, Inc. -- * Written by Douglas C. Schmidt (schmidt@ics.uci.edu). -- * -- * GRUB -- GRand Unified Bootloader -- * -- * GRUB is free software: you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published by -- * the Free Software Foundation, either version 3 of the License, or -- * (at your option) any later version. -- * -- * GRUB is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- * GNU General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with GRUB. If not, see . -- */ -- --/* If you consider tuning this algorithm, you should consult first: -- Engineering a sort function; Jon Bentley and M. Douglas McIlroy; -- Software - Practice and Experience; Vol. 23 (11), 1249-1265, 1993. */ -- --#include --#include --#include -- --#define CHAR_BIT 8 -- --/* Byte-wise swap two items of size SIZE. */ --#define SWAP(a, b, size) \ -- do \ -- { \ -- grub_size_t __size = (size); \ -- char *__a = (a), *__b = (b); \ -- do \ -- { \ -- char __tmp = *__a; \ -- *__a++ = *__b; \ -- *__b++ = __tmp; \ -- } while (--__size > 0); \ -- } while (0) -- --/* Discontinue quicksort algorithm when partition gets below this size. -- This particular magic number was chosen to work best on a Sun 4/260. */ --#define MAX_THRESH 4 -- --/* Stack node declarations used to store unfulfilled partition obligations. */ --typedef struct -- { -- char *lo; -- char *hi; -- } stack_node; -- --/* The next 4 #defines implement a very fast in-line stack abstraction. */ --/* The stack needs log (total_elements) entries (we could even subtract -- log(MAX_THRESH)). Since total_elements has type grub_size_t, we get as -- upper bound for log (total_elements): -- bits per byte (CHAR_BIT) * sizeof(grub_size_t). */ --#define STACK_SIZE (CHAR_BIT * sizeof(grub_size_t)) --#define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) --#define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) --#define STACK_NOT_EMPTY (stack < top) -- --typedef int (*grub_compar_d_fn_t) (const void *p0, const void *p1, void *state); -- --/* Order size using quicksort. This implementation incorporates -- four optimizations discussed in Sedgewick: -- -- 1. Non-recursive, using an explicit stack of pointer that store the -- next array partition to sort. To save time, this maximum amount -- of space required to store an array of SIZE_MAX is allocated on the -- stack. Assuming a 32-bit (64 bit) integer for grub_size_t, this needs -- only 32 * sizeof(stack_node) == 256 bytes (for 64 bit: 1024 bytes). -- Pretty cheap, actually. -- -- 2. Chose the pivot element using a median-of-three decision tree. -- This reduces the probability of selecting a bad pivot value and -- eliminates certain extraneous comparisons. -- -- 3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving -- insertion sort to order the MAX_THRESH items within each partition. -- This is a big win, since insertion sort is faster for small, mostly -- sorted array segments. -- -- 4. The larger of the two sub-partitions is always pushed onto the -- stack first, with the algorithm then concentrating on the -- smaller partition. This *guarantees* no more than log (total_elems) -- stack size is needed (actually O(1) in this case)! */ -- --static inline void UNUSED --bls_qsort (void *const pbase, grub_size_t total_elems, grub_size_t size, -- grub_compar_d_fn_t cmp, void *arg) --{ -- char *base_ptr = (char *) pbase; -- -- const grub_size_t max_thresh = MAX_THRESH * size; -- -- if (total_elems == 0) -- /* Avoid lossage with unsigned arithmetic below. */ -- return; -- -- if (total_elems > MAX_THRESH) -- { -- char *lo = base_ptr; -- char *hi = &lo[size * (total_elems - 1)]; -- stack_node stack[STACK_SIZE]; -- stack_node *top = stack; -- -- PUSH (NULL, NULL); -- -- while (STACK_NOT_EMPTY) -- { -- char *left_ptr; -- char *right_ptr; -- -- /* Select median value from among LO, MID, and HI. Rearrange -- LO and HI so the three values are sorted. This lowers the -- probability of picking a pathological pivot value and -- skips a comparison for both the LEFT_PTR and RIGHT_PTR in -- the while loops. */ -- -- char *mid = lo + size * ((hi - lo) / size >> 1); -- -- if ((*cmp) ((void *) mid, (void *) lo, arg) < 0) -- SWAP (mid, lo, size); -- if ((*cmp) ((void *) hi, (void *) mid, arg) < 0) -- SWAP (mid, hi, size); -- else -- goto jump_over; -- if ((*cmp) ((void *) mid, (void *) lo, arg) < 0) -- SWAP (mid, lo, size); -- jump_over:; -- -- left_ptr = lo + size; -- right_ptr = hi - size; -- -- /* Here's the famous ``collapse the walls'' section of quicksort. -- Gotta like those tight inner loops! They are the main reason -- that this algorithm runs much faster than others. */ -- do -- { -- while ((*cmp) ((void *) left_ptr, (void *) mid, arg) < 0) -- left_ptr += size; -- -- while ((*cmp) ((void *) mid, (void *) right_ptr, arg) < 0) -- right_ptr -= size; -- -- if (left_ptr < right_ptr) -- { -- SWAP (left_ptr, right_ptr, size); -- if (mid == left_ptr) -- mid = right_ptr; -- else if (mid == right_ptr) -- mid = left_ptr; -- left_ptr += size; -- right_ptr -= size; -- } -- else if (left_ptr == right_ptr) -- { -- left_ptr += size; -- right_ptr -= size; -- break; -- } -- } -- while (left_ptr <= right_ptr); -- -- /* Set up pointers for next iteration. First determine whether -- left and right partitions are below the threshold size. If so, -- ignore one or both. Otherwise, push the larger partition's -- bounds on the stack and continue sorting the smaller one. */ -- -- if ((grub_size_t) (right_ptr - lo) <= max_thresh) -- { -- if ((grub_size_t) (hi - left_ptr) <= max_thresh) -- /* Ignore both small partitions. */ -- POP (lo, hi); -- else -- /* Ignore small left partition. */ -- lo = left_ptr; -- } -- else if ((grub_size_t) (hi - left_ptr) <= max_thresh) -- /* Ignore small right partition. */ -- hi = right_ptr; -- else if ((right_ptr - lo) > (hi - left_ptr)) -- { -- /* Push larger left partition indices. */ -- PUSH (lo, right_ptr); -- lo = left_ptr; -- } -- else -- { -- /* Push larger right partition indices. */ -- PUSH (left_ptr, hi); -- hi = right_ptr; -- } -- } -- } -- -- /* Once the BASE_PTR array is partially sorted by quicksort the rest -- is completely sorted using insertion sort, since this is efficient -- for partitions below MAX_THRESH size. BASE_PTR points to the beginning -- of the array to sort, and END_PTR points at the very last element in -- the array (*not* one beyond it!). */ -- --#define min(x, y) ((x) < (y) ? (x) : (y)) -- -- { -- char *const end_ptr = &base_ptr[size * (total_elems - 1)]; -- char *tmp_ptr = base_ptr; -- char *thresh = min(end_ptr, base_ptr + max_thresh); -- char *run_ptr; -- -- /* Find smallest element in first threshold and place it at the -- array's beginning. This is the smallest array element, -- and the operation speeds up insertion sort's inner loop. */ -- -- for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) -- if ((*cmp) ((void *) run_ptr, (void *) tmp_ptr, arg) < 0) -- tmp_ptr = run_ptr; -- -- if (tmp_ptr != base_ptr) -- SWAP (tmp_ptr, base_ptr, size); -- -- /* Insertion sort, running from left-hand-side up to right-hand-side. */ -- -- run_ptr = base_ptr + size; -- while ((run_ptr += size) <= end_ptr) -- { -- tmp_ptr = run_ptr - size; -- while ((*cmp) ((void *) run_ptr, (void *) tmp_ptr, arg) < 0) -- tmp_ptr -= size; -- -- tmp_ptr += size; -- if (tmp_ptr != run_ptr) -- { -- char *trav; -- -- trav = run_ptr + size; -- while (--trav >= run_ptr) -- { -- char c = *trav; -- char *hi, *lo; -- -- for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) -- *hi = *lo; -- *hi = c; -- } -- } -- } -- } --} -- diff --git a/0277-blscfg-add-more-options-to-blscfg-command-to-make-it.patch b/0277-blscfg-add-more-options-to-blscfg-command-to-make-it.patch deleted file mode 100644 index 91947ec..0000000 --- a/0277-blscfg-add-more-options-to-blscfg-command-to-make-it.patch +++ /dev/null @@ -1,532 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 23 Jan 2019 16:33:32 +0100 -Subject: [PATCH] blscfg: add more options to blscfg command to make it more - flexible - -Currently the blscfg command is not flexible, it just loads all the BLS -entries from a predefined path and populate the menu entries at the same -time. But a user might want more control over what BLS snippets are used -to populate the entries and in which order. - -So lets make the BLS support more flexible by allowing to blscfg command -to populate only the default entry, the non-default entries or choose a -custom path to a BLS snippet or a BLS directory to load the entries from. - -The blscfg command now supports the following arguments: - -blscfg default -blscfg non-default -blscfg (hd0,gpt2)/boot/loader/entries/ -blscfg (hd0,gpt2)/boot/loader/entries/custom_entry.conf - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 241 +++++++++++++++++++++++++++++++---------- - grub-core/commands/legacycfg.c | 5 +- - grub-core/commands/menuentry.c | 8 +- - grub-core/normal/main.c | 6 + - include/grub/menu.h | 13 +++ - include/grub/normal.h | 2 +- - 6 files changed, 213 insertions(+), 62 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 304d73908ae..aa5bf0d3220 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -52,16 +52,6 @@ struct keyval - char *val; - }; - --struct bls_entry --{ -- struct bls_entry *next; -- struct bls_entry **prev; -- struct keyval **keyvals; -- int nkeyvals; -- char *filename; -- bool visible; --}; -- - static struct bls_entry *entries = NULL; - - #define FOR_BLS_ENTRIES(var) FOR_LIST_ELEMENTS (var, entries) -@@ -410,6 +400,7 @@ static int bls_add_entry(struct bls_entry *entry) - struct read_entry_info { - const char *devid; - const char *dirname; -+ grub_file_t file; - }; - - static int read_entry ( -@@ -417,9 +408,9 @@ static int read_entry ( - const struct grub_dirhook_info *dirhook_info UNUSED, - void *data) - { -+ grub_size_t m = 0, n, clip = 0; - int rc = 0; -- grub_size_t n; -- char *p; -+ char *p = NULL; - grub_file_t f = NULL; - grub_off_t sz; - struct bls_entry *entry; -@@ -427,21 +418,29 @@ static int read_entry ( - - grub_dprintf ("blscfg", "filename: \"%s\"\n", filename); - -- if (filename[0] == '.') -- return 0; -- - n = grub_strlen (filename); -- if (n <= 5) -- return 0; - -- if (grub_strcmp (filename + n - 5, ".conf") != 0) -- return 0; -+ if (info->file) -+ { -+ f = info->file; -+ } -+ else -+ { -+ if (filename[0] == '.') -+ return 0; - -- p = grub_xasprintf ("(%s)%s/%s", info->devid, info->dirname, filename); -+ if (n <= 5) -+ return 0; - -- f = grub_file_open (p); -- if (!f) -- goto finish; -+ if (grub_strcmp (filename + n - 5, ".conf") != 0) -+ return 0; -+ -+ p = grub_xasprintf ("(%s)%s/%s", info->devid, info->dirname, filename); -+ -+ f = grub_file_open (p); -+ if (!f) -+ goto finish; -+ } - - sz = grub_file_size (f); - if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024) -@@ -451,7 +450,30 @@ static int read_entry ( - if (!entry) - goto finish; - -- entry->filename = grub_strndup(filename, n - 5); -+ if (info->file) -+ { -+ char *slash; -+ -+ if (n > 5 && !grub_strcmp (filename + n - 5, ".conf") == 0) -+ clip = 5; -+ -+ slash = grub_strrchr (filename, '/'); -+ if (!slash) -+ slash = grub_strrchr (filename, '\\'); -+ -+ while (*slash == '/' || *slash == '\\') -+ slash++; -+ -+ m = slash ? slash - filename : 0; -+ } -+ else -+ { -+ m = 0; -+ clip = 5; -+ } -+ n -= m; -+ -+ entry->filename = grub_strndup(filename + m, n - clip); - if (!entry->filename) - goto finish; - -@@ -498,7 +520,8 @@ static int read_entry ( - bls_add_entry(entry); - - finish: -- grub_free (p); -+ if (p) -+ grub_free (p); - - if (f) - grub_file_close (f); -@@ -731,7 +754,7 @@ static void create_entry (struct bls_entry *entry) - GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", - initrd ? initrd : ""); - -- grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0, &index); -+ grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0, &index, entry); - grub_dprintf ("blscfg", "Added entry %d id:\"%s\"\n", index, id); - - finish: -@@ -745,10 +768,10 @@ finish: - } - - struct find_entry_info { -+ const char *dirname; - const char *devid; - grub_device_t dev; - grub_fs_t fs; -- int platform; - }; - - /* -@@ -757,20 +780,22 @@ struct find_entry_info { - static int find_entry (struct find_entry_info *info) - { - struct read_entry_info read_entry_info; -- struct bls_entry *entry = NULL; - grub_fs_t blsdir_fs = NULL; - grub_device_t blsdir_dev = NULL; -- const char *blsdir = NULL; -+ const char *blsdir = info->dirname; - int fallback = 0; - int r = 0; - -- blsdir = grub_env_get ("blsdir"); -- if (!blsdir) -- blsdir = GRUB_BLS_CONFIG_PATH; -+ if (!blsdir) { -+ blsdir = grub_env_get ("blsdir"); -+ if (!blsdir) -+ blsdir = GRUB_BLS_CONFIG_PATH; -+ } - -+ read_entry_info.file = NULL; - read_entry_info.dirname = blsdir; - -- grub_dprintf ("blscfg", "scanning blsdir: %s\n", GRUB_BLS_CONFIG_PATH); -+ grub_dprintf ("blscfg", "scanning blsdir: %s\n", blsdir); - - blsdir_dev = info->dev; - blsdir_fs = info->fs; -@@ -788,7 +813,7 @@ read_fallback: - } while (e); - } - -- if (!entries && !fallback) { -+ if (r && !info->dirname && !fallback) { - read_entry_info.dirname = "/boot" GRUB_BLS_CONFIG_PATH; - grub_dprintf ("blscfg", "Entries weren't found in %s, fallback to %s\n", - blsdir, read_entry_info.dirname); -@@ -796,45 +821,62 @@ read_fallback: - goto read_fallback; - } - -- grub_dprintf ("blscfg", "%s Creating entries from bls\n", __func__); -- FOR_BLS_ENTRIES(entry) { -- if (entry->visible) -- continue; -- -- create_entry(entry); -- entry->visible = true; -- } - return 0; - } - - static grub_err_t --grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, -- int argc UNUSED, -- char **args UNUSED) -+bls_load_entries (const char *path) - { -+ grub_size_t len; - grub_fs_t fs; - grub_device_t dev; - static grub_err_t r; -- const char *devid; -- struct find_entry_info info = -- { -+ const char *devid = NULL; -+ char *blsdir = NULL; -+ struct find_entry_info info = { - .dev = NULL, - .fs = NULL, -- }; -+ .dirname = NULL, -+ }; -+ struct read_entry_info rei = { -+ .devid = NULL, -+ .dirname = NULL, -+ }; - -+ if (path) { -+ len = grub_strlen (path); -+ if (grub_strcmp (path + len - 5, ".conf") == 0) { -+ rei.file = grub_file_open (path); -+ if (!rei.file) -+ return grub_errno; -+ /* -+ * read_entry() closes the file -+ */ -+ return read_entry(path, NULL, &rei); -+ } else if (path[0] == '(') { -+ devid = path + 1; - -- grub_dprintf ("blscfg", "finding boot\n"); -+ blsdir = grub_strchr (path, ')'); -+ if (!blsdir) -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Filepath isn't correct")); - -+ *blsdir = '\0'; -+ blsdir = blsdir + 1; -+ } -+ } -+ -+ if (!devid) { - #ifdef GRUB_MACHINE_EMU -- devid = "host"; -+ devid = "host"; - #elif defined(GRUB_MACHINE_EFI) -- devid = grub_env_get ("root"); -+ devid = grub_env_get ("root"); - #else -- devid = grub_env_get ("boot"); -+ devid = grub_env_get ("boot"); - #endif -- if (!devid) -- return grub_error (GRUB_ERR_FILE_NOT_FOUND, -- N_("variable `%s' isn't set"), "boot"); -+ if (!devid) -+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, -+ N_("variable `%s' isn't set"), "boot"); -+ } - - grub_dprintf ("blscfg", "opening %s\n", devid); - dev = grub_device_open (devid); -@@ -849,6 +891,7 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - goto finish; - } - -+ info.dirname = blsdir; - info.devid = devid; - info.dev = dev; - info.fs = fs; -@@ -861,6 +904,92 @@ finish: - return r; - } - -+static bool -+is_default_entry(const char *def_entry, struct bls_entry *entry, int idx) -+{ -+ const char *title; -+ int def_idx; -+ -+ if (!def_entry) -+ return false; -+ -+ if (grub_strcmp(def_entry, entry->filename) == 0) -+ return true; -+ -+ title = bls_get_val(entry, "title", NULL); -+ -+ if (title && grub_strcmp(def_entry, title) == 0) -+ return true; -+ -+ def_idx = (int)grub_strtol(def_entry, NULL, 0); -+ if (grub_errno == GRUB_ERR_BAD_NUMBER) -+ return false; -+ -+ if (def_idx == idx) -+ return true; -+ -+ return false; -+} -+ -+static grub_err_t -+bls_create_entries (bool show_default, bool show_non_default, char *entry_id) -+{ -+ const char *def_entry = NULL; -+ struct bls_entry *entry = NULL; -+ int idx = 0; -+ -+ def_entry = grub_env_get("default"); -+ -+ grub_dprintf ("blscfg", "%s Creating entries from bls\n", __func__); -+ FOR_BLS_ENTRIES(entry) { -+ if (entry->visible) { -+ idx++; -+ continue; -+ } -+ -+ if ((show_default && is_default_entry(def_entry, entry, idx)) || -+ (show_non_default && !is_default_entry(def_entry, entry, idx)) || -+ (entry_id && grub_strcmp(entry_id, entry->filename) == 0)) { -+ create_entry(entry); -+ entry->visible = 1; -+ } -+ idx++; -+ } -+ -+ return GRUB_ERR_NONE; -+} -+ -+static grub_err_t -+grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, -+ int argc, char **args) -+{ -+ grub_err_t r; -+ char *path = NULL; -+ char *entry_id = NULL; -+ bool show_default = true; -+ bool show_non_default = true; -+ -+ if (argc == 1) { -+ if (grub_strcmp (args[0], "default") == 0) { -+ show_non_default = false; -+ } else if (grub_strcmp (args[0], "non-default") == 0) { -+ show_default = false; -+ } else if (args[0][0] == '(') { -+ path = args[0]; -+ } else { -+ entry_id = args[0]; -+ show_default = false; -+ show_non_default = false; -+ } -+ } -+ -+ r = bls_load_entries(path); -+ if (r) -+ return r; -+ -+ return bls_create_entries(show_default, show_non_default, entry_id); -+} -+ - static grub_extcmd_t cmd; - static grub_extcmd_t oldcmd; - -diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c -index f9d7627bdc3..ef8dd74c589 100644 ---- a/grub-core/commands/legacycfg.c -+++ b/grub-core/commands/legacycfg.c -@@ -133,7 +133,7 @@ legacy_file (const char *filename) - args[0] = oldname; - grub_normal_add_menu_entry (1, args, NULL, NULL, "legacy", - NULL, NULL, -- entrysrc, 0, NULL); -+ entrysrc, 0, NULL, NULL); - grub_free (args); - entrysrc[0] = 0; - grub_free (oldname); -@@ -186,7 +186,8 @@ legacy_file (const char *filename) - } - args[0] = entryname; - grub_normal_add_menu_entry (1, args, NULL, NULL, NULL, -- NULL, NULL, entrysrc, 0, NULL); -+ NULL, NULL, entrysrc, 0, NULL, -+ NULL); - grub_free (args); - } - -diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c -index 7004e08ce78..29736f5cd03 100644 ---- a/grub-core/commands/menuentry.c -+++ b/grub-core/commands/menuentry.c -@@ -78,7 +78,7 @@ grub_normal_add_menu_entry (int argc, const char **args, - char **classes, const char *id, - const char *users, const char *hotkey, - const char *prefix, const char *sourcecode, -- int submenu, int *index) -+ int submenu, int *index, struct bls_entry *bls) - { - int menu_hotkey = 0; - char **menu_args = NULL; -@@ -195,6 +195,7 @@ grub_normal_add_menu_entry (int argc, const char **args, - (*last)->args = menu_args; - (*last)->sourcecode = menu_sourcecode; - (*last)->submenu = submenu; -+ (*last)->bls = bls; - - menu->size++; - if (index) -@@ -296,7 +297,7 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args) - ctxt->state[2].arg, 0, - ctxt->state[3].arg, - ctxt->extcmd->cmd->name[0] == 's', -- NULL); -+ NULL, NULL); - - src = args[argc - 1]; - args[argc - 1] = NULL; -@@ -313,7 +314,8 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args) - ctxt->state[0].args, ctxt->state[4].arg, - users, - ctxt->state[2].arg, prefix, src + 1, -- ctxt->extcmd->cmd->name[0] == 's', NULL); -+ ctxt->extcmd->cmd->name[0] == 's', NULL, -+ NULL); - - src[len - 1] = ch; - args[argc - 1] = src; -diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 04ae9ed02f6..4117317c4c4 100644 ---- a/grub-core/normal/main.c -+++ b/grub-core/normal/main.c -@@ -20,6 +20,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -70,6 +71,11 @@ grub_normal_free_menu (grub_menu_t menu) - grub_free (entry->args); - } - -+ if (entry->bls) -+ { -+ entry->bls->visible = 0; -+ } -+ - grub_free ((void *) entry->id); - grub_free ((void *) entry->users); - grub_free ((void *) entry->title); -diff --git a/include/grub/menu.h b/include/grub/menu.h -index ee2b5e91045..eea493f74b1 100644 ---- a/include/grub/menu.h -+++ b/include/grub/menu.h -@@ -20,6 +20,16 @@ - #ifndef GRUB_MENU_HEADER - #define GRUB_MENU_HEADER 1 - -+struct bls_entry -+{ -+ struct bls_entry *next; -+ struct bls_entry **prev; -+ struct keyval **keyvals; -+ int nkeyvals; -+ char *filename; -+ int visible; -+}; -+ - struct grub_menu_entry_class - { - char *name; -@@ -60,6 +70,9 @@ struct grub_menu_entry - - /* The next element. */ - struct grub_menu_entry *next; -+ -+ /* BLS used to populate the entry */ -+ struct bls_entry *bls; - }; - typedef struct grub_menu_entry *grub_menu_entry_t; - -diff --git a/include/grub/normal.h b/include/grub/normal.h -index cb9901f41b3..8839ad85a19 100644 ---- a/include/grub/normal.h -+++ b/include/grub/normal.h -@@ -145,7 +145,7 @@ grub_normal_add_menu_entry (int argc, const char **args, char **classes, - const char *id, - const char *users, const char *hotkey, - const char *prefix, const char *sourcecode, -- int submenu, int *index); -+ int submenu, int *index, struct bls_entry *bls); - - grub_err_t - grub_normal_set_password (const char *user, const char *password); diff --git a/0278-blscfg-add-support-for-prepend-early-initrds-to-the-.patch b/0278-blscfg-add-support-for-prepend-early-initrds-to-the-.patch deleted file mode 100644 index 6d40390..0000000 --- a/0278-blscfg-add-support-for-prepend-early-initrds-to-the-.patch +++ /dev/null @@ -1,173 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 30 Jan 2019 15:08:22 +0100 -Subject: [PATCH] blscfg: add support for prepend early initrds to the BLS - entries - -There are cases where is needed one or more initramfs besides the one that -is defined in the BLS entry. For example, a user may want to add an early -initramfs to override some ACPI tables, load CPU microcode, firmware, etc. - -Add support to preprend initrds if they are defined as an early_initrd var -in grubenv. Also honor GRUB_EARLY_INITRD_LINUX_CUSTOM in /etc/default/grub -and use that value to set the early_initrd var when running grub2-mkconfig. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 79 +++++++++++++++++++++++++++++++++++++++++++-- - util/grub.d/10_linux.in | 3 ++ - util/grub.d/10_linux_bls.in | 3 ++ - 3 files changed, 83 insertions(+), 2 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index aa5bf0d3220..1ef2ae06cff 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -660,6 +660,33 @@ static char *expand_val(char *value) - return buffer; - } - -+static char **early_initrd_list (const char *initrd) -+{ -+ int nlist = 0; -+ char **list = NULL; -+ char *separator; -+ -+ while ((separator = grub_strchr (initrd, ' '))) -+ { -+ list = grub_realloc (list, (nlist + 2) * sizeof (char *)); -+ if (!list) -+ return NULL; -+ -+ list[nlist++] = grub_strndup(initrd, separator - initrd); -+ list[nlist] = NULL; -+ initrd = separator + 1; -+ } -+ -+ list = grub_realloc (list, (nlist + 2) * sizeof (char *)); -+ if (!list) -+ return NULL; -+ -+ list[nlist++] = grub_strndup(initrd, grub_strlen(initrd)); -+ list[nlist] = NULL; -+ -+ return list; -+} -+ - static void create_entry (struct bls_entry *entry) - { - int argc = 0; -@@ -670,6 +697,9 @@ static void create_entry (struct bls_entry *entry) - char *options = NULL; - char **initrds = NULL; - char *initrd = NULL; -+ const char *early_initrd = NULL; -+ char **early_initrds = NULL; -+ char *initrd_prefix = NULL; - char *id = entry->filename; - char *dotconf = id; - char *hotkey = NULL; -@@ -716,13 +746,47 @@ static void create_entry (struct bls_entry *entry) - argv[i] = args[i-1]; - argv[argc] = NULL; - -+ early_initrd = grub_env_get("early_initrd"); -+ - grub_dprintf ("blscfg", "adding menu entry for \"%s\" with id \"%s\"\n", - title, id); -- if (initrds) -+ if (early_initrd) -+ { -+ early_initrds = early_initrd_list(early_initrd); -+ if (!early_initrds) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -+ goto finish; -+ } -+ -+ if (initrds != NULL && initrds[0] != NULL) -+ { -+ initrd_prefix = grub_strrchr (initrds[0], '/'); -+ initrd_prefix = grub_strndup(initrds[0], initrd_prefix - initrds[0] + 1); -+ } -+ else -+ { -+ initrd_prefix = grub_strrchr (clinux, '/'); -+ initrd_prefix = grub_strndup(clinux, initrd_prefix - clinux + 1); -+ } -+ -+ if (!initrd_prefix) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -+ goto finish; -+ } -+ } -+ -+ if (early_initrds || initrds) - { - int initrd_size = sizeof ("initrd"); - char *tmp; - -+ for (i = 0; early_initrds != NULL && early_initrds[i] != NULL; i++) -+ initrd_size += sizeof (" " GRUB_BOOT_DEVICE) \ -+ + grub_strlen(initrd_prefix) \ -+ + grub_strlen (early_initrds[i]) + 1; -+ - for (i = 0; initrds != NULL && initrds[i] != NULL; i++) - initrd_size += sizeof (" " GRUB_BOOT_DEVICE) \ - + grub_strlen (initrds[i]) + 1; -@@ -736,7 +800,16 @@ static void create_entry (struct bls_entry *entry) - } - - -- tmp = grub_stpcpy(initrd, "initrd "); -+ tmp = grub_stpcpy(initrd, "initrd"); -+ for (i = 0; early_initrds != NULL && early_initrds[i] != NULL; i++) -+ { -+ grub_dprintf ("blscfg", "adding early initrd %s\n", early_initrds[i]); -+ tmp = grub_stpcpy (tmp, " " GRUB_BOOT_DEVICE); -+ tmp = grub_stpcpy (tmp, initrd_prefix); -+ tmp = grub_stpcpy (tmp, early_initrds[i]); -+ grub_free(early_initrds[i]); -+ } -+ - for (i = 0; initrds != NULL && initrds[i] != NULL; i++) - { - grub_dprintf ("blscfg", "adding initrd %s\n", initrds[i]); -@@ -759,6 +832,8 @@ static void create_entry (struct bls_entry *entry) - - finish: - grub_free (initrd); -+ grub_free (initrd_prefix); -+ grub_free (early_initrds); - grub_free (initrds); - grub_free (options); - grub_free (classes); -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index da2992ac9f1..9c240f92625 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -167,6 +167,9 @@ EOF - - if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then - ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" -+ if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then -+ ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" -+ fi - fi - - exit 0 -diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in -index 175bedd0763..b14951daf82 100644 ---- a/util/grub.d/10_linux_bls.in -+++ b/util/grub.d/10_linux_bls.in -@@ -227,6 +227,9 @@ linux_entry () - - if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then - ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" -+ if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then -+ ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" -+ fi - fi - - exit 0 diff --git a/0282-Set-blsdir-if-the-BLS-directory-path-isn-t-one-of-th.patch b/0282-Set-blsdir-if-the-BLS-directory-path-isn-t-one-of-th.patch deleted file mode 100644 index 4082a1c..0000000 --- a/0282-Set-blsdir-if-the-BLS-directory-path-isn-t-one-of-th.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 12 Feb 2019 00:57:34 +0100 -Subject: [PATCH] Set blsdir if the BLS directory path isn't one of the looked - up by default - -The blscfg command searches for BLS snippets in the /loader/entries and the -/boot/loader/entries directories. If the /boot/loader/entries dir real path -isn't one of these (i.e: if is in a btrfs subvolme), set the blsdir grubenv -variable so the blscfg command will be able to find the BLS config snippets. - -Resolves: rhbz#1657240 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 5 +++++ - util/grub.d/10_linux_bls.in | 5 +++++ - 2 files changed, 10 insertions(+) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 9c240f92625..7e80245a151 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -166,6 +166,11 @@ fi - EOF - - if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then -+ blsdir=$(make_system_path_relative_to_its_root "/boot/loader/entries") -+ if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then -+ ${grub_editenv} - set blsdir="${blsdir}" -+ fi -+ - ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" - if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then - ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" -diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in -index b14951daf82..f0ad9a3da25 100644 ---- a/util/grub.d/10_linux_bls.in -+++ b/util/grub.d/10_linux_bls.in -@@ -226,6 +226,11 @@ linux_entry () - populate_menu - - if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then -+ blsdir=$(make_system_path_relative_to_its_root "/boot/loader/entries") -+ if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then -+ ${grub_editenv} - set blsdir="${blsdir}" -+ fi -+ - ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" - if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then - ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" diff --git a/0283-Check-if-blsdir-exists-before-attempting-to-get-it-s.patch b/0283-Check-if-blsdir-exists-before-attempting-to-get-it-s.patch deleted file mode 100644 index 6ab14e8..0000000 --- a/0283-Check-if-blsdir-exists-before-attempting-to-get-it-s.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 15 Feb 2019 18:15:45 +0100 -Subject: [PATCH] Check if blsdir exists before attempting to get it's real - path - -It's wrong to assume that the directory would always exist, grub2-mkconfig -shouldn't fail if that's not the case. - -Resolves: rhbz#1677415 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 9 ++++++--- - util/grub.d/10_linux_bls.in | 9 ++++++--- - 2 files changed, 12 insertions(+), 6 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 7e80245a151..22a85c69ea0 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -166,9 +166,12 @@ fi - EOF - - if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then -- blsdir=$(make_system_path_relative_to_its_root "/boot/loader/entries") -- if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then -- ${grub_editenv} - set blsdir="${blsdir}" -+ blsdir="/boot/loader/entries" -+ if [ -d "${blsdir}" ]; then -+ blsdir=$(make_system_path_relative_to_its_root "${blsdir}") -+ if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then -+ ${grub_editenv} - set blsdir="${blsdir}" -+ fi - fi - - ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" -diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in -index f0ad9a3da25..47b87c8a14b 100644 ---- a/util/grub.d/10_linux_bls.in -+++ b/util/grub.d/10_linux_bls.in -@@ -226,9 +226,12 @@ linux_entry () - populate_menu - - if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then -- blsdir=$(make_system_path_relative_to_its_root "/boot/loader/entries") -- if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then -- ${grub_editenv} - set blsdir="${blsdir}" -+ blsdir="/boot/loader/entries" -+ if [ -d "${blsdir}" ]; then -+ blsdir=$(make_system_path_relative_to_its_root "${blsdir}") -+ if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then -+ ${grub_editenv} - set blsdir="${blsdir}" -+ fi - fi - - ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" diff --git a/0284-blscfg-fallback-to-default_kernelopts-if-BLS-option-.patch b/0284-blscfg-fallback-to-default_kernelopts-if-BLS-option-.patch deleted file mode 100644 index d4b3889..0000000 --- a/0284-blscfg-fallback-to-default_kernelopts-if-BLS-option-.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 26 Feb 2019 20:11:27 +0100 -Subject: [PATCH] blscfg: fallback to default_kernelopts if BLS option field - isn't set - -If the $kernelopts variable isn't found, then the entry will fail to boot -since there won't be a kernel command line params set. This makes the BLS -configuration more fragile than a non-BLS one, since in that case it will -boot even without a correct grubenv file. - -So set a $default_kernelopts in the GRUB config file that will be used as -a fallback if the value in the BLS options field can't be resolved. - -Related: rhbz#1625124 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 7 +++++++ - util/grub.d/10_linux.in | 2 ++ - 2 files changed, 9 insertions(+) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 1ef2ae06cff..5635066e3eb 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -629,6 +629,9 @@ static char *expand_val(char *value) - char *end = value; - bool is_var = false; - -+ if (!value) -+ return NULL; -+ - while (*value) { - if (*value == '$') { - if (start != end) { -@@ -732,6 +735,10 @@ static void create_entry (struct bls_entry *entry) - - title = bls_get_val (entry, "title", NULL); - options = expand_val (bls_get_val (entry, "options", NULL)); -+ -+ if (!options) -+ options = expand_val (grub_env_get("default_kernelopts")); -+ - initrds = bls_make_list (entry, "initrd", NULL); - - hotkey = bls_get_val (entry, "grub_hotkey", NULL); -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 22a85c69ea0..2547dd52115 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -158,6 +158,8 @@ linux_entry () - populate_header_warn - - cat << EOF -+set default_kernelopts="root=${linux_root_device_thisversion} ro ${args}" -+ - insmod blscfg - blscfg - if [ -s \$prefix/grubenv ]; then diff --git a/0285-grub-switch-to-blscfg-copy-increment.mod-for-legacy-.patch b/0285-grub-switch-to-blscfg-copy-increment.mod-for-legacy-.patch deleted file mode 100644 index d7ac8ff..0000000 --- a/0285-grub-switch-to-blscfg-copy-increment.mod-for-legacy-.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 26 Feb 2019 21:25:39 +0100 -Subject: [PATCH] grub-switch-to-blscfg: copy increment.mod for legacy BIOS and - ppc64 - -This module is also used in newer GRUB config and weren't present in old -GRUB installations, so it has to be copied before attempting to generate -a BLS configuration. - -Resolves: rhbz#1652806 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 14 ++++++++------ - 1 file changed, 8 insertions(+), 6 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index eeea1307706..49b3985fadb 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -288,13 +288,15 @@ if [ "${GENERATE}" -eq 1 ] ; then - copy_bls - - if [ $arch = "x86_64" ] && [ ! -d /sys/firmware/efi ]; then -- if ! cp ${prefix}/lib/grub//i386-pc/blscfg.mod ${grubdir}/i386-pc/ ; then -- exit 1 -- fi -+ mod_dir="i386-pc" - elif [ $arch = "ppc64" -o $arch = "ppc64le" ] && [ ! -d /sys/firmware/opal ]; then -- if ! cp ${prefix}/lib/grub/powerpc-ieee1275/blscfg.mod ${grubdir}/powerpc-ieee1275/ ; then -- exit 1 -- fi -+ mod_dir="powerpc-ieee1275" -+ fi -+ -+ if [ -n "${mod_dir}" ]; then -+ for mod in blscfg increment; do -+ cp ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1 -+ done - fi - - cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}" diff --git a/0286-Only-set-blsdir-if-boot-loader-entries-is-in-a-btrfs.patch b/0286-Only-set-blsdir-if-boot-loader-entries-is-in-a-btrfs.patch deleted file mode 100644 index 341c143..0000000 --- a/0286-Only-set-blsdir-if-boot-loader-entries-is-in-a-btrfs.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 19 Mar 2019 01:27:57 +0100 -Subject: [PATCH] Only set blsdir if /boot/loader/entries is in a btrfs or zfs - partition - -Commit bfc756f8d86 ("Set blsdir if the BLS directory path isn't one of the -looked up by default") attempted to set blsdir if /boot/loader/entries was -not the real path of the directory containing the BLS snippets. Which may -be the case if for example /boot/loader/entries is in a btrfs subvolume. - -But in the case of ostree, /boot/loader is a symlink to the directory with -the entries for the current deployment. So with ostree the blsdir will be -wrongly set, since GRUB is able to follow the symlinks just fine. In fact, -it has to follow the symlink since otherwise GRUB will always use the BLS -files for the deployment that the symlink pointed out when blsdir was set. - -So only set blsdir if /boot/loader/entries is in a btrfs or zfs partition. - -Related: rhbz#1688453 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 3 ++- - util/grub.d/10_linux_bls.in | 3 ++- - 2 files changed, 4 insertions(+), 2 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 2547dd52115..8f7ecf65df9 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -169,7 +169,8 @@ EOF - - if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then - blsdir="/boot/loader/entries" -- if [ -d "${blsdir}" ]; then -+ [ -d "${blsdir}" ] && GRUB_BLS_FS="$(${grub_probe} --target=fs ${blsdir})" -+ if [ "x${GRUB_BLS_FS}" = "xbtrfs" ] || [ "x${GRUB_BLS_FS}" = "xzfs" ]; then - blsdir=$(make_system_path_relative_to_its_root "${blsdir}") - if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then - ${grub_editenv} - set blsdir="${blsdir}" -diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in -index 47b87c8a14b..1707e86f2d3 100644 ---- a/util/grub.d/10_linux_bls.in -+++ b/util/grub.d/10_linux_bls.in -@@ -227,7 +227,8 @@ linux_entry () - - if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then - blsdir="/boot/loader/entries" -- if [ -d "${blsdir}" ]; then -+ [ -d "${blsdir}" ] && GRUB_BLS_FS="$(${grub_probe} --target=fs ${blsdir})" -+ if [ "x${GRUB_BLS_FS}" = "xbtrfs" ] || [ "x${GRUB_BLS_FS}" = "xzfs" ]; then - blsdir=$(make_system_path_relative_to_its_root "${blsdir}") - if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then - ${grub_editenv} - set blsdir="${blsdir}" diff --git a/0288-blscfg-don-t-use-grub_list_t-and-the-GRUB_AS_LIST-ma.patch b/0288-blscfg-don-t-use-grub_list_t-and-the-GRUB_AS_LIST-ma.patch deleted file mode 100644 index a05da65..0000000 --- a/0288-blscfg-don-t-use-grub_list_t-and-the-GRUB_AS_LIST-ma.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 22 Mar 2019 11:14:26 +0100 -Subject: [PATCH] blscfg: don't use grub_list_t and the GRUB_AS_LIST() macro - -We are not using GRUB's list functions anyways since we want to add new -items in the middle ot the list but GRUB's grub_list_push() only allows -to add new items at the beginning of the list. So don't use grub_list_t -and GRUB_AS_LIST() macro and just reference struct bls_entry * directly. - -We can't change GRUB lists API because we want the blscfg module to not -need external symbols so it can be updated without updating GRUB's core. - -This also solves a bug where the struct bls_entry .next field wasn't set -correctly which caused some entries to not be populated in the grub menu. - -Resolves: rhbz#1691232 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 10 +++++----- - include/grub/menu.h | 2 +- - 2 files changed, 6 insertions(+), 6 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 5635066e3eb..bb93b7f4904 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -350,13 +350,13 @@ static int bls_cmp(const struct bls_entry *e0, const struct bls_entry *e1) - return r; - } - --static void list_add_tail(grub_list_t head, grub_list_t item) -+static void list_add_tail(struct bls_entry *head, struct bls_entry *item) - { - item->next = head; - if (head->prev) -- (*head->prev)->next = item; -+ head->prev->next = item; - item->prev = head->prev; -- head->prev = &item; -+ head->prev = item; - } - - static int bls_add_entry(struct bls_entry *entry) -@@ -378,7 +378,7 @@ static int bls_add_entry(struct bls_entry *entry) - - if (rc == 1) { - grub_dprintf ("blscfg", "Add entry with id \"%s\"\n", entry->filename); -- list_add_tail (GRUB_AS_LIST (e), GRUB_AS_LIST (entry)); -+ list_add_tail (e, entry); - if (e == entries) { - entries = entry; - entry->prev = NULL; -@@ -391,7 +391,7 @@ static int bls_add_entry(struct bls_entry *entry) - if (last) { - grub_dprintf ("blscfg", "Add entry with id \"%s\"\n", entry->filename); - last->next = entry; -- entry->prev = &last; -+ entry->prev = last; - } - - return 0; -diff --git a/include/grub/menu.h b/include/grub/menu.h -index eea493f74b1..0acdc2aa6bf 100644 ---- a/include/grub/menu.h -+++ b/include/grub/menu.h -@@ -23,7 +23,7 @@ - struct bls_entry - { - struct bls_entry *next; -- struct bls_entry **prev; -+ struct bls_entry *prev; - struct keyval **keyvals; - int nkeyvals; - char *filename; diff --git a/0292-10_linux_bls-don-t-add-users-option-to-generated-men.patch b/0292-10_linux_bls-don-t-add-users-option-to-generated-men.patch deleted file mode 100644 index 86955ac..0000000 --- a/0292-10_linux_bls-don-t-add-users-option-to-generated-men.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 28 Mar 2019 16:34:42 +0100 -Subject: [PATCH] 10_linux_bls: don't add --users option to generated menu - entries - -The generated menu entries have a --users $grub_users option but this will -fail on old versions of GRUB, since it expects the --users option argument -to either be a constant or a variable that has been set. - -The latest GRUB version fix this but the GRUB core isn't updated on a GRUB -package update, so this will cause the entries to not be shown in the menu -after a system upgrade. - -Since can cause issues and because the entries that weren't generated from -the BLS snippets didn't have the --users option either, just don't add it. - -Resolves: rhbz#1693515 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux_bls.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in -index 1707e86f2d3..b8ee9916329 100644 ---- a/util/grub.d/10_linux_bls.in -+++ b/util/grub.d/10_linux_bls.in -@@ -180,7 +180,7 @@ populate_menu() - for bls in "${files[@]}" ; do - read_config "${blsdir}/${bls}.conf" - -- menu="${menu}menuentry '${title}' --class ${grub_class} ${grub_arg} --users ${grub_users} --id ${bls} {\n" -+ menu="${menu}menuentry '${title}' --class ${grub_class} ${grub_arg} --id ${bls} {\n" - menu="${menu}\t linux ${linux} ${options}\n" - if [ -n "${initrd}" ] ; then - menu="${menu}\t initrd ${boot_prefix}${initrd}\n" diff --git a/0294-HTTP-boot-strncmp-returns-0-on-equal.patch b/0294-HTTP-boot-strncmp-returns-0-on-equal.patch deleted file mode 100644 index 09cbcb3..0000000 --- a/0294-HTTP-boot-strncmp-returns-0-on-equal.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Stephen Benjamin -Date: Fri, 12 Apr 2019 10:43:13 -0400 -Subject: [PATCH] HTTP boot: strncmp returns 0 on equal - ---- - grub-core/net/efi/http.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c -index 2a9624dacc4..484e0c68cee 100644 ---- a/grub-core/net/efi/http.c -+++ b/grub-core/net/efi/http.c -@@ -19,7 +19,7 @@ http_configure (struct grub_efi_net_device *dev, int prefer_ip6) - const char *rest, *http_server, *http_path = NULL; - - http_server = grub_env_get ("root"); -- https = grub_strncmp (http_server, "https", 5) ? 1 : 0; -+ https = (grub_strncmp (http_server, "https", 5) == 0) ? 1 : 0; - - /* extract http server + port */ - if (http_server) diff --git a/0298-Add-10_reset_boot_success-to-Makefile.patch b/0298-Add-10_reset_boot_success-to-Makefile.patch deleted file mode 100644 index 541b5f1..0000000 --- a/0298-Add-10_reset_boot_success-to-Makefile.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 18 Apr 2019 19:16:18 +0200 -Subject: [PATCH] Add 10_reset_boot_success to Makefile - -This was missing in a previous commit that added this script. - -Signed-off-by: Javier Martinez Canillas ---- - Makefile.util.def | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/Makefile.util.def b/Makefile.util.def -index cae6002d2e3..5062a0e50fa 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -515,6 +515,12 @@ script = { - condition = COND_HOST_LINUX; - }; - -+script = { -+ name = '10_reset_boot_success'; -+ common = util/grub.d/10_reset_boot_success.in; -+ installdir = grubconf; -+}; -+ - script = { - name = '10_xnu'; - common = util/grub.d/10_xnu.in; diff --git a/0300-blscfg-remove-BLS-file-size-check.patch b/0300-blscfg-remove-BLS-file-size-check.patch deleted file mode 100644 index edd6e9e..0000000 --- a/0300-blscfg-remove-BLS-file-size-check.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 7 May 2019 13:54:23 +0200 -Subject: [PATCH] blscfg: remove BLS file size check - -The read_entry() function checks the BLS file size and ignores the entry -if the file size isn't correct. The problem is that it will only work if -the struct grub_file layout and fields are the same in the GRUB version -used to build the blscfg.mod, than the one that's installed as GRUB core. - -But commit 84a0e9699f8 ("Add progress module to display load progress of -files.") added a .name field to struct grub_file, and this change landed -in the GRUB version used by Fedora 21. - -Since the GRUB core is never updated when the grub2 package is upgraded, -the blscfg module won't be compatible with any GRUB that was installed by -Fedora 20 or eralier. - -The blscfg.mod is copied to /boot/grub2/i386-pc/ in legacy BIOS installs -when the GRUB configuration is switched to BLS, so this will lead to BLS -files being ignored due grub_file_size() reporting wrong file sizes. This -is caused by the struct grub_file .size field offset being different in -Fedora 20 than later releases. - -This check is doing more harm than good, so let's just remove it to make -the blscfg module compatible at least up to GRUB core that was installed -by Fedora 19. - -Related: rhbz#1652806 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 5 ----- - 1 file changed, 5 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index bb93b7f4904..bd008b04bec 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -412,7 +412,6 @@ static int read_entry ( - int rc = 0; - char *p = NULL; - grub_file_t f = NULL; -- grub_off_t sz; - struct bls_entry *entry; - struct read_entry_info *info = (struct read_entry_info *)data; - -@@ -442,10 +441,6 @@ static int read_entry ( - goto finish; - } - -- sz = grub_file_size (f); -- if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024) -- goto finish; -- - entry = grub_zalloc (sizeof (*entry)); - if (!entry) - goto finish; diff --git a/0301-Remove-bogus-load_env-after-blscfg-command-in-10_lin.patch b/0301-Remove-bogus-load_env-after-blscfg-command-in-10_lin.patch deleted file mode 100644 index b5ad399..0000000 --- a/0301-Remove-bogus-load_env-after-blscfg-command-in-10_lin.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 14 May 2019 20:37:44 +0200 -Subject: [PATCH] Remove bogus load_env after blscfg command in 10_linux - -The grubenv is already loaded in the 00_header snippet, so there's -no need to load it anywhere else. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 8f7ecf65df9..350903fa5ab 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -162,9 +162,6 @@ set default_kernelopts="root=${linux_root_device_thisversion} ro ${args}" - - insmod blscfg - blscfg --if [ -s \$prefix/grubenv ]; then -- load_env --fi - EOF - - if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then diff --git a/0302-blscfg-Don-t-leave-grub_errno-set-to-an-error-if-the.patch b/0302-blscfg-Don-t-leave-grub_errno-set-to-an-error-if-the.patch deleted file mode 100644 index e02ca07..0000000 --- a/0302-blscfg-Don-t-leave-grub_errno-set-to-an-error-if-the.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 15 May 2019 01:46:00 +0200 -Subject: [PATCH] blscfg: Don't leave grub_errno set to an error if the command - succeeded - -After a command is executed, the function grub_print_error() is called to -print any active error messages if these exist. - -The blscfg command calls to the grub_strtol() function to try to convert -the default entry string to a number, in case the default is an index. - -If this function is not able to do the conversion, it sets the grub_errno -variable to GRUB_ERR_BAD_NUMBER. But the blscfg command wrongly left that -set and so the caller would be confused thinking that the command failed -and that an error message has to be printed. - -This caused the first error in the stack to be printed, polluting the GRUB -output and preventing the menu to be hidden. So reset the grub_error var -to GRUB_ERR_NONE again if was set to GRUB_ERR_BAD_NUMBER by grub_strtol(). - -Resolves: rhbz#1699761 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index bd008b04bec..26dbe873fe4 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -999,8 +999,10 @@ is_default_entry(const char *def_entry, struct bls_entry *entry, int idx) - return true; - - def_idx = (int)grub_strtol(def_entry, NULL, 0); -- if (grub_errno == GRUB_ERR_BAD_NUMBER) -+ if (grub_errno == GRUB_ERR_BAD_NUMBER) { -+ grub_errno = GRUB_ERR_NONE; - return false; -+ } - - if (def_idx == idx) - return true; diff --git a/0303-Fix-bls-directory-option-comment-in-grub2-switch-to-.patch b/0303-Fix-bls-directory-option-comment-in-grub2-switch-to-.patch deleted file mode 100644 index 6c1aa0d..0000000 --- a/0303-Fix-bls-directory-option-comment-in-grub2-switch-to-.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 29 May 2019 10:58:58 +0200 -Subject: [PATCH] Fix --bls-directory option comment in grub2-switch-to-blscfg - man page - -The default directory for BLS fragments is always /boot/loader/entries for -both EFI and non-EFI. Fix the man page accordingly to document this. - -Resolves: rhbz#1714835 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.8 | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub-switch-to-blscfg.8 b/util/grub-switch-to-blscfg.8 -index 7d99de2d2f9..9a886282976 100644 ---- a/util/grub-switch-to-blscfg.8 -+++ b/util/grub-switch-to-blscfg.8 -@@ -23,7 +23,7 @@ The defaults file for grub-mkconfig. The default value is \fI/etc/default/grub\ - - .TP - --bls-directory=\fIDIR\fR --Create BootLoaderSpec fragments in \fIDIR\fR. The default value is \fI/boot/loader/entries\fR on BIOS machines and \fI/boot/efi/EFI/\fBVENDOR\fI/loader/entries\fR on UEFI machines. -+Create BootLoaderSpec fragments in \fIDIR\fR. The default value is \fI/boot/loader/entries\fR. - - .TP - --backup-suffix=\fSUFFIX\fR diff --git a/0304-10_linux_bls-use-to-separate-id-argument-due-a-Petit.patch b/0304-10_linux_bls-use-to-separate-id-argument-due-a-Petit.patch deleted file mode 100644 index b6494b8..0000000 --- a/0304-10_linux_bls-use-to-separate-id-argument-due-a-Petit.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 19 Jun 2019 15:57:17 +0200 -Subject: [PATCH] 10_linux_bls: use '=' to separate --id argument due a - Petitboot bug - -The GRUB menuentry command allows to separate the arguments for options -using either a '=' or a ' '. The latter is the convention used when the -menu entries are defined in the GRUB config file, but this is currently -not supported by Petitboot. - -So as a workaround define the menu entries using '--id=${bls}' instead. - -Resolves: rhbz#1721815 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux_bls.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in -index b8ee9916329..76a5b9d75bc 100644 ---- a/util/grub.d/10_linux_bls.in -+++ b/util/grub.d/10_linux_bls.in -@@ -180,7 +180,7 @@ populate_menu() - for bls in "${files[@]}" ; do - read_config "${blsdir}/${bls}.conf" - -- menu="${menu}menuentry '${title}' --class ${grub_class} ${grub_arg} --id ${bls} {\n" -+ menu="${menu}menuentry '${title}' --class ${grub_class} ${grub_arg} --id=${bls} {\n" - menu="${menu}\t linux ${linux} ${options}\n" - if [ -n "${initrd}" ] ; then - menu="${menu}\t initrd ${boot_prefix}${initrd}\n" diff --git a/0305-grub-set-bootflag-Print-an-error-if-failing-to-read-.patch b/0305-grub-set-bootflag-Print-an-error-if-failing-to-read-.patch deleted file mode 100644 index 5ac0da3..0000000 --- a/0305-grub-set-bootflag-Print-an-error-if-failing-to-read-.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 20 Jun 2019 13:26:31 +0200 -Subject: [PATCH] grub-set-bootflag: Print an error if failing to read from - grubenv - -If the tool fails to read the grubenv file, it prints the following error: - - Error reading from /boot/grub2/grubenv: Success - -This is confusing for users, so instead print a proper error message. - -Resolves: rhbz#1702354 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-set-bootflag.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c -index 20062fe802b..6a79ee67444 100644 ---- a/util/grub-set-bootflag.c -+++ b/util/grub-set-bootflag.c -@@ -27,6 +27,7 @@ - #include - #include - #include /* For GRUB_ENVBLK_DEFCFG define */ -+#include - #include - #include - #include -@@ -87,6 +88,7 @@ int main(int argc, char *argv[]) - fclose (f); - if (ret != GRUBENV_SIZE) - { -+ errno = EINVAL; - perror ("Error reading from " GRUBENV); - return 1; - } diff --git a/0306-10_linux-generate-BLS-section-even-if-no-kernels-are.patch b/0306-10_linux-generate-BLS-section-even-if-no-kernels-are.patch deleted file mode 100644 index dc1a6d5..0000000 --- a/0306-10_linux-generate-BLS-section-even-if-no-kernels-are.patch +++ /dev/null @@ -1,138 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Tom Gundersen -Date: Wed, 26 Jun 2019 17:06:59 +0200 -Subject: [PATCH] 10_linux: generate BLS section even if no kernels are found - in /boot - -The 10_linux script exits if no kernels are found in the /boot directory. -This makes sense for a non-BLS configuration but doesn't when using BLS. - -Add a BLS section regardless if there are kernel images in /boot or not. -That way the grub.cfg can be generated even before a kernel is installed. ---- - util/grub.d/10_linux.in | 98 ++++++++++++++++++++++++------------------------- - 1 file changed, 48 insertions(+), 50 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 350903fa5ab..e6fd6f2a39a 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -96,6 +96,53 @@ cat <$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then -@@ -291,9 +291,7 @@ submenu_indentation="" - is_top_level=true - while [ "x$list" != "x" ] ; do - linux=`version_find_latest $list` -- if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then -- gettext_printf "Found linux image: %s\n" "$linux" >&2 -- fi -+ gettext_printf "Found linux image: %s\n" "$linux" >&2 - - basename=`basename $linux` - dirname=`dirname $linux` diff --git a/0307-10_linux-don-t-search-for-OSTree-kernels.patch b/0307-10_linux-don-t-search-for-OSTree-kernels.patch deleted file mode 100644 index 912119c..0000000 --- a/0307-10_linux-don-t-search-for-OSTree-kernels.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 26 Jun 2019 17:11:14 +0200 -Subject: [PATCH] 10_linux: don't search for OSTree kernels - -The 10_linux script used to exit if kernels weren't found in the /boot dir -so the path where OSTree kernels are installed was added to prevent that. - -But the script should really add a section to call the blscfg command even -if kernels have not been installed, it doesn't make sense to search these. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 6 ------ - 1 file changed, 6 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index e6fd6f2a39a..9fd5a16fa32 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -265,12 +265,6 @@ case "x$machine" in - done ;; - esac - --if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then -- for i in /boot/ostree/*/vmlinuz-* ; do -- if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi -- done --fi -- - case "$machine" in - i?86) GENKERNEL_ARCH="x86" ;; - mips|mips64) GENKERNEL_ARCH="mips" ;; diff --git a/0308-Don-t-duplicate-net-name-string-if-not-needed.patch b/0308-Don-t-duplicate-net-name-string-if-not-needed.patch deleted file mode 100644 index f890e90..0000000 --- a/0308-Don-t-duplicate-net-name-string-if-not-needed.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 25 Apr 2019 17:50:23 +0200 -Subject: [PATCH] Don't duplicate net->name string if not needed - -Related: rhbz#1490991 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/net/efi/http.c | 18 +++++++++--------- - 1 file changed, 9 insertions(+), 9 deletions(-) - -diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c -index 484e0c68cee..de351b2cd03 100644 ---- a/grub-core/net/efi/http.c -+++ b/grub-core/net/efi/http.c -@@ -394,27 +394,27 @@ grub_efihttp_open (struct grub_efi_net_device *dev, - grub_err_t err; - grub_off_t size; - char *buf; -- char *file_name; -+ char *file_name = NULL; - const char *http_path; - - /* If path is relative, prepend http_path */ - http_path = grub_env_get ("http_path"); -- if (http_path && file->device->net->name[0] != '/') -+ if (http_path && file->device->net->name[0] != '/') { - file_name = grub_xasprintf ("%s/%s", http_path, file->device->net->name); -- else -- file_name = grub_strdup (file->device->net->name); -+ if (!file_name) -+ return grub_errno; -+ } - -- if (!file_name) -- return grub_errno; -- -- err = efihttp_request (dev->http, file->device->net->server, file_name, type, 1, 0); -+ err = efihttp_request (dev->http, file->device->net->server, -+ file_name ? file_name : file->device->net->name, type, 1, 0); - if (err != GRUB_ERR_NONE) - { - grub_free (file_name); - return err; - } - -- err = efihttp_request (dev->http, file->device->net->server, file_name, type, 0, &size); -+ err = efihttp_request (dev->http, file->device->net->server, -+ file_name ? file_name : file->device->net->name, type, 0, &size); - grub_free (file_name); - if (err != GRUB_ERR_NONE) - { diff --git a/0313-Preserve-multi-device-workflows.patch b/0313-Preserve-multi-device-workflows.patch deleted file mode 100644 index 1d07b3f..0000000 --- a/0313-Preserve-multi-device-workflows.patch +++ /dev/null @@ -1,133 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Yclept Nemo -Date: Fri, 5 Jul 2019 12:14:51 +0200 -Subject: [PATCH] Preserve multi-device workflows - -The BLS patch [1] isn't POSIX-compliant (local shell variables), and -doesn't support multi-device workflows involving 'grub-probe'. This -breaks BTRFS RAID over multiple discs and possibly LVM, when /boot is on -the multi-device partition. The approach of this patch, using global -variables, is the only possibly approach if you want to maintain a -backwards-compatible 'prepare_grub_to_access_device' but still handle -both optional arguments and variadic arguments. Fixes [2]. - -[1] 0112-Add-BLS-support-to-grub-mkconfig.patch -[2] https://bugzilla.redhat.com/show_bug.cgi?id=1708389 ---- - util/grub-mkconfig_lib.in | 35 ++++++++++++++++++++--------------- - util/grub.d/10_linux.in | 4 ++-- - util/grub.d/10_linux_bls.in | 4 ++-- - 3 files changed, 24 insertions(+), 19 deletions(-) - -diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 1acc1d01c39..bc11df2bd84 100644 ---- a/util/grub-mkconfig_lib.in -+++ b/util/grub-mkconfig_lib.in -@@ -128,18 +128,23 @@ EOF - fi - } - -+prepare_grub_to_access_device_with_variable () -+{ -+ device_variable="$1" -+ shift -+ prepare_grub_to_access_device "$@" -+ unset "device_variable" -+} -+ - prepare_grub_to_access_device () - { -- local device=$1 && shift -- if [ "$#" -gt 0 ]; then -- local variable=$1 && shift -- else -- local variable=root -+ if [ -z "$device_variable" ]; then -+ device_variable="root" - fi - old_ifs="$IFS" - IFS=' - ' -- partmap="`"${grub_probe}" --device ${device} --target=partmap`" -+ partmap="`"${grub_probe}" --device $@ --target=partmap`" - for module in ${partmap} ; do - case "${module}" in - netbsd | openbsd) -@@ -150,34 +155,34 @@ prepare_grub_to_access_device () - done - - # Abstraction modules aren't auto-loaded. -- abstraction="`"${grub_probe}" --device ${device} --target=abstraction`" -+ abstraction="`"${grub_probe}" --device $@ --target=abstraction`" - for module in ${abstraction} ; do - echo "insmod ${module}" - done - -- fs="`"${grub_probe}" --device ${device} --target=fs`" -+ fs="`"${grub_probe}" --device $@ --target=fs`" - for module in ${fs} ; do - echo "insmod ${module}" - done - - if [ x$GRUB_ENABLE_CRYPTODISK = xy ]; then -- for uuid in `"${grub_probe}" --device ${device} --target=cryptodisk_uuid`; do -+ for uuid in `"${grub_probe}" --device $@ --target=cryptodisk_uuid`; do - echo "cryptomount -u $uuid" - done - fi - - # If there's a filesystem UUID that GRUB is capable of identifying, use it; - # otherwise set root as per value in device.map. -- fs_hint="`"${grub_probe}" --device ${device} --target=compatibility_hint`" -+ fs_hint="`"${grub_probe}" --device $@ --target=compatibility_hint`" - if [ "x$fs_hint" != x ]; then -- echo "set ${variable}='$fs_hint'" -+ echo "set ${device_variable}='$fs_hint'" - fi -- if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then -- hints="`"${grub_probe}" --device ${device} --target=hints_string 2> /dev/null`" || hints= -+ if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then -+ hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints= - echo "if [ x\$feature_platform_search_hint = xy ]; then" -- echo " search --no-floppy --fs-uuid --set=${variable} ${hints} ${fs_uuid}" -+ echo " search --no-floppy --fs-uuid --set=${device_variable} ${hints} ${fs_uuid}" - echo "else" -- echo " search --no-floppy --fs-uuid --set=${variable} ${fs_uuid}" -+ echo " search --no-floppy --fs-uuid --set=${device_variable} ${fs_uuid}" - echo "fi" - fi - IFS="$old_ifs" -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 9fd5a16fa32..3919b8aff4e 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -109,10 +109,10 @@ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then - - if [ -d /sys/firmware/efi ]; then - bootefi_device="`${grub_probe} --target=device /boot/efi/`" -- prepare_grub_to_access_device ${bootefi_device} boot -+ prepare_grub_to_access_device_with_variable boot ${bootefi_device} - else - boot_device="`${grub_probe} --target=device /boot/`" -- prepare_grub_to_access_device ${boot_device} boot -+ prepare_grub_to_access_device_with_variable boot ${boot_device} - fi - - populate_header_warn -diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in -index 76a5b9d75bc..1b7536435f1 100644 ---- a/util/grub.d/10_linux_bls.in -+++ b/util/grub.d/10_linux_bls.in -@@ -216,10 +216,10 @@ linux_entry () - - if [ -d /sys/firmware/efi ]; then - bootefi_device="`${grub_probe} --target=device /boot/efi/`" -- prepare_grub_to_access_device ${bootefi_device} boot -+ prepare_grub_to_access_device_with_variable boot ${bootefi_device} - else - boot_device="`${grub_probe} --target=device /boot/`" -- prepare_grub_to_access_device ${boot_device} boot -+ prepare_grub_to_access_device_with_variable boot ${boot_device} - fi - - populate_header_warn diff --git a/0314-Revert-Disable-multiboot-multiboot2-and-linux16-modu.patch b/0314-Revert-Disable-multiboot-multiboot2-and-linux16-modu.patch deleted file mode 100644 index 6653e65..0000000 --- a/0314-Revert-Disable-multiboot-multiboot2-and-linux16-modu.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 11 Jul 2019 13:04:21 +0200 -Subject: [PATCH] Revert "Disable multiboot, multiboot2, and linux16 modules on - EFI builds." - -This reverts commit 155d4e84604 which disabled building the multiboot and -multiboot2 modules on EFI builds. But that made the menu entries created -by the Xen package to stop working since they use the multiboot2 module. - -The mentioned commit disabled building the multiboot{,2} modules because -they can be used to bypass the Secure Boot mechanism. But it's enough to -not include these modules in the grub2 EFI binary that's signed, which -is the case already in the grub2 package. - -Having them as modules if the user installs the grub2-efi-x64-modules is -a valid use case. And since module loading isn't allowed when Secure Boot -is enabled, it doesn't represent any security threat. - -Resolves: rhbz#1703872 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/Makefile.core.def | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 8a00c6177e1..b662312ca6f 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -1696,7 +1696,7 @@ module = { - - common = loader/multiboot.c; - common = loader/multiboot_mbi2.c; -- enable = i386_pc; -+ enable = x86; - enable = mips; - }; - -@@ -1705,7 +1705,7 @@ module = { - common = loader/multiboot.c; - x86 = loader/i386/multiboot_mbi.c; - extra_dist = loader/multiboot_elfxx.c; -- enable = i386_pc; -+ enable = x86; - }; - - module = { diff --git a/grub.patches b/grub.patches index c6a907c..b0680ca 100644 --- a/grub.patches +++ b/grub.patches @@ -17,298 +17,171 @@ Patch0016: 0016-Make-exit-take-a-return-code.patch Patch0017: 0017-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch Patch0018: 0018-Make-efi-machines-load-an-env-block-from-a-variable.patch Patch0019: 0019-DHCP-client-ID-and-UUID-options-added.patch -Patch0020: 0020-trim-arp-packets-with-abnormal-size.patch -Patch0021: 0021-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch -Patch0022: 0022-Add-support-for-UEFI-operating-systems-returned-by-o.patch -Patch0023: 0023-Migrate-PPC-from-Yaboot-to-Grub2.patch -Patch0024: 0024-Add-fw_path-variable-revised.patch -Patch0025: 0025-Pass-x-hex-hex-straight-through-unmolested.patch -Patch0026: 0026-Add-X-option-to-printf-functions.patch -Patch0027: 0027-Search-for-specific-config-file-for-netboot.patch -Patch0028: 0028-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch -Patch0029: 0029-Add-devicetree-loading.patch -Patch0030: 0030-Don-t-write-messages-to-the-screen.patch -Patch0031: 0031-Don-t-print-GNU-GRUB-header.patch -Patch0032: 0032-Don-t-add-to-highlighted-row.patch -Patch0033: 0033-Message-string-cleanups.patch -Patch0034: 0034-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch -Patch0035: 0035-Use-the-correct-indentation-for-the-term-help-text.patch -Patch0036: 0036-Indent-menu-entries.patch -Patch0037: 0037-Fix-margins.patch -Patch0038: 0038-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch -Patch0039: 0039-Enable-pager-by-default.-985860.patch -Patch0040: 0040-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch -Patch0041: 0041-Don-t-say-GNU-Linux-in-generated-menus.patch -Patch0042: 0042-Don-t-draw-a-border-around-the-menu.patch -Patch0043: 0043-Use-the-standard-margin-for-the-timeout-string.patch -Patch0044: 0044-Add-.eh_frame-to-list-of-relocations-stripped.patch -Patch0045: 0045-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch -Patch0046: 0046-Don-t-require-a-password-to-boot-entries-generated-b.patch -Patch0047: 0047-Don-t-emit-Booting-.-message.patch -Patch0048: 0048-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch -Patch0049: 0049-use-fw_path-prefix-when-fallback-searching-for-grub-.patch -Patch0050: 0050-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch -Patch0051: 0051-Fix-convert-function-to-support-NVMe-devices.patch -Patch0052: 0052-reopen-SNP-protocol-for-exclusive-use-by-grub.patch -Patch0053: 0053-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch -Patch0054: 0054-Add-grub_util_readlink.patch -Patch0055: 0055-Make-editenv-chase-symlinks-including-those-across-d.patch -Patch0056: 0056-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch -Patch0057: 0057-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch -Patch0058: 0058-Try-prefix-if-fw_path-doesn-t-work.patch -Patch0059: 0059-Update-info-with-grub.cfg-netboot-selection-order-11.patch -Patch0060: 0060-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch -Patch0061: 0061-Handle-rssd-storage-devices.patch -Patch0062: 0062-Make-grub2-mkconfig-construct-titles-that-look-like-.patch -Patch0063: 0063-Add-friendly-grub2-password-config-tool-985962.patch -Patch0064: 0064-Try-to-make-sure-configure.ac-and-grub-rpm-sort-play.patch -Patch0065: 0065-tcp-add-window-scaling-support.patch -Patch0066: 0066-efinet-add-filter-for-the-first-exclusive-reopen-of-.patch -Patch0067: 0067-Fix-security-issue-when-reading-username-and-passwor.patch -Patch0068: 0068-Warn-if-grub-password-will-not-be-read-1290803.patch -Patch0069: 0069-Clean-up-grub-setpassword-documentation-1290799.patch -Patch0070: 0070-Fix-locale-issue-in-grub-setpassword-1294243.patch -Patch0071: 0071-efiemu-Handle-persistent-RAM-and-unknown-possible-fu.patch -Patch0072: 0072-efiemu-Fix-compilation-failure.patch -Patch0073: 0073-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch -Patch0074: 0074-Add-a-url-parser.patch -Patch0075: 0075-efinet-and-bootp-add-support-for-dhcpv6.patch -Patch0076: 0076-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch -Patch0077: 0077-Normalize-slashes-in-tftp-paths.patch -Patch0078: 0078-Fix-malformed-tftp-packets.patch -Patch0079: 0079-bz1374141-fix-incorrect-mask-for-ppc64.patch -Patch0080: 0080-Make-grub_fatal-also-backtrace.patch -Patch0081: 0081-Make-grub-editenv-build-again.patch -Patch0082: 0082-Fix-up-some-man-pages-rpmdiff-noticed.patch -Patch0083: 0083-Make-exit-take-a-return-code.patch -Patch0084: 0084-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch -Patch0085: 0085-Make-our-info-pages-say-grub2-where-appropriate.patch -Patch0086: 0086-print-more-debug-info-in-our-module-loader.patch -Patch0087: 0087-macos-just-build-chainloader-entries-don-t-try-any-x.patch -Patch0088: 0088-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch -Patch0089: 0089-export-btrfs_subvol-and-btrfs_subvolid.patch -Patch0090: 0090-grub2-btrfs-03-follow_default.patch -Patch0091: 0091-grub2-btrfs-04-grub2-install.patch -Patch0092: 0092-grub2-btrfs-05-grub2-mkconfig.patch -Patch0093: 0093-grub2-btrfs-06-subvol-mount.patch -Patch0094: 0094-No-more-Bootable-Snapshot-submenu-in-grub.cfg.patch -Patch0095: 0095-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch -Patch0096: 0096-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch -Patch0097: 0097-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch -Patch0098: 0098-Use-grub_efi_.-memory-helpers-where-reasonable.patch -Patch0099: 0099-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch -Patch0100: 0100-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch -Patch0101: 0101-don-t-ignore-const.patch -Patch0102: 0102-don-t-use-int-for-efi-status.patch -Patch0103: 0103-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch -Patch0104: 0104-editenv-handle-relative-symlinks.patch -Patch0105: 0105-Make-libgrub.pp-depend-on-config-util.h.patch -Patch0106: 0106-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch -Patch0107: 0107-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch -Patch0108: 0108-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch -Patch0109: 0109-align-struct-efi_variable-better.patch -Patch0110: 0110-Add-quicksort-implementation.patch -Patch0111: 0111-Add-blscfg-command-support-to-parse-BootLoaderSpec-c.patch -Patch0112: 0112-Add-BLS-support-to-grub-mkconfig.patch -Patch0113: 0113-Remove-duplicated-grub_exit-definition-for-grub-emu-.patch -Patch0114: 0114-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch -Patch0115: 0115-Enable-blscfg-command-for-the-emu-platform.patch -Patch0116: 0116-Add-linux-and-initrd-commands-for-grub-emu.patch -Patch0117: 0117-Fix-the-efidir-in-grub-setpassword.patch -Patch0118: 0118-Add-grub2-switch-to-blscfg.patch -Patch0119: 0119-Add-grub_debug_enabled.patch -Patch0120: 0120-make-better-backtraces.patch -Patch0121: 0121-normal-don-t-draw-our-startup-message-if-debug-is-se.patch -Patch0122: 0122-Work-around-some-minor-include-path-weirdnesses.patch -Patch0123: 0123-Make-it-possible-to-enabled-build-id-sha1.patch -Patch0124: 0124-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch -Patch0125: 0125-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch -Patch0126: 0126-Only-attempt-to-scan-different-BLS-directories-on-EF.patch -Patch0127: 0127-Core-TPM-support.patch -Patch0128: 0128-Measure-kernel-initrd.patch -Patch0129: 0129-Add-BIOS-boot-measurement.patch -Patch0130: 0130-Measure-kernel-and-initrd-on-BIOS-systems.patch -Patch0131: 0131-Measure-the-kernel-commandline.patch -Patch0132: 0132-Measure-commands.patch -Patch0133: 0133-Measure-multiboot-images-and-modules.patch -Patch0134: 0134-Fix-boot-when-there-s-no-TPM.patch -Patch0135: 0135-Rework-TPM-measurements.patch -Patch0136: 0136-Fix-event-log-prefix.patch -Patch0137: 0137-Set-the-first-boot-menu-entry-as-default-when-using-.patch -Patch0138: 0138-tpm-fix-warnings-when-compiling-for-platforms-other-.patch -Patch0139: 0139-Make-TPM-errors-less-fatal.patch -Patch0140: 0140-blscfg-handle-multiple-initramfs-images.patch -Patch0141: 0141-BLS-Fix-grub2-switch-to-blscfg-on-non-EFI-machines.patch -Patch0142: 0142-BLS-Use-etcdefaultgrub-instead-of-etc.patch -Patch0143: 0143-Add-missing-options-to-grub2-switch-to-blscfg-man-pa.patch -Patch0144: 0144-Make-grub2-switch-to-blscfg-to-generate-debug-BLS-wh.patch -Patch0145: 0145-Make-grub2-switch-to-blscfg-to-generate-BLS-fragment.patch -Patch0146: 0146-Only-attempt-to-query-dev-mounted-in-boot-efi-as-boo.patch -Patch0147: 0147-Include-OSTree-path-when-searching-kernels-images-if.patch -Patch0148: 0148-Use-BLS-version-field-to-compare-entries-if-id-field.patch -Patch0149: 0149-Add-version-field-to-BLS-generated-by-grub2-switch-t.patch -Patch0150: 0150-Fixup-for-newer-compiler.patch -Patch0151: 0151-Don-t-attempt-to-export-the-start-and-_start-symbols.patch -Patch0152: 0152-Simplify-BLS-entry-key-val-pairs-lookup.patch -Patch0153: 0153-Add-relative-path-to-the-kernel-and-initrds-BLS-fiel.patch -Patch0154: 0154-Skip-leading-spaces-on-BLS-field-values.patch -Patch0155: 0155-Fixup-for-newer-compiler.patch -Patch0156: 0156-TPM-Fix-hash_log_extend_event-function-prototype.patch -Patch0157: 0157-TPM-Fix-compiler-warnings.patch -Patch0158: 0158-grub-switch-to-blscfg.in-get-rid-of-a-bunch-of-bashi.patch -Patch0159: 0159-grub-switch-to-blscfg.in-Better-boot-prefix-checking.patch -Patch0160: 0160-Use-boot-loader-entries-as-BLS-directory-path-also-o.patch -Patch0161: 0161-Use-BLS-fragment-filename-as-menu-entry-id-and-for-c.patch -Patch0162: 0162-Fix-grub-switch-to-blscfg-boot-prefix-handling.patch -Patch0163: 0163-Revert-trim-arp-packets-with-abnormal-size.patch -Patch0164: 0164-Use-xid-to-match-DHCP-replies.patch -Patch0165: 0165-Add-support-for-non-Ethernet-network-cards.patch -Patch0166: 0166-misc-fix-invalid-character-recongition-in-strto-l.patch -Patch0167: 0167-net-read-bracketed-ipv6-addrs-and-port-numbers.patch -Patch0168: 0168-net-read-bracketed-ipv6-addrs-and-port-numbers-pjone.patch -Patch0169: 0169-bootp-New-net_bootp6-command.patch -Patch0170: 0170-Put-back-our-code-to-add-a-local-route.patch -Patch0171: 0171-efinet-UEFI-IPv6-PXE-support.patch -Patch0172: 0172-grub.texi-Add-net_bootp6-doument.patch -Patch0173: 0173-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch -Patch0174: 0174-efinet-Setting-network-from-UEFI-device-path.patch -Patch0175: 0175-efinet-Setting-DNS-server-from-UEFI-protocol.patch -Patch0176: 0176-Fix-one-more-coverity-complaint.patch -Patch0177: 0177-Fix-grub_net_hwaddr_to_str.patch -Patch0178: 0178-Support-UEFI-networking-protocols.patch -Patch0179: 0179-AUDIT-0-http-boot-tracker-bug.patch -Patch0180: 0180-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch -Patch0181: 0181-efi-uga-use-64-bit-for-fb_base.patch -Patch0182: 0182-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch -Patch0183: 0183-EFI-console-Add-grub_console_read_key_stroke-helper-.patch -Patch0184: 0184-EFI-console-Implement-getkeystatus-support.patch -Patch0185: 0185-Make-grub_getkeystatus-helper-funtion-available-ever.patch -Patch0186: 0186-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch -Patch0187: 0187-grub-editenv-Add-incr-command-to-increment-integer-v.patch -Patch0188: 0188-Add-auto-hide-menu-support.patch -Patch0189: 0189-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch -Patch0190: 0190-Add-grub-set-bootflag-utility.patch -Patch0191: 0191-Fix-grub-setpassword-o-s-output-path.patch -Patch0192: 0192-Make-grub-set-password-be-named-like-all-the-other-g.patch -Patch0193: 0193-docs-Add-grub-boot-indeterminate.service-example.patch -Patch0194: 0194-00_menu_auto_hide-Use-a-timeout-of-60s-for-menu_show.patch -Patch0195: 0195-00_menu_auto_hide-Reduce-number-of-save_env-calls.patch -Patch0196: 0196-30_uefi-firmware-fix-use-with-sys-firmware-efi-efiva.patch -Patch0197: 0197-gentpl-add-disable-support.patch -Patch0198: 0198-gentpl-add-pc-firmware-type.patch -Patch0199: 0199-blscfg-remove-unused-typedef.patch -Patch0200: 0200-blscfg-don-t-dynamically-allocate-default_blsdir.patch -Patch0201: 0201-blscfg-sort-BLS-entries-by-version-field.patch -Patch0202: 0202-blscfg-remove-NULL-guards-around-grub_free.patch -Patch0203: 0203-blscfg-fix-filename-in-no-linux-key-error.patch -Patch0204: 0204-blscfg-don-t-leak-bls_entry.filename.patch -Patch0205: 0205-blscfg-fix-compilation-on-EFI-and-EMU.patch -Patch0206: 0206-Add-loadenv-to-blscfg-and-loadenv-source-file-list.patch -Patch0207: 0207-blscfg-Get-rid-of-the-linuxefi-linux16-linux-distinc.patch -Patch0208: 0208-grub-switch-to-blscfg-Only-fix-boot-prefix-for-non-g.patch -Patch0209: 0209-blscfg-Expand-the-BLS-options-field-instead-of-showi.patch -Patch0210: 0210-blscfg-Fallback-to-search-BLS-snippets-in-boot-loade.patch -Patch0211: 0211-blscfg-Don-t-attempt-to-sort-by-version-if-not-prese.patch -Patch0212: 0212-blscfg-remove-logic-to-read-the-grubenv-file-and-set.patch -Patch0213: 0213-Rename-00_menu_auto_hide.in-to-01_menu_auto_hide.in.patch -Patch0214: 0214-efinet-also-use-the-firmware-acceleration-for-http.patch -Patch0215: 0215-efi-http-Make-root_url-reflect-the-protocol-hostname.patch -Patch0216: 0216-Disable-multiboot-multiboot2-and-linux16-modules-on-.patch -Patch0217: 0217-Force-everything-to-use-python3.patch -Patch0218: 0218-Fix-an-8-year-old-typo.patch -Patch0219: 0219-autogen-don-t-run-autoreconf-in-the-topdir.patch -Patch0220: 0220-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch -Patch0221: 0221-module-verifier-make-it-possible-to-run-checkers-on-.patch -Patch0222: 0222-grub-module-verifier-report-the-filename-or-modname-.patch -Patch0223: 0223-Make-efi_netfs-not-duplicate-symbols-from-efinet.patch -Patch0224: 0224-Rework-how-the-fdt-command-builds.patch -Patch0225: 0225-Disable-non-wordsize-allocations-on-arm.patch -Patch0226: 0226-strip-R-.note.gnu.property-at-more-places.patch -Patch0227: 0227-Prepend-prefix-when-HTTP-path-is-relative.patch -Patch0228: 0228-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch -Patch0229: 0229-Mark-some-unused-stuff-unused.patch -Patch0230: 0230-Make-grub_error-more-verbose.patch -Patch0231: 0231-Make-reset-an-alias-for-the-reboot-command.patch -Patch0232: 0232-EFI-more-debug-output-on-GOP-and-UGA-probing.patch -Patch0233: 0233-Add-a-version-command.patch -Patch0234: 0234-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch -Patch0235: 0235-arm-arm64-loader-Better-memory-allocation-and-error-.patch -Patch0236: 0236-Try-to-pick-better-locations-for-kernel-and-initrd.patch -Patch0237: 0237-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch -Patch0238: 0238-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch -Patch0239: 0239-grub-boot-success.timer-Add-a-few-Conditions-for-run.patch -Patch0240: 0240-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch -Patch0241: 0241-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch -Patch0242: 0242-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch -Patch0243: 0243-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch -Patch0244: 0244-docs-Stop-using-polkit-pkexec-for-grub-boot-success..patch -Patch0245: 0245-drop-TPM-support-for-legacy-BIOS.patch -Patch0246: 0246-Move-quicksort-function-from-kernel.exec-to-the-blsc.patch -Patch0247: 0247-Include-blscfg-module-for-powerpc-ieee1275.patch -Patch0248: 0248-grub-switch-to-blscfg-copy-blscfg-module-for-legacy-.patch -Patch0249: 0249-Fix-getroot.c-s-trampolines.patch -Patch0250: 0250-Do-not-allow-stack-trampolines-anywhere.patch -Patch0251: 0251-Reimplement-boot_counter.patch -Patch0252: 0252-blscfg-don-t-include-.conf-at-the-end-of-our-id.patch -Patch0253: 0253-grub-get-kernel-settings-expose-some-more-config-var.patch -Patch0254: 0254-Reimplement-boot_counter.patch -Patch0255: 0255-add-10_linux_bls-grub.d-snippet-to-generate-menu-ent.patch -Patch0256: 0256-Only-set-kernelopts-in-grubenv-if-it-wasn-t-set-befo.patch -Patch0257: 0257-blscfg-sort-everything-with-rpm-package-comparison.patch -Patch0258: 0258-10_linux_bls-use-grub2-rpm-sort-instead-of-ls-vr-to-.patch -Patch0259: 0259-don-t-set-saved_entry-on-grub2-mkconfig.patch -Patch0260: 0260-grub-switch-to-blscfg-use-debug-instead-of-debug-as-.patch -Patch0261: 0261-Make-blscfg-debug-messages-more-useful.patch -Patch0262: 0262-Make-grub_strtoul-end-pointer-have-the-right-constif.patch -Patch0263: 0263-Fix-menu-entry-selection-based-on-ID-and-title.patch -Patch0264: 0264-Add-comments-and-revert-logic-changes-in-01_fallback.patch -Patch0265: 0265-Remove-quotes-when-reading-ID-value-from-etc-os-rele.patch -Patch0266: 0266-blscfg-expand-grub_users-before-passing-to-grub_norm.patch -Patch0267: 0267-Make-the-menu-entry-users-option-argument-to-be-opti.patch -Patch0268: 0268-10_linux_bls-add-missing-menu-entries-options.patch -Patch0269: 0269-Fix-menu-entry-selection-based-on-title.patch -Patch0270: 0270-BLS-files-should-only-be-copied-by-grub-switch-to-bl.patch -Patch0271: 0271-Fix-get_entry_number-wrongly-dereferencing-the-tail-.patch -Patch0272: 0272-Make-grub2-mkconfig-to-honour-GRUB_CMDLINE_LINUX-in-.patch -Patch0273: 0273-Add-efi-export-env-and-efi-load-env-commands.patch -Patch0274: 0274-Make-it-possible-to-subtract-conditions-from-debug.patch -Patch0275: 0275-Export-all-variables-from-the-initial-context-when-c.patch -Patch0276: 0276-blscfg-store-the-BLS-entries-in-a-sorted-linked-list.patch -Patch0277: 0277-blscfg-add-more-options-to-blscfg-command-to-make-it.patch -Patch0278: 0278-blscfg-add-support-for-prepend-early-initrds-to-the-.patch -Patch0279: 0279-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch -Patch0280: 0280-Try-to-set-fPIE-and-friends-on-libgnu.a.patch -Patch0281: 0281-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch -Patch0282: 0282-Set-blsdir-if-the-BLS-directory-path-isn-t-one-of-th.patch -Patch0283: 0283-Check-if-blsdir-exists-before-attempting-to-get-it-s.patch -Patch0284: 0284-blscfg-fallback-to-default_kernelopts-if-BLS-option-.patch -Patch0285: 0285-grub-switch-to-blscfg-copy-increment.mod-for-legacy-.patch -Patch0286: 0286-Only-set-blsdir-if-boot-loader-entries-is-in-a-btrfs.patch -Patch0287: 0287-Fix-the-type-of-grub_efi_status_t.patch -Patch0288: 0288-blscfg-don-t-use-grub_list_t-and-the-GRUB_AS_LIST-ma.patch -Patch0289: 0289-mkimage-Use-EFI32_HEADER_SIZE-define-in-arm-efi-case.patch -Patch0290: 0290-mkimage-Align-efi-sections-on-4k-boundary.patch -Patch0291: 0291-mkimage-Clarify-file-alignment-in-efi-case.patch -Patch0292: 0292-10_linux_bls-don-t-add-users-option-to-generated-men.patch -Patch0293: 0293-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch -Patch0294: 0294-HTTP-boot-strncmp-returns-0-on-equal.patch -Patch0295: 0295-Fix-systemctl-kexec-exit-status-check.patch -Patch0296: 0296-Print-grub-emu-linux-loader-messages-as-debug.patch -Patch0297: 0297-Don-t-assume-that-boot-commands-will-only-return-on-.patch -Patch0298: 0298-Add-10_reset_boot_success-to-Makefile.patch -Patch0299: 0299-Fix-undefined-references-for-fdt-when-building-with-.patch -Patch0300: 0300-blscfg-remove-BLS-file-size-check.patch -Patch0301: 0301-Remove-bogus-load_env-after-blscfg-command-in-10_lin.patch -Patch0302: 0302-blscfg-Don-t-leave-grub_errno-set-to-an-error-if-the.patch -Patch0303: 0303-Fix-bls-directory-option-comment-in-grub2-switch-to-.patch -Patch0304: 0304-10_linux_bls-use-to-separate-id-argument-due-a-Petit.patch -Patch0305: 0305-grub-set-bootflag-Print-an-error-if-failing-to-read-.patch -Patch0306: 0306-10_linux-generate-BLS-section-even-if-no-kernels-are.patch -Patch0307: 0307-10_linux-don-t-search-for-OSTree-kernels.patch -Patch0308: 0308-Don-t-duplicate-net-name-string-if-not-needed.patch -Patch0309: 0309-arm-Move-trampolines-into-code-section.patch -Patch0310: 0310-arm-Align-section-alignment-with-manual-relocation-o.patch -Patch0311: 0311-grub-core-loader-efi-fdt.c-Do-not-copy-random-memory.patch -Patch0312: 0312-linux-efi-arm-fdt-break-FDT-extra-allocation-space-o.patch -Patch0313: 0313-Preserve-multi-device-workflows.patch -Patch0314: 0314-Revert-Disable-multiboot-multiboot2-and-linux16-modu.patch +Patch0020: 0020-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch +Patch0021: 0021-Add-support-for-UEFI-operating-systems-returned-by-o.patch +Patch0022: 0022-Migrate-PPC-from-Yaboot-to-Grub2.patch +Patch0023: 0023-Add-fw_path-variable-revised.patch +Patch0024: 0024-Pass-x-hex-hex-straight-through-unmolested.patch +Patch0025: 0025-Add-X-option-to-printf-functions.patch +Patch0026: 0026-Search-for-specific-config-file-for-netboot.patch +Patch0027: 0027-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch +Patch0028: 0028-Add-devicetree-loading.patch +Patch0029: 0029-Don-t-write-messages-to-the-screen.patch +Patch0030: 0030-Don-t-print-GNU-GRUB-header.patch +Patch0031: 0031-Don-t-add-to-highlighted-row.patch +Patch0032: 0032-Message-string-cleanups.patch +Patch0033: 0033-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch +Patch0034: 0034-Use-the-correct-indentation-for-the-term-help-text.patch +Patch0035: 0035-Indent-menu-entries.patch +Patch0036: 0036-Fix-margins.patch +Patch0037: 0037-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch +Patch0038: 0038-Enable-pager-by-default.-985860.patch +Patch0039: 0039-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch +Patch0040: 0040-Don-t-say-GNU-Linux-in-generated-menus.patch +Patch0041: 0041-Don-t-draw-a-border-around-the-menu.patch +Patch0042: 0042-Use-the-standard-margin-for-the-timeout-string.patch +Patch0043: 0043-Add-.eh_frame-to-list-of-relocations-stripped.patch +Patch0044: 0044-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch +Patch0045: 0045-Don-t-require-a-password-to-boot-entries-generated-b.patch +Patch0046: 0046-Don-t-emit-Booting-.-message.patch +Patch0047: 0047-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch +Patch0048: 0048-use-fw_path-prefix-when-fallback-searching-for-grub-.patch +Patch0049: 0049-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch +Patch0050: 0050-Fix-convert-function-to-support-NVMe-devices.patch +Patch0051: 0051-Add-grub_util_readlink.patch +Patch0052: 0052-Make-editenv-chase-symlinks-including-those-across-d.patch +Patch0053: 0053-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch +Patch0054: 0054-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch +Patch0055: 0055-Try-prefix-if-fw_path-doesn-t-work.patch +Patch0056: 0056-Update-info-with-grub.cfg-netboot-selection-order-11.patch +Patch0057: 0057-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch +Patch0058: 0058-Handle-rssd-storage-devices.patch +Patch0059: 0059-Make-grub2-mkconfig-construct-titles-that-look-like-.patch +Patch0060: 0060-Add-friendly-grub2-password-config-tool-985962.patch +Patch0061: 0061-tcp-add-window-scaling-support.patch +Patch0062: 0062-Fix-security-issue-when-reading-username-and-passwor.patch +Patch0063: 0063-Add-a-url-parser.patch +Patch0064: 0064-efinet-and-bootp-add-support-for-dhcpv6.patch +Patch0065: 0065-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch +Patch0066: 0066-Normalize-slashes-in-tftp-paths.patch +Patch0067: 0067-bz1374141-fix-incorrect-mask-for-ppc64.patch +Patch0068: 0068-Make-grub_fatal-also-backtrace.patch +Patch0069: 0069-Fix-up-some-man-pages-rpmdiff-noticed.patch +Patch0070: 0070-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch +Patch0071: 0071-Make-our-info-pages-say-grub2-where-appropriate.patch +Patch0072: 0072-print-more-debug-info-in-our-module-loader.patch +Patch0073: 0073-macos-just-build-chainloader-entries-don-t-try-any-x.patch +Patch0074: 0074-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch +Patch0075: 0075-export-btrfs_subvol-and-btrfs_subvolid.patch +Patch0076: 0076-grub2-btrfs-03-follow_default.patch +Patch0077: 0077-grub2-btrfs-04-grub2-install.patch +Patch0078: 0078-grub2-btrfs-05-grub2-mkconfig.patch +Patch0079: 0079-grub2-btrfs-06-subvol-mount.patch +Patch0080: 0080-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch +Patch0081: 0081-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch +Patch0082: 0082-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch +Patch0083: 0083-Use-grub_efi_.-memory-helpers-where-reasonable.patch +Patch0084: 0084-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch +Patch0085: 0085-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch +Patch0086: 0086-don-t-ignore-const.patch +Patch0087: 0087-don-t-use-int-for-efi-status.patch +Patch0088: 0088-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch +Patch0089: 0089-editenv-handle-relative-symlinks.patch +Patch0090: 0090-Make-libgrub.pp-depend-on-config-util.h.patch +Patch0091: 0091-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch +Patch0092: 0092-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch +Patch0093: 0093-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch +Patch0094: 0094-align-struct-efi_variable-better.patch +Patch0095: 0095-Add-BLS-support-to-grub-mkconfig.patch +Patch0096: 0096-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch +Patch0097: 0097-Add-linux-and-initrd-commands-for-grub-emu.patch +Patch0098: 0098-Add-grub2-switch-to-blscfg.patch +Patch0099: 0099-Add-grub_debug_enabled.patch +Patch0100: 0100-make-better-backtraces.patch +Patch0101: 0101-normal-don-t-draw-our-startup-message-if-debug-is-se.patch +Patch0102: 0102-Work-around-some-minor-include-path-weirdnesses.patch +Patch0103: 0103-Make-it-possible-to-enabled-build-id-sha1.patch +Patch0104: 0104-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch +Patch0105: 0105-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch +Patch0106: 0106-TPM-support.patch +Patch0107: 0107-Fixup-for-newer-compiler.patch +Patch0108: 0108-Don-t-attempt-to-export-the-start-and-_start-symbols.patch +Patch0109: 0109-Fixup-for-newer-compiler.patch +Patch0110: 0110-Use-xid-to-match-DHCP-replies.patch +Patch0111: 0111-Add-support-for-non-Ethernet-network-cards.patch +Patch0112: 0112-misc-fix-invalid-character-recongition-in-strto-l.patch +Patch0113: 0113-net-read-bracketed-ipv6-addrs-and-port-numbers.patch +Patch0114: 0114-bootp-New-net_bootp6-command.patch +Patch0115: 0115-efinet-UEFI-IPv6-PXE-support.patch +Patch0116: 0116-grub.texi-Add-net_bootp6-doument.patch +Patch0117: 0117-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch +Patch0118: 0118-efinet-Setting-network-from-UEFI-device-path.patch +Patch0119: 0119-efinet-Setting-DNS-server-from-UEFI-protocol.patch +Patch0120: 0120-Fix-one-more-coverity-complaint.patch +Patch0121: 0121-Support-UEFI-networking-protocols.patch +Patch0122: 0122-AUDIT-0-http-boot-tracker-bug.patch +Patch0123: 0123-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch +Patch0124: 0124-efi-uga-use-64-bit-for-fb_base.patch +Patch0125: 0125-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch +Patch0126: 0126-EFI-console-Add-grub_console_read_key_stroke-helper-.patch +Patch0127: 0127-EFI-console-Implement-getkeystatus-support.patch +Patch0128: 0128-Make-grub_getkeystatus-helper-funtion-available-ever.patch +Patch0129: 0129-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch +Patch0130: 0130-grub-editenv-Add-incr-command-to-increment-integer-v.patch +Patch0131: 0131-Add-auto-hide-menu-support.patch +Patch0132: 0132-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch +Patch0133: 0133-Add-grub-set-bootflag-utility.patch +Patch0134: 0134-docs-Add-grub-boot-indeterminate.service-example.patch +Patch0135: 0135-gentpl-add-disable-support.patch +Patch0136: 0136-gentpl-add-pc-firmware-type.patch +Patch0137: 0137-efinet-also-use-the-firmware-acceleration-for-http.patch +Patch0138: 0138-efi-http-Make-root_url-reflect-the-protocol-hostname.patch +Patch0139: 0139-Force-everything-to-use-python3.patch +Patch0140: 0140-Fix-an-8-year-old-typo.patch +Patch0141: 0141-autogen-don-t-run-autoreconf-in-the-topdir.patch +Patch0142: 0142-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch +Patch0143: 0143-module-verifier-make-it-possible-to-run-checkers-on-.patch +Patch0144: 0144-grub-module-verifier-report-the-filename-or-modname-.patch +Patch0145: 0145-Rework-how-the-fdt-command-builds.patch +Patch0146: 0146-Disable-non-wordsize-allocations-on-arm.patch +Patch0147: 0147-strip-R-.note.gnu.property-at-more-places.patch +Patch0148: 0148-Prepend-prefix-when-HTTP-path-is-relative.patch +Patch0149: 0149-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch +Patch0150: 0150-Make-grub_error-more-verbose.patch +Patch0151: 0151-Make-reset-an-alias-for-the-reboot-command.patch +Patch0152: 0152-EFI-more-debug-output-on-GOP-and-UGA-probing.patch +Patch0153: 0153-Add-a-version-command.patch +Patch0154: 0154-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch +Patch0155: 0155-arm-arm64-loader-Better-memory-allocation-and-error-.patch +Patch0156: 0156-Try-to-pick-better-locations-for-kernel-and-initrd.patch +Patch0157: 0157-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch +Patch0158: 0158-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch +Patch0159: 0159-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch +Patch0160: 0160-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch +Patch0161: 0161-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch +Patch0162: 0162-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch +Patch0163: 0163-Fix-getroot.c-s-trampolines.patch +Patch0164: 0164-Do-not-allow-stack-trampolines-anywhere.patch +Patch0165: 0165-Reimplement-boot_counter.patch +Patch0166: 0166-Make-grub_strtoul-end-pointer-have-the-right-constif.patch +Patch0167: 0167-Fix-menu-entry-selection-based-on-ID-and-title.patch +Patch0168: 0168-Make-the-menu-entry-users-option-argument-to-be-opti.patch +Patch0169: 0169-Add-efi-export-env-and-efi-load-env-commands.patch +Patch0170: 0170-Make-it-possible-to-subtract-conditions-from-debug.patch +Patch0171: 0171-Export-all-variables-from-the-initial-context-when-c.patch +Patch0172: 0172-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch +Patch0173: 0173-Try-to-set-fPIE-and-friends-on-libgnu.a.patch +Patch0174: 0174-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch +Patch0175: 0175-Fix-the-type-of-grub_efi_status_t.patch +Patch0176: 0176-mkimage-Use-EFI32_HEADER_SIZE-define-in-arm-efi-case.patch +Patch0177: 0177-mkimage-Align-efi-sections-on-4k-boundary.patch +Patch0178: 0178-mkimage-Clarify-file-alignment-in-efi-case.patch +Patch0179: 0179-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch +Patch0180: 0180-Fix-systemctl-kexec-exit-status-check.patch +Patch0181: 0181-Print-grub-emu-linux-loader-messages-as-debug.patch +Patch0182: 0182-Don-t-assume-that-boot-commands-will-only-return-on-.patch +Patch0183: 0183-Fix-undefined-references-for-fdt-when-building-with-.patch +Patch0184: 0184-arm-Move-trampolines-into-code-section.patch +Patch0185: 0185-arm-Align-section-alignment-with-manual-relocation-o.patch +Patch0186: 0186-grub-core-loader-efi-fdt.c-Do-not-copy-random-memory.patch +Patch0187: 0187-linux-efi-arm-fdt-break-FDT-extra-allocation-space-o.patch diff --git a/grub2.spec b/grub2.spec index af0981b..b89e548 100644 --- a/grub2.spec +++ b/grub2.spec @@ -7,7 +7,7 @@ Name: grub2 Epoch: 1 Version: 2.02 -Release: 91%{?dist} +Release: 92%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -518,6 +518,9 @@ rm -r /boot/grub2.tmp/ || : %endif %changelog +* Tue Jul 16 2019 Javier Martinez Canillas - 2.02-92 +- Cleanup our patchset to reduce the number of patches + * Sat Jul 13 2019 Javier Martinez Canillas - 2.02-91 - Includes security modules in Grub2 EFI builds (benjamin.doron) Resolves: rhbz#1722938