Blame SPECS/fapolicyd.spec

037a42
%global selinuxtype targeted
037a42
%global moduletype contrib
7aaf18
%define semodule_version 0.4
037a42
714ab2
Summary: Application Whitelisting Daemon
714ab2
Name: fapolicyd
a46afc
Version: 1.1.3
a46afc
Release: 6%{?dist}
714ab2
License: GPLv3+
714ab2
URL: http://people.redhat.com/sgrubb/fapolicyd
714ab2
Source0: https://people.redhat.com/sgrubb/fapolicyd/%{name}-%{version}.tar.gz
037a42
Source1: https://github.com/linux-application-whitelisting/%{name}-selinux/releases/download/v%{semodule_version}/%{name}-selinux-%{semodule_version}.tar.gz
037a42
BuildRequires: gcc
714ab2
BuildRequires: kernel-headers
714ab2
BuildRequires: autoconf automake make gcc libtool
e4d26d
BuildRequires: systemd-devel libgcrypt-devel rpm-devel file-devel file
714ab2
BuildRequires: libcap-ng-devel libseccomp-devel lmdb-devel
714ab2
BuildRequires: python3-devel
714ab2
BuildRequires: python2-devel
e4d26d
BuildRequires: uthash-devel
e4d26d
Requires: rpm-plugin-fapolicyd >= 4.14.3-12
037a42
Recommends: %{name}-selinux
714ab2
Requires(pre): shadow-utils
714ab2
Requires(post): systemd-units
714ab2
Requires(preun): systemd-units
714ab2
Requires(postun): systemd-units
714ab2
e4d26d
# we are making the dnf-plugin completelly dummy because of
e4d26d
# https://bugzilla.redhat.com/show_bug.cgi?id=1929163
cced7c
# we require the rpm-plugin from now on and the dnf-plugin still needs to be part of
cced7c
# the fapolicyd package because it provides safe upgrade path
26e946
Patch1: fapolicyd-dnf-plugin.patch
26e946
Patch2: fapolicyd-selinux.patch
a46afc
Patch3: fagenrules-group.patch
10e794
714ab2
%description
714ab2
Fapolicyd (File Access Policy Daemon) implements application whitelisting
714ab2
to decide file access rights. Applications that are known via a reputation
714ab2
source are allowed access while unknown applications are not. The daemon
714ab2
makes use of the kernel's fanotify interface to determine file access rights.
714ab2
037a42
%package        selinux
037a42
Summary:        Fapolicyd selinux
037a42
Group:          Applications/System
037a42
Requires:       %{name} = %{version}-%{release}
037a42
BuildRequires:  selinux-policy
037a42
BuildRequires:  selinux-policy-devel
037a42
BuildArch: noarch
e4d26d
%{?selinux_requires}
037a42
037a42
%description    selinux
037a42
The %{name}-selinux package contains selinux policy for the %{name} daemon.
714ab2
714ab2
%prep
037a42
714ab2
%setup -q
714ab2
037a42
# selinux
037a42
%setup -q -D -T -a 1
714ab2
26e946
%patch1 -p1 -b .plugin
26e946
%patch2 -p1 -b .selinux
a46afc
%patch3 -p1 -b .group
10e794
714ab2
# generate rules for python
a88243
sed -i "s|%python2_path%|`readlink -f %{__python2}`|g" rules.d/*.rules
a88243
sed -i "s|%python3_path%|`readlink -f %{__python3}`|g" rules.d/*.rules
a88243
a88243
interpret=`readelf -e /usr/bin/bash \
a88243
                   | grep Requesting \
a88243
                   | sed 's/.$//' \
a88243
                   | rev | cut -d" " -f1 \
a88243
                   | rev`
a88243
a88243
sed -i "s|%ld_so_path%|`realpath $interpret`|g" rules.d/*.rules
037a42
714ab2
%build
714ab2
./autogen.sh
037a42
%configure \
037a42
    --with-audit \
037a42
    --with-rpm \
037a42
    --disable-shared
037a42
26e946
%make_build
714ab2
037a42
# selinux
037a42
pushd %{name}-selinux-%{semodule_version}
037a42
make
037a42
popd
037a42
26e946
%check
26e946
make check
26e946
037a42
# selinux
037a42
%pre selinux
037a42
%selinux_relabel_pre -s %{selinuxtype}
037a42
714ab2
%install
26e946
%make_install
714ab2
mkdir -p %{buildroot}/%{python3_sitelib}/dnf-plugins/
714ab2
install -p -m 644 dnf/%{name}-dnf-plugin.py %{buildroot}/%{python3_sitelib}/dnf-plugins/
714ab2
install -p -m 644 -D init/%{name}-tmpfiles.conf %{buildroot}/%{_tmpfilesdir}/%{name}.conf
714ab2
mkdir -p %{buildroot}/%{_localstatedir}/lib/%{name}
714ab2
mkdir -p %{buildroot}/run/%{name}
7aaf18
mkdir -p %{buildroot}%{_sysconfdir}/%{name}/trust.d
26e946
mkdir -p %{buildroot}%{_sysconfdir}/%{name}/rules.d
07959c
# get list of file names between known-libs and restrictive from sample-rules/README-rules
07959c
cat %{buildroot}/%{_datadir}/%{name}/sample-rules/README-rules \
07959c
  | grep -A 100 'known-libs' \
07959c
  | grep -B 100 'restrictive' \
07959c
  | grep '^[0-9]' > %{buildroot}/%{_datadir}/%{name}/default-ruleset.known-libs
07959c
chmod 644 %{buildroot}/%{_datadir}/%{name}/default-ruleset.known-libs
714ab2
037a42
# selinux
037a42
install -d %{buildroot}%{_datadir}/selinux/packages/%{selinuxtype}
037a42
install -m 0644 %{name}-selinux-%{semodule_version}/%{name}.pp.bz2 %{buildroot}%{_datadir}/selinux/packages/%{selinuxtype}
037a42
install -d -p %{buildroot}%{_datadir}/selinux/devel/include/%{moduletype}
037a42
install -p -m 644 %{name}-selinux-%{semodule_version}/%{name}.if %{buildroot}%{_datadir}/selinux/devel/include/%{moduletype}/ipp-%{name}.if
037a42
037a42
#cleanup
26e946
find %{buildroot} \( -name '*.la' -o -name '*.a' \) -delete
037a42
07959c
%define manage_default_rules   default_changed=0 \
07959c
  # check changed fapolicyd.rules \
07959c
  if [ -e %{_sysconfdir}/%{name}/%{name}.rules ]; then \
07959c
    diff %{_sysconfdir}/%{name}/%{name}.rules %{_datadir}/%{name}/%{name}.rules.known-libs >/dev/null 2>&1 || { \
07959c
      default_changed=1; \
07959c
      #echo "change detected in fapolicyd.rules"; \
07959c
      } \
07959c
  fi \
07959c
  if [ -e %{_sysconfdir}/%{name}/rules.d ]; then \
07959c
    default_ruleset='' \
07959c
    # get listing of default rule files in known-libs \
07959c
    [ -e %{_datadir}/%{name}/default-ruleset.known-libs ] && default_ruleset=`cat %{_datadir}/%{name}/default-ruleset.known-libs` \
07959c
    # check for removed or added files \
07959c
    default_count=`echo "$default_ruleset" | wc -l` \
07959c
    current_count=`ls -1 %{_sysconfdir}/%{name}/rules.d/*.rules | wc -l` \
07959c
    [ $default_count -eq $current_count ] || { \
07959c
      default_changed=1; \
07959c
      #echo "change detected in number of rule files d:$default_count vs c:$current_count"; \
07959c
      } \
07959c
    for file in %{_sysconfdir}/%{name}/rules.d/*.rules; do \
07959c
      if echo "$default_ruleset" | grep -q "`basename $file`"; then \
07959c
        # compare content of the rule files \
07959c
        diff $file %{_datadir}/%{name}/sample-rules/`basename $file` >/dev/null 2>&1 || { \
07959c
          default_changed=1; \
07959c
          #echo "change detected in `basename $file`"; \
07959c
          } \
07959c
      else \
07959c
        # added file detected \
07959c
        default_changed=1 \
07959c
        #echo "change detected in added rules file `basename $file`"; \
07959c
      fi \
07959c
    done \
07959c
  fi \
07959c
  # remove files if no change against default rules detected \
07959c
  [ $default_changed -eq 0 ] && rm -rf %{_sysconfdir}/%{name}/%{name}.rules %{_sysconfdir}/%{name}/rules.d/* || : \
07959c
07959c
714ab2
%pre
714ab2
getent passwd %{name} >/dev/null || useradd -r -M -d %{_localstatedir}/lib/%{name} -s /sbin/nologin -c "Application Whitelisting Daemon" %{name}
07959c
if [ $1 -eq 2 ]; then
07959c
# detect changed default rules in case of upgrade
07959c
%manage_default_rules
07959c
fi
714ab2
714ab2
%post
26e946
# if no pre-existing rule file
26e946
if [ ! -e %{_sysconfdir}/%{name}/%{name}.rules ] ; then
26e946
 files=`ls %{_sysconfdir}/%{name}/rules.d/ 2>/dev/null | wc -w`
26e946
 # Only if no pre-existing component rules
26e946
 if [ "$files" -eq 0 ] ; then
26e946
  ## Install the known libs policy
07959c
  for rulesfile in `cat %{_datadir}/%{name}/default-ruleset.known-libs`; do
07959c
    cp %{_datadir}/%{name}/sample-rules/$rulesfile  %{_sysconfdir}/%{name}/rules.d/
07959c
  done
26e946
  chgrp %{name} %{_sysconfdir}/%{name}/rules.d/*
26e946
  if [ -x /usr/sbin/restorecon ] ; then
26e946
   # restore correct label
26e946
   /usr/sbin/restorecon -F %{_sysconfdir}/%{name}/rules.d/*
26e946
  fi
a46afc
  fagenrules --load
26e946
 fi
26e946
fi
714ab2
%systemd_post %{name}.service
714ab2
714ab2
%preun
714ab2
%systemd_preun %{name}.service
07959c
if [ $1 -eq 0 ]; then
07959c
# detect changed default rules in case of uninstall
07959c
%manage_default_rules
07959c
else
07959c
  [ -e %{_sysconfdir}/%{name}/%{name}.rules ] && rm -rf %{_sysconfdir}/%{name}/rules.d/* || :
07959c
fi
714ab2
714ab2
%postun
714ab2
%systemd_postun_with_restart %{name}.service
714ab2
714ab2
%files
714ab2
%doc README.md
714ab2
%{!?_licensedir:%global license %%doc}
714ab2
%license COPYING
037a42
%attr(755,root,%{name}) %dir %{_datadir}/%{name}
26e946
%attr(755,root,%{name}) %dir %{_datadir}/%{name}/sample-rules
07959c
%attr(644,root,%{name}) %{_datadir}/%{name}/default-ruleset.known-libs
26e946
%attr(644,root,%{name}) %{_datadir}/%{name}/sample-rules/*
26e946
%attr(644,root,%{name}) %{_datadir}/%{name}/fapolicyd-magic.mgc
714ab2
%attr(750,root,%{name}) %dir %{_sysconfdir}/%{name}
7aaf18
%attr(750,root,%{name}) %dir %{_sysconfdir}/%{name}/trust.d
26e946
%attr(750,root,%{name}) %dir %{_sysconfdir}/%{name}/rules.d
07959c
%ghost %verify(not md5 size mtime) %attr(644,root,%{name}) %{_sysconfdir}/%{name}/rules.d/*
07959c
%ghost %verify(not md5 size mtime) %attr(644,root,%{name}) %{_sysconfdir}/%{name}/%{name}.rules
07959c
%ghost %verify(not md5 size mtime) %attr(644,root,%{name}) %{_sysconfdir}/%{name}/compiled.rules
714ab2
%config(noreplace) %attr(644,root,%{name}) %{_sysconfdir}/%{name}/%{name}.conf
037a42
%config(noreplace) %attr(644,root,%{name}) %{_sysconfdir}/%{name}/%{name}.trust
714ab2
%attr(644,root,root) %{_unitdir}/%{name}.service
714ab2
%attr(644,root,root) %{_tmpfilesdir}/%{name}.conf
714ab2
%attr(755,root,root) %{_sbindir}/%{name}
714ab2
%attr(755,root,root) %{_sbindir}/%{name}-cli
26e946
%attr(755,root,root) %{_sbindir}/fagenrules
714ab2
%attr(644,root,root) %{_mandir}/man8/*
714ab2
%attr(644,root,root) %{_mandir}/man5/*
714ab2
%attr(644,root,root) %{_mandir}/man1/*
26e946
%ghost %attr(440,%{name},%{name}) %verify(not md5 size mtime) %{_localstatedir}/log/%{name}-access.log
714ab2
%attr(770,root,%{name}) %dir %{_localstatedir}/lib/%{name}
714ab2
%attr(770,root,%{name}) %dir /run/%{name}
26e946
%ghost %attr(660,root,%{name}) /run/%{name}/%{name}.fifo
26e946
%ghost %attr(660,%{name},%{name}) %verify(not md5 size mtime) %{_localstatedir}/lib/%{name}/data.mdb
26e946
%ghost %attr(660,%{name},%{name}) %verify(not md5 size mtime) %{_localstatedir}/lib/%{name}/lock.mdb
714ab2
%{python3_sitelib}/dnf-plugins/%{name}-dnf-plugin.py
714ab2
%{python3_sitelib}/dnf-plugins/__pycache__/%{name}-dnf-plugin.*.pyc
714ab2
037a42
# selinux
037a42
%files selinux
037a42
%{_datadir}/selinux/packages/%{selinuxtype}/%{name}.pp.bz2
7aaf18
%ghost %verify(not md5 size mode mtime) %{_sharedstatedir}/selinux/%{selinuxtype}/active/modules/200/%{name}
037a42
%{_datadir}/selinux/devel/include/%{moduletype}/ipp-%{name}.if
037a42
037a42
%post selinux
037a42
%selinux_modules_install -s %{selinuxtype} %{_datadir}/selinux/packages/%{selinuxtype}/%{name}.pp.bz2
fd2e1e
%selinux_relabel_post -s %{selinuxtype}
037a42
037a42
%postun selinux
037a42
if [ $1 -eq 0 ]; then
037a42
    %selinux_modules_uninstall -s %{selinuxtype} %{name}
037a42
fi
037a42
037a42
%posttrans selinux
037a42
%selinux_relabel_post -s %{selinuxtype}
037a42
714ab2
%changelog
a46afc
* Wed Jun 22 2022 Radovan Sroka <rsroka@redhat.com> - 1.1.3-6
a46afc
RHEL 8.7.0 ERRATUM
a46afc
- rebase fapolicyd to the latest stable vesion
a46afc
Resolves: rhbz#2100087
a46afc
- fapolicyd gets way too easily killed by OOM killer
a46afc
Resolves: rhbz#2100089
a46afc
- compiled.rules file ownership and mode
a46afc
Resolves: rhbz#2066653
df5829
- Faulty handling of static applications
a46afc
Resolves: rhbz#2084497
a46afc
- fapolicyd does not correctly handle SIGHUP
a46afc
Resolves: rhbz#2070639
a46afc
- Introduce ppid rule attribute
a46afc
Resolves: rhbz#2102563
a46afc
- CVE-2022-1117 fapolicyd: fapolicyd wrongly prepares ld.so path [rhel-8.7.0]
a46afc
Resolves: rhbz#2069121
a46afc
- Fapolicyd denies access to /usr/lib64/ld-2.28.so [rhel-8.7.0]
a46afc
Resolves: rhbz#2068105
07959c
26e946
* Wed Feb 16 2022 Radovan Sroka <rsroka@redhat.com> - 1.1-1
26e946
RHEL 8.6.0 ERRATUM
26e946
- rebase to 1.1
26e946
Resolves: rhbz#1939379
26e946
- introduce rules.d feature
26e946
Resolves: rhbz#2054741
26e946
- remove pretrans scriptlet
26e946
Resolves: rhbz#2051485
26e946
7aaf18
* Mon Dec 13 2021 Zoltan Fridrich <zfridric@redhat.com> - 1.0.4-2
7aaf18
RHEL 8.6.0 ERRATUM
7aaf18
- rebase to 1.0.4
7aaf18
- added rpm_sha256_only option
7aaf18
- added trust.d directory
7aaf18
- allow file names with whitespace in trust files
7aaf18
- use full paths in trust files
7aaf18
Resolves: rhbz#1939379
7aaf18
- fix libc.so getting identified as application/x-executable
7aaf18
Resolves: rhbz#1989272
7aaf18
- fix fapolicyd-dnf-plugin reporting as '<invalid>'
7aaf18
Resolves: rhbz#1997414
7aaf18
- fix selinux DSP module definition in spec file
7aaf18
Resolves: rhbz#2014445
7aaf18
7aaf18
* Thu Aug 19 2021 Radovan Sroka <rsroka@redhat.com> - 1.0.2-7
10e794
- fapolicyd abnormally exits by executing sosreport
fd2e1e
- fixed multiple problems with unlink()
cced7c
- fapolicyd breaks system upgrade, leaving system in dead state - complete fix
7aaf18
Resolves: rhbz#1943251
cced7c
e4d26d
* Tue Feb 16 2021 Radovan Sroka <rsroka@redhat.com> - 1.0.2-3
e4d26d
RHEL 8.4.0 ERRATUM
e4d26d
- rebase to 1.0.2
e4d26d
- strong dependency on rpm/rpm-plugin-fapolicyd
e4d26d
- installed dnf-plugin is dummy and we are not using it anymore
e4d26d
- enabled integrity setting
e4d26d
Resolves: rhbz#1887451
e4d26d
- added make check
e4d26d
- Adding DISA STIG during OS installation causes 'ipa-server-install' to fail
4255d0
- fixed java detection
e4d26d
Resolves: rhbz#1895435
e4d26d
- dnf update fails when fapolicyd is enabled
e4d26d
Resolves: rhbz#1876975
e4d26d
- fapolicyd breaks system upgrade, leaving system in dead state - complete fix
e4d26d
Resolves: rhbz#1896875
4255d0
037a42
* Tue Jun 30 2020 Radovan Sroka <rsroka@redhat.com> - 1.0-3
037a42
RHEL 8.3 ERRATUM
037a42
- fixed manpage fapolicyd-conf
037a42
Resolves: rhbz#1817413
037a42
037a42
* Mon May 25 2020 Radovan Sroka <rsroka@redhat.com> - 1.0-2
037a42
RHEL 8.3 ERRATUM
037a42
- rebase to v1.0
037a42
- installed multiple policies to /usr/share/fapolicyd
037a42
  - known-libs (default)
037a42
  - restrictive
037a42
- installed fapolicyd.trust file
037a42
- enhanced fapolicyd-cli
037a42
Resolves: rhbz#1817413
037a42
- introduced fapolicyd-selinux that provides SELinux policy module
037a42
Resolves: rhbz#1714529
037a42
714ab2
* Tue Mar 03 2020 Radovan Sroka <rsroka@redhat.com> - 0.9.1-4
714ab2
RHEL 8.2 ERRATUM
714ab2
- fixed possible heap buffer overflow in elf parser
714ab2
Resolves: rhbz#1807912
714ab2
714ab2
* Tue Feb 11 2020 Radovan Sroka <rsroka@redhat.com> - 0.9.1-3
714ab2
RHEL 8.2 ERRATUM
714ab2
- fixed build time python interpreter detection (spec)
714ab2
- added python2-devel as a BuildRequires (spec)
714ab2
- allow running bash scripts in home directories
714ab2
Resolves: rhbz#1801872
714ab2
714ab2
* Wed Nov 20 2019 Radovan Sroka <rsroka@redhat.com> - 0.9.1-2
714ab2
RHEL 8.2 ERRATUM
714ab2
- rebase to v0.9.1
714ab2
- updated default configuration with new syntax
714ab2
- removed daemon mounts configuration
714ab2
Resolves: rhbz#1759895
714ab2
- default fapolicyd policy prevents Ansible from running
714ab2
- added ansible rule to default ruleset
714ab2
Resolves: rhbz#1746464
714ab2
- suspicious logs on service start
714ab2
Resolves: rhbz#1747494
714ab2
- fapolicyd blocks dracut from generating initramfs
714ab2
- added dracut rule to default configuration
714ab2
Resolves: rhbz#1757736
714ab2
- fapolicyd fails to identify perl interpreter
714ab2
Resolves: rhbz#1765039
714ab2
714ab2
* Wed Jul 24 2019 Radovan Sroka <rsroka@redhat.com> - 0.8.10-3
714ab2
- added missing manpage for fapolicyd-cli
714ab2
Resolves: rhbz#1708015
714ab2
714ab2
* Mon Jul 22 2019 Radovan Sroka <rsroka@redhat.com> - 0.8.10-2
714ab2
- Convert hashes to lowercase like sha256sum outputs
714ab2
- Stop littering STDOUT output for dnf plugin in fapolicyd
714ab2
Resolves: rhbz#1721496
714ab2
714ab2
* Tue Jun 18 2019 Radovan Sroka <rsroka@redhat.com> - 0.8.10-1
714ab2
- new upstream release
714ab2
Resolves: rhbz#1673323
714ab2
714ab2
* Mon May 06 2019 Radovan Sroka <rsroka@redhat.com> - 0.8.9-1
714ab2
- New upstream release
714ab2
- imported from fedora30
714ab2
  resolves: rhbz#1673323
714ab2
714ab2
* Wed Mar 13 2019 Radovan Sroka <rsroka@redhat.com> - 0.8.8-2
714ab2
- backport some patches to resolve dac_override for fapolicyd
714ab2
714ab2
* Mon Mar 11 2019 Radovan Sroka <rsroka@redhat.com> - 0.8.8-1
714ab2
- New upstream release
714ab2
- Added new DNF plugin that can update the trust database when rpms are installed
714ab2
- Added support for FAN_OPEN_EXEC_PERM
714ab2
714ab2
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.7-3
714ab2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
714ab2
714ab2
714ab2
* Wed Oct 03 2018 Steve Grubb <sgrubb@redhat.com> 0.8.7-1
714ab2
- New upstream bugfix release
714ab2
714ab2
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.6-2
714ab2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
714ab2
714ab2
* Thu Jun 07 2018 Steve Grubb <sgrubb@redhat.com> 0.8.6-1
714ab2
- New upstream feature release
714ab2
714ab2
* Fri May 18 2018 Steve Grubb <sgrubb@redhat.com> 0.8.5-2
714ab2
- Add dist tag (#1579362)
714ab2
714ab2
* Fri Feb 16 2018 Steve Grubb <sgrubb@redhat.com> 0.8.5-1
714ab2
- New release