parent
73a3ee0778
commit
00422adb28
@ -0,0 +1,73 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fedora Ninjas <grub2-owner@fedoraproject.org>
|
||||
Date: Tue, 8 Aug 2023 05:44:48 -0400
|
||||
Subject: [PATCH] grub-mkconfig dont overwrite BLS cmdline if BLSCFG
|
||||
|
||||
If GRUB_ENABLE_BLSCFG is true, running grub2-mkconfig will not
|
||||
overwrite kernel cmdline in BLS snippets with what is in
|
||||
GRUB_CMDLINE_LINUX in /etc/default/grub. Update can be forced by
|
||||
sending new arg --update-bls-cmdline
|
||||
|
||||
Signed-off-by: mkl <mlewando@redhat.com>
|
||||
---
|
||||
util/grub-mkconfig.in | 10 ++++++++++
|
||||
util/grub.d/10_linux.in | 4 +++-
|
||||
2 files changed, 13 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
|
||||
index 520a672cd2c8..30a2d097823d 100644
|
||||
--- a/util/grub-mkconfig.in
|
||||
+++ b/util/grub-mkconfig.in
|
||||
@@ -51,6 +51,7 @@ export TEXTDOMAIN=@PACKAGE@
|
||||
export TEXTDOMAINDIR="@localedir@"
|
||||
|
||||
export GRUB_GRUBENV_UPDATE="yes"
|
||||
+export GRUB_UPDATE_BLS_CMDLINE="yes"
|
||||
|
||||
. "${pkgdatadir}/grub-mkconfig_lib"
|
||||
|
||||
@@ -62,6 +63,7 @@ usage () {
|
||||
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 "--update-bls-cmdline" "$(gettext "overwrite BLS cmdline args with default args")"
|
||||
print_option_help "-h, --help" "$(gettext "print this message and exit")"
|
||||
print_option_help "-V, --version" "$(gettext "print the version information and exit")"
|
||||
echo
|
||||
@@ -100,6 +102,9 @@ do
|
||||
--no-grubenv-update)
|
||||
GRUB_GRUBENV_UPDATE="no"
|
||||
;;
|
||||
+ --update-bls-cmdline)
|
||||
+ bls_cmdline_update=true
|
||||
+ ;;
|
||||
-*)
|
||||
gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2
|
||||
usage
|
||||
@@ -167,6 +172,11 @@ fi
|
||||
|
||||
eval "$("${grub_get_kernel_settings}")" || true
|
||||
|
||||
+if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ] && \
|
||||
+ [ "x${bls_cmdline_update}" != "xtrue" ]; then
|
||||
+ GRUB_UPDATE_BLS_CMDLINE="no"
|
||||
+fi
|
||||
+
|
||||
if [ "x${GRUB_DISABLE_UUID}" = "xtrue" ]; then
|
||||
if [ -z "${GRUB_DISABLE_LINUX_UUID}" ]; then
|
||||
GRUB_DISABLE_LINUX_UUID="true"
|
||||
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
|
||||
index 4795a63b4ce6..76fc21fb6528 100644
|
||||
--- a/util/grub.d/10_linux.in
|
||||
+++ b/util/grub.d/10_linux.in
|
||||
@@ -265,7 +265,9 @@ if [ -z "\${kernelopts}" ]; then
|
||||
fi
|
||||
EOF
|
||||
|
||||
- if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then
|
||||
+ if [ "x${GRUB_UPDATE_BLS_CMDLINE}" = "xyes" ] || \
|
||||
+ ( [ -w /etc/kernel ] && [[ ! -f /etc/kernel/cmdline ]] && \
|
||||
+ [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ] ); then
|
||||
update_bls_cmdline
|
||||
fi
|
||||
|
@ -0,0 +1,37 @@
|
||||
From f4f134582912851628e15df4963b3b8a6652aa26 Mon Sep 17 00:00:00 2001
|
||||
From: Marta Lewandowska <mlewando@redhat.com>
|
||||
Date: Tue, 29 Aug 2023 16:40:47 +0200
|
||||
Subject: [PATCH] grub2-mkconfig: Pass all boot params when used by anaconda
|
||||
|
||||
Previous patch makes it so that the machine can boot, but not all
|
||||
boot params are passed from /etc/default/grub to BLS snippets
|
||||
because /etc/default/grub gets written by anaconda during boot
|
||||
loader installation, long after grub rpms first got installed.
|
||||
|
||||
Signed-off-by: Marta Lewandowska <mlewando@redhat.com>
|
||||
---
|
||||
util/grub.d/10_linux.in | 8 +++++---
|
||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
|
||||
index 76fc21fb6528..041a11529588 100644
|
||||
--- a/util/grub.d/10_linux.in
|
||||
+++ b/util/grub.d/10_linux.in
|
||||
@@ -265,9 +265,11 @@ if [ -z "\${kernelopts}" ]; then
|
||||
fi
|
||||
EOF
|
||||
|
||||
- if [ "x${GRUB_UPDATE_BLS_CMDLINE}" = "xyes" ] || \
|
||||
- ( [ -w /etc/kernel ] && [[ ! -f /etc/kernel/cmdline ]] && \
|
||||
- [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ] ); then
|
||||
+ if [ "x${GRUB_UPDATE_BLS_CMDLINE}" = "xyes" ] || [[ -d /run/install ]]; then
|
||||
+ # only update the bls cmdline if the user specifically requests it or _anytime_
|
||||
+ # in the installer environment: /run/install directory only exists during the
|
||||
+ # installation and not in cloud images, so this should get all the boot params
|
||||
+ # from /etc/default/grub into BLS snippets
|
||||
update_bls_cmdline
|
||||
fi
|
||||
|
||||
--
|
||||
2.41.0
|
||||
|
@ -0,0 +1,159 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Marta Lewandowska <mlewando@redhat.com>
|
||||
Date: Mon, 9 Oct 2023 08:53:18 +0200
|
||||
Subject: [PATCH] search command: add flag to only search root dev
|
||||
|
||||
bz#2223437
|
||||
Signed-off-by: Marta Lewandowska <mlewando@redhat.com>
|
||||
---
|
||||
grub-core/commands/search.c | 36 ++++++++++++++++++++++++++++++++++++
|
||||
grub-core/commands/search_wrap.c | 5 +++++
|
||||
grub-core/kern/misc.c | 30 ++++++++++++++++++++++++++++++
|
||||
include/grub/misc.h | 1 +
|
||||
include/grub/search.h | 3 ++-
|
||||
5 files changed, 74 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c
|
||||
index 57d26ced8a8e..94fe8b2872a1 100644
|
||||
--- a/grub-core/commands/search.c
|
||||
+++ b/grub-core/commands/search.c
|
||||
@@ -85,6 +85,42 @@ iterate_device (const char *name, void *data)
|
||||
grub_device_close (dev);
|
||||
}
|
||||
|
||||
+ /* Skip it if it's not the root device when requested. */
|
||||
+ if (ctx->flags & SEARCH_FLAGS_ROOTDEV_ONLY)
|
||||
+ {
|
||||
+ const char *root_dev;
|
||||
+ root_dev = grub_env_get ("root");
|
||||
+ if (root_dev != NULL && *root_dev != '\0')
|
||||
+ {
|
||||
+ char *root_disk = grub_malloc (grub_strlen(root_dev) + 1);
|
||||
+ char *name_disk = grub_malloc (grub_strlen(name) + 1);
|
||||
+ char *rem_1 = grub_malloc(grub_strlen(root_dev) + 1);
|
||||
+ char *rem_2 = grub_malloc(grub_strlen(name) + 1);
|
||||
+
|
||||
+ if (root_disk != NULL && name_disk != NULL &&
|
||||
+ rem_1 != NULL && rem_2 != NULL)
|
||||
+ {
|
||||
+ /* get just the disk name; partitions will be different. */
|
||||
+ grub_str_sep (root_dev, root_disk, ',', rem_1);
|
||||
+ grub_str_sep (name, name_disk, ',', rem_2);
|
||||
+ if (root_disk != NULL && *root_disk != '\0' &&
|
||||
+ name_disk != NULL && *name_disk != '\0')
|
||||
+ if (grub_strcmp(root_disk, name_disk) != 0)
|
||||
+ {
|
||||
+ grub_free (root_disk);
|
||||
+ grub_free (name_disk);
|
||||
+ grub_free (rem_1);
|
||||
+ grub_free (rem_2);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ }
|
||||
+ grub_free (root_disk);
|
||||
+ grub_free (name_disk);
|
||||
+ grub_free (rem_1);
|
||||
+ grub_free (rem_2);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
#ifdef DO_SEARCH_FS_UUID
|
||||
#define compare_fn grub_strcasecmp
|
||||
#else
|
||||
diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c
|
||||
index 0b62acf85359..06b5f51eefb5 100644
|
||||
--- a/grub-core/commands/search_wrap.c
|
||||
+++ b/grub-core/commands/search_wrap.c
|
||||
@@ -41,6 +41,7 @@ static const struct grub_arg_option options[] =
|
||||
ARG_TYPE_STRING},
|
||||
{"no-floppy", 'n', 0, N_("Do not probe any floppy drive."), 0, 0},
|
||||
{"efidisk-only", 0, 0, N_("Only probe EFI disks."), 0, 0},
|
||||
+ {"root-dev-only", 'r', 0, N_("Only probe root device."), 0, 0},
|
||||
{"hint", 'h', GRUB_ARG_OPTION_REPEATABLE,
|
||||
N_("First try the device HINT. If HINT ends in comma, "
|
||||
"also try subpartitions"), N_("HINT"), ARG_TYPE_STRING},
|
||||
@@ -75,6 +76,7 @@ enum options
|
||||
SEARCH_SET,
|
||||
SEARCH_NO_FLOPPY,
|
||||
SEARCH_EFIDISK_ONLY,
|
||||
+ SEARCH_ROOTDEV_ONLY,
|
||||
SEARCH_HINT,
|
||||
SEARCH_HINT_IEEE1275,
|
||||
SEARCH_HINT_BIOS,
|
||||
@@ -189,6 +191,9 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
if (state[SEARCH_EFIDISK_ONLY].set)
|
||||
flags |= SEARCH_FLAGS_EFIDISK_ONLY;
|
||||
|
||||
+ if (state[SEARCH_ROOTDEV_ONLY].set)
|
||||
+ flags |= SEARCH_FLAGS_ROOTDEV_ONLY;
|
||||
+
|
||||
if (state[SEARCH_LABEL].set)
|
||||
grub_search_label (id, var, flags, hints, nhints);
|
||||
else if (state[SEARCH_FS_UUID].set)
|
||||
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
|
||||
index cb454614022f..50af9ee1bdd9 100644
|
||||
--- a/grub-core/kern/misc.c
|
||||
+++ b/grub-core/kern/misc.c
|
||||
@@ -619,6 +619,36 @@ grub_reverse (char *str)
|
||||
}
|
||||
}
|
||||
|
||||
+/* Separate string into two parts, broken up by delimiter delim. */
|
||||
+void
|
||||
+grub_str_sep (const char *s, char *p, char delim, char *r)
|
||||
+{
|
||||
+ char* t = grub_strndup(s, grub_strlen(s));
|
||||
+
|
||||
+ if (t != NULL && *t != '\0')
|
||||
+ {
|
||||
+ char* tmp = t;
|
||||
+
|
||||
+ while (((*p = *t) != '\0') && ((*p = *t) != delim))
|
||||
+ {
|
||||
+ p++;
|
||||
+ t++;
|
||||
+ }
|
||||
+ *p = '\0';
|
||||
+
|
||||
+ if (*t != '\0')
|
||||
+ {
|
||||
+ t++;
|
||||
+ while ((*r++ = *t++) != '\0')
|
||||
+ ;
|
||||
+ *r = '\0';
|
||||
+ }
|
||||
+ grub_free (tmp);
|
||||
+ }
|
||||
+ else
|
||||
+ grub_free (t);
|
||||
+}
|
||||
+
|
||||
/* Divide N by D, return the quotient, and store the remainder in *R. */
|
||||
grub_uint64_t
|
||||
grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)
|
||||
diff --git a/include/grub/misc.h b/include/grub/misc.h
|
||||
index faae0ae8606c..981526644d29 100644
|
||||
--- a/include/grub/misc.h
|
||||
+++ b/include/grub/misc.h
|
||||
@@ -314,6 +314,7 @@ void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n);
|
||||
grub_size_t EXPORT_FUNC(grub_strlen) (const char *s) WARN_UNUSED_RESULT;
|
||||
int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2)));
|
||||
int EXPORT_FUNC(grub_printf_) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2)));
|
||||
+void EXPORT_FUNC(grub_str_sep) (const char *s, char *p, char delim, char *r);
|
||||
|
||||
/* Replace all `ch' characters of `input' with `with' and copy the
|
||||
result into `output'; return EOS address of `output'. */
|
||||
diff --git a/include/grub/search.h b/include/grub/search.h
|
||||
index 4190aeb2cbf5..321d1400e451 100644
|
||||
--- a/include/grub/search.h
|
||||
+++ b/include/grub/search.h
|
||||
@@ -22,7 +22,8 @@
|
||||
enum search_flags
|
||||
{
|
||||
SEARCH_FLAGS_NO_FLOPPY = 1,
|
||||
- SEARCH_FLAGS_EFIDISK_ONLY = 2
|
||||
+ SEARCH_FLAGS_EFIDISK_ONLY = 2,
|
||||
+ SEARCH_FLAGS_ROOTDEV_ONLY = 4
|
||||
};
|
||||
|
||||
void grub_search_fs_file (const char *key, const char *var,
|
@ -1,4 +1,4 @@
|
||||
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
|
||||
grub,3,Free Software Foundation,grub,@@VERSION@@,https//www.gnu.org/software/grub/
|
||||
grub.rh,2,Red Hat,grub2,@@RHEL_VERSION_RELEASE@@,mailto:secalert@redhat.com
|
||||
grub.msvsphere,2,MSVSphere,grub2,@@VERSION_RELEASE@@,mailto:security@msvsphere.ru
|
||||
grub.msvsphere,2,MSVSphere,grub2,@@VERSION_RELEASE@@,mailto:security@msvsphere-os.ru
|
||||
|
Loading…
Reference in new issue