From ceb3e8717f2ae2868d13c6558b00c5ce4190ae1b Mon Sep 17 00:00:00 2001 From: "Stuart D. Gathman" Date: Tue, 17 Oct 2017 18:01:26 -0400 Subject: [PATCH] Port to EL7 and systemd --- README.md | 6 ++++- makefile | 9 +++---- pysrs.html | 20 ++++++--------- pysrs.py | 2 +- pysrs.spec | 75 +++++++++++++++++++++++++++++++++++++++++------------- setup.cfg | 4 +-- setup.py | 4 +-- 7 files changed, 79 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 95a2700..9d37d52 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # pysrs -python-pymilter is now included in EPEL for Redhat and Redhat based distros like CentOS. The EPEL rpm does not include start.sh, which is good, since it isn't really part of pymilter. This pysrs release now uses the standard daemonize package to replace start.sh. + +A python library and sendmail/Exim socketmap that rewrites MAIL FROM. Often used with [python milter](http://pythonhosted.org/milter/) to reject forged bounces (that lack a valid SRS signature). + +The pysrs rpm now uses the standard daemonize package to replace start.sh on EL6. This is all moot with EL7 and systemd, of course. + diff --git a/makefile b/makefile index c0aad25..4924dec 100644 --- a/makefile +++ b/makefile @@ -2,14 +2,11 @@ web: doxygen rsync -ravK doc/html/ spidey2.bmsi.com:/Public/pymilter -VERSION=1.0 -CVSTAG=pysrs-1_0 +VERSION=1.0.1 PKG=pysrs-$(VERSION) SRCTAR=$(PKG).tar.gz $(SRCTAR): - cvs export -r$(CVSTAG) -d $(PKG) pysrs - tar cvfz $(PKG).tar.gz $(PKG) - rm -r $(PKG) + git archive --format=tar.gz --prefix=$(PKG)/ -o $(SRCTAR) $(PKG) -cvstar: $(SRCTAR) +srctar: $(SRCTAR) diff --git a/pysrs.html b/pysrs.html index e776254..91ae640 100644 --- a/pysrs.html +++ b/pysrs.html @@ -6,10 +6,10 @@

-Viewable With Any Browser -Your vote?

Sender Rewriting Scheme in Python

-This web page is written by Stuart D. Gathman
and
sponsored by +This web page is written by Stuart D. Gathman
and
originally sponsored by Business Management Systems, Inc.
-Last updated Jul 31, 2006

+Last updated Oct 17, 2017

This is a Python implementation of @@ -33,20 +33,16 @@

levels of forwarding and subsequent reversal for the Guarded, DB, and Reversible implementations.

Sendmail integration

diff --git a/pysrs.py b/pysrs.py index 5c70654..28ca2de 100755 --- a/pysrs.py +++ b/pysrs.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2.6 +#!/usr/bin/python2 # Sendmail socket server daemon # # Copyright (c) 2004-2010 Business Management Systems. All rights reserved. diff --git a/pysrs.spec b/pysrs.spec index d71ff35..8ee5235 100644 --- a/pysrs.spec +++ b/pysrs.spec @@ -1,23 +1,39 @@ -%define sysvinit pysrs.rc -%define __python python2.6 -# set to python26 for EL4,EL5 -%define pythonbase python +%if 0%{?rhel} == 6 +%global __python python2.6 +%global sysvinit pysrs.rc +%endif + +%global pythonbase python +%global use_systemd 1 Summary: Python SRS (Sender Rewriting Scheme) library Name: %{pythonbase}-pysrs Version: 1.0.1 -Release: 1 -Source: https://github.com/sdgathman/%{name}/archive/%{name}-%{version}.tar.gz -Patch: %{name}-%{version}.patch +Release: 1%{?dist} +Source0: pysrs-%{version}.tar.gz License: Python license Group: Development/Libraries BuildRoot: %{_tmppath}/%{name}-buildroot Prefix: %{_prefix} BuildArch: noarch +BuildRequires: python >= 2.6 Vendor: Stuart Gathman (Perl version by Shevek) Packager: Stuart D. Gathman -Requires: chkconfig, %{pythonbase}, daemonize -Url: http://bmsi.com/python/pysrs.html +Requires: %{pythonbase} sendmail sendmail-cf + +%if %{use_systemd} +# systemd macros are not defined unless systemd is present +BuildRequires: systemd +Requires: systemd +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd +%else +BuildRequires: ed +Requires: chkconfig, daemonize +%endif + +Url: http://pythonhosted.org/milter/pysrs.html %description Python SRS (Sender Rewriting Scheme) library. @@ -34,7 +50,6 @@ used as a form of authentication. %prep %setup -n pysrs-%{version} -%patch -p0 -b.sdg %build %{__python} setup.py build @@ -56,8 +71,12 @@ cp pysrsprog.m4 $RPM_BUILD_ROOT/usr/share/sendmail-cf/hack # We use same log dir as milter since we also are a sendmail add-on mkdir -p $RPM_BUILD_ROOT/var/log/milter -mkdir -p $RPM_BUILD_ROOT/var/run/milter -mkdir -p $RPM_BUILD_ROOT/usr/lib/pymilter +mkdir -p $RPM_BUILD_ROOT%{_libdir}/pymilter +cp -p pysrs.py $RPM_BUILD_ROOT%{_libdir}/pymilter/pysrs +%if %{use_systemd} +mkdir -p $RPM_BUILD_ROOT%{_unitdir} +cp -p pysrs.service $RPM_BUILD_ROOT%{_unitdir} +%else mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d cp %{sysvinit} $RPM_BUILD_ROOT/etc/rc.d/init.d/pysrs ed $RPM_BUILD_ROOT/etc/rc.d/init.d/pysrs <<'EOF' @@ -68,7 +87,7 @@ python="%{__python}" w q EOF -cp -p pysrs.py $RPM_BUILD_ROOT/usr/lib/pymilter +%endif # logfile rotation mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d @@ -82,6 +101,19 @@ EOF %clean rm -rf $RPM_BUILD_ROOT +%if %{use_systemd} + +%post +%systemd_post pysrs.service + +%postun +%systemd_postun_with_restart pysrs.service + +%preun +%systemd_preun pysrs.service + +%else + %post #echo "Syntax of HACK(pysrs) has changed. Update sendmail.mc." /sbin/chkconfig --add pysrs @@ -91,19 +123,28 @@ if [ $1 = 0 ]; then /sbin/chkconfig --del pysrs fi +%endif + %files -f INSTALLED_FILES %doc COPYING LICENSE.python LICENSE.sendmail CHANGES %defattr(-,root,root) %config(noreplace) /etc/mail/pysrs.cfg %config(noreplace) /etc/mail/no-srs-mailers /etc/logrotate.d/pysrs -/etc/rc.d/init.d/pysrs /usr/share/sendmail-cf/hack/* -/usr/lib/pymilter/pysrs.py +%{_libdir}/pymilter/pysrs +%if %{use_systemd} +%{_unitdir}/* +%else +/etc/rc.d/init.d/pysrs +%endif %changelog -* Sat Sep 30 2017 Stuart Gathman 1.0.1-1 -- Support both python2 and python3 +* Tue Oct 17 2017 Stuart Gathman 1.0.1-1 +- Initial python3 port + +* Fri Sep 15 2017 Stuart Gathman 1.0-5 +- Port to EL7 and systemd * Sat Mar 1 2014 Stuart Gathman 1.0-4 - Fix initscript error diff --git a/setup.cfg b/setup.cfg index 9038f0b..837ba5c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,5 +4,5 @@ optimize = 1 [bdist_rpm] group = Development/Libraries -python=python2.6 -packager=Stuart D. Gathman +python=python +packager=Stuart D. Gathman diff --git a/setup.py b/setup.py index db284f3..97bf2f3 100644 --- a/setup.py +++ b/setup.py @@ -31,8 +31,8 @@ http://www.libsrs2.org/ """, author = 'Stuart Gathman (Perl version by Shevek)', - author_email = 'stuart@bmsi.com', - url = 'http://bmsi.com/python/pysrs.html', + author_email = 'stuart@gathman.org', + url = 'http://pythonhosted.org/milter/pysrs.html', py_modules = ['SocketMap'], packages = ['SRS','SES'], scripts = ['envfrom2srs.py','srs2envtol.py'],