Blame SPECS/fapolicyd.spec

037a42
%global selinuxtype targeted
037a42
%global moduletype contrib
e4d26d
%define semodule_version 0.3
037a42
037a42
714ab2
Summary: Application Whitelisting Daemon
714ab2
Name: fapolicyd
e4d26d
Version: 1.0.2
cced7c
Release: 4%{?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
e4d26d
Patch1: fapolicyd-magic-override.patch
e4d26d
Patch2: selinux.patch
e4d26d
Patch3: fapolicyd-startup-message.patch
e4d26d
Patch4: fapolicyd-cli-hang.patch
e4d26d
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
e4d26d
Patch5: fapolicyd-dnf-plugin.patch
4255d0
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
e4d26d
%patch1 -p1 -b .magic
e4d26d
%patch2 -p1 -b .selinux
e4d26d
%patch3 -p1 -b .startup
e4d26d
%patch4 -p1 -b .cli-hang
e4d26d
e4d26d
%patch5 -p1 -b .plugin
e4d26d
714ab2
# generate rules for python
037a42
sed -i "s/%python2_path%/`readlink -f %{__python2} | sed 's/\//\\\\\//g'`/g" init/%{name}.rules.*
037a42
sed -i "s/%python3_path%/`readlink -f %{__python3} | sed 's/\//\\\\\//g'`/g" init/%{name}.rules.*
037a42
sed -i "s/%ld_so_path%/`find /usr/lib64/ -type f -name 'ld-2\.*.so' | sed 's/\//\\\\\//g'`/g" init/%{name}.rules.*
037a42
714ab2
%build
714ab2
./autogen.sh
037a42
%configure \
037a42
    --with-audit \
037a42
    --with-rpm \
037a42
    --disable-shared
037a42
714ab2
make CFLAGS="%{optflags}" %{?_smp_mflags}
714ab2
037a42
# selinux
037a42
pushd %{name}-selinux-%{semodule_version}
037a42
make
037a42
popd
037a42
037a42
# selinux
037a42
%pre selinux
037a42
%selinux_relabel_pre -s %{selinuxtype}
037a42
e4d26d
%check
e4d26d
make check
e4d26d
714ab2
%install
714ab2
make DESTDIR="%{buildroot}" INSTALL='install -p' 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
037a42
install -p -m 644 init/%{name}.rules.known-libs %{buildroot}/%{_sysconfdir}/%{name}/%{name}.rules
714ab2
mkdir -p %{buildroot}/%{_localstatedir}/lib/%{name}
714ab2
mkdir -p %{buildroot}/run/%{name}
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
037a42
find %{buildroot} \( -name '*.la' -o -name '*.a' \) -exec rm -f {} ';'
037a42
714ab2
%pre
714ab2
getent passwd %{name} >/dev/null || useradd -r -M -d %{_localstatedir}/lib/%{name} -s /sbin/nologin -c "Application Whitelisting Daemon" %{name}
714ab2
4255d0
%pretrans -p <lua>
4255d0
if posix.access("/run/fapolicyd.pid", "f") then
4255d0
  os.execute([[
4255d0
    c=/etc/fapolicyd/fapolicyd.rules
4255d0
    release=/etc/redhat-release
4255d0
    rule="allow perm=any uid=0 : all"
4255d0
    if test -e $release; then
4255d0
       if grep -q '8.1' $release; then
4255d0
          rule="allow uid=0 all"
4255d0
       fi
4255d0
    fi
4255d0
4255d0
    if test -e $c; then
4255d0
       if systemctl is-active fapolicyd &> /dev/null; then
4255d0
          tmp=`mktemp`
4255d0
          cat $c > $tmp
4255d0
          echo "$rule" > $c
4255d0
          cat $tmp >> $c
4255d0
          systemctl restart fapolicyd || true
cced7c
          sleep 10
4255d0
          cat $tmp > $c
4255d0
          rm -f $tmp
4255d0
        fi
4255d0
    fi
4255d0
    ]])
4255d0
end
4255d0
714ab2
%post
714ab2
%systemd_post %{name}.service
714ab2
714ab2
%preun
714ab2
%systemd_preun %{name}.service
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}
037a42
%attr(644,root,%{name}) %{_datadir}/%{name}/%{name}.rules.*
714ab2
%attr(750,root,%{name}) %dir %{_sysconfdir}/%{name}
714ab2
%config(noreplace) %attr(644,root,%{name}) %{_sysconfdir}/%{name}/%{name}.conf
037a42
%config(noreplace) %attr(644,root,%{name}) %{_sysconfdir}/%{name}/%{name}.trust
037a42
%config(noreplace) %attr(644,root,%{name}) %{_sysconfdir}/%{name}/%{name}.rules
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
714ab2
%attr(644,root,root) %{_mandir}/man8/*
714ab2
%attr(644,root,root) %{_mandir}/man5/*
714ab2
%attr(644,root,root) %{_mandir}/man1/*
037a42
%attr(644,root,root) %{_datadir}/%{name}/*
714ab2
%ghost %{_localstatedir}/log/%{name}-access.log
714ab2
%attr(770,root,%{name}) %dir %{_localstatedir}/lib/%{name}
714ab2
%attr(770,root,%{name}) %dir /run/%{name}
714ab2
%ghost %{_localstatedir}/run/%{name}/%{name}.fifo
714ab2
%ghost %{_localstatedir}/lib/%{name}/data.mdb
714ab2
%ghost %{_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
e4d26d
037a42
# selinux
037a42
%files selinux
037a42
%{_datadir}/selinux/packages/%{selinuxtype}/%{name}.pp.bz2
037a42
%ghost %{_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
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
cced7c
* Tue Mar 02 2021 Radovan Sroka <rsroka@redhat.com> - 1.0.2-4
cced7c
RHEL 8.4.0 ERRATUM
cced7c
- fapolicyd breaks system upgrade, leaving system in dead state - complete fix
cced7c
Resolves: rhbz#1896875
cced7c
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