arrfab / rpms / shim-signed

Forked from rpms/shim-signed 4 years ago
Clone
670361
Name:           shim-signed
670361
Version:        15
670361
Release:        1%{?dist}%{?buildid}
670361
Summary:        First-stage UEFI bootloader
670361
%define unsigned_release 1%{?dist}
670361
670361
License:        BSD
670361
URL:            https://github.com/rhboot/shim/
670361
# incorporate mokutil for packaging simplicity
670361
%global mokutil_version 0.3.0
670361
Source0:        https://github.com/lcp/mokutil/archive/mokutil-%{mokutil_version}.tar.gz
670361
Source1:        secureboot.cer
670361
Source2:        securebootca.cer
670361
Source10:       shimx64.efi
670361
Source11:       shimia32.efi
670361
Source12:       shimaa64.efi
670361
Source20:       BOOTX64.CSV
670361
Source21:       BOOTIA32.CSV
670361
Source22:       BOOTAA64.CSV
670361
670361
Patch0001: 0001-Fix-the-potential-buffer-overflow.patch
670361
Patch0002: 0002-Fix-the-32bit-signedness-comparison.patch
670361
Patch0003: 0003-Build-with-fshort-wchar-so-toggle-passwords-work-rig.patch
670361
Patch0004: 0004-Don-t-allow-sha1-on-the-mokutil-command-line.patch
670361
Patch0005: 0005-Make-all-efi_guid_t-const.patch
670361
Patch0006: 0006-mokutil-be-explicit-about-file-modes-in-all-cases.patch
670361
Patch0007: 0007-Add-bash-completion-file.patch
670361
Patch0008: 0008-Fix-typo-in-error-message-when-the-system-lacks-Secu.patch
670361
Patch0009: 0009-list_keys_in_var-check-errno-correctly-not-ret-twice.patch
670361
Patch0010: 0010-generate_hash-generate_pw_hash-don-t-use-strlen-for-.patch
670361
670361
%ifarch x86_64
670361
%global efiarch X64
670361
%global efiarchlc x64
670361
%global shimsrc %{SOURCE10}
670361
%global bootsrc %{SOURCE20}
670361
670361
%global shimsrcia32 %{SOURCE11}
670361
%global bootsrcia32 %{SOURCE21}
670361
%define unsigned_dir_ia32 %{_datadir}/shim/ia32-%{version}-%{unsigned_release}/
670361
%endif
670361
%ifarch aarch64
670361
%global efiarch AA64
670361
%global efiarchlc aa64
670361
%global shimsrc %{SOURCE12}
670361
%global bootsrc %{SOURCE22}
670361
%endif
670361
%define unsigned_dir %{_datadir}/shim/%{efiarchlc}-%{version}-%{unsigned_release}/
670361
670361
BuildRequires: git
670361
BuildRequires: openssl-devel openssl
670361
BuildRequires: pesign >= 0.106-5%{dist}
670361
BuildRequires: efivar-devel
670361
BuildRequires: shim-unsigned-%{efiarchlc} = %{version}-%{unsigned_release}
670361
%ifarch x86_64
670361
BuildRequires: shim-unsigned-ia32 = %{version}-%{unsigned_release}
670361
%endif
670361
670361
# for mokutil's configure
670361
BuildRequires: autoconf automake
670361
670361
# Shim is only required on platforms implementing the UEFI secure boot
670361
# protocol. The only one of those we currently wish to support is 64-bit x86.
670361
# Adding further platforms will require adding appropriate relocation code.
670361
ExclusiveArch: x86_64 aarch64
670361
670361
%define debug_package \
670361
%ifnarch noarch\
670361
%global __debug_package 1\
670361
%package -n mokutil-debuginfo\
670361
Summary: Debug information for package %{name}\
670361
Group: Development/Debug\
670361
AutoReqProv: 0\
670361
%description -n mokutil-debuginfo\
670361
This package provides debug information for package %{name}.\
670361
Debug information is useful when developing applications that use this\
670361
package or when debugging this package.\
670361
%files -n mokutil-debuginfo -f debugfiles.list\
670361
%defattr(-,root,root,-)\
670361
%endif\
670361
%{nil}
670361
670361
# Figure out the right file path to use
670361
%global efidir %(eval echo $(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/'))
670361
670361
%define ca_signed_arches x86_64
670361
%define rh_signed_arches x86_64 aarch64
670361
670361
%description
670361
Initial UEFI bootloader that handles chaining to a trusted full bootloader
670361
under secure boot environments. This package contains the version signed by
670361
the UEFI signing service.
670361
670361
%package -n shim-%{efiarchlc}
670361
Summary: First-stage UEFI bootloader
670361
Requires: mokutil = %{version}-%{release}
670361
Provides: shim = %{version}-%{release}
670361
Obsoletes: shim <= 12
670361
# Shim uses OpenSSL, but cannot use the system copy as the UEFI ABI is not
670361
# compatible with SysV (there's no red zone under UEFI) and there isn't a
670361
# POSIX-style C library.
670361
# BuildRequires: OpenSSL
670361
Provides: bundled(openssl) = 0.9.8zb
670361
670361
%description -n shim-%{efiarchlc}
670361
Initial UEFI bootloader that handles chaining to a trusted full bootloader
670361
under secure boot environments. This package contains the version signed by
670361
the UEFI signing service.
670361
670361
%ifarch x86_64
670361
%package -n shim-ia32
670361
Summary: First-stage UEFI bootloader
670361
Requires: mokutil = %{version}-%{release}
670361
# Shim uses OpenSSL, but cannot use the system copy as the UEFI ABI is not
670361
# compatible with SysV (there's no red zone under UEFI) and there isn't a
670361
# POSIX-style C library.
670361
# BuildRequires: OpenSSL
670361
Provides: bundled(openssl) = 0.9.8zb
670361
670361
%description -n shim-ia32
670361
Initial UEFI bootloader that handles chaining to a trusted full bootloader
670361
under secure boot environments. This package contains the version signed by
670361
the UEFI signing service.
670361
%endif
670361
670361
%package -n mokutil
670361
Summary: Utilities for managing Secure Boot/MoK keys.
670361
670361
%description -n mokutil
670361
Utilities for managing the "Machine's Own Keys" list.
670361
670361
%prep
670361
%setup -T -q -a 0 -n shim-signed-%{version} -c
670361
git init
670361
git config user.email "example@example.com"
670361
git config user.name "rpmbuild -bp"
670361
git add .
670361
git commit -a -q -m "%{version} baseline."
670361
cd mokutil-%{mokutil_version}
670361
git am --ignore-whitespace --directory=mokutil-%{mokutil_version} %{patches} 
670361
git config --unset user.email
670361
git config --unset user.name
670361
cd ..
670361
670361
%build
670361
%define vendor_token_str %{expand:%%{nil}%%{?vendor_token_name:-t "%{vendor_token_name}"}}
670361
%define vendor_cert_str %{expand:%%{!?vendor_cert_nickname:-c "Red Hat Test Certificate"}%%{?vendor_cert_nickname:-c "%%{vendor_cert_nickname}"}}
670361
670361
%ifarch %{ca_signed_arches}
670361
pesign -i %{shimsrc} -h -P > shim%{efiarchlc}.hash
670361
if ! cmp shim%{efiarchlc}.hash %{unsigned_dir}shim%{efiarchlc}.hash ; then
670361
  echo Invalid signature\! > /dev/stderr
670361
  echo saved hash is $(cat %{unsigned_dir}shim%{efiarchlc}.hash) > /dev/stderr
670361
  echo shim%{efiarchlc}.efi hash is $(cat shim%{efiarchlc}.hash) > /dev/stderr
670361
  exit 1
670361
fi
670361
cp %{shimsrc} shim%{efiarchlc}.efi
670361
%ifarch x86_64
670361
pesign -i %{shimsrcia32} -h -P > shimia32.hash
670361
if ! cmp shimia32.hash %{unsigned_dir_ia32}shimia32.hash ; then
670361
  echo Invalid signature\! > /dev/stderr
670361
  echo saved hash is $(cat %{unsigned_dir_ia32}shimia32.hash) > /dev/stderr
670361
  echo shimia32.efi hash is $(cat shimia32.hash) > /dev/stderr
670361
  exit 1
670361
fi
670361
cp %{shimsrcia32} shimia32.efi
670361
%endif
670361
%endif
670361
%ifarch %{rh_signed_arches}
670361
%pesign -s -i %{unsigned_dir}shim%{efiarchlc}.efi -a %{SOURCE2} -c %{SOURCE1} -n redhatsecureboot301 -o shim%{efiarchlc}-%{efidir}.efi
670361
%ifarch x86_64
670361
%pesign -s -i %{unsigned_dir_ia32}shimia32.efi -a %{SOURCE2} -c %{SOURCE1} -n redhatsecureboot301 -o shimia32-%{efidir}.efi
670361
%endif
670361
%endif
670361
%ifarch %{rh_signed_arches}
670361
%ifnarch %{ca_signed_arches}
670361
cp shim%{efiarchlc}-%{efidir}.efi shim%{efiarchlc}.efi
670361
%endif
670361
%endif
670361
670361
%pesign -s -i %{unsigned_dir}mm%{efiarchlc}.efi -o mm%{efiarchlc}.efi -a %{SOURCE2} -c %{SOURCE1} -n redhatsecureboot301
670361
%pesign -s -i %{unsigned_dir}fb%{efiarchlc}.efi -o fb%{efiarchlc}.efi -a %{SOURCE2} -c %{SOURCE1} -n redhatsecureboot301
670361
670361
%ifarch x86_64
670361
%pesign -s -i %{unsigned_dir_ia32}mmia32.efi -o mmia32.efi -a %{SOURCE2} -c %{SOURCE1} -n redhatsecureboot301
670361
%pesign -s -i %{unsigned_dir_ia32}fbia32.efi -o fbia32.efi -a %{SOURCE2} -c %{SOURCE1} -n redhatsecureboot301
670361
%endif
670361
670361
cd mokutil-%{mokutil_version}
670361
./autogen.sh
670361
%configure
670361
make %{?_smp_mflags}
670361
670361
%install
670361
rm -rf $RPM_BUILD_ROOT
670361
install -D -d -m 0700 $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/
670361
install -m 0700 shim%{efiarchlc}.efi $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/shim%{efiarchlc}.efi
670361
install -m 0700 shim%{efiarchlc}-%{efidir}.efi $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/shim%{efiarchlc}-%{efidir}.efi
670361
install -m 0700 mm%{efiarchlc}.efi $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/mm%{efiarchlc}.efi
670361
install -m 0700 %{bootsrc} $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/BOOT%{efiarch}.CSV
670361
670361
install -D -d -m 0700 $RPM_BUILD_ROOT/boot/efi/EFI/BOOT/
670361
install -m 0700 shim%{efiarchlc}.efi $RPM_BUILD_ROOT/boot/efi/EFI/BOOT/BOOT%{efiarch}.EFI
670361
install -m 0700 fb%{efiarchlc}.efi $RPM_BUILD_ROOT/boot/efi/EFI/BOOT/fb%{efiarchlc}.efi
670361
670361
%ifarch aarch64
670361
# In case old boot entries aren't updated
670361
install -m 0700 %{shimsrc} $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/shim.efi
670361
%endif
670361
670361
%ifarch x86_64
670361
# In case old boot entries aren't updated
670361
install -m 0700 shimx64.efi $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/shim.efi
670361
install -m 0700 %{bootsrc} $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/BOOT.CSV
670361
670361
install -m 0700 shimia32.efi $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/shimia32.efi
670361
install -m 0700 shimia32.efi $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/shimia32.efi
670361
install -m 0700 shimia32-%{efidir}.efi $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/shimia32-%{efidir}.efi
670361
install -m 0700 mmia32.efi $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/mmia32.efi
670361
install -m 0700 %{bootsrcia32} $RPM_BUILD_ROOT/boot/efi/EFI/%{efidir}/BOOTIA32.CSV
670361
670361
install -m 0700 shimia32.efi $RPM_BUILD_ROOT/boot/efi/EFI/BOOT/BOOTIA32.EFI
670361
install -m 0700 fbia32.efi $RPM_BUILD_ROOT/boot/efi/EFI/BOOT/fbia32.efi
670361
%endif
670361
670361
cd mokutil-%{mokutil_version}
670361
make PREFIX=%{_prefix} LIBDIR=%{_libdir} DESTDIR=%{buildroot} install
670361
670361
%files -n shim-%{efiarchlc}
670361
%defattr(0700,root,root,-)
670361
/boot/efi/EFI/%{efidir}/shim%{efiarchlc}.efi
670361
/boot/efi/EFI/%{efidir}/shim%{efiarchlc}-%{efidir}.efi
670361
/boot/efi/EFI/%{efidir}/mm%{efiarchlc}.efi
670361
/boot/efi/EFI/%{efidir}/BOOT%{efiarch}.CSV
670361
/boot/efi/EFI/BOOT/BOOT%{efiarch}.EFI
670361
/boot/efi/EFI/BOOT/fb%{efiarchlc}.efi
670361
/boot/efi/EFI/%{efidir}/shim.efi
670361
670361
%ifarch x86_64
670361
/boot/efi/EFI/%{efidir}/BOOT.CSV
670361
670361
%files -n shim-ia32
670361
%defattr(0700,root,root,-)
670361
/boot/efi/EFI/%{efidir}/shimia32.efi
670361
/boot/efi/EFI/%{efidir}/shimia32-%{efidir}.efi
670361
/boot/efi/EFI/%{efidir}/mmia32.efi
670361
/boot/efi/EFI/%{efidir}/BOOTIA32.CSV
670361
/boot/efi/EFI/BOOT/BOOTIA32.EFI
670361
/boot/efi/EFI/BOOT/fbia32.efi
670361
%endif
670361
670361
%files -n mokutil
670361
%{!?_licensedir:%global license %%doc}
670361
%license mokutil-%{mokutil_version}/COPYING
670361
%doc mokutil-%{mokutil_version}/README
670361
%{_bindir}/mokutil
670361
%{_mandir}/man1/*
670361
%{_datadir}/bash-completion/completions/mokutil
670361
670361
%changelog
670361
* Fri Jul 20 2018 Peter Jones <pjones@redhat.com> - 15-1
670361
- Update to shim version 15
670361
  Resolves: rhbz#1589962
670361
670361
* Wed Jul 11 2018 Peter Jones <pjones@redhat.com> - 12-3
670361
- Fix broken file owner/modes
670361
  Resolves: rhbz#1595677
670361
670361
* Sat Jun 23 2018 Peter Jones <pjones@redhat.com> - 12-2
670361
- Fix /boot/efi/... permissions to match the filesystem's requirements
670361
  Related: rhbz#1512749
670361
- Minor .spec cleanups
670361
  Related: rhbz#1512749
670361
670361
* Mon May 01 2017 Peter Jones <pjones@redhat.com> - 12-1
670361
- Update to 12-1 to work around a signtool.exe bug
670361
  Resolves: rhbz#1445393
670361
670361
* Mon Apr 24 2017 Peter Jones <pjones@redhat.com> - 11-4
670361
- Another shot at better obsoletes.
670361
  Related: rhbz#1310764
670361
670361
* Mon Apr 24 2017 Peter Jones <pjones@redhat.com> - 11-3
670361
- Fix Obsoletes
670361
  Related: rhbz#1310764
670361
670361
* Thu Apr 13 2017 Peter Jones <pjones@redhat.com> - 11-2
670361
- Make sure Aarch64 still has shim.efi as well
670361
  Related: rhbz#1310766
670361
670361
* Wed Apr 12 2017 Peter Jones <pjones@redhat.com> - 11-1
670361
- Rebuild with signed shim
670361
  Related: rhbz#1310766
670361
670361
* Mon Apr 03 2017 Peter Jones <pjones@redhat.com> - 11-0.1
670361
- Update to 11-0.1 to match shim-11-1
670361
  Related: rhbz#1310766
670361
- Fix regression in PE loader
670361
  Related: rhbz#1310766
670361
- Fix case where BDS invokes us wrong and we exec shim again as a result
670361
  Related: rhbz#1310766
670361
670361
* Mon Mar 27 2017 Peter Jones <pjones@redhat.com> - 10-0.1
670361
- Support ia32
670361
  Resolves: rhbz#1310766
670361
- Handle various different load option implementation differences
670361
- TPM 1 and TPM 2 support.
670361
- Update to OpenSSL 1.0.2k
670361
670361
* Mon Jul 20 2015 Peter Jones <pjones@redhat.com> - 0.9-2
670361
- Apparently I'm *never* going to learn to build this in the right target
670361
  the first time through.
670361
  Related: rhbz#1100048
670361
670361
* Mon Jun 29 2015 Peter Jones <pjones@redhat.com> - 0.9-0.1
670361
- Bump version for 0.9
670361
  Also use mokutil-0.3.0
670361
  Related: rhbz#1100048
670361
670361
* Tue Jun 23 2015 Peter Jones <pjones@redhat.com> - 0.7-14.1
670361
- Fix mokutil_version usage.
670361
  Related: rhbz#1100048
670361
670361
* Mon Jun 22 2015 Peter Jones <pjones@redhat.com> - 0.7-14
670361
- Pull in aarch64 build so they can compose that tree.
670361
  (-14 to match -unsigned)
670361
  Related: rhbz#1100048
670361
670361
* Wed Feb 25 2015 Peter Jones <pjones@redhat.com> - 0.7-12
670361
- Fix some minor build bugs on Aarch64
670361
  Related: rhbz#1190191
670361
670361
* Tue Feb 24 2015 Peter Jones <pjones@redhat.com> - 0.7-11
670361
- Fix section loading on Aarch64
670361
  Related: rhbz#1190191
670361
670361
* Wed Dec 17 2014 Peter Jones <pjones@redhat.com> - 0.7-10
670361
- Rebuild for Aarch64 to get \EFI\BOOT\BOOTAA64.EFI named right.
670361
  (I managed to fix the inputs but not the outputs in -9.)
670361
  Related: rhbz#1100048
670361
670361
* Wed Dec 17 2014 Peter Jones <pjones@redhat.com> - 0.7-9
670361
- Rebuild for Aarch64 to get \EFI\BOOT\BOOTAA64.EFI named right.
670361
  Related: rhbz#1100048
670361
670361
* Tue Oct 21 2014 Peter Jones <pjones@redhat.com> - 0.7-8
670361
- Build for aarch64 as well 
670361
  Related: rhbz#1100048
670361
- out-of-bounds memory read flaw in DHCPv6 packet processing
670361
  Resolves: CVE-2014-3675
670361
- heap-based buffer overflow flaw in IPv6 address parsing
670361
  Resolves: CVE-2014-3676
670361
- memory corruption flaw when processing Machine Owner Keys (MOKs)
670361
  Resolves: CVE-2014-3677
670361
670361
* Tue Sep 23 2014 Peter Jones <pjones@redhat.com> - 0.7-7
670361
- Make sure we use the right keys on Aarch64.
670361
  (It's only a demo at this stage.)
670361
  Related: rhbz#1100048
670361
670361
* Tue Sep 23 2014 Peter Jones <pjones@redhat.com> - 0.7-6
670361
- Add ARM Aarch64.
670361
  Related: rhbz#1100048
670361
670361
* Thu Feb 27 2014 Peter Jones <pjones@redhat.com> - 0.7-5.2
670361
- Get the right signatures on shim-redhat.efi
670361
  Related: rhbz#1064449
670361
670361
* Thu Feb 27 2014 Peter Jones <pjones@redhat.com> - 0.7-5.1
670361
- Update for signed shim for RHEL 7
670361
  Resolves: rhbz#1064449
670361
670361
* Thu Nov 21 2013 Peter Jones <pjones@redhat.com> - 0.7-5
670361
- Fix shim-unsigned deps.
670361
  Related: rhbz#1032583
670361
670361
* Thu Nov 21 2013 Peter Jones <pjones@redhat.com> - 0.7-4
670361
- Make dhcp4 work better.
670361
  Related: rhbz#1032583
670361
670361
* Thu Nov 14 2013 Peter Jones <pjones@redhat.com> - 0.7-3
670361
- Make lockdown include UEFI and other KEK/DB entries.
670361
  Related: rhbz#1030492
670361
670361
* Fri Nov 08 2013 Peter Jones <pjones@redhat.com> - 0.7-2
670361
- Handle SetupMode better in lockdown as well
670361
  Related: rhbz#996863
670361
670361
* Wed Nov 06 2013 Peter Jones <pjones@redhat.com> - 0.7-1
670361
- Don't treat SetupMode variable's presence as meaning we're in SetupMode.
670361
  Related: rhbz#996863
670361
670361
* Wed Nov 06 2013 Peter Jones <pjones@redhat.com> - 0.6-3
670361
- Use the correct CA and signer certificates.
670361
  Related: rhbz#996863
670361
670361
* Thu Oct 31 2013 Peter Jones <pjones@redhat.com> - 0.6-1
670361
- Update to 0.6-1
670361
  Resolves: rhbz#1008379
670361
670361
* Wed Aug 07 2013 Peter Jones <pjones@redhat.com> - 0.4-3.2
670361
- Depend on newer pesign.
670361
  Related: rhbz#989442
670361
670361
* Tue Aug 06 2013 Peter Jones <pjones@redhat.com> - 0.4-3.1
670361
- Rebuild with newer pesign
670361
  Related: rhbz#989442
670361
670361
* Tue Aug 06 2013 Peter Jones <pjones@redhat.com> - 0.4-3
670361
- Update for RHEL signing with early test keys.
670361
  Related: rhbz#989442
670361
670361
* Thu Jun 20 2013 Peter Jones <pjones@redhat.com> - 0.4-1
670361
- Provide a fallback for uninitialized Boot#### and BootOrder
670361
  Resolves: rhbz#963359
670361
- Move all signing from shim-unsigned to here
670361
- properly compare our generated hash from shim-unsigned with the hash of
670361
  the signed binary (as opposed to doing it manually)
670361
670361
* Fri May 31 2013 Peter Jones <pjones@redhat.com> - 0.2-4.4
670361
- Re-sign to get alignments that match the new specification.
670361
  Resolves: rhbz#963361
670361
670361
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2-4.3
670361
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
670361
670361
* Wed Jan 02 2013 Peter Jones <pjones@redhat.com> - 0.2-3.3
670361
- Add obsoletes and provides for earlier shim-signed packages, to cover
670361
  the package update cases where previous versions were installed.
670361
  Related: rhbz#888026
670361
670361
* Mon Dec 17 2012 Peter Jones <pjones@redhat.com> - 0.2-3.2
670361
- Make the shim-unsigned dep be on the subpackage.
670361
670361
* Sun Dec 16 2012 Peter Jones <pjones@redhat.com> - 0.2-3.1
670361
- Rebuild to provide "shim" package directly instead of just as a Provides:
670361
670361
* Sat Dec 15 2012 Peter Jones <pjones@redhat.com> - 0.2-3
670361
- Also provide shim-fedora.efi, signed only by the fedora signer.
670361
- Fix the fedora signature on the result to actually be correct.
670361
- Update for shim-unsigned 0.2-3
670361
670361
* Mon Dec 03 2012 Peter Jones <pjones@redhat.com> - 0.2-2
670361
- Initial build