1
2POLICYD-SPF(1)              General Commands Manual             POLICYD-SPF(1)
3
4
5

NAME

7       policyd-spf - pure-Python Postfix policy daemon for SPF checking
8

VERSION

10       2.0.0
11
12

USAGE

14       NOTE: Depending on the packaging and distribution, the exact path to
15       the executable may vary.
16
17       $ policyd-spf (Start using installed config file)
18
19       $ policyd-spf -h (Display usage message)
20
21       $ policyd-spf /etc/policyd-spf/policyd-spf.conf (Config file name to
22       use)
23
24       Configuration options are described in the sample configuration file
25       provided with the package (policyd-spf.conf.commented) and in policyd-
26       spf.conf(5).  The the configuration file provided with the package can
27       generally be found in /usr/local/etc/policyd-spf/, but installation lo‐
28       cation varies depending on installtion method.
29
30       Additionally, whitelisting certain IP addresses or IP addresses used by
31       listed domains from SPF checks is supported.  Skipping SPF checks for
32       local submission or trusted relays is also provided.  The sample con‐
33       figuration file and policyd-spf.conf(5) shows the format to use.
34
35

OTHER DOCUMENTATION

37       This documentation assumes you have read Postfix's README_FILES/
38       SMTPD_POLICY_README and are generally familiar with Sender Policy
39       Framework (SPF).  See RFC 7208 for details.
40
41       See man 5 policyd-spf.conf for configuration file information.
42
43       man 5 policyd-spf.peruser provides documentation on setting up and us‐
44       ing different configuration options on a per user (mail reciepient) ba‐
45       sis.
46
47

SYNOPSIS

49       python-policyd-spf is a Postfix SMTPd policy daemon for SPF checking.
50       It is implemented in pure Python and uses the pyspf module.  The SPF
51       web site is http://www.openspf.org/.  The Postfix configuration must be
52       changed to check SPF.
53
54

DESCRIPTION

56       Logging is sent to syslogd.
57
58       Each time a Postfix SMTP server process is started it connects to the
59       policy service socket and Postfix runs one instance of this Python
60       script.  By default, a Postfix SMTP server process terminates after 100
61       seconds of idle time, or after serving 100 clients.  Thus, the cost of
62       starting this Python script is smoothed over time
63
64       The default policy_time_limit is 1000 seconds.  This may be too short
65       for some SMTP transactions to complete.  As recommended in SMTPD_POL‐
66       ICY_README, this should be extended to 3600 seconds.  To do so, set
67       "policy_time_limit = 3600" in /etc/postfix/main.cf.
68
69       Messages that get a Fail SPF result will be rejected.  Messages that
70       get a Permerror are, by default, treated as if they had no SPF record.
71       Messages that get a Temperror result are, by default, treated as if
72       they had no SPF record, but can (and probably should) be deferred if
73       otherwise permitted.  Messages that get other SPF results (Pass, None,
74       Neutral, Softfail) will have the SPF Received header prepended.  Note:
75       Spamasassisn 3.2 and follow will use this header for spam scoring so
76       there is no need to configure a separate SPF check in these Spamassas‐
77       sin versions.  See Spamassassin documentation for details.
78
79       Default Mail From rejection/deferal criteria are, by design, conserva‐
80       tive.  Default HELO check actions are to reject mail with other than
81       Pass/None. HELO records are much simpler than Mail From records and re‐
82       jecting based on HELO checking does not present a false positive risk.
83       These settings are a matter of local policy and should be adjusted to
84       meet the requirements of site administrators.  See policyd-spf.conf(5)
85       for configuration file details.
86
87

LOGGING

89       Policyd-spf will log messages to syslog about it's activities.  The
90       "debugLevel" value in "policyd-spf.conf" can be increased to get addi‐
91       tional information to be logged.  When set to a value of "0", only test
92       results (SPF hits/misses) are logged.  Results will be returned to
93       Postfix and logged as a warning by Postfix also.  For logging by this
94       policy server, look for "policyd-spf" in your mail log files.
95
96

TESTING THE POLICY DAEMON

98       Testing the policy daemon
99
100       To test the policy daemon by hand, execute:
101
102           policyd-spf
103
104       Each query is a bunch of attributes.  Order does not matter, and the
105       daemon uses only a few of all the attributes shown below:
106
107           request=smtpd_access_policy
108           protocol_state=RCPT
109           protocol_name=SMTP
110           helo_name=some.domain.tld
111           queue_id=8045F2AB23
112           instance=12345.6789
113           sender=foo@bar.tld
114           recipient=bar@foo.tld
115           client_address=1.2.3.4
116           client_name=another.domain.tld
117           [empty line]
118
119       The policy daemon will answer in the same style, with an attribute list
120       followed by a empty line:
121
122           action=dunno
123           [empty line]
124
125

POSTFIX INTEGRATION

127        1. Add the following to /etc/postfix/master.cf:
128
129               policyd-spf  unix  -       n       n       -       0
130       spawn
131                   user=policyd-spf argv=/usr/bin/policyd-spf
132
133           NOTE: Check the path to both the installed Python 3 interpreter and
134                 policyd-spf.  These vary from system to system.  To use non-
135       default
136                 settings, you must also add the config file (see above and
137                 policyd-spf.conf(5) for details).  Python and Python 3 ver‐
138       sions
139                 prior to 3.3 are not supported.
140
141        2. Configure the Postfix policy service in /etc/postfix/main.cf:
142
143               smtpd_recipient_restrictions =
144                   ...
145                   reject_unauth_destination
146                   check_policy_service unix:private/policyd-spf
147                   ...
148               policyd-spf_time_limit = 3600
149
150               policyd-spf_time_limit is an instance of transport_time_limit.
151       See
152               SMTPD_POLICY_README or postconf (5) transport_time_limit for
153       details.
154
155           NOTE:  Specify check_policy_service AFTER reject_unauth_destination
156       or
157                  else your system can become an open relay.
158
159
160        3. Reload Postfix.
161
162

PERFORMANCE CONSIDERATIONS

164       The time to complete DNS lookups associated with SPF checks is the most
165       significant factor in policy server performance.  Use of a capable lo‐
166       cal caching resolver is highly recommended.  Specifics of resolver
167       setup are outside the scope of this document.
168
169       Long waits for DNS answers can cause performance bottlenecks.  There
170       are two primary controls, policyd-spf.conf(5) has details, provided to
171       affect DNS timing.  Lookup_Time controls the overall time, in seconds,
172       allowed for an SPF check to complete.  Whitelist_Lookup_Time controls
173       the amount of time allowed for individual DNS lookups associated with
174       name based whitelist options.
175
176       Lookup_Time defaults to the 20 second value recommended by RFC 7208.
177       This is a conservative recommendation and often a lower limit works
178       quite well.  Delays associated with whitelisting related DNS lookups
179       can be avoided by using IP based options instead.
180
181       A shorter time increases the likelihood that the result for some mes‐
182       sages will be a temporary error rather then the actual correct result.
183       To avoid some reported interoperability issues with some greylisting
184       implementations, TempError_Defer defaults to False.  With TempError_De‐
185       fer set to True, such TempError messages will be deferred and when re‐
186       tried, the responses should be in the local DNS resolver's cache.
187
188       The combination of a low Lookup_Time setting, TempError_Defer = True,
189       and no DNS name based whitelisting will maximize SPF checking through‐
190       put with only mimimal delays.  Consider a value of Lookup_Time = 5 sec‐
191       onds and monitor the system mail logs.  If TempError results are rare
192       or non-existent, the value can be lowered.  If such result are common
193       (more than 1% of mail), then the value should be raised.
194
195

SEE ALSO

197       policyd-spf.conf(5), policyd-spf.peruser(5), python-spf,
198       <http://www.openspf.org>, RFC 7208
199
200

AUTHORS

202       This version of policyd-spf (python) was written by Copyright ©
203       2007-2016 Scott Kitterman <scott@kitterman.com>.  It is derived from
204       Tumgreyspf, written by Sean Reifschneider, tummy.com, ltd
205       <jafo@tummy.com>. Portions of the documentation were written by Meng
206       Weng Wong <mengwong@pobox.com>.
207
208       This man-page was created by Scott Kitterman <scott@kitterman.com>.  It
209       is licensed under the same terms as the program.
210
211
212
213
214                                                                POLICYD-SPF(1)
Impressum