2013-01-17 09:43:06 +00:00
#
# spec file for package shim
#
2021-01-22 04:22:49 +00:00
# Copyright (c) 2021 SUSE LLC
2013-01-17 09:43:06 +00:00
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
2019-08-16 04:12:38 +00:00
# Please submit bugfixes or comments via https://bugs.opensuse.org/
2013-01-17 09:43:06 +00:00
#
2013-02-07 13:54:45 +00:00
# needssslcertforbuild
2016-12-05 08:35:58 +00:00
2018-01-04 03:48:47 +00:00
%undefine _debuginfo_subpackages
2015-07-20 10:27:18 +00:00
%undefine _build_create_debug
2019-01-25 09:28:34 +00:00
%ifarch aarch64
%define grubplatform arm64-efi
%else
%define grubplatform %{_target_cpu}-efi
%endif
2019-02-15 03:26:41 +00:00
%if %{defined sle_version} && 0%{?sle_version} <= 150000
%define sysefidir /usr/lib64/efi
%else
2019-01-25 09:28:34 +00:00
%define sysefibasedir %{_datadir}/efi
%define sysefidir %{sysefibasedir}/%{_target_cpu}
2020-03-30 06:34:16 +00:00
%if "%{grubplatform}" == "x86_64-efi" && 0%{?suse_version} < 1600
2019-02-15 03:26:41 +00:00
# provide compatibility sym-link for residual kiwi, etc.
%define shim_lib64_share_compat 1
%endif
2019-01-25 09:28:34 +00:00
%endif
2015-07-20 10:27:18 +00:00
2013-01-17 09:43:06 +00:00
Name : shim
2021-03-31 08:55:10 +00:00
Version : 15.4
2013-01-17 09:43:06 +00:00
Release : 0
Summary : UEFI shim loader
License : BSD-2-Clause
Group : System/Boot
2020-03-16 09:43:20 +00:00
URL : https://github.com/rhboot/shim
2018-12-20 08:53:52 +00:00
Source : %{name} -%{version} .tar.bz2
2013-08-09 09:33:45 +00:00
# run "extract_signature.sh shim.efi" where shim.efi is the binary
# with the signature from the UEFI signing service.
2016-12-05 08:35:58 +00:00
# Note: For signature requesting, check SIGNATURE_UPDATE.txt
2018-09-07 09:39:12 +00:00
Source1 : signature-opensuse.x86_64.asc
2013-01-29 13:42:18 +00:00
Source2 : openSUSE-UEFI-CA-Certificate.crt
2013-02-07 13:54:45 +00:00
Source3 : shim-install
2013-02-27 14:53:25 +00:00
Source4 : SLES-UEFI-CA-Certificate.crt
2013-08-09 09:33:45 +00:00
Source5 : extract_signature.sh
Source6 : attach_signature.sh
Source7 : show_hash.sh
2013-08-28 09:32:58 +00:00
Source8 : show_signatures.sh
2018-12-20 08:53:52 +00:00
Source9 : timestamp.pl
Source10 : strip_signature.sh
Source11 : signature-sles.x86_64.asc
Source12 : signature-opensuse.aarch64.asc
Source13 : signature-sles.aarch64.asc
2020-08-06 03:10:22 +00:00
Source50 : dbx-cert.tar.xz
2021-04-28 10:01:26 +00:00
# vendor-dbx*.bin are generated by generate-vendor-dbx.sh in dbx-cert.tar.xz
2020-08-06 03:10:22 +00:00
Source51 : vendor-dbx.bin
2021-04-28 10:01:26 +00:00
Source52 : vendor-dbx-sles.bin
Source53 : vendor-dbx-opensuse.bin
2016-12-05 08:35:58 +00:00
Source99 : SIGNATURE_UPDATE.txt
2017-09-13 04:49:11 +00:00
# PATCH-FIX-SUSE shim-arch-independent-names.patch glin@suse.com -- Use the Arch-independent names
2018-12-20 08:53:52 +00:00
Patch1 : shim-arch-independent-names.patch
2015-07-20 10:27:18 +00:00
# PATCH-FIX-OPENSUSE shim-change-debug-file-path.patch glin@suse.com -- Change the default debug file path
2018-12-20 08:53:52 +00:00
Patch2 : shim-change-debug-file-path.patch
2020-11-03 06:49:18 +00:00
# PATCH-FIX-SUSE shim-bsc1177315-verify-eku-codesign.patch bsc#1177315 glin@suse.com -- Verify CodeSign in the signer's EKU
2021-03-24 03:16:20 +00:00
Patch3 : shim-bsc1177315-verify-eku-codesign.patch
2020-11-03 06:49:18 +00:00
# PATCH-FIX-UPSTREAM shim-bsc1177789-fix-null-pointer-deref-AuthenticodeVerify.patch bsc#1177789 glin@suse.com -- Fix the NULL pointer dereference in AuthenticodeVerify()
2021-03-24 03:16:20 +00:00
Patch4 : shim-bsc1177789-fix-null-pointer-deref-AuthenticodeVerify.patch
2021-04-08 09:16:46 +00:00
# PATCH-FIX-SUSE remove_build_id.patch -- Remove the build ID to make the binary reproducible when building with AArch64 container
Patch5 : remove_build_id.patch
# PATCH-FIX-UPSTREAM shim-bsc1184454-allocate-mok-config-table-BS.patch bsc#1184454 glin@suse.com -- Allocate MOK config table as BootServicesData to avoid the error message from linux kernel
Patch6 : shim-bsc1184454-allocate-mok-config-table-BS.patch
2021-05-06 03:35:27 +00:00
# PATCH-FIX-UPSTREAM shim-bsc1185441-fix-handling-of-ignore_db-and-user_insecure_mode.patch bsc#1184454 glin@suse.com -- Handle ignore_db and user_insecure_mode correctly
Patch7 : shim-bsc1185441-fix-handling-of-ignore_db-and-user_insecure_mode.patch
# PATCH-FIX-UPSTREAM shim-bsc1185621-relax-max-var-sz-check.patch bsc#1185621 glin@suse.com -- Relax the maximum variable size check for u-boot
Patch8 : shim-bsc1185621-relax-max-var-sz-check.patch
2021-05-19 01:26:58 +00:00
# PATCH-FIX-UPSTREAM shim-bsc1185261-relax-import_mok_state_check.patch bsc#1185261 glin@suse.com -- Relax the check for import_mok_state() when Secure Boot is off
Patch9 : shim-bsc1185261-relax-import_mok_state-check.patch
2021-03-24 03:16:20 +00:00
BuildRequires : dos2unix
2013-01-17 09:43:06 +00:00
BuildRequires : mozilla-nss-tools
BuildRequires : openssl >= 0.9.8
BuildRequires : pesign
2013-02-07 13:54:45 +00:00
BuildRequires : pesign-obs-integration
2017-02-16 02:17:33 +00:00
%if 0%{?suse_version} > 1320
BuildRequires : update-bootloader-rpm-macros
%endif
%if 0%{?update_bootloader_requires:1}
%update_bootloader_requires
%else
2013-04-03 06:25:09 +00:00
Requires : perl-Bootloader
2017-02-16 02:17:33 +00:00
%endif
2013-01-17 09:43:06 +00:00
BuildRoot : %{_tmppath} /%{name} -%{version} -build
2014-08-04 09:46:50 +00:00
# For shim-install script
2019-01-25 09:28:34 +00:00
Requires : grub2-%{grubplatform}
2020-09-07 01:45:46 +00:00
ExclusiveArch : x86_64 aarch64
2013-01-17 09:43:06 +00:00
%description
shim is a trivial EFI application that, when run, attempts to open and
execute another application.
2015-07-20 10:27:18 +00:00
%package -n shim-debuginfo
Summary : UEFI shim loader - debug symbols
2018-01-04 03:48:47 +00:00
Group : Development/Debug
2015-07-20 10:27:18 +00:00
%description -n shim-debuginfo
The debug symbols of UEFI shim loader
%package -n shim-debugsource
Summary : UEFI shim loader - debug source
2018-01-04 03:48:47 +00:00
Group : Development/Debug
2013-01-17 09:43:06 +00:00
2015-07-20 10:27:18 +00:00
%description -n shim-debugsource
The source code of UEFI shim loader
2013-01-17 09:43:06 +00:00
%prep
%setup -q
%patch1 -p1
2017-08-22 06:17:06 +00:00
%patch2 -p1
2017-08-25 03:47:51 +00:00
%patch3 -p1
%patch4 -p1
2021-04-08 09:16:46 +00:00
%patch5 -p1
%patch6 -p1
2021-05-06 03:35:27 +00:00
%patch7 -p1
%patch8 -p1
2021-05-19 01:26:58 +00:00
%patch9 -p1
2021-03-24 03:16:20 +00:00
%build
# generate the vendor SBAT metadata
%if 0%{?is_opensuse} == 1 || 0%{?sle_version} == 0
distro_id=" o p e n s u s e "
distro_name=" T h e o p e n S U S E p r o j e c t "
2021-01-22 04:22:49 +00:00
%else
2021-03-24 03:16:20 +00:00
distro_id=" s l e "
distro_name=" S U S E L i n u x E n t e r p r i s e "
2017-08-22 06:17:06 +00:00
%endif
2021-03-24 03:16:20 +00:00
distro_sbat=1
sbat=" s h i m . $ { d i s t r o _ i d } , $ { d i s t r o _ s b a t } , $ { d i s t r o _ n a m e } , %{name} , %{version} , m a i l : s e c u r i t y - t e a m @ s u s e . d e "
echo " $ { s b a t } " > data/sbat.vendor.csv
2019-01-25 09:28:34 +00:00
2013-08-29 08:43:23 +00:00
# first, build MokManager and fallback as they don't depend on a
# specific certificate
2021-03-24 03:16:20 +00:00
make RELEASE=0 \
2018-01-04 08:44:05 +00:00
MMSTEM=MokManager FBSTEM=fallback \
MokManager.efi.debug fallback.efi.debug \
MokManager.efi fallback.efi
2013-08-29 08:43:23 +00:00
# now build variants of shim that embed different certificates
default=''
suffixes=(opensuse sles)
# check whether the project cert is a known one. If it is we build
# just one shim that embeds this specific cert. If it's a devel
# project we build all variants to simplify testing.
2013-02-27 14:53:25 +00:00
if test -e %{_sourcedir} /_projectcert.crt ; then
prjsubject=$(openssl x509 -in %{_sourcedir} /_projectcert.crt -noout -subject_hash)
prjissuer=$(openssl x509 -in %{_sourcedir} /_projectcert.crt -noout -issuer_hash)
opensusesubject=$(openssl x509 -in %{SOURCE2} -noout -subject_hash)
slessubject=$(openssl x509 -in %{SOURCE4} -noout -subject_hash)
2021-04-28 10:01:26 +00:00
if test " $ p r j i s s u e r " = " $ o p e n s u s e s u b j e c t " ; then
2013-08-29 08:43:23 +00:00
suffixes=(opensuse)
elif test " $ p r j i s s u e r " = " $ s l e s s u b j e c t " ; then
suffixes=(sles)
elif test " $ p r j s u b j e c t " = " $ p r j i s s u e r " ; then
suffixes=(devel opensuse sles)
2013-02-27 14:53:25 +00:00
fi
2013-08-29 08:43:23 +00:00
fi
for suffix in " $ { s u f f i x e s [ @ ] } " ; do
if test " $ s u f f i x " = " o p e n s u s e " ; then
cert=%{SOURCE2}
2014-04-29 07:15:01 +00:00
verify='openSUSE Secure Boot CA1'
2021-04-28 10:01:26 +00:00
vendor_dbx=%{SOURCE53}
2018-09-07 09:39:12 +00:00
%ifarch x86_64
2014-04-29 07:15:01 +00:00
signature=%{SOURCE1}
2018-09-07 09:39:12 +00:00
%else
# AArch64 signature
2020-11-04 06:15:49 +00:00
# Disable AArch64 signature attachment temporarily
# until we get a real one.
#signature=%{SOURCE12}
2018-09-07 09:39:12 +00:00
%endif
2013-08-29 08:43:23 +00:00
elif test " $ s u f f i x " = " s l e s " ; then
cert=%{SOURCE4}
2014-04-29 07:15:01 +00:00
verify='SUSE Linux Enterprise Secure Boot CA1'
2021-04-28 10:01:26 +00:00
vendor_dbx=%{SOURCE52}
2018-09-07 09:39:12 +00:00
%ifarch x86_64
2018-12-20 08:53:52 +00:00
signature=%{SOURCE11}
2018-09-07 09:39:12 +00:00
%else
# AArch64 signature
2020-11-04 06:15:49 +00:00
# Disable AArch64 signature attachment temporarily
# until we get a real one.
#signature=%{SOURCE13}
2018-09-07 09:39:12 +00:00
%endif
2013-08-29 08:43:23 +00:00
elif test " $ s u f f i x " = " d e v e l " ; then
cert=%{_sourcedir} /_projectcert.crt
2014-04-29 07:15:01 +00:00
verify=`openssl x509 -in " $ c e r t " -noout -email`
2021-04-28 10:01:26 +00:00
vendor_dbx=%{SOURCE51}
2014-04-29 07:15:01 +00:00
signature=''
2013-08-29 08:43:23 +00:00
test -e " $ c e r t " || continue
else
echo " i n v a l i d s u f f i x "
false
2013-02-27 14:53:25 +00:00
fi
2013-08-29 08:43:23 +00:00
openssl x509 -in $cert -outform DER -out shim-$suffix.der
2021-03-24 03:16:20 +00:00
make RELEASE=0 SHIMSTEM=shim \
2018-01-04 08:44:05 +00:00
VENDOR_CERT_FILE=shim-$suffix.der ENABLE_HTTPBOOT=1 \
2018-03-23 06:40:17 +00:00
DEFAULT_LOADER=" \\ \\ \\ \\ g r u b . e f i " \
2021-04-28 10:01:26 +00:00
VENDOR_DBX_FILE=$vendor_dbx \
2018-01-04 08:44:05 +00:00
shim.efi.debug shim.efi
2014-04-29 07:15:01 +00:00
#
# assert correct certificate embedded
grep -q " $ v e r i f y " shim.efi
2020-08-06 03:10:22 +00:00
# make VENDOR_CERT_FILE=cert.der VENDOR_DBX_FILE=dbx
chmod 755 %{SOURCE9}
2013-08-29 08:43:23 +00:00
# alternative: verify signature
#sbverify --cert MicCorThiParMarRoo_2010-10-05.pem shim-signed.efi
2020-08-06 03:10:22 +00:00
if test -n " $ s i g n a t u r e " ; then
2014-04-29 07:15:01 +00:00
head -1 " $ s i g n a t u r e " > hash1
cp shim.efi shim.efi.bak
# pe header contains timestamp and checksum. we need to
# restore that
2018-12-20 08:53:52 +00:00
%{SOURCE9} --set-from-file " $ s i g n a t u r e " shim.efi
2014-04-29 07:15:01 +00:00
pesign -h -P -i shim.efi > hash2
cat hash1 hash2
if ! cmp -s hash1 hash2; then
echo " E R R O R : $ s u f f i x b i n a r y c h a n g e d , n e e d t o r e q u e s t n e w s i g n a t u r e ! "
2020-08-06 10:25:36 +00:00
%if %{defined shim_enforce_ms_signature} && 0%{?shim_enforce_ms_signature} > 0
2014-09-03 13:40:07 +00:00
false
%endif
2014-04-29 07:15:01 +00:00
mv shim.efi.bak shim-$suffix.efi
rm shim.efi
else
# attach signature
pesign -m " $ s i g n a t u r e " -i shim.efi -o shim-$suffix.efi
rm -f shim.efi
fi
2014-08-12 09:40:50 +00:00
else
mv shim.efi shim-$suffix.efi
2013-08-29 08:43:23 +00:00
fi
2015-07-20 10:27:18 +00:00
mv shim.efi.debug shim-$suffix.debug
2018-12-20 08:53:52 +00:00
# remove the build cert if exists
rm -f shim_cert.h shim.cer shim.crt
# make sure all object files gets rebuilt
rm -f *.o
2013-08-29 08:43:23 +00:00
done
2013-02-27 14:53:25 +00:00
2013-08-29 08:43:23 +00:00
ln -s shim-${suffixes[0]}.efi shim.efi
2015-07-20 10:27:18 +00:00
mv shim-${suffixes[0]}.debug shim.debug
# Collect the source for debugsource
2017-07-22 13:51:59 +00:00
mkdir ../source
find . \( -name " * . c " -o -name " * . h " \) -type f -exec cp --parents -a {} ../source/ \;
mv ../source .
2013-01-17 09:43:06 +00:00
%install
2019-01-25 09:28:34 +00:00
export BRP_PESIGN_FILES='%{sysefidir}/shim*.efi %{sysefidir}/MokManager.efi %{sysefidir}/fallback.efi'
install -d %{buildroot} /%{sysefidir}
cp -a shim*.efi %{buildroot} /%{sysefidir}
install -m 444 shim-*.der %{buildroot} /%{sysefidir}
install -m 644 MokManager.efi %{buildroot} /%{sysefidir} /MokManager.efi
install -m 644 fallback.efi %{buildroot} /%{sysefidir} /fallback.efi
2013-02-07 13:54:45 +00:00
install -d %{buildroot} /%{_sbindir}
install -m 755 %{SOURCE3} %{buildroot} /%{_sbindir} /
2013-07-23 04:44:22 +00:00
# install SUSE certificate
install -d %{buildroot} /%{_sysconfdir} /uefi/certs/
2013-08-29 08:43:23 +00:00
for file in shim-*.der; do
fpr=$(openssl x509 -sha1 -fingerprint -inform DER -noout -in $file | cut -c 18- | cut -d " : " -f 1,2,3,4 | sed 's/://g' )
2018-04-03 09:13:29 +00:00
install -m 644 $file %{buildroot} /%{_sysconfdir} /uefi/certs/${fpr}-shim.crt
2013-08-29 08:43:23 +00:00
done
2019-02-15 03:26:41 +00:00
%if %{defined shim_lib64_share_compat}
[ " %{sysefidir} " != " / u s r / l i b 6 4 / e f i " ] || exit 1
# provide compatibility sym-link for residual "consumers"
install -d %{buildroot} /usr/lib64/efi
ln -srf %{buildroot} /%{sysefidir} /*.efi %{buildroot} /usr/lib64/efi/
2019-01-25 09:28:34 +00:00
%endif
2013-01-17 09:43:06 +00:00
2015-07-20 10:27:18 +00:00
# install the debug symbols
2019-01-25 09:28:34 +00:00
install -d %{buildroot} /usr/lib/debug/%{sysefidir}
install -m 644 shim.debug %{buildroot} /usr/lib/debug/%{sysefidir}
install -m 644 MokManager.efi.debug %{buildroot} /usr/lib/debug/%{sysefidir} /MokManager.debug
install -m 644 fallback.efi.debug %{buildroot} /usr/lib/debug/%{sysefidir} /fallback.debug
2015-07-20 10:27:18 +00:00
# install the debug source
install -d %{buildroot} /usr/src/debug/%{name} -%{version}
cp -r source/* %{buildroot} /usr/src/debug/%{name} -%{version}
2013-01-17 09:43:06 +00:00
%clean
%{?buildroot:%__rm -rf " %{buildroot} " }
2013-04-03 06:25:09 +00:00
%post
2021-04-28 10:01:26 +00:00
%if 0%{?update_bootloader_check_type_reinit_post:1}
2017-02-16 02:17:33 +00:00
%update_bootloader_check_type_reinit_post grub2-efi
%else
2014-05-14 10:01:52 +00:00
/sbin/update-bootloader --reinit || true
2017-02-16 02:17:33 +00:00
%endif
2019-02-15 03:26:41 +00:00
%if %{defined update_bootloader_posttrans}
2017-02-16 02:17:33 +00:00
%posttrans
%{?update_bootloader_posttrans}
2019-02-15 03:26:41 +00:00
%endif
2013-04-03 06:25:09 +00:00
2013-01-17 09:43:06 +00:00
%files
%defattr (-,root,root)
%doc COPYRIGHT
2019-01-25 09:28:34 +00:00
%dir %{?sysefibasedir}
%dir %{sysefidir}
%{sysefidir} /shim.efi
%{sysefidir} /shim-*.efi
%{sysefidir} /shim-*.der
%{sysefidir} /MokManager.efi
%{sysefidir} /fallback.efi
2013-02-07 13:54:45 +00:00
%{_sbindir} /shim-install
2013-07-23 04:44:22 +00:00
%dir %{_sysconfdir} /uefi/
%dir %{_sysconfdir} /uefi/certs/
%{_sysconfdir} /uefi/certs/*.crt
2019-02-15 03:26:41 +00:00
%if %{defined shim_lib64_share_compat}
2019-01-25 09:28:34 +00:00
# provide compatibility sym-link for previous kiwi, etc.
%dir /usr/lib64/efi
/usr/lib64/efi/*.efi
%endif
2013-01-17 09:43:06 +00:00
2015-07-20 10:27:18 +00:00
%files -n shim-debuginfo
%defattr (-,root,root,-)
2019-01-25 09:28:34 +00:00
/usr/lib/debug%{sysefidir} /shim.debug
/usr/lib/debug%{sysefidir} /MokManager.debug
/usr/lib/debug%{sysefidir} /fallback.debug
2015-07-20 10:27:18 +00:00
%files -n shim-debugsource
%defattr (-,root,root,-)
%dir /usr/src/debug/%{name} -%{version}
/usr/src/debug/%{name} -%{version} /*
2013-01-17 09:43:06 +00:00
%changelog