-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpysrs.spec
194 lines (164 loc) · 5.66 KB
/
pysrs.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
%global pythonbase python
%global use_systemd 1
Summary: Python SRS (Sender Rewriting Scheme) library
Name: %{pythonbase}-pysrs
Version: 1.0.3
Release: 1%{?dist}
Source0: pysrs-%{version}.tar.gz
License: Python license
Group: Development/Libraries
BuildRoot: %{_tmppath}/%{name}-buildroot
Prefix: %{_prefix}
BuildArch: noarch
BuildRequires: python >= 3.6
Requires: %{pythonbase} sendmail sendmail-cf python-pymilter
%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.
As SPF is implemented, mail forwarders must rewrite envfrom for domains
they are not authorized to send from.
See http://www.openspf.org/SRS for details.
The Perl reference implementation is at http://srs-socketmap.info/
SRS is also useful for detecting forged DSNs (bounces). SES (Signed
Envelope Sender) is a variation that is more compact for this purpose,
and in conjuction with some kind of replay protection can also be
used as a form of authentication.
%prep
%setup -n pysrs-%{version}
%build
%{__python} setup.py build
%install
%{__python} setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES
mkdir -p $RPM_BUILD_ROOT/etc/mail
cp pysrs.cfg $RPM_BUILD_ROOT/etc/mail
cat >$RPM_BUILD_ROOT/etc/mail/no-srs-mailers <<'EOF'
# no-srs-mailers - list hosts (RHS) we should not SRS encode for when we
# send to them. E.g. primary MX servers for which we are a secondary.
# NOTE - mailertable can change the RHS for delivery purposes, you
# must match the mailertable RHS in that case.
#
EOF
mkdir -p $RPM_BUILD_ROOT/usr/share/sendmail-cf/hack
cp pysrs.m4 $RPM_BUILD_ROOT/usr/share/sendmail-cf/hack
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%{_libexecdir}/milter
cp -p pysrs.py $RPM_BUILD_ROOT%{_libexecdir}/milter/pysrs
cp -p srsmilter.py $RPM_BUILD_ROOT%{_libexecdir}/milter/srsmilter
%if %{use_systemd}
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
cp -p pysrs.service $RPM_BUILD_ROOT%{_unitdir}
cp -p srsmilter.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'
/^python=/
c
python="%{__python}"
.
w
q
EOF
%endif
%if !%{use_systemd}
# logfile rotation
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
cat >$RPM_BUILD_ROOT/etc/logrotate.d/pysrs <<'EOF'
/var/log/milter/pysrs.log {
copytruncate
compress
}
EOF
%endif
%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
%preun
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
/usr/share/sendmail-cf/hack/*
%{_libexecdir}/milter/pysrs
%{_libexecdir}/milter/srsmilter
%if %{use_systemd}
%{_unitdir}/*
%else
/etc/rc.d/init.d/pysrs
%endif
%changelog
- Python3 update
- drop EL6 support
- Include srsmilter
- Fix daemon to run in python2
- Move daemons to /usr/libexec/milter so they get bin_t selinux label
- Initial python3 port
- Port to EL7 and systemd
- Fix initscript error
- Use daemonize instead of start.sh, which is gone from pymilter
- Foundation for python milter envfrom rewriting (in progress)
- Python 2.6
- Depend on pymilter for dirs, even though we don't
really need it for anything else until envfrom rewriting is done.
- Support logging recipient host, and nosrs in pysrs.cfg
- support SRS signing mode
- support SES
- chkconfig --add pysrs
- Sendmail Socketmap Daemon
- Use HMAC instead of straight sha
- Pass SRS_DOMAIN to envfrom2srs.py
- Put SRS rewriting rule at end of EnvFromSMTP in pysrs.m4
- Fix regex for is_srs macro in pysrs.m4
- set alwaysrewrite=True in envfrom2srs.py since pysrs.m4 skips local domains
- Incorporate m4 macro from Alain Knaff for cleaner sendmail support
- Make sendmail map use config in /etc/mail/pysrs.cfg