Make grubenv work correctly on UEFI machines.
Related: rhbz#1119943 Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
parent
7e21de47e7
commit
9ccddf4254
3734
0144-Add-grub_util_readlink.patch
Normal file
3734
0144-Add-grub_util_readlink.patch
Normal file
File diff suppressed because it is too large
Load Diff
106
0145-Make-editenv-chase-symlinks-including-those-across-d.patch
Normal file
106
0145-Make-editenv-chase-symlinks-including-those-across-d.patch
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
From 4ebb0b512d9cf934ace9478fde7890cebb33f56d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Peter Jones <pjones@redhat.com>
|
||||||
|
Date: Wed, 3 Sep 2014 10:38:00 -0400
|
||||||
|
Subject: [PATCH 145/145] Make editenv chase symlinks including those across
|
||||||
|
devices.
|
||||||
|
|
||||||
|
This lets us make /boot/grub2/grubenv a symlink to
|
||||||
|
/boot/efi/EFI/fedora/grubenv even though they're different mount points,
|
||||||
|
which allows /usr/bin/grub2-editenv to be the same across platforms
|
||||||
|
(i.e. UEFI vs BIOS).
|
||||||
|
|
||||||
|
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||||
|
Reviewed-by: Adam Jackson <ajax@redhat.com>
|
||||||
|
---
|
||||||
|
Makefile.util.def | 9 +++++++++
|
||||||
|
util/editenv.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
|
||||||
|
2 files changed, 53 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/Makefile.util.def b/Makefile.util.def
|
||||||
|
index 8f40e78..87029a1 100644
|
||||||
|
--- a/Makefile.util.def
|
||||||
|
+++ b/Makefile.util.def
|
||||||
|
@@ -228,8 +228,17 @@ program = {
|
||||||
|
|
||||||
|
common = util/grub-editenv.c;
|
||||||
|
common = util/editenv.c;
|
||||||
|
+ common = util/grub-install-common.c;
|
||||||
|
common = grub-core/osdep/init.c;
|
||||||
|
+ common = grub-core/osdep/compress.c;
|
||||||
|
+ extra_dist = grub-core/osdep/unix/compress.c;
|
||||||
|
+ extra_dist = grub-core/osdep/basic/compress.c;
|
||||||
|
+ common = util/mkimage.c;
|
||||||
|
+ common = grub-core/osdep/config.c;
|
||||||
|
+ common = util/config.c;
|
||||||
|
+ common = util/resolve.c;
|
||||||
|
|
||||||
|
+ ldadd = '$(LIBLZMA)';
|
||||||
|
ldadd = libgrubmods.a;
|
||||||
|
ldadd = libgrubgcry.a;
|
||||||
|
ldadd = libgrubkern.a;
|
||||||
|
diff --git a/util/editenv.c b/util/editenv.c
|
||||||
|
index c6f8d22..d8d1dad 100644
|
||||||
|
--- a/util/editenv.c
|
||||||
|
+++ b/util/editenv.c
|
||||||
|
@@ -37,6 +37,7 @@ grub_util_create_envblk_file (const char *name)
|
||||||
|
FILE *fp;
|
||||||
|
char *buf;
|
||||||
|
char *namenew;
|
||||||
|
+ char *rename_target = xstrdup(name);
|
||||||
|
|
||||||
|
buf = xmalloc (DEFAULT_ENVBLK_SIZE);
|
||||||
|
|
||||||
|
@@ -59,7 +60,48 @@ grub_util_create_envblk_file (const char *name)
|
||||||
|
free (buf);
|
||||||
|
fclose (fp);
|
||||||
|
|
||||||
|
- if (grub_util_rename (namenew, name) < 0)
|
||||||
|
- grub_util_error (_("cannot rename the file %s to %s"), namenew, name);
|
||||||
|
+ ssize_t size = 1;
|
||||||
|
+ while (1)
|
||||||
|
+ {
|
||||||
|
+ char *linkbuf;
|
||||||
|
+ ssize_t retsize;
|
||||||
|
+
|
||||||
|
+ linkbuf = xmalloc(size+1);
|
||||||
|
+ retsize = grub_util_readlink (rename_target, linkbuf, size);
|
||||||
|
+ if (retsize < 0 && (errno == ENOENT || errno == EINVAL))
|
||||||
|
+ {
|
||||||
|
+ free (linkbuf);
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ else if (retsize < 0)
|
||||||
|
+ {
|
||||||
|
+ grub_util_error (_("cannot rename the file %s to %s: %m"), namenew, name);
|
||||||
|
+ free (linkbuf);
|
||||||
|
+ free (namenew);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ else if (retsize == size)
|
||||||
|
+ {
|
||||||
|
+ free(linkbuf);
|
||||||
|
+ size += 128;
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ free (rename_target);
|
||||||
|
+ linkbuf[retsize] = '\0';
|
||||||
|
+ rename_target = linkbuf;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ int rc = grub_util_rename (namenew, rename_target);
|
||||||
|
+ if (rc < 0 && errno == EXDEV)
|
||||||
|
+ {
|
||||||
|
+ rc = grub_install_copy_file (namenew, rename_target, 1);
|
||||||
|
+ grub_util_unlink (namenew);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (rc < 0)
|
||||||
|
+ grub_util_error (_("cannot rename the file %s to %s: %m"), namenew, name);
|
||||||
|
+
|
||||||
|
free (namenew);
|
||||||
|
+ free (rename_target);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
1.9.3
|
||||||
|
|
14
grub2.spec
14
grub2.spec
@ -204,6 +204,8 @@ Patch0140: 0140-always-return-error-to-UEFI.patch
|
|||||||
Patch0141: 0141-Add-powerpc-little-endian-ppc64le-flags.patch
|
Patch0141: 0141-Add-powerpc-little-endian-ppc64le-flags.patch
|
||||||
Patch0142: 0142-Files-reorganization-and-include-some-libgcc-fuction.patch
|
Patch0142: 0142-Files-reorganization-and-include-some-libgcc-fuction.patch
|
||||||
Patch0143: 0143-Suport-for-bi-endianess-in-elf-file.patch
|
Patch0143: 0143-Suport-for-bi-endianess-in-elf-file.patch
|
||||||
|
Patch0144: 0144-Add-grub_util_readlink.patch
|
||||||
|
Patch0145: 0145-Make-editenv-chase-symlinks-including-those-across-d.patch
|
||||||
|
|
||||||
BuildRequires: flex bison binutils python
|
BuildRequires: flex bison binutils python
|
||||||
BuildRequires: ncurses-devel xz-devel bzip2-devel
|
BuildRequires: ncurses-devel xz-devel bzip2-devel
|
||||||
@ -347,7 +349,7 @@ make %{?_smp_mflags}
|
|||||||
|
|
||||||
GRUB_MODULES=" all_video boot btrfs cat chain configfile echo efifwsetup \
|
GRUB_MODULES=" all_video boot btrfs cat chain configfile echo efifwsetup \
|
||||||
efinet ext2 fat font gfxmenu gfxterm gzio halt hfsplus iso9660 \
|
efinet ext2 fat font gfxmenu gfxterm gzio halt hfsplus iso9660 \
|
||||||
jpeg lvm mdraid09 mdraid1x minicmd normal part_apple \
|
jpeg loadenv lvm mdraid09 mdraid1x minicmd normal part_apple \
|
||||||
part_msdos part_gpt password_pbkdf2 png reboot search \
|
part_msdos part_gpt password_pbkdf2 png reboot search \
|
||||||
search_fs_uuid search_fs_file search_label sleep syslinuxcfg \
|
search_fs_uuid search_fs_file search_label sleep syslinuxcfg \
|
||||||
test tftp video xfs"
|
test tftp video xfs"
|
||||||
@ -508,6 +510,11 @@ cat << EOF > ${RPM_BUILD_ROOT}%{_sysconfdir}/prelink.conf.d/grub2.conf
|
|||||||
-b /usr/sbin/grub2-sparc64-setup
|
-b /usr/sbin/grub2-sparc64-setup
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
%ifarch %{efiarchs}
|
||||||
|
mkdir -p boot/efi/EFI/%{efidir}/
|
||||||
|
ln -s /boot/efi/EFI/%{efidir}/grubenv boot/grub2/grubenv
|
||||||
|
%endif
|
||||||
|
|
||||||
%clean
|
%clean
|
||||||
rm -rf $RPM_BUILD_ROOT
|
rm -rf $RPM_BUILD_ROOT
|
||||||
|
|
||||||
@ -555,6 +562,7 @@ fi
|
|||||||
%config(noreplace) %{_sysconfdir}/%{name}.cfg
|
%config(noreplace) %{_sysconfdir}/%{name}.cfg
|
||||||
%ghost %config(noreplace) /boot/%{name}/grub.cfg
|
%ghost %config(noreplace) /boot/%{name}/grub.cfg
|
||||||
%doc grub-%{tarversion}/COPYING
|
%doc grub-%{tarversion}/COPYING
|
||||||
|
%config(noreplace) %ghost /boot/grub2/grubenv
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%ifarch %{efiarchs}
|
%ifarch %{efiarchs}
|
||||||
@ -565,6 +573,10 @@ fi
|
|||||||
%attr(0755,root,root)/boot/efi/EFI/%{efidir}/fonts
|
%attr(0755,root,root)/boot/efi/EFI/%{efidir}/fonts
|
||||||
%ghost %config(noreplace) /boot/efi/EFI/%{efidir}/grub.cfg
|
%ghost %config(noreplace) /boot/efi/EFI/%{efidir}/grub.cfg
|
||||||
%doc grub-%{tarversion}/COPYING
|
%doc grub-%{tarversion}/COPYING
|
||||||
|
/boot/grub2/grubenv
|
||||||
|
# I know 0700 seems strange, but it lives on FAT so that's what it'll
|
||||||
|
# get no matter what we do.
|
||||||
|
%config(noreplace) %ghost %attr(0700,root,root)/boot/efi/EFI/%{efidir}/grubenv
|
||||||
|
|
||||||
%files efi-modules
|
%files efi-modules
|
||||||
%defattr(-,root,root,-)
|
%defattr(-,root,root,-)
|
||||||
|
Loading…
Reference in New Issue
Block a user