a9f7d2a
Summary:           Milter to check mails for suspicious Microsoft VBA macro code
a9f7d2a
Name:              macromilter
a9f7d2a
URL:               https://github.com/sbidy/MacroMilter
rpmbuild d90e44c
Version:           3.7.0
rpmbuild d90e44c
License:           MIT
cbdcf24
%global            baserelease      14
rpmbuild d90e44c
rpmbuild d90e44c
# Build from release or from git snapshot
rpmbuild d90e44c
%bcond_without     snapshot
rpmbuild d90e44c
rpmbuild d90e44c
# Build python2 up till fc31 and rhel7, use python3 on fc32+ and rhel8+
7bc8303
%if ( 0%{?fedora} && 0%{?fedora} >= 32 ) || ( 0%{?rhel} && 0%{?rhel} >= 8 )
rpmbuild d90e44c
%bcond_without     python3
7bc8303
%else
7bc8303
%bcond_with        python3
rpmbuild d90e44c
%endif
rpmbuild d90e44c
rpmbuild d90e44c
%global            gituser         sbidy
rpmbuild d90e44c
%global            gitname         MacroMilter
rpmbuild d90e44c
#                                  3.7 branch pre-release
rpmbuild d90e44c
%global            gitdate         20191111
rpmbuild d90e44c
%global            commit          2761838f0358995828e38cdcce06f845162cc55f
rpmbuild d90e44c
%global            shortcommit     %(c=%{commit}; echo ${c:0:7})
rpmbuild d90e44c
rpmbuild d90e44c
rpmbuild d90e44c
%if ! 0%{?with_snapshot}
rpmbuild d90e44c
#Build from release
rpmbuild d90e44c
Source0:           https://github.com/%{gituser}/%{gitname}/archive/%{version}/%{name}-%{version}.tar.gz
rpmbuild d90e44c
Release:           %{baserelease}%{?dist}
rpmbuild d90e44c
%else
rpmbuild d90e44c
#Build from git snapshot
rpmbuild d90e44c
Source0:           https://github.com/%{gituser}/%{gitname}/archive/%{commit}/%{name}-%{version}-%{shortcommit}.tar.gz
rpmbuild d90e44c
Release:           0.%{baserelease}.%{gitdate}git%{shortcommit}%{?dist}
rpmbuild d90e44c
%endif
rpmbuild d90e44c
a9f7d2a
Source1:           macromilter.service
a9f7d2a
Source2:           macromilter.logrotate
d4c5ee1
Source3:           macromilter.tmpfilesd
d4c5ee1
Source4:           README.fedora
rpmbuild d90e44c
#Patch0:            macromilter-3.4.3-var-lib.patch
rpmbuild d90e44c
a9f7d2a
BuildArch:         noarch
rpmbuild d90e44c
a9f7d2a
BuildRequires:     systemd
rpmbuild d90e44c
a9f7d2a
Requires(pre):     shadow-utils
a9f7d2a
Requires(post):    systemd
a9f7d2a
Requires(preun):   systemd
a9f7d2a
Requires(postun):  systemd
rpmbuild d90e44c
rpmbuild d90e44c
%if 0%{?with_python3}
rpmbuild d90e44c
BuildRequires:     python%{python3_pkgversion}-devel
rpmbuild d90e44c
Requires:          python%{python3_pkgversion}-oletools
rpmbuild d90e44c
Requires:          python%{python3_pkgversion}-pymilter
rpmbuild d90e44c
rpmbuild d90e44c
%else
rpmbuild d90e44c
BuildRequires:     python2-devel
rpmbuild d90e44c
Requires:          python2-oletools
rpmbuild d90e44c
a9f7d2a
# No python3-pymilter package yet
a9f7d2a
%if 0%{?rhel} > 7 || 0%{?fedora} > 27
a9f7d2a
Requires:          python2-pymilter
a9f7d2a
%else
a9f7d2a
Requires:          python-pymilter
a9f7d2a
%endif
rpmbuild d90e44c
%endif
rpmbuild d90e44c
8846adb
Provides:          MacroMilter = %{version}-%{release}
a9f7d2a
a9f7d2a
%description
a9f7d2a
Python based milter for Sendmail and Postfix MTA servers to check incoming
a9f7d2a
e-mails for Microsoft Office attachments. If a Microsoft Office document is
a9f7d2a
attached to the e-mail, it will be scanned for suspicious VBA macro code.
a9f7d2a
Files with malicious macros are, depending on configuration, either removed
a9f7d2a
and replaced by harmless text files or alternatively the whole e-mail will
a9f7d2a
be rejected.
a9f7d2a
rpmbuild d90e44c
a9f7d2a
%prep
rpmbuild d90e44c
%if ! 0%{?with_snapshot}
rpmbuild d90e44c
%autosetup -n MacroMilter-%{version}
rpmbuild d90e44c
%else
rpmbuild d90e44c
%autosetup -n MacroMilter-%{commit}
rpmbuild d90e44c
%endif
d4c5ee1
cp -pf %{SOURCE4} .
rpmbuild d90e44c
a9f7d2a
a9f7d2a
%build
a9f7d2a
# Empty build section, most likely nothing required.
a9f7d2a
rpmbuild d90e44c
a9f7d2a
%install
rpmbuild d90e44c
install -D -p -m 755 %{name}/macromilter.py %{buildroot}%{_bindir}/%{name}
rpmbuild d90e44c
%if 0%{?with_python3}
rpmbuild d90e44c
sed -e '1i #!%{_bindir}/python3' -i %{buildroot}%{_bindir}/%{name}
rpmbuild d90e44c
%else
rpmbuild d90e44c
sed -e '1i #!%{_bindir}/python2' -i %{buildroot}%{_bindir}/%{name}
rpmbuild d90e44c
%endif
rpmbuild d90e44c
touch -c -r %{name}/macromilter.py %{buildroot}%{_bindir}/%{name}
rpmbuild d90e44c
install -D -p -m 644 %{name}/config.yaml %{buildroot}%{_sysconfdir}/%{name}/config.yaml
rpmbuild d90e44c
install -D -p -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
rpmbuild d90e44c
install -D -p -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
rpmbuild d90e44c
install -D -p -m 644 %{SOURCE3} %{buildroot}%{_tmpfilesdir}/%{name}.conf
rpmbuild d90e44c
mkdir -p %{buildroot}{/run,%{_localstatedir}/{lib,log}}/%{name}/
rpmbuild d90e44c
a9f7d2a
a9f7d2a
%pre
a9f7d2a
getent group %{name} > /dev/null || %{_sbindir}/groupadd -r %{name}
a9f7d2a
getent passwd %{name} > /dev/null || %{_sbindir}/useradd -r -g %{name} -d %{_localstatedir}/lib/%{name} -s /sbin/nologin -c "MacroMilter service" %{name}
a9f7d2a
exit 0
a9f7d2a
rpmbuild d90e44c
a9f7d2a
%post
a9f7d2a
%systemd_post %{name}.service
a9f7d2a
rpmbuild d90e44c
a9f7d2a
%preun
a9f7d2a
%systemd_preun %{name}.service
a9f7d2a
rpmbuild d90e44c
a9f7d2a
%postun
a9f7d2a
%systemd_postun_with_restart %{name}.service
a9f7d2a
rpmbuild d90e44c
a9f7d2a
%files
a9f7d2a
%license LICENSE.md
d4c5ee1
%doc README.fedora README.md
a9f7d2a
%{_bindir}/%{name}
a9f7d2a
%dir %{_sysconfdir}/%{name}/
rpmbuild d90e44c
%config(noreplace) %{_sysconfdir}/%{name}/config.yaml
a9f7d2a
%dir %{_sysconfdir}/logrotate.d/
a9f7d2a
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
a9f7d2a
%{_unitdir}/%{name}.service
d4c5ee1
%{_tmpfilesdir}/%{name}.conf
d4c5ee1
%dir %attr(0755,%{name},%{name}) /run/%{name}/
d4c5ee1
%dir %attr(0750,%{name},%{name}) %{_localstatedir}/lib/%{name}/
d4c5ee1
%dir %attr(0750,%{name},%{name}) %{_localstatedir}/log/%{name}/
a9f7d2a
a9f7d2a
%changelog
cbdcf24
* Thu Jan 25 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.7.0-0.14.20191111git2761838
cbdcf24
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
cbdcf24
c667a80
* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.7.0-0.13.20191111git2761838
c667a80
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
c667a80
637e049
* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.7.0-0.12.20191111git2761838
637e049
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
637e049
15e7943
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.7.0-0.11.20191111git2761838
15e7943
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
15e7943
c9bf90b
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 3.7.0-0.10.20191111git2761838
c9bf90b
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
c9bf90b
f4cbb25
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 3.7.0-0.9.20191111git2761838
f4cbb25
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
f4cbb25
545b9a5
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.7.0-0.8.20191111git2761838
545b9a5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
545b9a5
e87f60b
* Tue Mar 02 2021 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 3.7.0-0.7.20191111git2761838
e87f60b
- Rebuilt for updated systemd-rpm-macros
e87f60b
  See https://pagure.io/fesco/issue/2583.
e87f60b
1d3e50d
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.7.0-0.6.20191111git2761838
1d3e50d
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
1d3e50d
8b3abe8
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.7.0-0.5.20191111git2761838
8b3abe8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
8b3abe8
6fb99d6
* Mon May 04 2020 Robert Scheck <robert@fedoraproject.org> 3.7.0-0.4.20191111git2761838
6fb99d6
- Removed unnecessary dependency on python configparser package (#1825543)
6fb99d6
bd69736
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.7.0-0.3.20191111git2761838
bd69736
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
bd69736
7bc8303
* Sat Nov 16 2019 Robert Scheck <robert@fedoraproject.org> 3.7.0-0.2.20191111git2761838
7bc8303
- Correct Python 3 conditionals in spec file (thanks to Michal Ambroz)
7bc8303
7bc8303
* Fri Nov 15 2019 Michal Ambroz <rebus AT_ seznam.cz> - 3.7.0-0.1.20191111git2761838
7bc8303
- Upgrade to 3.7.0 (GIT 20191111) (#1738083, #1770551)
7bc8303
26c4402
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.3-5
26c4402
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
26c4402
9944e6f
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.3-4
9944e6f
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
9944e6f
157344f
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.3-3
157344f
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
157344f
1cd0038
* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.3-2
1cd0038
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
1cd0038
d4c5ee1
* Mon Oct 30 2017 Robert Scheck <robert@fedoraproject.org> 3.4.3-1
d4c5ee1
- Upgrade to 3.4.3
d4c5ee1
dab15e8
* Mon Oct 09 2017 Robert Scheck <robert@fedoraproject.org> 3.3-1.20171009git4e8295f
a9f7d2a
- Upgrade to 3.3 (GIT 20171009)
a9f7d2a
dab15e8
* Sat Oct 07 2017 Robert Scheck <robert@fedoraproject.org> 3.3-1.20171007giteae1667
a9f7d2a
- Upgrade to 3.3 (GIT 20171007)
a9f7d2a
- Initial spec file for Fedora and Red Hat Enterprise Linux