keylime/keylime.spec

416 lines
12 KiB
RPMSpec
Raw Normal View History

2019-12-13 16:30:21 +00:00
%global srcname keylime
%global policy_version 1.0.0
2019-12-13 16:30:21 +00:00
# Package is actually noarch, but it has an optional dependency that is
# arch-specific.
%global debug_package %{nil}
%global with_selinux 1
%global selinuxtype targeted
2019-12-13 16:30:21 +00:00
Name: keylime
2023-04-07 12:22:36 +00:00
Version: 7.2.5
2022-07-07 15:20:17 +00:00
Release: %autorelease
2019-12-13 16:30:21 +00:00
Summary: Open source TPM software for Bootstrapping and Maintaining Trust
URL: https://github.com/keylime/keylime
Source0: https://github.com/keylime/keylime/archive/refs/tags/v%{version}.tar.gz
Source1: %{srcname}.sysusers
# The selinux policy for keylime is distributed via this repo: https://github.com/RedHat-SP-Security/keylime-selinux
Source2: https://github.com/RedHat-SP-Security/%{name}-selinux/archive/v%{policy_version}/keylime-selinux-%{policy_version}.tar.gz
2023-01-25 15:03:28 +00:00
Patch: 01-duplicate-str-to-version.patch
2023-04-07 12:22:36 +00:00
Patch: 0002-templates-Fix-mapping-and-adjust-for-Rust-agent.patch
2019-12-13 16:30:21 +00:00
# Main program: BSD
# Icons: MIT
2020-07-17 10:20:44 +00:00
License: ASL 2.0 and MIT
2019-12-13 16:30:21 +00:00
BuildRequires: git-core
2019-12-13 16:30:21 +00:00
BuildRequires: swig
BuildRequires: openssl-devel
BuildRequires: python3-devel
2021-01-23 14:10:32 +00:00
BuildRequires: python3-dbus
2023-01-25 15:03:28 +00:00
BuildRequires: python3-jinja2
BuildRequires: python3-setuptools
2019-12-13 16:30:21 +00:00
BuildRequires: systemd-rpm-macros
Requires: python3-%{srcname} = %{version}-%{release}
Requires: %{srcname}-base = %{version}-%{release}
Requires: %{srcname}-verifier = %{version}-%{release}
Requires: %{srcname}-registrar = %{version}-%{release}
Requires: %{srcname}-tenant = %{version}-%{release}
Requires: %{srcname}-tools = %{version}-%{release}
# webapp was removed upstream in release 6.4.2.
Obsoletes: %{srcname}-webapp < 6.4.2
2023-04-07 12:22:36 +00:00
# python agent was removed upstream in release 6.8.0.
Obsoletes: python3-%{srcname}-agent < 6.8.0
# Agent.
Requires: keylime-agent
2023-04-07 12:22:36 +00:00
Suggests: %{srcname}-agent-rust
# Conflicts with the monolithic versions of the package, before the split.
Conflicts: keylime < 6.3.0-3
%{?python_enable_dependency_generator}
%description
Keylime is a TPM based highly scalable remote boot attestation
and runtime integrity measurement solution.
%package base
Summary: The base package contains the default configuration
License: MIT
# Conflicts with the monolithic versions of the package, before the split.
Conflicts: keylime < 6.3.0-3
Requires(pre): shadow-utils
2019-12-13 16:30:21 +00:00
Requires: procps-ng
Requires: tpm2-tss
2023-01-25 15:03:28 +00:00
Requires: python3-jinja2
%if 0%{?with_selinux}
# This ensures that the *-selinux package and all its dependencies are not pulled
# into containers and other systems that do not use SELinux
Recommends: (%{srcname}-selinux if selinux-policy-%{selinuxtype})
%endif
%ifarch %efi
Requires: efivar-libs
%endif
%description base
The base package contains the Keylime default configuration
%package -n python3-%{srcname}
Summary: The Python Keylime module
License: MIT
# Conflicts with the monolithic versions of the package, before the split.
Conflicts: keylime < 6.3.0-3
Requires: %{srcname}-base = %{version}-%{release}
%{?python_provide:%python_provide python3-%{srcname}}
Requires: python3-tornado
Requires: python3-sqlalchemy
Requires: python3-alembic
Requires: python3-cryptography
Requires: python3-pyyaml
Requires: python3-packaging
Requires: python3-requests
Requires: python3-gpg
Requires: python3-lark-parser
2022-08-24 19:25:43 +00:00
Requires: python3-pyasn1
Requires: python3-pyasn1-modules
Requires: tpm2-tools
%description -n python3-%{srcname}
The python3-keylime module implements the functionality used
by Keylime components.
%package verifier
Summary: The Python Keylime Verifier component
License: MIT
# Conflicts with the monolithic versions of the package, before the split.
Conflicts: keylime < 6.3.0-3
Requires: %{srcname}-base = %{version}-%{release}
Requires: python3-%{srcname} = %{version}-%{release}
%description verifier
The Keylime Verifier continuously verifies the integrity state
of the machine that the agent is running on.
%package registrar
Summary: The Keylime Registrar component
License: MIT
# Conflicts with the monolithic versions of the package, before the split.
Conflicts: keylime < 6.3.0-3
Requires: %{srcname}-base = %{version}-%{release}
Requires: python3-%{srcname} = %{version}-%{release}
%description registrar
The Keylime Registrar is a database of all agents registered
with Keylime and hosts the public keys of the TPM vendors.
%package -n python3-%{srcname}-agent
Summary: The Python Keylime Agent
License: MIT
# Conflicts with the monolithic versions of the package, before the split.
Conflicts: keylime < 6.3.0-3
Requires: %{srcname}-base = %{version}-%{release}
Requires: python3-%{srcname} = %{version}-%{release}
Requires: python3-psutil
Requires: python3-zmq
# Virtual Provides to support swapping between Python and Rust implementation.
Provides: keylime-agent
Conflicts: keylime-agent
%description -n python3-%{srcname}-agent
The Keylime Agent is deployed to the remote machine that is to be
measured or provisioned with secrets stored within an encrypted
payload released once trust is established.
%if 0%{?with_selinux}
# SELinux subpackage
%package selinux
Summary: keylime SELinux policy
BuildArch: noarch
Requires: selinux-policy-%{selinuxtype}
Requires(post): selinux-policy-%{selinuxtype}
BuildRequires: selinux-policy-devel
%{?selinux_requires}
%description selinux
Custom SELinux policy module
%endif
%package tenant
Summary: The Python Keylime Tenant
License: MIT
# Conflicts with the monolithic versions of the package, before the split.
Conflicts: keylime < 6.3.0-3
Requires: %{srcname}-base = %{version}-%{release}
Requires: python3-%{srcname} = %{version}-%{release}
%description tenant
The Keylime Tenant can be used to provision a Keylime Agent.
%package tools
Summary: Keylime tools
License: MIT
# Conflicts with the monolithic versions of the package, before the split.
Conflicts: keylime < 6.3.0-3
Requires: %{srcname}-base = %{version}-%{release}
Requires: python3-%{srcname} = %{version}-%{release}
%description tools
The keylime tools package includes miscelaneous tools.
2019-12-13 16:30:21 +00:00
2019-12-13 16:30:21 +00:00
%prep
%autosetup -S git -n %{srcname}-%{version} -a2
%if 0%{?with_selinux}
# SELinux policy (originally from selinux-policy-contrib)
# this policy module will override the production module
make -f %{_datadir}/selinux/devel/Makefile %{srcname}.pp
bzip2 -9 %{srcname}.pp
%endif
2019-12-13 16:30:21 +00:00
%build
%py3_build
%install
%py3_install
mkdir -p %{buildroot}/%{_sharedstatedir}/%{srcname}
mkdir -p --mode=0700 %{buildroot}/%{_rundir}/%{srcname}
2023-01-25 15:03:28 +00:00
mkdir -p --mode=0700 %{buildroot}/%{_sysconfdir}/%{srcname}/
2023-04-07 12:22:36 +00:00
for comp in "verifier" "tenant" "registrar" "ca" "logging"; do
2023-01-25 15:03:28 +00:00
mkdir -p --mode=0700 %{buildroot}/%{_sysconfdir}/%{srcname}/${comp}.conf.d
done
# Ship some scripts.
mkdir -p %{buildroot}/%{_datadir}/%{srcname}/scripts
2023-02-03 10:54:45 +00:00
for s in create_runtime_policy.sh \
2023-01-25 15:03:28 +00:00
create_mb_refstate \
ek-openssl-verify; do
install -Dpm 755 scripts/${s} \
%{buildroot}/%{_datadir}/%{srcname}/scripts/${s}
done
# Ship configuration templates.
cp -r ./templates %{buildroot}%{_datadir}/%{srcname}/templates/
2019-12-13 16:30:21 +00:00
2023-01-25 15:03:28 +00:00
mkdir -p --mode=0755 %{buildroot}/%{_bindir}
cp -a ./keylime/cmd/convert_config.py %{buildroot}/%{_bindir}/keylime_upgrade_config
2022-08-24 19:25:43 +00:00
%if 0%{?with_selinux}
install -D -m 0644 %{srcname}.pp.bz2 %{buildroot}%{_datadir}/selinux/packages/%{selinuxtype}/%{srcname}.pp.bz2
install -D -p -m 0644 keylime-selinux-%{policy_version}/%{srcname}.if %{buildroot}%{_datadir}/selinux/devel/include/distributed/%{srcname}.if
%endif
2022-02-15 03:19:03 +00:00
install -Dpm 644 ./services/%{srcname}_verifier.service \
2019-12-13 16:30:21 +00:00
%{buildroot}%{_unitdir}/%{srcname}_verifier.service
2022-02-15 03:19:03 +00:00
install -Dpm 644 ./services/%{srcname}_registrar.service \
2019-12-13 16:30:21 +00:00
%{buildroot}%{_unitdir}/%{srcname}_registrar.service
2023-01-25 15:03:28 +00:00
cp -r ./tpm_cert_store %{buildroot}%{_sharedstatedir}/%{srcname}/
2020-02-06 15:43:50 +00:00
install -p -d %{buildroot}/%{_tmpfilesdir}
cat > %{buildroot}/%{_tmpfilesdir}/%{srcname}.conf << EOF
d %{_rundir}/%{srcname} 0700 %{srcname} %{srcname} -
EOF
install -p -D -m 0644 %{SOURCE1} %{buildroot}%{_sysusersdir}/%{srcname}.conf
%pre base
%sysusers_create_compat %{SOURCE1}
2022-04-06 22:05:45 +00:00
exit 0
2023-01-25 15:03:28 +00:00
%post base
/usr/bin/keylime_upgrade_config
exit 0
%pre verifier
/usr/bin/keylime_upgrade_config
exit 0
%pre registrar
/usr/bin/keylime_upgrade_config
exit 0
%pre tenant
/usr/bin/keylime_upgrade_config
exit 0
2022-04-06 22:05:45 +00:00
%posttrans base
2023-01-25 15:03:28 +00:00
if [ -d %{_sysconfdir}/%{srcname} ]; then
chmod 500 %{_sysconfdir}/%{srcname}
chown -R %{srcname}:%{srcname} %{_sysconfdir}/%{srcname}
2023-04-07 12:22:36 +00:00
for comp in "verifier" "tenant" "registrar" "ca" "logging"; do
2023-01-25 15:03:28 +00:00
[ -d %{_sysconfdir}/%{srcname}/${comp}.conf.d ] && \
chmod 500 %{_sysconfdir}/%{srcname}/${comp}.conf.d
done
fi
2022-05-04 17:28:12 +00:00
[ -d %{_sharedstatedir}/%{srcname} ] && \
chown -R %{srcname} %{_sharedstatedir}/%{srcname}/
2023-01-25 15:03:28 +00:00
[ -d %{_sharedstatedir}/%{srcname}/tpm_cert_store ] && \
chmod 400 %{_sharedstatedir}/%{srcname}/tpm_cert_store/*.pem && \
chmod 500 %{_sharedstatedir}/%{srcname}/tpm_cert_store/
2022-05-04 17:28:12 +00:00
[ -d %{_localstatedir}/log/%{srcname} ] && \
chown -R %{srcname} %{_localstatedir}/log/%{srcname}/
exit 0
2019-12-13 16:30:21 +00:00
%post verifier
%systemd_post %{srcname}_verifier.service
2019-12-13 16:30:21 +00:00
%post registrar
%systemd_post %{srcname}_registrar.service
2019-12-13 16:30:21 +00:00
%if 0%{?with_selinux}
# SELinux contexts are saved so that only affected files can be
# relabeled after the policy module installation
%pre selinux
%selinux_relabel_pre -s %{selinuxtype}
%post selinux
%selinux_modules_install -s %{selinuxtype} %{_datadir}/selinux/packages/%{selinuxtype}/%{srcname}.pp.bz2
%selinux_relabel_post -s %{selinuxtype}
if [ "$1" -le "1" ]; then # First install
# The services need to be restarted for the custom label to be
# applied in case they where already present in the system,
# restart fails silently in case they where not.
2023-04-07 12:22:36 +00:00
for svc in registrar verifier; do
[ -f "%{_unitdir}/%{srcname}_${svc}".service ] && \
%systemd_postun_with_restart "%{srcname}_${svc}".service
done
fi
exit 0
%postun selinux
if [ $1 -eq 0 ]; then
%selinux_modules_uninstall -s %{selinuxtype} %{srcname}
%selinux_relabel_post -s %{selinuxtype}
fi
%endif
%preun verifier
%systemd_preun %{srcname}_verifier.service
%preun registrar
%systemd_preun %{srcname}_registrar.service
2023-01-25 15:03:28 +00:00
%preun tenant
%systemd_preun %{srcname}_registrar.service
%postun verifier
%systemd_postun_with_restart %{srcname}_verifier.service
%postun registrar
%systemd_postun_with_restart %{srcname}_registrar.service
%files verifier
%license LICENSE
2023-01-25 15:03:28 +00:00
%attr(500,%{srcname},%{srcname}) %dir %{_sysconfdir}/%{srcname}/verifier.conf.d
2019-12-13 16:30:21 +00:00
%{_bindir}/%{srcname}_verifier
%{_bindir}/%{srcname}_ca
%{_unitdir}/keylime_verifier.service
%files registrar
%license LICENSE
2023-01-25 15:03:28 +00:00
%attr(500,%{srcname},%{srcname}) %dir %{_sysconfdir}/%{srcname}/registrar.conf.d
2019-12-13 16:30:21 +00:00
%{_bindir}/%{srcname}_registrar
%{_unitdir}/keylime_registrar.service
%if 0%{?with_selinux}
%files selinux
%{_datadir}/selinux/packages/%{selinuxtype}/%{srcname}.pp.*
%{_datadir}/selinux/devel/include/distributed/%{srcname}.if
%ghost %verify(not md5 size mode mtime) %{_sharedstatedir}/selinux/%{selinuxtype}/active/modules/200/%{srcname}
%endif
%files tenant
%license LICENSE
2023-01-25 15:03:28 +00:00
%attr(500,%{srcname},%{srcname}) %dir %{_sysconfdir}/%{srcname}/tenant.conf.d
2019-12-13 16:30:21 +00:00
%{_bindir}/%{srcname}_tenant
%files -n python3-%{srcname}
%license LICENSE
%{python3_sitelib}/%{srcname}-*.egg-info/
%{python3_sitelib}/%{srcname}
2023-01-25 15:03:28 +00:00
%{_datadir}/%{srcname}/scripts/create_mb_refstate
%{_bindir}/keylime_attest
2023-04-07 12:22:36 +00:00
%{_bindir}/keylime_convert_runtime_policy
%{_bindir}/keylime_create_policy
%{_bindir}/keylime_sign_runtime_policy
%files tools
%license LICENSE
2019-12-13 16:30:21 +00:00
%{_bindir}/%{srcname}_userdata_encrypt
%files base
%license LICENSE
%doc README.md
2023-01-25 15:03:28 +00:00
%attr(500,%{srcname},%{srcname}) %dir %{_sysconfdir}/%{srcname}/{ca,logging}.conf.d
%attr(700,%{srcname},%{srcname}) %dir %{_rundir}/%{srcname}
2023-01-25 15:03:28 +00:00
%attr(700,%{srcname},%{srcname}) %dir %{_sharedstatedir}/%{srcname}
%attr(500,%{srcname},%{srcname}) %dir %{_sharedstatedir}/%{srcname}/tpm_cert_store
%attr(400,%{srcname},%{srcname}) %{_sharedstatedir}/%{srcname}/tpm_cert_store/*.pem
%{_tmpfilesdir}/%{srcname}.conf
%{_sysusersdir}/%{srcname}.conf
2023-02-03 10:54:45 +00:00
%{_datadir}/%{srcname}/scripts/create_runtime_policy.sh
2023-01-25 15:03:28 +00:00
%{_datadir}/%{srcname}/scripts/ek-openssl-verify
%{_datadir}/%{srcname}/templates
%{_bindir}/keylime_upgrade_config
%files
%license LICENSE
2019-12-13 16:30:21 +00:00
%changelog
2022-07-07 15:20:17 +00:00
%autochangelog