• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

contrib/H07-May-2022-

debian/H07-May-2022-803627

eximinc/H07-May-2022-310157

Greylisting.pmH A D11-Jan-20069.3 KiB297200

INSTALLH A D08-Mar-20054.5 KiB10180

LICENSEH A D08-Mar-200533 21

MakefileH A D11-Jan-20063.4 KiB10848

READMEH A D09-Jan-200614.2 KiB353268

README.greylistingH A D12-Jan-200613 KiB259218

SA-greylisting-2.4x.diffH A D08-Mar-20058.3 KiB265255

SA-greylisting-2.6.diffH A D08-Mar-20059.8 KiB305294

TODOH A D08-Mar-200547 21

accept.cH A D08-Mar-20051 KiB4620

greylistcleanH A D09-Jan-20065.3 KiB17874

greylistclean.cronH A D12-Jan-2006214 43

localscan_dlopen_exim_4.20_or_better.patchH A D08-Mar-20059.6 KiB269253

localscan_dlopen_up_to_exim_4.14.patchH A D08-Mar-200510.4 KiB288268

sa-exim.cH A D08-Mar-200545.5 KiB1,5151,126

sa-exim.confH A D08-Mar-200516.3 KiB35944

sa.html.templateH A D08-Mar-20058.2 KiB222186

versionH A D09-Jan-20066 21

README

1COPYRIGHTS
2----------
3SA-Exim was written by Marc MERLIN <marc_soft@merlins.org>
4You can find the latest version here:
5    http://sa-exim.sf.net/
6or here:
7    http://marc.merlins.org/linux/exim/sa.html
8
9greylisting was written by and is copyright Mark Lawrence <nomad@null.net>
10
11
12INSTALL
13-------
14See the file named INSTALL for installations instructions (either compiled
15in exim, or as a stand-alone shared library)
16
17If you got sa-exim prepackaged (like on debian), you have to make sure that
18your exim supports a dynamically loadable local_scan (which is true on debian
19and probably on other distros too if they shipped sa-exim as a package), and
20that your exim4.conf file contains the following:
21local_scan_path = /usr/lib/exim4/local_scan/sa-exim.so
22If you are using the split configuration file on debian with the sa-exim deb
23package, you'll be fine. If you're using the monolithic file, you are on your
24own until/unless the sa-exim packages try to do an in place edit (i.e. you have
25to add the above configuration line yourself)
26
27
28UPGRADING
29---------
30Deleting greylisting tuplets pre-4.2.1:
31If you are installing this package yourself, and ever installed the old
32greylistclean.cron which contained the complicated shell commands to clean
33old tuplets, you should stop using those commands and upgrade to greylistclean.
34Upgrading Greylisting.pm should also create safer tuplets without whitespace,
35but it's better to get rid of the old shell cron jobs either way
36
37
38PRIVACY WARNING
39---------------
40SA-Exim can add a header with the list of recipients in an Email (including
41Bcced folks).
42X-SA-Exim-Rcpt-To is used to allow you to see who a spam went to easily (i.e.
43without scanning the exim logs), and to write SpamAssassin rules on the envelope
44To (like adding a score if there were too many recipients or a recipient who you
45know only receives spam)
46X-SA-Exim-Rcpt-To is not added anymore by default, you need to enable it by
47setting SAmaxrcptlistlength to a value up to 8000, but if you do add it,
48you should consider removing it in exim's system_filter or in a transport.
49If SARewriteBody is true you should also consider setting
50SAaddSAEheaderBeforeSA to false (see the config) as all the recipients
51will be visible in the attached spam, note that this disables the
52ability to write SpamAssassin rules based on X-SA-Exim-Rcpt-From/To.
53In real life, who a spam was sent to isn't really a problem, but it could be if
54a private message is mis-categorized as spam
55Note however that if you disable X-SA-Exim-Rcpt-To by setting
56SAmaxrcptlistlength to 0, you will not be able to use greylisting, which
57depends on this header (however you'd still be welcome to remove the header in
58system_filter)
59
60
61CONFIGURATION
62-------------
63You should read sa-exim.conf, all the options there should be well
64documented.
65
66Note that the code will not act on any mail before it is flagged as SPAM by SA.
67
68Having SA flag the mail however doesn't mean the code rejects it or throws
69the alleged spam away, you control what you want to do depending on the score.
70The only restriction is that things happen in this order (for increasing SA
71scores)
72
73    - Save in SAnotspamsave if enabled
74    - Save in SAspamacceptsave if enabled
75    - Temporarily reject and optionally save if enabled
76    - Permanently reject and optionally save if enabled
77    - Accept, drop the mail, and optionally save if enabled
78    - Teergrube (i.e. stall) the sender to waste his resources (and yours)
79
80Note that you cannot set a teergrube threshold of 12, and a permreject
81threshold of 20 (not that it would make much sense anyway).
82Threshold scores should decrease as you apply the highest to the lowest penalty
83(i.e. the rules are run in this order: teergrube, devnull, permreject,
84tempreject)
85
86Now, as of SA-Exim 4.2, things get slightly more complicated as scores are
87actually full exim conditions, and therefore you could have:
88SAteergrube: ${if and { {!eq {$sender_host_address}{127.0.0.1}} {!eq {$sender_host_address}{127.0.0.2}} } {25}{1048576}}
89This means that if your condition succeeds, the teergrube score is set to 25,
90and if the condition fails, the teergrube score is set to 2^20, which for all
91intents and purposes, disables teergrubing.
92Regardless of what your scores end up being after the conditions are evaluated,
93sa-exim still tests them in this order: teergrube, devnull, permreject,
94tempreject)
95
96
97
98
99CONFIGURING SPAMASSASSIN
100------------------------
101A good example of spamassassin configuration would be:
102
103    report_safe            0
104    use_terse_report       1	# for SA < 3.x
105
106This will put a non-verbose SPAM-report in the headers, but leave the
107message itself intact for easy analyzing and for easy feeding to
108sa-learn when mis-flagged as spam or ham. The only way to see the
109message is spam, is by looking in the headers.
110
111If you have an older version of SpamAssassin (<= 2.50), you'd probably
112want to add 'report_header 1' to that list. But this is default and
113un-needed in new versions of SA)
114
115If you set 'report_safe' to a true value, you might also want to set
116use_terse_report to a false value, in case you'll get the long header
117which might be friendlier to your users.
118
119For SA before 3.x, add 'always_add_report 1' to always have a spamcheck report
120put in the message. This might be useful to test rules.
121For SA 3.x onward, the syntax you'd want, is:
122add_header                      all Report _REPORT_
123
124Since SA is usually configured to pass messages on that are beyond the SA
125spam threshold, it can make sense to rewrite the subject line.
126To achieve this, you would use this for SA 2.x:
127    rewrite_subject        1
128    subject_tag            SPAM: _HITS_:
129
130For SA 3.x, the syntax is:
131    rewrite_header Subject SPAM: _HITS_:
132
133
134If you are using SA 2.50 or better, by default, you should probably set:
135    report_safe            0
136
137Now, if you are willing to take a small speed and I/O hit, you can have
138sa-exim read the body back from SA, and replace the original mail with
139the new body.
140
141You would use this if you want to set SA's report_safe to 1 or 2 (in
142which case you also have to set SARewriteBody: 1 in SA-Exim's config)
143
144Note that if you do so, unfortunately archived messages will have the
145body modified by SA. This is not very trivial to fix, so if you archive
146anything, you may not want to use SARewriteBody
147
148
149Important:
150You want to run spamd as such:
151/usr/sbin/spamd -d -u nobody -H /var/spool/spamassassin/
152
153It may not work if you run spamd with -c (debian default),
154(you shouldn't run spamassassin as root for this purpose anyway (there
155is no reason to, so why take the risk)
156
157You can edit this in /etc/default/spamassassin (debian) and probably
158/etc/sysconfig/spamassassin (redhat)
159
160With SA 3.x is better, the updated syntax would look like this:
161/usr/sbin/spamd --max-children 50 --daemonize --username=nobody --nouser-config --helper-home-dir=/var/spool/spamassassin/
162
163
164
165CONFIGURING EXIM4.CONF
166----------------------
167This code works without anything in the exim conf, but you probably want to use
168some knobs to disable scanning for some users (like setting X-SA-Do-Not-Rej
169or X-SA-Do-Not-Run in the rcpt ACL and removing those headers in the right
170places)
171
172See http://marc.merlins.org/linux/exim/#conf and more specifically
173http://marc.merlins.org/linux/exim/exim4-conf/exim4.conf
174
175Note that obviously if you set those headers, spammers can set them too, so
176if you are concerned about this, you can either change the header name, or set
177it to something else than 'Yes' and check for that value in sa-exim.conf
178(or as a 3rd option, you can use exim ACL variables to pass values to SA-Exim
179without generating headers; see the section contributed by Chirik, lower in
180this file)
181
182
183
184EXIM4 INTEGRATION / NOT SCANNING YOUR OWN MAILS
185-----------------------------------------------
186For a very complete exim4 config, including settings for SA, you should
187look at sa-exim.conf and play with:
188
189SAEximRunCond: ${if and{ \
190                            {def:sender_host_address} \
191                            {!eq {$sender_host_address}{127.0.0.1}} \
192                            {!eq {$h_X-SA-Do-Not-Run:}{Yes}} \
193                        } \
194                    {1}{0} \
195                }
196
197You may also want to look at my exim4.conf config if you haven't done so yet:
198http://marc.merlins.org/linux/exim/#conf
199
200The check_rcpt ACL has:
201  warn     message       = X-SA-Do-Not-Rej: Yes
202           local_parts   = +nosarej:postmaster:abuse
203
204  warn     message       = X-SA-Do-Not-Run: Yes
205           hosts         = +relay_from_hosts
206
207  warn     message       = X-SA-Do-Not-Run: Yes
208           authenticated = *
209
210Then, you'll want to strip SA headers for messages that aren't local
211This means you should strip them at least in the remote_smtp transport
212with this configuration snippet:
213
214  # This is generally set on messages originating from local users and it tells
215  # SA-Exim not to scan the message or that the message was scanned.
216  # Let's remove these headers if the message is sent remotely
217  headers_remove = "X-SA-Do-Not-Run:X-SA-Exim-Scanned:X-SA-Exim-Mail-From:X-SA-Exim-Rcpt-To:X-SA-Exim-Connect-IP"
218
219
220You can also use another option, which can't be spoofed by a spammer, but
221won't show you why a mail didn't get scanned if it was sent to multiple
222people (which is why I personally prefer the above, even if it's spoofable)
223
224Contributed by Chirik <chirik@castlefur.com>:
225----------------------------------------------------------------------------
226I have the following:
227
228SAEximRunCond: ${if !eq {$acl_m0}{do-not-scan} {1} {0}}
229SAEximRejCond: ${if !eq {$acl_m0}{do-not-reject} {1} {0}}
230
231Then, in my recipient ACL, I have:
232
233  ##### Checks for postmaster or abuse - we'll scan, still, but not reject
234  ##### Don't reject for certain users
235  warn     local_parts   = postmaster : abuse
236           set acl_m0    = do-not-reject
237
238  ##### Check for situations we don't even scan (local mail)
239  ##### Don't scan if hosts we relay for (probably dumb MUAs),
240  warn     hosts         = +relay_from_hosts:127.0.0.1/8
241           set acl_m0    = do-not-scan
242
243  ##### Don't scan non-smtp connections (empty host list)
244  warn     hosts         = :
245           set acl_m0    = do-not-scan
246
247  ##### Don't scan if authenticated
248  warn     authenticated = *
249           set acl_m0    = do-not-scan
250----------------------------------------------------------------------------
251
252
253
254TEERGRUBING: SAteergrube
255------------------------
256The idea is for mail that you know for sure is spam (I use a threshold of 25),
257you can stall the spammer for as long as possible by sending a continuation
258line every 10 seconds:
259451- wait for more output
260451- wait for more output
261451- wait for more output
262(...)
263
264You can go there for details:
265http://www.iks-jena.de/mitarb/lutz/usenet/teergrube.en.html
266
267What should you know?
2681) This is obviously going to use up some of your resources
2692) You should not teergrube SMTP servers that relay mail for you, be
270   courteous (set a condition in SAteergrube like in the example
271   provided). Besides they are real mail relays, so they will diligently
272   try to send you the spam over and over for days)
273   (note that you should probably not teergrube mailling lists you subscribed
274   to either, or you risk getting unsubscribed)
275   See a sample in sa-exim.conf for example syntax.
2763) Because of limitations in the current exim code, teergrubing will not work
277   over TLS.
278   This shouldn't be a problem since real spammers should not be using TLS,
279   and you shouldn't teergrube relays that do TLS with you.
280   If you do teergrube a TLS connection, it will break the connection and you
281   will see this in your logs:
28218640m-0000Vb-00 SSL_write error 5
283TLS error (SSL_write): error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
284   This is not ideal, but in real life, that's ok.
285
286
287
288GREYLISTING
289-----------
290See README.greylisting
291
292
293
294READING ARCHIVED SPAMS
295----------------------
296Spams are optionally saved in individual files in a 'new' subdirectory
297of some place like /var/spool/sa-exim/SAteergrube.
298
299There are two ways to read them:
3001) cat new/*  > /tmp/mailbox, and use  the resulting file as  a standard
301   mbox file with any mail client (if SAPrependArchiveWithFrom is true)
3022) Use a maildir capable mail client, like mutt, and run something like
303   'mutt -f /var/spool/sa-exim/SAteergrube'. This will read the messages in
304   place, since what sa-exim creates looks like a valid Maildir spool.
305
306If you configured SA-Exim to set X-SA-Exim-Rcpt-To, you can even resend
307archived refused messages to the users they were meant for
308
309Note that sa-exim runs with the same uid/gid than the exim daemon (something
310like mail, exim, or Debian-Exim), so /var/spool/sa-exim/SAteergrube must exist
311and be writeable by exim.
312SA-Exim will then create (sub-)directories with the permissions 0770 as
313needed (those permissions aren't a configuration option, but you can change
314them after the fact or pre-create the directories with the permissions of your
315choice)
316Files are created with 0664 permissions so that anyone who has directory access
317can read (and maybe write) the files.
318If you chgrp the parent 'new' directory to a group of your choice, and give it
319permissions 2770 or 2775, the files will be created with that group instead of
320the default exim group
321
322
323
324LOG AND SMTP OUTPUT
325-------------------
326As of SA-Exim 3.0, SMTP output does not contain the spam score anymore,
327and you can change the messages or re-add the score by changing the
328runtime SAmsg* variables
329
330All SA-Exim log now looks like this:
331- "SA: PANIC: "		-> severe errors
332- "SA: Warning: "	-> config file parsing errors
333- "SA: Notice: "	-> misc info on what SA-Exim is doing or not doing
334- "SA: Action: "	-> what action SA-Exim took on a mail after scanning
335- "SA: Debug[X]: "	-> misc debug info if enabled
336
337Marin Balvers has written a nice log parser here:
338http://nossie.addicts.nl/projects/sa-exim-stats/
339
340
341
342FAQ
343---
344Why do I get this in my exim logs?
345
3462004-05-15 12:43:57 1BP54T-0002gV-Nu TLS send error on connection from internalmx1.company.tld (internalmx.company.tld) [192.168.1.1]:51552: Error in the push function.
3472004-05-15 12:43:57 TLS recv error on connection from internalmx1.company.tld (internalmx.company.tld)
348[192.168.1.1]:51552: The specified session has been invalidated for some reason.
349
350This is because you are teergrubing a host that is doing TLS. Teergrubing does
351not work with TLS, and people doing TLS with you are probably known relays which
352you should exclude from your teergrube list (SAteergrubecond)
353

README.greylisting

1                          GREYLISTING with SA-Exim
2                          ------------------------
3
4
5INTRODUCTION
6------------
7SA-Exim allows for intelligent greylisting by combining the idea of greylisting
8with Spam scores from SpamAssassin
9
10If you don't know what greylisting is, you should probably go read up there:
11http://projects.puremagic.com/greylisting/
12(note that this implementation works differently than the one described there)
13
14So, SA-Exim isn't just yet another greylisting implementation. By tying it
15into SA-Exim, and especially by running SA at SMTP time, you can do the
16following things:
17- do not bother greylisting people who send messages detected as spam by SA
18  (indeed, regular greylisting will accept mail from a spammer if he retries
19  or sends it from an open relay)
20  SA-Exim will never greylist, or whitelist a sender based on a mail clearly
21  marked as spam by SA.
22
23- do not delay mail from people who aren't spamming you (this one is the most
24  important feature of SA-Exim greylisting, as it removes the biggest
25  disadvantage linkes to greylisting)
26
27- only greylist (and maybe later whitelist) hosts that send you mail with
28  a certain SA score.
29
30
31IMPLEMENTATION
32--------------
33So how does this all work?
34SA comes with a patch for SA 2.x (and a module for SA 3.x) that does the
35following things:
36- add a greylisting rule which gets run at the very end, and where if
37  the score is already higher than a configured value, we do not bother
38  greylisting the host. We just return a rule failure, which doesn't
39  change the score and lets SA-Exim reject the mail as usual
40- if the score is lower than the "surely spam" threshold (shown as 11 in the
41  example below), check for a file in
42  /var/spool/sa-exim/messageids/co/nn/ect/ip/envfrom/envto
43  - if it's there, check if it was written more than x seconds ago (1800s/30mn
44    in the example below)
45    - if so, change the status to whitelisted and return true so that SA applies
46      the whitelist negative score
47    - if not, simply increase counters, host is still greylisted
48  - if the file is not there, create it
49- every x time (like 4 hours or two days), remove all greylist entries that
50  only saw one mail (i.e. still greylisted, not whitelisted yet).
51  This is done with a find cron job
52- every y time (like 1 week), remove whitelisted entries so that your filesystem
53  doesn't clutter up with hosts you're not going to hear from again in a while
54
55
56Then, you call the greylisting rule with this (in SA's local.cf)
57# reseval is a special eval which only runs after you have the result from
58# everything else (lets us not greylist a host that is sending spam, otherwise
59# this rule might set a sufficiently negative score that the next spam would
60# be allowed in)
61# Note the 'key' -> 'value'; syntax. It's a special hack to go through SA's
62# config parser. You need to keep that exact syntax
63# greylistsecs: how long you greylist a tuplet because whitelisting it
64# greylistnullfrom: set to 1 to also greylist mail with a null env from
65# greylistfourthbyte: keep the 4 bytes of the connecting host instead of 3
66header GREYLIST_ISWHITE reseval:greylisting("( 'dir' => '/var/spool/sa-exim/tuplets'; 'method' => 'dir'; 'greylistsecs' => '1800'; 'dontgreylistthreshold' => 11; 'connectiphdr' => 'X-SA-Exim-Connect-IP'; 'envfromhdr' => 'X-SA-Exim-Mail-From'; 'rcpttohdr' => 'X-SA-Exim-Rcpt-To'; 'greylistnullfrom' => 0; 'greylistfourthbyte' => 0 )")
67describe GREYLIST_ISWHITE The incoming server has been whitelisted for this rece
68ipient and sender
69score GREYLIST_ISWHITE  -1.5
70
71Note that SA greylisting depends on X-SA-Exim-Rcpt-To, so you have to ensure
72that SAmaxrcptlistlength is set to a reasonably high value (up to 8000) instead
73of the current default of 0 (you can remove the header in exim's system_filter
74or a transport if you don't want it to show in user's mails, see "privacy
75warning" in README)
76
77
78Now, in case you aren't confused yet, you get even more knobs to play with :)
79If a spammer resends you a spam until it gets whitelisted (or typically, it
80gets sent to a relay that resends it to you), even if you are setup to
81accept the spam at the point, you don't want to lower the SA score too much
82just because the mail was resent to you several times (i.e. a rather negative
83score for GREYLIST_ISWHITE). So, you can actually configure SA-Exim to temp
84reject messages on a much higher score than usual, if they don't have the
85GREYLIST_ISWHITE tag.
86
87In other words, let's say you have this in sa-exim.conf:
88SApermreject: 11.0
89SAtempreject: 3.0
90SAgreylistraisetempreject: 6.5
91
92If a mail comes in at less than 3.0, the SA patch/module remembers the sending
93server's connecting IP, the env from, and the rcpt to(s), and whitelists those.
94(those will be referred to as tuplets, one for each rcpt to)
95
96If the score is between 3.0 and 11.0,
97- if at least one of the tuplets is already whitelisted, SA applies the -1.5
98  score and yields an end score below 9.5, Now, at the same time, SAtempreject
99  is temporarily raised by 6.5, so everything under 9.5 is accepted, which
100  basically means that the mail goes through.
101- if none of the tuplets are whitelisted, they get greylisted
102- if they are greylisted, they can get upgraded to whitelisted status if the
103  sending server has been trying for long enough (1800secs in the example given
104  above). At this point the same thing happens as in case #1 and the mail is
105  accepted
106
107If a tuplet that is going to be whitelisted or greylisted, already is, SA
108updates counters to let you run reports and anything else you want, like
109deciding if or when you'd like to expire the entry
110
111If by now you wonder why you would want to both decrease the SA score and
112increase the maximum score you'll accept mails on, the reason is as follows:
113You probably don't want to lower the SA score by 8 just because the tuplet
114is whitelisted (not only does it mess with the SA scoring of messages that used
115to be flagged as spam, but a spam with a score of 13.5 would then be lowered
116to 5.5, be temprejected, and be close to the accept range).
117Instead, giving an SA score of -1.5, a message with 13.5 becomes 12.0 and still
118gets rejected right away. You also do not overly (and artifically) lower the
119score of a message, just for SA-Exim's sake
120
121If you so wish, you can also give the SA rule a score of -0.1, and only
122dynamically raise the tempreject score for messages that are whitelisted.
123
124
125SCORE SETUP
126-----------
127It makes little sense to have
128SAtempreject + SAgreylistraisetempreject + SA GREYLIST_ISWHITE > SApermreject
129as there is little point to raise SAtempreject if the message that's
130whitelisted still gets refused by the SApermreject score
131
132As to whether you want to put more points into SA GREYLIST_ISWHITE or
133SAgreylistraisetempreject, this is your call, but as a general rule, you only
134want to change the SA score in a way that makes sense for spam scoring,
135as it similarly affects the score of all messages, whether SA-Exim sees them
136in the non spam range, tempreject range, or "this is spam that I would never
137let in" range.
138
139
140FILE SETUP
141----------
142Make very sure that uid nobody can traverse /var/spool/sa-exim and
143create tuplets writeable by nobody (or whoever you run SA as)
144
145Then, setup a cron job to delete tuplets that are older than 14 days for
146whitelisted entries, and 2 days for greylisted entries (or whatever
147values you fancy).
148Note that because this implementation does not systematically force the senders to resend you mail, unless they sent something that looks too much like spam,
149you will typically see few whitelisted entries, and those will either be
150potential spam that was actually resent to you at least 30mn after the
151initial copy (or whatever value you setup in "header GREYLIST_ISWHITE"), or
152people who sent you several Emails (where the second Email will just happen to
153trigger a whitelisting).
154
155
156FILE SETUP
157----------
158You should install greylistclean.cron in /etc/cron.d/ on your system to
159call greylistclean and clean up greylisted entries and whitelisted entries
160that haven't been used in a while.
161You can optionally modify it to tweak the cleanup times.
162Note that you need to tweak greylistclean.cron to match the user spamd runs
163as if you aren't using the recommended --username=nobody
164
165
166SA PATCH (SA 2.x)
167-----------------
168For all this to work, you also need to patch SA with SA-greylist.diff
169from the source tar (or /usr/share/doc/sa-exim*/ for a precompiled package).
170This patch never made it to the main SA 2.x branch as the developers had mostly
171switched to 3.x where you can use plugins.
172If you still use SA 3.x, you can go to /usr/share/perl5/Mail (or wherever
173appropriate on your system), and run
174patch -p0 -s < /path/to/sa-exim/SA-greylisting.diff
175Note that while the patch works, it will not be maintained anymore since
176it is deprecated for the SA 3.x plugin
177
178
179SA PLUGIN (SA 3.x)
180------------------
181Newer versions of SpamAssassin support plugins, so there is no need to
182patch SA anymore, you can just install the Greylisting.pm module on your
183system and get SA to use it
184This is how you call the module in SA 3.x (i.e. put this in your
185/etc/spamassassin/local.cf)
186
187# Note the 'key' -> 'value'; syntax. It's a special hack to go through SA's
188# config parser. You need to keep that exact syntax
189# greylistsecs: how long you greylist a tuplet because whitelisting it
190# greylistnullfrom: set to 1 to also greylist mail with a null env from
191# greylistfourthbyte: keep the 4 bytes of the connecting host instead of 3
192loadplugin Greylisting /usr/share/perl5/Mail/SpamAssassin/Plugin/Greylisting.pm
193header GREYLIST_ISWHITE eval:greylisting("( 'dir' => '/var/spool/sa-exim/tuplets'; 'method' => 'dir'; 'greylistsecs' => '1800'; 'dontgreylistthreshold' => 11; 'connectiphdr' => 'X-SA-Exim-Connect-IP'; 'envfromhdr' => 'X-SA-Exim-Mail-From'; 'rcpttohdr' => 'X-SA-Exim-Rcpt-To'; 'greylistnullfrom' => 1; 'greylistfourthbyte' => 0 )")
194describe GREYLIST_ISWHITE The incoming server has been whitelisted for this recipient and sender
195score GREYLIST_ISWHITE  -1.5
196# Run SpamAssassin last, after all other rules.
197# (lets us not greylist a host that is sending spam, otherwise this rule might
198# set a sufficiently negative score that the next spam would be allowed in)
199priority GREYLIST_ISWHITE 99999
200
201
202SA-EXIM NEW BEHAVIOR CONCERNS
203-----------------------------
204What greylisting changes as far as spam accepting or rejection is concerned:
205Once a tuplet has been whitelisted, spam from that host is more likely
206to be accepted until the tuplet expires. In the case of a mailing list,
207unless you run a find / rm based on the creation time and not the last
208modified time, you will then be a bit more likely to accept spam from
209that list.
210If this turns out to not be acceptable in your case, there isn't a whole
211lot you can do about this, except deleting greylist entries for the host
212from cron before they get promoted to whitelist.
213
214What you can do on top of the existing greylisting code:
215Parse the SA-Exim logs and if you get spam from an IP, you can decide
216to delete greylist entries in /var/spool/sa-exim/tuplets/IP or just
217/var/spool/sa-exim/tuplets/IP/envfrom
218This may not may not be a good thing if you receive the occasional spam
219from a mailing list as you'll then re-delay mail for that list, but then
220again, it will also remove whitelisting for a host that spammed you once
221with an Email that managed to get under the SA scoring radar
222
223
224GREYLISTING AND MXES
225--------------------
226Depending on your configuration, you may have realized that SA-Exim doesn't
227play very well with secondary MXes for your domain if they don't run SA-Exim
228too (for instance, you'd send a tempreject on spam and clog up your
229secondary, or maybe even teergrube it if you forgot to add your MX's IP
230in the do not teergrube list.
231For greylisting, it's even more simple:
232If your secondary MXes aren't running SA-Exim with greylisting, then
233greylisting's efficiency will be greatly reduced as most spammers will send
234their spams to your secondary MXes which will accept the mail for you,
235even if it's sent only once, and then your MXes will resend the spam to you
236until you accept it (rendering greylisting useless)
237
238Now, if your secondaries are running greylisting too, most mail will flow
239through with no delay whatsoever. However, in the worst case scenario, a mail
240that isn't spam, but triggers greylisting because its score is high enough to
241generate a tempreject, could be delayed up to twice the whitelisting time
242if it were to go to your secondary MX first (assuming your primary is
243unreachable or temporarily overloaded), and then be resent to your primary
244MX, which would trigger a second greylisting delay
245FIXME: implement a whitelist of sending IPs so that greylisting returns
246whitelisted right away
247
248
249SECURITY
250--------
251The greylisting function works around the SA parser by sending all the options
252as a hash inside a string. In turn, greylisting evals the said string.
253This is a security problem if you allow your users to run custom rules and it
254gives them access to run spamassassin as a user different from their own, or
255in a way that they otherwise wouldn't be able to.
256Do not run greylisting if this a problem for you (in the default SA/SA-Exim
257setup, this shouldn't be a concern since it doesn't even parse users' config
258files)
259