Blame SPECS/fapolicyd.spec

afdf34
%global selinuxtype targeted
afdf34
%global moduletype contrib
afdf34
%define semodule_version 0.4
afdf34
afdf34
Summary: Application Whitelisting Daemon
afdf34
Name: fapolicyd
f9ee98
Version: 1.1
f9ee98
Release: 100%{?dist}
afdf34
License: GPLv3+
afdf34
URL: http://people.redhat.com/sgrubb/fapolicyd
afdf34
Source0: https://people.redhat.com/sgrubb/fapolicyd/%{name}-%{version}.tar.gz
afdf34
Source1: https://github.com/linux-application-whitelisting/%{name}-selinux/releases/download/v%{semodule_version}/%{name}-selinux-%{semodule_version}.tar.gz
afdf34
# we bundle uthash for rhel9
afdf34
Source2: https://github.com/troydhanson/uthash/archive/refs/tags/v2.3.0.tar.gz#/uthash-2.3.0.tar.gz
afdf34
BuildRequires: gcc
afdf34
BuildRequires: kernel-headers
afdf34
BuildRequires: autoconf automake make gcc libtool
afdf34
BuildRequires: systemd-devel libgcrypt-devel rpm-devel file-devel file
afdf34
BuildRequires: libcap-ng-devel libseccomp-devel lmdb-devel
afdf34
BuildRequires: python3-devel
afdf34
afdf34
%if 0%{?rhel} == 0
afdf34
BuildRequires: uthash-devel
afdf34
%endif
afdf34
afdf34
Requires: %{name}-plugin
afdf34
Recommends: %{name}-selinux
afdf34
Requires(pre): shadow-utils
afdf34
Requires(post): systemd-units
afdf34
Requires(preun): systemd-units
afdf34
Requires(postun): systemd-units
afdf34
afdf34
Patch1: fapolicyd-uthash-bundle.patch
b63e47
Patch2: fapolicyd-selinux.patch
afdf34
afdf34
%description
afdf34
Fapolicyd (File Access Policy Daemon) implements application whitelisting
afdf34
to decide file access rights. Applications that are known via a reputation
afdf34
source are allowed access while unknown applications are not. The daemon
afdf34
makes use of the kernel's fanotify interface to determine file access rights.
afdf34
afdf34
%package        selinux
afdf34
Summary:        Fapolicyd selinux
afdf34
Group:          Applications/System
afdf34
Requires:       %{name} = %{version}-%{release}
afdf34
BuildRequires:  selinux-policy
afdf34
BuildRequires:  selinux-policy-devel
afdf34
BuildArch: noarch
afdf34
%{?selinux_requires}
afdf34
afdf34
%description    selinux
afdf34
The %{name}-selinux package contains selinux policy for the %{name} daemon.
afdf34
afdf34
%package        dnf-plugin
afdf34
Summary:        Fapolicyd dnf plugin
afdf34
Group:          Applications/System
afdf34
Requires:       %{name} = %{version}-%{release}
afdf34
BuildArch:      noarch
afdf34
Provides:       %{name}-plugin
afdf34
afdf34
%description    dnf-plugin
afdf34
The %{name}-dnf-plugin notifies %{name} daemon about dnf update.
afdf34
The dnf plugin will be replaced with rpm plugin later.
afdf34
Don't use dnf and rpm plugin together.
afdf34
afdf34
afdf34
%prep
afdf34
afdf34
%setup -q
afdf34
afdf34
# selinux
afdf34
%setup -q -D -T -a 1
afdf34
afdf34
%if 0%{?rhel} != 0
afdf34
# uthash
afdf34
%setup -q -D -T -a 2
afdf34
%patch1 -p1 -b .uthash
afdf34
%endif
afdf34
b63e47
%patch2 -p1 -b .selinux
afdf34
f9ee98
sed -i "s/%python2_path%/`readlink -f %{__python2} | sed 's/\//\\\\\//g'`/g" rules.d/*.rules
f9ee98
sed -i "s/%python3_path%/`readlink -f %{__python3} | sed 's/\//\\\\\//g'`/g" rules.d/*.rules
f9ee98
sed -i "s/%ld_so_path%/`find /usr/lib64/ -type f -name  'ld-linux-*.so.*' | sed 's/\//\\\\\//g'`/g" rules.d/*.rules
afdf34
afdf34
%build
afdf34
./autogen.sh
afdf34
%configure \
afdf34
    --with-audit \
afdf34
    --with-rpm \
afdf34
    --disable-shared
afdf34
afdf34
make CFLAGS="%{optflags}" %{?_smp_mflags}
afdf34
afdf34
# selinux
afdf34
pushd %{name}-selinux-%{semodule_version}
afdf34
make
afdf34
popd
afdf34
afdf34
%check
afdf34
make check
afdf34
afdf34
# selinux
afdf34
%pre selinux
afdf34
%selinux_relabel_pre -s %{selinuxtype}
afdf34
afdf34
%install
f9ee98
%make_install
afdf34
mkdir -p %{buildroot}/%{python3_sitelib}/dnf-plugins/
afdf34
install -p -m 644 dnf/%{name}-dnf-plugin.py %{buildroot}/%{python3_sitelib}/dnf-plugins/
afdf34
install -p -m 644 -D init/%{name}-tmpfiles.conf %{buildroot}/%{_tmpfilesdir}/%{name}.conf
afdf34
mkdir -p %{buildroot}/%{_localstatedir}/lib/%{name}
afdf34
mkdir -p %{buildroot}/run/%{name}
b63e47
mkdir -p %{buildroot}%{_sysconfdir}/%{name}/trust.d
f9ee98
mkdir -p %{buildroot}%{_sysconfdir}/%{name}/rules.d
f9ee98
afdf34
afdf34
# selinux
afdf34
install -d %{buildroot}%{_datadir}/selinux/packages/%{selinuxtype}
afdf34
install -m 0644 %{name}-selinux-%{semodule_version}/%{name}.pp.bz2 %{buildroot}%{_datadir}/selinux/packages/%{selinuxtype}
afdf34
install -d -p %{buildroot}%{_datadir}/selinux/devel/include/%{moduletype}
afdf34
install -p -m 644 %{name}-selinux-%{semodule_version}/%{name}.if %{buildroot}%{_datadir}/selinux/devel/include/%{moduletype}/ipp-%{name}.if
afdf34
afdf34
#cleanup
f9ee98
find %{buildroot} \( -name '*.la' -o -name '*.a' \) -delete
afdf34
afdf34
%pre
afdf34
getent passwd %{name} >/dev/null || useradd -r -M -d %{_localstatedir}/lib/%{name} -s /sbin/nologin -c "Application Whitelisting Daemon" %{name}
afdf34
afdf34
%post
f9ee98
# if no pre-existing rule file
f9ee98
if [ ! -e %{_sysconfdir}/%{name}/%{name}.rules ] ; then
f9ee98
 files=`ls %{_sysconfdir}/%{name}/rules.d/ 2>/dev/null | wc -w`
f9ee98
 # Only if no pre-existing component rules
f9ee98
 if [ "$files" -eq 0 ] ; then
f9ee98
  ## Install the known libs policy
f9ee98
  cp %{_datadir}/%{name}/sample-rules/10-languages.rules  %{_sysconfdir}/%{name}/rules.d/
f9ee98
  cp %{_datadir}/%{name}/sample-rules/20-patterns.rules %{_sysconfdir}/%{name}/rules.d/
f9ee98
  cp %{_datadir}/%{name}/sample-rules/30-dracut.rules %{_sysconfdir}/%{name}/rules.d/
f9ee98
  cp %{_datadir}/%{name}/sample-rules/30-updaters.rules  %{_sysconfdir}/%{name}/rules.d/
f9ee98
  cp %{_datadir}/%{name}/sample-rules/40-bad-elf.rules  %{_sysconfdir}/%{name}/rules.d/
f9ee98
  cp %{_datadir}/%{name}/sample-rules/41-shared-obj.rules  %{_sysconfdir}/%{name}/rules.d/
f9ee98
  cp %{_datadir}/%{name}/sample-rules/42-trusted-elf.rules  %{_sysconfdir}/%{name}/rules.d/
f9ee98
  cp %{_datadir}/%{name}/sample-rules/70-trusted-lang.rules  %{_sysconfdir}/%{name}/rules.d/
f9ee98
  cp %{_datadir}/%{name}/sample-rules/72-shell.rules  %{_sysconfdir}/%{name}/rules.d/
f9ee98
  cp %{_datadir}/%{name}/sample-rules/90-deny-execute.rules %{_sysconfdir}/%{name}/rules.d/
f9ee98
  cp %{_datadir}/%{name}/sample-rules/95-allow-open.rules  %{_sysconfdir}/%{name}/rules.d/
f9ee98
  chgrp %{name} %{_sysconfdir}/%{name}/rules.d/*
f9ee98
  if [ -x /usr/sbin/restorecon ] ; then
f9ee98
   # restore correct label
f9ee98
   /usr/sbin/restorecon -F %{_sysconfdir}/%{name}/rules.d/*
f9ee98
  fi
f9ee98
  fagenrules --load
f9ee98
 fi
f9ee98
fi
afdf34
%systemd_post %{name}.service
afdf34
afdf34
%preun
afdf34
%systemd_preun %{name}.service
afdf34
afdf34
%postun
afdf34
%systemd_postun_with_restart %{name}.service
afdf34
afdf34
%files
afdf34
%doc README.md
afdf34
%{!?_licensedir:%global license %%doc}
afdf34
%license COPYING
afdf34
%attr(755,root,%{name}) %dir %{_datadir}/%{name}
f9ee98
%attr(755,root,%{name}) %dir %{_datadir}/%{name}/sample-rules
f9ee98
%attr(644,root,%{name}) %{_datadir}/%{name}/sample-rules/*
f9ee98
%attr(644,root,%{name}) %{_datadir}/%{name}/fapolicyd-magic.mgc
afdf34
%attr(750,root,%{name}) %dir %{_sysconfdir}/%{name}
b63e47
%attr(750,root,%{name}) %dir %{_sysconfdir}/%{name}/trust.d
f9ee98
%attr(750,root,%{name}) %dir %{_sysconfdir}/%{name}/rules.d
f9ee98
%ghost %{_sysconfdir}/%{name}/rules.d/*
f9ee98
%ghost %{_sysconfdir}/%{name}/%{name}.rules
afdf34
%config(noreplace) %attr(644,root,%{name}) %{_sysconfdir}/%{name}/%{name}.conf
afdf34
%config(noreplace) %attr(644,root,%{name}) %{_sysconfdir}/%{name}/%{name}.trust
f9ee98
%ghost %attr(644,root,%{name}) %{_sysconfdir}/%{name}/compiled.rules
afdf34
%attr(644,root,root) %{_unitdir}/%{name}.service
afdf34
%attr(644,root,root) %{_tmpfilesdir}/%{name}.conf
afdf34
%attr(755,root,root) %{_sbindir}/%{name}
afdf34
%attr(755,root,root) %{_sbindir}/%{name}-cli
f9ee98
%attr(755,root,root) %{_sbindir}/fagenrules
afdf34
%attr(644,root,root) %{_mandir}/man8/*
afdf34
%attr(644,root,root) %{_mandir}/man5/*
afdf34
%attr(644,root,root) %{_mandir}/man1/*
f9ee98
%ghost %attr(440,%{name},%{name}) %verify(not md5 size mtime) %{_localstatedir}/log/%{name}-access.log
afdf34
%attr(770,root,%{name}) %dir %{_localstatedir}/lib/%{name}
afdf34
%attr(770,root,%{name}) %dir /run/%{name}
f9ee98
%ghost %attr(660,root,%{name}) /run/%{name}/%{name}.fifo
f9ee98
%ghost %attr(660,%{name},%{name}) %verify(not md5 size mtime) %{_localstatedir}/lib/%{name}/data.mdb
f9ee98
%ghost %attr(660,%{name},%{name}) %verify(not md5 size mtime) %{_localstatedir}/lib/%{name}/lock.mdb
f9ee98
afdf34
afdf34
%files selinux
afdf34
%{_datadir}/selinux/packages/%{selinuxtype}/%{name}.pp.bz2
b63e47
%ghost %verify(not md5 size mode mtime) %{_sharedstatedir}/selinux/%{selinuxtype}/active/modules/200/%{name}
afdf34
%{_datadir}/selinux/devel/include/%{moduletype}/ipp-%{name}.if
afdf34
afdf34
%post selinux
afdf34
%selinux_modules_install -s %{selinuxtype} %{_datadir}/selinux/packages/%{selinuxtype}/%{name}.pp.bz2
afdf34
%selinux_relabel_post -s %{selinuxtype}
afdf34
afdf34
%postun selinux
afdf34
if [ $1 -eq 0 ]; then
afdf34
    %selinux_modules_uninstall -s %{selinuxtype} %{name}
afdf34
fi
afdf34
afdf34
%posttrans selinux
afdf34
%selinux_relabel_post -s %{selinuxtype}
afdf34
afdf34
%files dnf-plugin
afdf34
%{python3_sitelib}/dnf-plugins/%{name}-dnf-plugin.py
afdf34
%{python3_sitelib}/dnf-plugins/__pycache__/%{name}-dnf-plugin.*.pyc
afdf34
afdf34
afdf34
%changelog
f9ee98
* Wed Feb 16 2022 Radovan Sroka <rsroka@redhat.com> - 1.1-100
f9ee98
RHEL 9.0.0 ERRATUM
f9ee98
- rebase to 1.1
f9ee98
Resolves: rhbz#2032408
f9ee98
- introduce rules.d
f9ee98
Resolves: rhbz#2054740
f9ee98
- remove pretrans scriptlet
f9ee98
Resolve: rhbz#2051481
f9ee98
b63e47
* Tue Dec 14 2021 Zoltan Fridrich <zfridric@redhat.com> - 1.0.4-101
b63e47
RHEL 9.0.0 ERRATUM
b63e47
- rebase to 1.0.4
b63e47
- added rpm_sha256_only option
b63e47
- added trust.d directory
b63e47
- allow file names with whitespaces in trust files
b63e47
- use full paths in trust files
b63e47
Resolves: rhbz#2032408
b63e47
- fix libc.so getting identified as application/x-executable
b63e47
Resolves: rhbz#2015307
b63e47
- fix selinux DSP module definition in spec file
b63e47
Resolves: rhbz#2014449
b63e47
afdf34
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 1.0.3-4
afdf34
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
afdf34
  Related: rhbz#1991688
afdf34
afdf34
* Tue Jul 20 2021 Radovan Sroka <rsroka@redhat.com> - 1.0.3-3
afdf34
RHEL 9 BETA
afdf34
- SELinux prevents fapolicyd from watch_mount/watch_with_perm on /dev/shm
afdf34
Resolves: rhbz#1932225
afdf34
Resolves: rhbz#1977731
afdf34
afdf34
* Thu Apr 15 2021 Mohan Boddu <mboddu@redhat.com> - 1.0.3-2
afdf34
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
afdf34
afdf34
* Thu Apr 01 2021 Radovan Sroka <rsroka@redhat.com> - 1.0.3-1
afdf34
- rebase to 1.0.3
afdf34
- sync fedora with rhel
afdf34
afdf34
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.2-2
afdf34
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
afdf34
afdf34
* Wed Jan 06 2021 Radovan Sroka <rsroka@redhat.com> - 1.0.2-1
afdf34
- rebase to 1.0.2
afdf34
- enabled make check
afdf34
- dnf-plugin is now required subpackage
afdf34
afdf34
* Mon Nov 16 2020 Radovan Sroka <rsroka@redhat.com> - 1.0.1-1
afdf34
- rebase to 1.0.1
afdf34
- introduced uthash dependency
afdf34
- SELinux prevents the fapolicyd process from writing to /run/dbus/system_bus_socket
afdf34
Resolves: rhbz#1874491
afdf34
- SELinux prevents the fapolicyd process from writing to /var/lib/rpm directory
afdf34
Resolves: rhbz#1876538
afdf34
afdf34
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.0-4
afdf34
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
afdf34
afdf34
* Wed Jun 24 2020 Radovan Sroka <rsroka@redhat.com> - 1.0-3
afdf34
- backported few cosmetic small patches from upstream master
afdf34
- rebase selinux tarbal to v0.3
afdf34
- file context pattern for /run/fapolicyd.pid is missing
afdf34
Resolves: rhbz#1834674
afdf34
afdf34
* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 1.0-2
afdf34
- Rebuilt for Python 3.9
afdf34
afdf34
* Mon May 25 2020 Radovan Sroka <rsroka@redhat.com> - 1.0-1
afdf34
- rebase fapolicyd to 1.0
afdf34
- allowed sys_ptrace for user namespace
afdf34
afdf34
* Mon Mar 23 2020 Radovan Sroka <rsroka@redhat.com> - 0.9.4-1
afdf34
- rebase fapolicyd to 0.9.4
afdf34
- polished the pattern detection engine
afdf34
- rpm backend now drops most of the files in /usr/share/ to dramatically reduce
afdf34
  memory consumption and improve startup speed
afdf34
- the commandline utility can now delete the lmdb trust database and manage
afdf34
  the file trust source
afdf34
afdf34
* Mon Feb 24 2020 Radovan Sroka <rsroka@redhat.com> - 0.9.3-1
afdf34
- rebase fapolicyd to 0.9.3
afdf34
- dramatically improved startup time
afdf34
- fapolicyd-cli has picked up --list and --ftype commands to help debug/write policy
afdf34
- file type identification has been improved
afdf34
- trust database statistics have been added to the reports
afdf34
afdf34
* Tue Feb 04 2020 Radovan Sroka <rsroka@redhat.com> - 0.9.2-2
afdf34
- Label all fifo_file as fapolicyd_var_run_t in /var/run.
afdf34
- Allow fapolicyd_t domain to create fifo files labeled as
afdf34
  fapolicyd_var_run_t
afdf34
afdf34
* Fri Jan 31 2020 Radovan Sroka <rsroka@redhat.com> - 0.9.2-1
afdf34
- rebase fapolicyd to 0.9.2
afdf34
- allows watched mount points to be specified by file system types
afdf34
- ELF file detection was improved
afdf34
- the rules have been rewritten to express the policy based on subject
afdf34
  object trust for better performance and reliability
afdf34
- exceptions for dracut and ansible were added to the rules to avoid problems
afdf34
  under normal system use
afdf34
- adds an admin defined trust database (fapolicyd.trust)
afdf34
- setting boost, queue, user, and group on the daemon
afdf34
  command line are deprecated
afdf34
afdf34
* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.9-4
afdf34
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
afdf34
afdf34
* Tue Nov 05 2019 Marek Tamaskovic <mtamasko@redhat.com> - 0.9-3
afdf34
- Updated fapolicyd-selinux subpackage to v0.2
afdf34
  Selinux subpackage is recommended for fapolicyd.
afdf34
afdf34
* Mon Oct 07 2019 Radovan Sroka <rsroka@redhat.com> - 0.9-2
afdf34
- Added fapolicyd-selinux subpackage
afdf34
afdf34
* Mon Oct 07 2019 Radovan Sroka <rsroka@redhat.com> - 0.9-1
afdf34
- rebase to v0.9
afdf34
afdf34
* Thu Oct 03 2019 Miro Hrončok <mhroncok@redhat.com> - 0.8.10-2
afdf34
- Rebuilt for Python 3.8.0rc1 (#1748018)
afdf34
afdf34
* Wed Aug 28 2019 Radovan Sroka <rsroka@redhat.com> - 0.8.10-1
afdf34
- rebase to 0.8.10
afdf34
- generate python paths dynamically
afdf34
afdf34
* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 0.8.9-5
afdf34
- Rebuilt for Python 3.8
afdf34
afdf34
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.9-4
afdf34
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
afdf34
afdf34
* Mon Jun 10 22:13:18 CET 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.8.9-3
afdf34
- Rebuild for RPM 4.15
afdf34
afdf34
* Mon Jun 10 15:42:01 CET 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.8.9-2
afdf34
- Rebuild for RPM 4.15
afdf34
afdf34
* Mon May 06 2019 Radovan Sroka <rsroka@redhat.com> - 0.8.9-1
afdf34
- New upstream release
afdf34
afdf34
* Wed Mar 13 2019 Radovan Sroka <rsroka@redhat.com> - 0.8.8-2
afdf34
- backport some patches to resolve dac_override for fapolicyd
afdf34
afdf34
* Mon Mar 11 2019 Radovan Sroka <rsroka@redhat.com> - 0.8.8-1
afdf34
- New upstream release
afdf34
- Added new DNF plugin that can update the trust database when rpms are installed
afdf34
- Added support for FAN_OPEN_EXEC_PERM
afdf34
afdf34
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.7-3
afdf34
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
afdf34
afdf34
afdf34
* Wed Oct 03 2018 Steve Grubb <sgrubb@redhat.com> 0.8.7-1
afdf34
- New upstream bugfix release
afdf34
afdf34
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.6-2
afdf34
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
afdf34
afdf34
* Thu Jun 07 2018 Steve Grubb <sgrubb@redhat.com> 0.8.6-1
afdf34
- New upstream feature release
afdf34
afdf34
* Fri May 18 2018 Steve Grubb <sgrubb@redhat.com> 0.8.5-2
afdf34
- Add dist tag (#1579362)
afdf34
afdf34
* Fri Feb 16 2018 Steve Grubb <sgrubb@redhat.com> 0.8.5-1
afdf34
- New release