Skip to content

Commit

Permalink
Port to EL7 and systemd
Browse files Browse the repository at this point in the history
  • Loading branch information
sdgathman committed Oct 17, 2017
1 parent c0dc31e commit ceb3e87
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 41 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

9 changes: 3 additions & 6 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
20 changes: 8 additions & 12 deletions pysrs.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
</head><body>

<P ALIGN="CENTER"><A HREF="http://www.anybrowser.org/campaign/">
<IMG SRC="/art/brain1.gif"
<IMG SRC="art/brain1.gif"
ALT="Viewable With Any Browser" BORDER="0"></A>

<img src="/art/banner_4.gif" width="468" height="60" border="0"
<img src="art/banner_4.gif" width="468" height="60" border="0"
usemap="#banner_4" alt="Your vote?">
<map name="banner_4">
<area shape="rect" coords="330,25,426,59"
Expand All @@ -20,9 +20,9 @@
</P>
<h1 align=center>Sender Rewriting Scheme in Python</h1>
<h4 align=center>
This web page is written by Stuart D. Gathman<br>and<br>sponsored by
This web page is written by Stuart D. Gathman<br>and<br>originally sponsored by
<a href="http://www.bmsi.com">Business Management Systems, Inc.</a> <br>
Last updated Jul 31, 2006</h4>
Last updated Oct 17, 2017</h4>

<p>
This is a <a href="http://www.python.org/">Python</a> implementation of
Expand All @@ -33,20 +33,16 @@ <h4 align=center>
levels of forwarding and subsequent reversal for the Guarded, DB, and
Reversible implementations.
<ul>
<li>This package includes scripts to be used as sendmail program maps. See
<a href="http://asarian-host.net/srs/sendmailsrs.htm">sendmail integration</a>
for an explanation and instructions on incorporating SRS into
<code>sendmail.cf</code>, substituting <code>envfrom2srs.py</code> and
<code>srs2envtol.py</code> for the perl scripts. Even simpler, use the
supplied sendmail m4 hack with <code>sendmail.mc</code>.
<li>SRS.Daemon.Daemon() provides a simple socket daemon suitable
for use with the Exim mailer.
<li>RPM now includes a sendmail socketmap daemon. The program map is
no longer recommended. It is slow and a security risk. Prior to socketmaps,
it was all that was available for a custom map. Socketmap is available
in <a href="http://www.sendmail.org">sendmail 8.13</a>.
<li>For best results, use with <a href="milter.html">Python milter</a>
to reject unsigned recipients.
Use the supplied sendmail m4 hack with <code>sendmail.mc</code> to
install the socketmap.
<li>For best results, use with <a href="http://pythonhosted.org/milter/">
Python milter</a> to reject unsigned recipients.
</ul>

<h3> Sendmail integration </h3>
Expand Down
2 changes: 1 addition & 1 deletion pysrs.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
75 changes: 58 additions & 17 deletions pysrs.spec
Original file line number Diff line number Diff line change
@@ -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) <[email protected]>
Packager: Stuart D. Gathman <[email protected]>
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.
Expand All @@ -34,7 +50,6 @@ used as a form of authentication.

%prep
%setup -n pysrs-%{version}
%patch -p0 -b.sdg

%build
%{__python} setup.py build
Expand All @@ -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'
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 <[email protected]> 1.0.1-1
- Support both python2 and python3
* Tue Oct 17 2017 Stuart Gathman <[email protected]> 1.0.1-1
- Initial python3 port

* Fri Sep 15 2017 Stuart Gathman <[email protected]> 1.0-5
- Port to EL7 and systemd

* Sat Mar 1 2014 Stuart Gathman <[email protected]> 1.0-4
- Fix initscript error
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ optimize = 1

[bdist_rpm]
group = Development/Libraries
python=python2.6
packager=Stuart D. Gathman <stuart@bmsi.com>
python=python
packager=Stuart D. Gathman <stuart@gathman.org>
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',

This comment has been minimized.

Copy link
@hefee

hefee Oct 18, 2017

Contributor

You should also update the hompage itself and not link to sourceforge anymore :)

This comment has been minimized.

Copy link
@sdgathman

sdgathman Oct 20, 2017

Author Owner

I cannot update the homepage. It seems that pythonhosted.org has died, and my only choice is to delete it (after making a new home). For now, I put the updated docs on http://bmsi.com/python/pysrs.html (with no doubt many links still to pythonhosted.org). That is my old company, so I'll probably move it gathman.org. I looked at readthedocs - and it requires Yet Another Registration and Login, so I hate it.

py_modules = ['SocketMap'],
packages = ['SRS','SES'],
scripts = ['envfrom2srs.py','srs2envtol.py'],
Expand Down

0 comments on commit ceb3e87

Please sign in to comment.