Blame SPECS/keylime.spec

d32965
%global srcname keylime
d32965
%global with_selinux 1
d32965
%global selinuxtype targeted
d32965
d32965
# Package is actually noarch, but it has an optional dependency that is
d32965
# arch-specific.
d32965
%global debug_package %{nil}
d32965
d32965
Name:    keylime
1bad35
Version: 6.5.1
c49324
Release: 1%{?dist}.4
d32965
Summary: Open source TPM software for Bootstrapping and Maintaining Trust
d32965
d32965
URL:            https://github.com/keylime/keylime
d32965
Source0:        https://github.com/keylime/keylime/archive/refs/tags/v%{version}.tar.gz
d32965
Source1:        %{srcname}.sysusers
d32965
Source2:        %{srcname}.te
d32965
Source3:        %{srcname}.if
d32965
Source4:        %{srcname}.fc
d32965
c49324
Patch: 0001-ima-Fix-log-evaluation-on-quick-succession-execution.patch
c49324
Patch: 0002-tpm_bootlog_enrich-Get-DevicePath-length-from-Length.patch
c49324
Patch: 0003-Backport-upsteam-PR-1156.patch
c49324
Patch: 0004-Do-not-use-default-values-that-need-reading-the-conf.patch
c49324
d32965
License: ASL 2.0 and MIT
d32965
d32965
BuildRequires: git-core
d32965
BuildRequires: swig
d32965
BuildRequires: openssl-devel
d32965
BuildRequires: python3-devel
d32965
BuildRequires: python3-dbus
d32965
BuildRequires: python3-jinja2
d32965
BuildRequires: python3-setuptools
d32965
BuildRequires: systemd-rpm-macros
d32965
d32965
Requires: python3-%{srcname} = %{version}-%{release}
d32965
Requires: %{srcname}-base = %{version}-%{release}
d32965
Requires: %{srcname}-verifier = %{version}-%{release}
d32965
Requires: %{srcname}-registrar = %{version}-%{release}
d32965
Requires: %{srcname}-tenant = %{version}-%{release}
d32965
d32965
# Agent.
d32965
Requires: keylime-agent
d32965
Suggests: keylime-agent-rust
d32965
d32965
%{?python_enable_dependency_generator}
d32965
%description
d32965
Keylime is a TPM based highly scalable remote boot attestation
d32965
and runtime integrity measurement solution.
d32965
d32965
%package base
d32965
Summary: The base package contains the default configuration
d32965
License: MIT
d32965
d32965
d32965
Requires(pre): shadow-utils
d32965
Requires: procps-ng
d32965
Requires: tpm2-tss
d32965
d32965
%if 0%{?with_selinux}
d32965
# This ensures that the *-selinux package and all it’s dependencies are not pulled
d32965
# into containers and other systems that do not use SELinux
d32965
Recommends:       (%{srcname}-selinux if selinux-policy-%{selinuxtype})
d32965
%endif
d32965
d32965
%ifarch %efi
d32965
Requires: efivar-libs
d32965
%endif
d32965
d32965
d32965
%description base
d32965
The base package contains the Keylime default configuration
d32965
d32965
%package -n python3-%{srcname}
d32965
Summary: The Python Keylime module
d32965
License: MIT
d32965
d32965
Requires: %{srcname}-base = %{version}-%{release}
d32965
%{?python_provide:%python_provide python3-%{srcname}}
d32965
d32965
Requires: python3-tornado
d32965
Requires: python3-sqlalchemy
d32965
Requires: python3-alembic
d32965
Requires: python3-cryptography
d32965
Requires: python3-pyyaml
d32965
Requires: python3-packaging
d32965
Requires: python3-requests
d32965
Requires: python3-gpg
d32965
Requires: python3-lark-parser
d32965
Requires: python3-pyasn1
d32965
Requires: python3-pyasn1-modules
d32965
Requires: tpm2-tools
c49324
Requires: openssl
d32965
d32965
%description -n python3-%{srcname}
d32965
The python3-keylime module implements the functionality used
d32965
by Keylime components.
d32965
d32965
%package verifier
d32965
Summary: The Python Keylime Verifier component
d32965
License: MIT
d32965
d32965
Requires: %{srcname}-base = %{version}-%{release}
d32965
Requires: python3-%{srcname} = %{version}-%{release}
d32965
d32965
%description verifier
d32965
The Keylime Verifier continuously verifies the integrity state
d32965
of the machine that the agent is running on.
d32965
d32965
%package registrar
d32965
Summary: The Keylime Registrar component
d32965
License: MIT
d32965
d32965
Requires: %{srcname}-base = %{version}-%{release}
d32965
Requires: python3-%{srcname} = %{version}-%{release}
d32965
d32965
%description registrar
d32965
The Keylime Registrar is a database of all agents registered
d32965
with Keylime and hosts the public keys of the TPM vendors.
d32965
d32965
%if 0%{?with_selinux}
d32965
# SELinux subpackage
d32965
%package selinux
d32965
Summary:             keylime SELinux policy
d32965
BuildArch:           noarch
d32965
Requires:            selinux-policy-%{selinuxtype}
d32965
Requires(post):      selinux-policy-%{selinuxtype}
d32965
BuildRequires:       selinux-policy-devel
d32965
%{?selinux_requires}
d32965
d32965
%description selinux
d32965
Custom SELinux policy module
d32965
%endif
d32965
d32965
%package tenant
d32965
Summary: The Python Keylime Tenant
d32965
License: MIT
d32965
d32965
Requires: %{srcname}-base = %{version}-%{release}
d32965
Requires: python3-%{srcname} = %{version}-%{release}
d32965
d32965
d32965
%description tenant
d32965
The Keylime Tenant can be used to provision a Keylime Agent.
d32965
d32965
%prep
d32965
%autosetup -S git -n %{srcname}-%{version}
d32965
d32965
%if 0%{?with_selinux}
d32965
# SELinux policy (originally from selinux-policy-contrib)
d32965
# this policy module will override the production module
d32965
mkdir selinux
d32965
cp -p %{SOURCE2} selinux/
d32965
cp -p %{SOURCE3} selinux/
d32965
cp -p %{SOURCE4} selinux/
d32965
d32965
make -f %{_datadir}/selinux/devel/Makefile %{srcname}.pp
d32965
bzip2 -9 %{srcname}.pp
d32965
%endif
d32965
d32965
%build
d32965
%py3_build
d32965
d32965
%install
d32965
%py3_install
d32965
mkdir -p %{buildroot}/%{_sharedstatedir}/%{srcname}
d32965
mkdir -p --mode=0700 %{buildroot}/%{_rundir}/%{srcname}
d32965
mkdir -p --mode=0700 %{buildroot}/%{_localstatedir}/log/%{srcname}
d32965
d32965
mkdir -p --mode=0700 %{buildroot}/%{_sysconfdir}/%{srcname}/
d32965
for comp in "verifier" "tenant" "registrar" "ca" "logging"; do
d32965
    mkdir -p --mode=0700  %{buildroot}/%{_sysconfdir}/%{srcname}/${comp}.conf.d
d32965
    install -Dpm 400 config/${comp}.conf %{buildroot}/%{_sysconfdir}/%{srcname}
d32965
done
d32965
d32965
# Remove agent.
d32965
rm -f %{buildroot}/%{_bindir}/%{srcname}_agent
d32965
rm -f %{buildroot}%{python3_sitelib}/%{srcname}/__pycache__/%{srcname}_agent*
d32965
rm -f %{buildroot}%{python3_sitelib}/%{srcname}/cmd/__pycache__/agent.*
d32965
rm -f %{buildroot}%{python3_sitelib}/%{srcname}/cmd/agent.*
d32965
rm -f %{buildroot}%{python3_sitelib}/%{srcname}/%{srcname}_agent.*
d32965
d32965
# Remove misc progs.
d32965
rm -f %{buildroot}/%{_bindir}/%{srcname}_ima_emulator
d32965
rm -f %{buildroot}/%{_bindir}/%{srcname}_userdata_encrypt
d32965
d32965
# Ship some scripts.
d32965
mkdir -p %{buildroot}/%{_datadir}/%{srcname}/scripts
d32965
for s in create_allowlist.sh \
d32965
         create_mb_refstate \
c49324
         create_policy \
c49324
         ek-openssl-verify; do
d32965
    install -Dpm 755 scripts/${s} \
d32965
        %{buildroot}/%{_datadir}/%{srcname}/scripts/${s}
d32965
done
d32965
d32965
%if 0%{?with_selinux}
d32965
install -D -m 0644 %{srcname}.pp.bz2 %{buildroot}%{_datadir}/selinux/packages/%{selinuxtype}/%{srcname}.pp.bz2
d32965
install -D -p -m 0644 selinux/%{srcname}.if %{buildroot}%{_datadir}/selinux/devel/include/distributed/%{srcname}.if
d32965
%endif
d32965
d32965
d32965
install -Dpm 644 ./services/%{srcname}_verifier.service \
d32965
    %{buildroot}%{_unitdir}/%{srcname}_verifier.service
d32965
d32965
install -Dpm 644 ./services/%{srcname}_registrar.service \
d32965
    %{buildroot}%{_unitdir}/%{srcname}_registrar.service
d32965
d32965
cp -r ./tpm_cert_store %{buildroot}%{_sharedstatedir}/%{srcname}/
d32965
chmod 400 %{buildroot}%{_sharedstatedir}/%{srcname}/tpm_cert_store/*.pem
d32965
d32965
install -p -d %{buildroot}/%{_tmpfilesdir}
d32965
cat > %{buildroot}/%{_tmpfilesdir}/%{srcname}.conf << EOF
d32965
d %{_rundir}/%{srcname} 0700 %{srcname} %{srcname} -
d32965
EOF
d32965
d32965
install -p -D -m 0644 %{SOURCE1} %{buildroot}%{_sysusersdir}/%{srcname}.conf
d32965
d32965
%pre base
d32965
%sysusers_create_compat %{SOURCE1}
d32965
exit 0
d32965
d32965
%posttrans base
d32965
if [ -d %{_sysconfdir}/%{srcname} ]; then
d32965
    chmod 500 %{_sysconfdir}/%{srcname}
d32965
    chown -R %{srcname}:%{srcname} %{_sysconfdir}/%{srcname}
d32965
d32965
    for comp in "verifier" "tenant" "registrar" "ca" "logging"; do
d32965
        [ -d %{_sysconfdir}/%{srcname}/${comp}.conf.d ] && \
d32965
            chmod 500 %{_sysconfdir}/%{srcname}/${comp}.conf.d
d32965
    done
d32965
fi
d32965
d32965
d32965
[ -d %{_sharedstatedir}/%{srcname} ] && \
d32965
    chown -R %{srcname} %{_sharedstatedir}/%{srcname}/
d32965
d32965
[ -d %{_sharedstatedir}/%{srcname}/tpm_cert_store ] && \
d32965
    chmod 400 %{_sharedstatedir}/%{srcname}/tpm_cert_store/*.pem && \
d32965
    chmod 500 %{_sharedstatedir}/%{srcname}/tpm_cert_store/
d32965
d32965
[ -d %{_localstatedir}/log/%{srcname} ] && \
d32965
    chown -R %{srcname} %{_localstatedir}/log/%{srcname}/
d32965
exit 0
d32965
d32965
%post verifier
d32965
%systemd_post %{srcname}_verifier.service
d32965
d32965
%post registrar
d32965
%systemd_post %{srcname}_registrar.service
d32965
d32965
%preun verifier
d32965
%systemd_preun %{srcname}_verifier.service
d32965
d32965
%preun registrar
d32965
%systemd_preun %{srcname}_registrar.service
d32965
d32965
%postun verifier
d32965
%systemd_postun_with_restart %{srcname}_verifier.service
d32965
d32965
%postun registrar
d32965
%systemd_postun_with_restart %{srcname}_registrar.service
d32965
d32965
%if 0%{?with_selinux}
d32965
# SELinux contexts are saved so that only affected files can be
d32965
# relabeled after the policy module installation
d32965
%pre selinux
d32965
%selinux_relabel_pre -s %{selinuxtype}
d32965
d32965
%post selinux
d32965
%selinux_modules_install -s %{selinuxtype} %{_datadir}/selinux/packages/%{selinuxtype}/%{srcname}.pp.bz2
d32965
%selinux_relabel_post -s %{selinuxtype}
d32965
d32965
if [ "$1" -le "1" ]; then # First install
d32965
    # The services need to be restarted for the custom label to be
d32965
    # applied in case they where already present in the system,
d32965
    # restart fails silently in case they where not.
d32965
    for svc in agent registrar verifier; do
d32965
        [ -f "%{_unitdir}/%{srcname}_${svc}".service ] && \
d32965
            %systemd_postun_with_restart "%{srcname}_${svc}".service
d32965
    done
d32965
fi
d32965
exit 0
d32965
d32965
%postun selinux
d32965
if [ $1 -eq 0 ]; then
d32965
    %selinux_modules_uninstall -s %{selinuxtype} %{srcname}
d32965
    %selinux_relabel_post -s %{selinuxtype}
d32965
fi
d32965
%endif
d32965
d32965
%files verifier
d32965
%license LICENSE
d32965
%attr(500,%{srcname},%{srcname}) %dir %{_sysconfdir}/%{srcname}/verifier.conf.d
d32965
%config(noreplace) %attr(400,%{srcname},%{srcname}) %{_sysconfdir}/%{srcname}/verifier.conf
d32965
%{_bindir}/%{srcname}_verifier
d32965
%{_bindir}/%{srcname}_ca
d32965
%{_bindir}/%{srcname}_migrations_apply
d32965
%{_unitdir}/keylime_verifier.service
d32965
d32965
%files registrar
d32965
%license LICENSE
d32965
%attr(500,%{srcname},%{srcname}) %dir %{_sysconfdir}/%{srcname}/registrar.conf.d
d32965
%config(noreplace) %attr(400,%{srcname},%{srcname}) %{_sysconfdir}/%{srcname}/registrar.conf
d32965
%{_bindir}/%{srcname}_registrar
d32965
%{_unitdir}/keylime_registrar.service
d32965
d32965
%if 0%{?with_selinux}
d32965
%files selinux
d32965
%{_datadir}/selinux/packages/%{selinuxtype}/%{srcname}.pp.*
d32965
%{_datadir}/selinux/devel/include/distributed/%{srcname}.if
d32965
%ghost %verify(not md5 size mode mtime) %{_sharedstatedir}/selinux/%{selinuxtype}/active/modules/200/%{srcname}
d32965
%endif
d32965
d32965
%files tenant
d32965
%license LICENSE
d32965
%attr(500,%{srcname},%{srcname}) %dir %{_sysconfdir}/%{srcname}/tenant.conf.d
d32965
%config(noreplace) %attr(400,%{srcname},%{srcname}) %{_sysconfdir}/%{srcname}/tenant.conf
d32965
%{_bindir}/%{srcname}_tenant
d32965
d32965
%files -n python3-%{srcname}
d32965
%license LICENSE
d32965
%{python3_sitelib}/%{srcname}-*.egg-info/
d32965
%{python3_sitelib}/%{srcname}
d32965
%{_datadir}/%{srcname}/scripts/create_mb_refstate
d32965
%{_datadir}/%{srcname}/scripts/create_policy
d32965
d32965
%files base
d32965
%license LICENSE
d32965
%doc README.md
d32965
%attr(500,%{srcname},%{srcname}) %dir %{_sysconfdir}/%{srcname}/{ca,logging}.conf.d
d32965
%config(noreplace) %attr(400,%{srcname},%{srcname}) %{_sysconfdir}/%{srcname}/ca.conf
d32965
%config(noreplace) %attr(400,%{srcname},%{srcname}) %{_sysconfdir}/%{srcname}/logging.conf
d32965
%attr(700,%{srcname},%{srcname}) %dir %{_rundir}/%{srcname}
d32965
%attr(700,%{srcname},%{srcname}) %dir %{_localstatedir}/log/%{srcname}
d32965
%attr(700,%{srcname},%{srcname}) %dir %{_sharedstatedir}/%{srcname}
d32965
%attr(500,%{srcname},%{srcname}) %dir %{_sharedstatedir}/%{srcname}/tpm_cert_store
d32965
%attr(400,%{srcname},%{srcname}) %{_sharedstatedir}/%{srcname}/tpm_cert_store/*.pem
d32965
%{_tmpfilesdir}/%{srcname}.conf
d32965
%{_sysusersdir}/%{srcname}.conf
d32965
%{_datadir}/%{srcname}/scripts/create_allowlist.sh
c49324
%{_datadir}/%{srcname}/scripts/ek-openssl-verify
d32965
d32965
%files
d32965
%license LICENSE
d32965
d32965
%changelog
c49324
* Tue Nov 15 2022 Sergio Correia <scorreia@redhat.com> - 6.5.1-1.4
c49324
- Do not use default values that need reading the config in methods
c49324
  Resolves: rhbz#2142033 - Registrar may crash during EK validation when require_ek_cert is enabled [rhel-9.1.0.z]
c49324
c49324
* Mon Nov 14 2022 Sergio Correia <scorreia@redhat.com> - 6.5.1-1.3
c49324
- Backport upstream PR#1156
c49324
  Resolves: rhbz#2142033 - Registrar may crash during EK validation when require_ek_cert is enabled [rhel-9.1.0.z]
c49324
c49324
* Mon Nov 14 2022 Sergio Correia <scorreia@redhat.com> - 6.5.1-1.2
c49324
- Segmentation fault in create_mb_refstate script
c49324
  Resolves: rhbz#2142034 - Segmentation fault in /usr/share/keylime/create_mb_refstate script [rhel-9.1.0.z]
c49324
c49324
* Mon Nov 14 2022 Sergio Correia <scorreia@redhat.com> - 6.5.1-1.1
c49324
- ima: Fix log evaluation on quick-succession execution of scripts
c49324
  Resolves: rhbz#2142032 - agent fails IMA attestation when one scripts is executed quickly after the other [rhel-9.1.0.z]
c49324
1bad35
* Thu Oct 13 2022 Sergio Correia <scorreia@redhat.com> - 6.5.1-1
1bad35
- Update to 6.5.1
1bad35
  Resolves: CVE-2022-3500
1bad35
d32965
* Tue Sep 13 2022 Sergio Correia <scorreia@redhat.com> - 6.5.0-1
d32965
- Update to 6.5.0
d32965
  Resolves: rhbz#2120686 - Keylime configuration is too complex
d32965
d32965
* Fri Aug 26 2022 Sergio Correia <scorreia@redhat.com> - 6.4.3-1
d32965
- Update to 6.4.3
d32965
  Resolves: rhbz#2121044 - Error parsing EK ASN.1 certificate of Nuvoton HW TPM
d32965
d32965
* Fri Aug 26 2022 Patrik Koncity <pkoncity@redhat.com> - 6.4.2-6
d32965
- Update keylime SELinux policy
d32965
- Resolves: rhbz#2121058
d32965
d32965
* Fri Aug 26 2022 Patrik Koncity <pkoncity@redhat.com> - 6.4.2-5
d32965
- Update keylime SELinux policy and removed duplicate rules
d32965
- Resolves: rhbz#2121058
d32965
d32965
* Fri Aug 26 2022 Patrik Koncity <pkoncity@redhat.com> - 6.4.2-4
d32965
- Update keylime SELinux policy
d32965
- Resolves: rhbz#2121058
d32965
d32965
* Wed Aug 17 2022 Patrik Koncity <pkoncity@redhat.com> - 6.4.2-3
d32965
- Add keylime-selinux policy as subpackage
d32965
- See https://fedoraproject.org/wiki/SELinux/IndependentPolicy
d32965
- Resolves: rhbz#2121058
d32965
d32965
* Mon Jul 11 2022 Sergio Correia <scorreia@redhat.com> - 6.4.2-2
d32965
- Fix efivar-libs dependency
d32965
  Related: rhbz#2082989
d32965
d32965
* Thu Jul 07 2022 Sergio Correia <scorreia@redhat.com> - 6.4.2-1
d32965
- Update to 6.4.2
d32965
  Related: rhbz#2082989
d32965
d32965
* Tue Jun 21 2022 Sergio Correia <scorreia@redhat.com> - 6.4.1-1
d32965
- Add keylime to RHEL-9
d32965
  Resolves: rhbz#2082989