1# $Id: README,v 1.69 2017/07/07 21:59:13 manu Exp $
2###########################################################################
3
4 ======================================
5 milter-greylist installation notes
6 $Date: 2017/07/07 21:59:13 $
7 ======================================
8
9 Emmanuel Dreyfus <manu@netbsd.org>
10
11Table of contents:
12==================
13
14 1 Building and installing milter-greylist
15 2 Configuring Sendmail with milter-greylist
16 3 Configuring Postfix with milter-greylist
17 4 Configuring milter-greylist
18 5 Trying it out for a few users
19 6 Running it for the whole site
20 7 Lists and per-ACL settings
21 8 Dealing with mail farms
22 9 Working with multiple MXs
23 10 Using DNSRBL
24 11 Building with SPF
25 12 Using DRAC
26 13 Using URL checks
27 14 Using LDAP natively
28 15 Using TLS
29 16 Using tarpit
30 17 Custom logs
31 18 Packaging
32 19 Things to look at if things get wrong
33 20 Known problems
34 21 License
35
36Run this command to regenerate a table of contents:
37 sed '/^.====/{g;p;};h;d' README
38
39 1 Building and installing milter-greylist
40 =========================================
41
42This section deals with installing milter-greylist from sources. If you
43want to generate a RPM, see section 16 of this document.
44
45First, download the sources. You can get a tarball from
46http://ftp.espci.fr/pub/milter-greylist
47
48or you can check out bleeding edge source from milter-greylist CVS:
49cvs -danoncvs@anoncvs.fr.netbsd.org:/milter-greylist co -P milter-greylist
50Don't forget to set CVS_RSH=ssh if this is not your system default.
51
52Build dependencies:
53- flex (AT&T lex cannot build milter-greylist sources)
54- yacc or bison (some older yacc will fail, use bison instead)
55- libmilter (comes with Sendmail, or with the sendmail-devel
56 package on RedHat, Fedora and SuSE. Debian and Ubuntu have it
57 in libmilter-dev)
58- Any POSIX threads library (Provided by libc on some systems)
59
60Optional dependencies:
61- libspf2, libspf_alt or libspf, for SPF support
62- libcurl, for URL checks support
63- libGeoIP, for GeoIP support
64- libbind from BIND 9, for DNSRBL support, except if your system has a
65 thread-safe DNS resolver built-in.
66
67Before building milter-greylist, it might be wise to view the
68configuration options by running:
69./configure -help
70
71To build milter-greylist, just do the usual
72./configure && make && make install
73
74If libpthread and libmilter are not automatically located, use
75--with-libpthread and --with-libmilter flags to the configure
76script.
77
78If you intend to run milter-greylist under an unprivileged
79UID, use the --with-user flag.
80
81A Makefile is supplied in the distribution in case you run into real
82trouble with configure and are unable to get it generating a Makefile
83suited to your system. Of course this Makefile is not likely to work
84on your system (it is configured for NetBSD-3.0) and it will probably
85need manual tweaks.
86
87On the make install step, the Makefile will install a default config
88file in /etc/mail/greylist.conf, except if there is already such
89a file. In that case the original file is preserved. Great care is taken
90to maintain milter-greylist backward compatibility, so no config file
91change should be nescessary when upgrading: Just replacing the
92milter-greylist binary and restarting the milter should be enough.
93
94Some startup scripts are available: rc-redhat.sh, rc-debian, rc-gentoo.sh,
95rc-suse.sh for Linux, rc-bsd.sh for NetBSD and FreeBSD, and rc-solaris.sh
96for Solaris. They are not installed by default; you have to install the
97startup script manually if you want to use one.
98
99
100 2 Configuring Sendmail with milter-greylist
101 ===========================================
102
103You need a few options in sendmail.cf to use milter-greylist:
104
105O InputMailFilters=greylist
106Xgreylist, S=local:/var/milter-greylist/milter-greylist.sock
107O Milter.macros.connect=j,{if_addr}
108O Milter.macros.envfrom=i
109
110If you use SPF, DNSRBL or urlchecks, then milter-greylist can
111spend a lot of time waiting for DNS lookups to complete. This
112may lead to sendmail reporting timeout errors. If you see such
113messages, consider setting a timeout larger than the default (see
114Sendmail's milter documentation for more details on timeout settings):
115
116Xgreylist, S=local:/var/milter-greylist/milter-greylist.sock, T=R:1m
117
118Note that InputMailFilters and Milter.macros.* options are shared
119with other milters, and the other milters you have set up may
120require additionnal macros. Therefore you need to merge what
121milter-greylist needs with what other milters need. If you just
122copy the lines proposed in this file, this is likely to break
123other milters setup. In this section we simply list the macros
124milter-greylist require. Your default sendmail.cf is likely to already
125contain the proper Milter.macros.* setup.
126
127If you want to bypass greylisting for users that succeeded SMTP AUTH,
128you also need {auth_authen} in Milter.macros.envfrom:
129O Milter.macros.envfrom=i, {auth_authen}
130
131If you want to bybass greylisting for users that use STARTTLS with
132a client certificate, you also need {verify} and {cert_subject}
133in Milter.macros.helo:
134O Milter.macros.helo={verify},{cert_subject}
135
136If you want to use Sendmail access DB as a whitelisting source, you
137will need {greylist} too. milter-greylist will whitelist a message
138when the {greylist} macro is defined and set as WHITE.
139O Milter.macros.envrcpt={greylist}
140
141When using access DB as a whitelisting source, you will also need some
142rules for the ruleset "Local_check_rcpt" which assign a value to the
143macro {greylist}.
144Kstorage macro
145SLocal_check_rcpt
146R$+ $: $(storage {greylist} $) $&{client_addr}
147R$+ $: $>A <$1> <?> <+Connect> <$1>
148R<$+> <$*> $: $(storage {greylist} $@ $1 $) $2
149
150Alternatively, you can use the following m4 macro definitions
151if you build sendmail.cf with m4 (contributed by Hubert Ulliac).
152Here again, confMILTER_MACROS_* are shared with other milters,
153so you need to merge the definitions with what others milters
154require. Just copying the lines below is likely to cause other
155milters to malfunction.
156
157INPUT_MAIL_FILTER(`greylist',
158`S=local:/var/milter-greylist/milter-greylist.sock')
159define(`confMILTER_MACROS_CONNECT', `j, {if_addr}')
160define(`confMILTER_MACROS_HELO', `{verify}, {cert_subject}')
161define(`confMILTER_MACROS_ENVFROM', `i, {auth_authen}')
162define(`confMILTER_MACROS_ENVRCPT', `{greylist}')
163
164Ivan F. Martinez contributed the milter-greylist.m4 file that includes
165thoses definitions and will take care of adding the macros required by
166milter-greylist instead of overwriting what has already been done. This
167should simplify an automatic generation of sendmail.cf.
168
169To add the rules for defining the {greylist} macro via m4, add the following
170lines to your m4 input file:
171
172LOCAL_CONFIG
173Kstorage macro
174LOCAL_RULESETS
175SLocal_check_rcpt
176R$+ $: $(storage {greylist} $) $&{client_addr}
177R$+ $: $>A <$1> <?> <+Connect> <$1>
178+R<?> <$+> $: <?> $&{client_name}
179+R<?> $+ $: $>D <$1> <?> <+Connect> <$1>
180+R<$+> <$*> $: $(storage {greylist} $@ $1 $) $1
181
182Note that there must be tabs and no spaces before the "$:"!
183
184Some sample entries for /etc/mail/access:
185
186Connect:1.2.3 OK
187Connect:provider.net OK
188
189As RHS the keywords "WHITE", "RELAY" or "OK" are allowed. But to make sure
190Sendmail keeps accepting mails from the given source "OK" is the usually
191the best, except explicitly full relaying is desired where "RELAY" should
192be given.
193
194On the LHS the tag "connect:" is mandatory, followed by either an address
195or a domain (both of them might be partial, covering a whole network or
196any subdoman).
197
198 3 Configuring Postfix with milter-greylist
199 ==========================================
200
201As Postfix currently does not provide milter library, you need to have
202sendmail sources or development package installed. See
203http://www.postfix.org/MILTER_README.html#limitations
204
205Use --enable-postfix flag when configuring milter-greylist, or you
206can build an rpm like this:
207rpmbuild --define "build_postfix 1" -tb milter-greylist-3.1.4.tgz
208
209Add the following to postfix main.cf (customize for your needs):
210milter_default_action = accept
211milter_connect_macros = j
212milter_protocol = 3
213smtpd_milters = unix:/var/milter-greylist/milter-greylist.sock
214
215To include postfix queue IDs in the milter-greylist log, add the
216following to postfix main.cf (this may impact performance of postfix;
217see postconf(5) man page for details):
218smtpd_delay_open_until_valid_rcpt = no
219
220
221 4 Configuring milter-greylist
222 =============================
223
224Edit /etc/mail/greylist.conf, and add addr lines for at least
225localhost and all your local network addresses. Here is an example:
226
227racl whitelist addr 127.0.0.0/8
228racl whitelist addr 192.0.2.0/24
229racl whitelist addr 10.0.0.0/8
230
231Then consider adding addresses of all the friendly networks you get
232mail from. By friendly networks, we mean networks with no spammers:
233Universities are usually friendly, some companies are friendly,
234some others are not, and dial-up and ADSL ISPs are definitively not
235friendly at all.
236
237For the sake of completeness, "racl" stands for RCPT-stage ACL. This
238rule is evaluated on each of the RCPT stages of the SMTP transaction.
239milter-greylist also supports "dacl", evaluated once after DATA stage.
240
241 5 Trying it out for a few users
242 ===============================
243
244Add some rcpt access-lists to /etc/mail/greylist.conf for the users
245that want to try milter-greylist filtering. Here is an example:
246
247racl greylist rcpt John.Doe@example.net
248racl greylist rcpt webmaster@example.net
249racl greylist rcpt postmaster@example.net
250
251Then finish your ACL with the default rule: here, anything that
252is not for John.Doe@example.net, webmaster@example.net, or
253postmaster@example.net will not get greylisted:
254
255racl whitelist default
256
257Now you can start milter-greylist:
258
259milter-greylist -u smmsp -p /var/milter-greylist/milter-greylist.sock
260
261If you have trouble with the socket file, check the permissions of
262the directory where the socket is located. The default directory is
263/var/milter-greylist and it should be chmod 0755 and owner smmsp, if
264you are running the milter as smmsp. If permissions are wrong,
265sendmail will complain to syslog, stating the directory is unsafe.
266
267If sendmail complains it cannot connect to the milter because of a
268connection refused, that either means that the milter is not running,
269or that the socket location configured in sendmail.cf is not the same
270as what was given to milter-greylist with the -p flag.
271
272Sometimes, milter-greylist has trouble starting up because of a stale
273socket file in /var/milter-greylist/milter-greylist.sock. Just removing
274the socket and restarting milter-greylist should fix the problem.
275
276You might want to add -v and -D to get more debugging output. The
277-w flag is used to choose how long we will refuse a given message.
278If you want to check that things work, try 10 seconds with -w10.
279
280The -a option controls auto-whitelisting. Once a (sender IP, sender e-mail,
281recipient e-mail) tuple has been accepted, it is marked autowhitelisted,
282and similar tuples will be accepted with no retry for one day. Using -a0
283disables this feature.
284
285
286 6 Running it for the whole site
287 ===============================
288
289Remove the "racl greylist rcpt ..." lines from /etc/mail/greylist.conf,
290and replace "racl whitelist default" by
291
292racl greylist default
293
294Now greylisting is enabled for every recipient. If some of your
295users don't want greylisting, add a "racl whitelist rcpt" line for them
296in /etc/mail/greylist.conf. Make sure you put it before
297"racl greylist default": ordering does matter, as the ACL rules are
298evaluated on a first match wins basis.
299
300If your mail server handles several domains and you want to enable
301milter-greylist for a whole domain but not for everyone, this is
302possible, just use a regular expression:
303
304racl greylist rcpt /@example\.net$/
305racl whitelist default
306
307
308 7 Lists and per-ACL settings
309 ============================
310
311It is possible to have per-ACL greylisting and autowhitelisting
312settings:
313
314racl greylist rcpt /@example\.net$/ delay 15m autowhite 3d
315racl greylist default delay 30m autowhite 1d
316
317Here, all messages to domain example.net will have a greylisting delay
318of 15 minutes and will be autowhitelisted for 3 days, while messages
319to other domains will be greylisted for 30 minutes and autowhitelisted
320for one day.
321
322milter-greylist is now also able to use lists, which is very useful for
323factoring rules:
324
325list "users" rcpt { user1@example.com user2@example.com user3@example.com }
326racl greylist list "users"
327racl whitelist default
328
329Here message sent to members of the "users" list will be greylisted, while
330other messages will not.
331
332Theses two advanced features were added in release 2.1.7 and may not be
333fully stable.
334
335
336 8 Dealing with mail farms
337 =========================
338
339Some Internet service provider such as Hotmail feature mail farms,
340where several different machines are able to resend an e-mail. The
341message is likely to be resent from different IP addresses, and this
342is likely to break with milter-greylist.
343
344The -L option is an ad-hoc hack for this problem. It provides
345milter-greylist a CIDR mask to use when comparing IPv4 addresses.
346With -L24, the match mask is 255.255.255.0, and any address in a
347class C network is considered the same.
348
349There is also a real fix for the problem: SPF. SPF is a DNS based
350mechanism that enables domains to publish the identity of machines
351allowed to send mail on behalf of the domain. milter-greylist knows
352how to use SPF through libspf or libspf_alt. See section 8 of this
353document: Building with SPF
354
355Another workaround is simply to whitelist the netblocks allocated to
356mail farms. As any machine in theses IP address ranges are real SMTP
357servers that will always resend their messages, there is no point in
358greylisting them.
359
360
361 9 Working with multiple MXs
362 ===========================
363
364When running several MXs, the client should try each server after
365its message gets refused, thus causing greylist entries creation
366on each MX. Things should work, but with two minor problems:
367
368* Some stupid clients don't try all the available MXs. In that
369 situation, it could take some time before the message gets in,
370 as the client might try a different MX each time and wait for
371 several hours between the retries.
372
373* After a messages is accepted, its entry is removed for one MX,
374 but not the others. Stale entries remain until being flushed
375 because of a timeout. If a message with the same {IP, from, rcpt}
376 gets in on an MX with a stale entry, it will be accepted
377 immediately, and the X-Greylist header will report it had been
378 delayed for some time.
379
380In order to address these issues, milter-greylist is now able to
381sync the greylist among different MXs. This can be configured in
382the greylist.conf file, by adding one line per peer MX,
383like this:
384peer 192.0.2.17
385peer 192.0.2.18
386
387If you have firewalls between your MXs, you should enable TCP
388connections in both directions between random unprivileged
389source ports and destination port 5252.
390
391
392 10 Using DNSRBL
393 ===============
394
395milter-greylist can use a DNSRBL to decide wether a host should be
396greylisted or whitelisted. For instance, let us say that you want to
397greylist any host appearing in the SORBS dynamic pool list (this include
398DSL and cable pools). You would do this:
399
400# if IP 192.0.2.18 is positive, then nslookup of 18.2.0.192.dnsbl.sorbs.net
401# returns 127.0.0.10
402dnsrbl "SORBS DUN" dnsbl.sorbs.net 127.0.0.10
403racl greylist dnsrbl "SORBS DUN"
404
405You can combine it with variable greylisting delays so that dynamic hosts
406get a greylisting delay of 12 hours while other hosts only get 15 minutes:
407
408dnsrbl "SORBS DUN" dnsbl.sorbs.net 127.0.0.10
409racl greylist dnsrbl "SORBS DUN" delay 12h
410racl greylist default delay 15m
411
412This feature was introduced in milter-greylist 2.1.7 and may not be
413fully stable. You need the --enable-dnsrbl flag to configure to use
414it. You must link milter-greylist with a thread-safe resolver, else
415the milter will be unstable (see the explanation in the SPF section).
416
417If your resolver is not thread safe, install BIND9, and use
418--with-libbind. If you know your resolver is thread-safe but
419configure tells otherwise (because you lack the res_ninit() function),
420then use --with-thread-safe-resolver.
421
422If you install BIND9, make sure it includes libbind.a, since this is
423what milter-greylist needs. libbind.a is not created in BIND9 default
424build setup, so you might not have it in a precompiled package. If you
425cannot find a package that contains libbind.a, then you have to rebuild
426BIND9 from sources, using the --enable-libbind
427flag to BIND9's configure.
428
429
430 11 Building with SPF
431 ====================
432
433milter-greylist can use either libspf or libspf2 to perform SPF
434checks. Use --with-libspf=DIR or --with-libspf2=DIR to enable this
435feature. DIR must be the base directory where include and lib
436directories containing the headers and library can be found.
437
438If you want to link with an older version of libspf2, you will
439need one of the following configure flags:
440For older libspf_alt: --with-libspf_alt=DIR
441For older libspf2 up to version 1.0: --with-libspf2_10=DIR
442For newer libspf2: --with-libspf2=DIR
443
444WARNING: milter-greylist is a multithreaded program. The external
445functions it uses must be thread-safe. While libspf and libspf_alt
446contain only thread-safe code, they use the DNS resolver. By default,
447the DNS resolver from libc or libresolv is used. If this resolver
448is not thread-safe, milter-greylist with SPF will quickly crash or
449hang.
450
451You need to make sure that libspf or libspf_alt are linked against
452a thread-safe DNS resolver. For instance, NetBSD-1.6.2 libc-supplied
453resolver is from BIND 4, and it is not thread safe. In order to get
454a stable milter-greylist, you need to link with a BIND 8.2 or higher
455resolver.
456
457When building with libspf_alt-0.4, you might encounter problems if
458libbind is only available as a static library. It seems to be the
459default with BIND 8, which causes troubles. BIND 9 is fine.
460
461
462 12 Using DRAC
463 =============
464
465milter-greylist can be built with DRAC (Dynamic Relay Authorization
466Control) support, by giving the --enable-drac flag to configure.
467Location of the DRAC DB file can be chosen at build time with
468--with-dracdb=PATH, and at runtime with the drac db "PATH"
469configuration file option.
470
471If built-in, DRAC can be disabled by the nodrac configuration file
472option.
473
474More information on DRAC can be obtained at
475http://mail.cc.umanitoba.ca/drac/
476
477
478 13 Using URL checks
479 ===================
480
481ACL can cause URL lookups:
482
483urlcheck "mytest" "http://www.example.net/mgl.php?rcpt=%r+ip=%i" 10
484racl greylist urlcheck "mytest"
485
486For each ACL evaluation will spawn a request to
487http://www.example.net/mgl.php?rcpt=%r+ip=%i, with
488%r replaced by recipient e-mail
489%i replaced by IP address
490You can also substitute domain, sender address, and various other data,
491including any sendmail macro. Check the greylist.conf(5) man page for
492details. The trailing 10 is the maximum number of simultaneous
493connections you want to have.
494
495The mgl.php script is to answer if you get a match by sending back this:
496milterGreylistStatus: Ok
497
498Even better, you can send settings in the reply:
499milterGreylistStatus: Ok
500milterGreylistDelay: 1h
501
502autowhite, code, ecode, flushaddr and msg can be overloaded. You can
503even overload the ACL action (ie: turning a greylist ACL into a
504blacklist action), see the man page for details.
505
506Something to note: the reply format is LDIF-like. It was chosen so that
507the URL could be a ldap:// query, though this has not been experimented
508yet.
509
510
511 14 Using LDAP natively
512 ======================
513
514It is possible to use URL checks against an LDAP URL, but that method
515has some drawbacks:
516- This uses CURL, which must be built with LDAP support
517- There might be thread-safety problems. A workaround it to use the
518 fork option of urlcheck statement, so that milter-greylist forks
519 a pool of instances to perform queries. This may not be very reliable
520 on some setups.
521- It is not possible to fallback to another server if the LDAP directory
522 goes down.
523
524milter-greylist can also support LDAP natively, using OpenLDAP libraries,
525if configure --with-openldap is used.
526
527Here is an example that pulls a per-user sender whitelist from the
528directory:
529
530ldapconf "ldapi:// ldaps://ldap.example.net"
531ldapcheck "mytest" "ldap://ldap.example.net/o=example?whitelist?sub?mail=%r"
532racl whitelist ldapcheck "mytest" $whitelist "%f"
533racl greylist default
534
535The ldapconf statement is used to list LDAP servers. If one goes down,
536another will be contacted. For ldaps:// URLs, certificate information
537is taken from system ldap.conf.
538
539ldapcheck definition works like urlcheck with the getprop option (see
540the man page for details). Note that the scheme and host parts of the
541URL are just ignored: information from ldapconf is used instead.
542
543
544 15 Using TLS
545 ==============
546
547Using the "tls" clause, an ACL could match any email that succeeded TLS
548check in sendmail (STARTTLS giving "verify=OK"). This assumes you already
549have TLS working in sendmail.
550
551racl whitelist tls "DN1"
552racl whitelist tls "DN2"
553
554or
555
556list "trusted" tls { "DN1" "DN2" }
557racl whitelist list "trusted"
558
559A DN has a special syntax.
560If you used the 'update_tls' script provided with sendmail to generate
561your certificates, your DN should look like this:
562
563"/O=Sendmail/OU=Sendmail+20Client/CN=machine.example.net/emailAddress=admin@machine.example.net"
564
565Note that it's the "client" certificate (of the remote server) that is used
566as (the local) sendmail is acting as server during that transaction.
567
568To find the DN of any certificate, you can use the openssl command:
569
570$ openssl x509 -noout -issuer < some.crt | cut -d' ' -f2- | sed -e 's/ /+20/g'
571
572 15 Using tarpit
573 ===============
574
575'tarpit' is an anti-spam technique by lazy response.
576
577 racl whitelist tarpit 65s
578
579This ACL means that clients that can wait a response in
58065s are whitelisted. If the clients access again, they are
581accepted without lazy response because they are in
582auto-whitelist.
583
584If clients that couldn't wait a lazy response access again,
585the ACL doesn't match.
586
587 racl whitelist tarpit 65s
588 racl default greylist
589
590Those ACLs means that clients that can wait a lazy
591response or resend a message are acceptable.
592
593 racl greylist tarpit 10s
594
595This ACL means that clients should wait a response in 10s
596then pass greylist.
597
598If clients that couldn't wait a lazy response access again,
599the ACL doesn't match.
600
601 racl greylist tarpit 10s
602 racl default blacklist
603
604Those ACLs means that clients should wait a lazy response
605and pass greylist. Otherwise they are rejected.
606
607There is a 'tarpit_scope' configuration parameter. It
608controls how to count tarpitted time. Available values are
609'session' and 'command'. 'session' means that tarpitted time
610is counted in a SMTP session scope. 'command' means that
611tarpitted time is counted in an SMTP command (request/response)
612scope. The default is 'session'.
613
614 racl whitelist rcpt user1@example.com tarpit 10s
615 racl whitelist rcpt user2@example.com tarpit 30s
616 racl whitelist rcpt user3@example.com tarpit 15s
617
618It assumes that a client sends a mail to user1@example.com,
619user2@example.com and user3@example.com in a SMTP session
620when those ACLs are used.
621
622'session' case:
623 milter-greylist waits to return a response in
624 10s for user1@example.com. Then milter-greylist waits to
625 return a response in 20s for user2@example.com. 20s is
626 30s (tarpit time for user2@example.com) - 10s (tarpit time
627 for user1@example.com). milter-greylist just wait 20s
628 because milter-greylist had waited 10s. Then
629 milter-greylist doesn't wait to return a response for
630 user3@example.com because total 30s had waited in this
631 SMTP session.
632
633 user1@example.com: tarpit 10s
634 user2@example.com: tarpit 20s
635 user3@example.com: not tarpitted
636
637'command' case:
638 milter-greylist waits to return a response in 10s for
639 user1@example.com. Then milter-greylist waits to return a
640 response in 30s for user2@example.com. Waited time in the
641 previous SMTP command is not counted. Then milter-greylist
642 doesn't wait to return a response for user3@example.com
643 because over 10s had waited in other SMTP command.
644
645 user1@example.com: tarpit 10s
646 user2@example.com: tarpit 30s
647 user3@example.com: not tarpitted
648
649 17 Custom logs
650 ==============
651
652It is possible to monitor milter-greylist activity with a custom log
653format. You can choose where the output is sent (file or external
654command), and the output format. If you have this in greylist.conf:
655stat ">>/var/log/milter-greylist.log" "%T{%T} %i:%f:%r:%S\n"
656
657On each mail, this will give you a line like this in milter-greylist.log:
65810:08:04 192.0.2.16:spammer@evil.com:postmaster@example.net:reject
659
660Another example, to send the data to the local7 facility of syslog,
661using the external command logger:
662stat "|logger -p local7.info" "%i:%f:%r:%S\n"
663
664Substitutions are the same as in URL checks (%i becomes sender IP, %s
665becomes sender e-mail, %r becomes recipient, and so on). A few nifty
666additions:
667
668%T{format} is substituted by strftime(3) time format. So %T{%F %T} gives
669you a date/time in the following format: YYYY-MM-DD HH:MM:SS
670%S is substituted by the action milter-greylist chose: accept, tempfail
671or reject
672%A is substituted by the line number of the ACL that caused the decision
673
674
675 18 Packaging
676 ============
677
678milter-greylist is available from NetBSD pkgsrc and FreeBSD ports.
679A .spec file is included in the distribution to build an RPM for
680RedHat Linux. This is achieved by running rpmbuild on milter-greylist
681source tarball: rpmbuild -tb milter-greylist-3.1.4.tgz. You can define
682build_user, build_postfix, build_dnsrbl, build_libbind - for example,
683to build with DNSRBL support and choose smmsp as the user that will run
684milter-greylist, use
685rpmbuild --define "build_user smmsp" --define "build_dnsrbl 1" \
686 -tb milter-greylist-3.1.4.tgz
687
688
689 19 Things to look at if things get wrong
690 ========================================
691
692First, read the milter-greylist(8) and greylist.conf(5) man page! :-)
693
694Second, reread the installation notes at the beginning this file! ;-)
695
696Each message will get an X-Greylist header indicating either how long the
697message has been delayed, or that it has been passed through because of
698whitelisting. It looks something like this:
699
700For messages which were delayed because of greylisting:
701 X-Greylist: Delayed for 00:53:21 by milter-greylist-M.m
702 (mail.example.net [192.0.2.16]); Wed, 3 Mar 2004 17:01:06 -0000
703
704For messages which were not delayed because of whitelisting (e.g. they
705are whitelisted in the configuration file):
706 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-M.m
707 (mail.example.net [192.0.2.16]); Wed, 3 Mar 2004 17:01:06 -0000
708 X-Greylist: Sender DNS name whitelisted, not delayed by milter-greylist-M.m
709 (mail.example.net [192.0.2.16]); Wed, 3 Mar 2004 17:01:06 -0000
710
711For messages which were not delayed because of auto-whitelisting from a
712previously resent and accepted message:
713 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by
714 milter-greylist-M.m (mail.example.net [192.0.2.16]); Wed, 3 Mar 2004
715 17:01:06 -0000
716
717where M.m is the major and minor version number of milter-greylist.
718
719The file /var/milter-greylist/greylist.db is a dump of the greylist.
720It is done periodically and is used to restore state after
721milter-greylist has been restarted. The file contains an entry per
722line, with four columns: IP address, sender e-mail address,
723recipient e-mail address, and time when the message will be accepted
724(in seconds since 00:00:00 01-01-1970). Here is an example:
725
72610.0.23.1 <evilspammer@example.com> <pooruser@example.net> 1078344409
727
728Additionally, you can find a human-readable time in the comment at the
729end of each line.
730
731At the end of the file, you will find entries with the keyword AUTO
732at the end of the line. Theses are auto-whitelisted tuples. The date
733tells you when the entry will expire.
734
735Examining the tail of this file may reveal problems with domains which
736use multiple MX servers or whose mail is actually served by another site.
737
738
739 20 Known problems
740 =================
741
742If milter-greylist terminates during its operation, first check your
743system limits with ulimit (sh/ksh/bash) or limit (csh/tcsh). As it stores
744its complete database in memory, milter-greylist can eat a large amount of
745memory on a busy mail server. Each incoming connection uses a socket, so
746file descriptors can easily be exhausted too. Any resource shortage will
747cause milter-greylist to quit. This is not specific to milter-greylist;
748all milters do that.
749
750When SPF support is compiled in, if milter-greylist hangs and/or crashes
751regularly, check that you linked your SPF library with a thread-safe
752resolver. This can be done by running nm(1) on milter-greylist: if
753nres_init is referenced, you are fine. If res_init is referenced, you
754are probably at risk.
755
756When DNSRBL support is compiled in, you also need to make sure that
757milter-greylist itself is linked with a thread-safe resolver.
758
759On Solaris 2.8, milter-greylist may grow out of memory rather quickly
760due to some bugs in the pthread nsl and socket libraries. It is strongly
761recommended that you install the latest revision of patch 108993 (sparc)
762or 108994 (x86). Solaris 9 and later do not seem to be affected.
763Solaris patches are available from <http://sunsolve.sun.com/>
764
765On Solaris, and on some IRIX releases, the file descriptor field
766of <stdio.h>'s FILE structure is a char, and thus no more than 255
767streams can be open at once. This will cause failures in milter-greylist
768when handling a large number of connections. If you are not sure whether
769your system is affected or not, check your system headers for the FILE
770definition. On Solaris, the problem only exists with the 32 bit ABI,
771so rebuilding milter-greylist with a 64 bit compiler will fix the problem.
772An alternative is to use the --enable-stdio-hack option to configure
773
774On IRIX, milter-greylist has to be compiled with the same ABI as
775libmilter. If libmilter was built with the MIPSpro compiler,
776milter-greylist should be too, because of binary incompatibility
777between gcc and the MIPSpro compilers. This can be achieved by invoking
778configure with the CC environment variable set to cc. This
779incompatibility may be fixed in gcc 3.4.
780
781
782 21 License
783 ==========
784
785This software is available under a 3 clauses BSD license:
786 Copyright (c) 2004-2007 Emmanuel Dreyfus
787 All rights reserved.
788
789 Redistribution and use in source and binary forms, with or without
790 modification, are permitted provided that the following conditions
791 are met:
792 1. Redistributions of source code must retain the above copyright
793 notice, this list of conditions and the following disclaimer.
794 2. Redistributions in binary form must reproduce the above copyright
795 notice, this list of conditions and the following disclaimer in the
796 documentation and/or other materials provided with the distribution.
797 3. All advertising materials mentioning features or use of this software
798 must display the following acknowledgement:
799 This product includes software developed by Emmanuel Dreyfus
800
801 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
802 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
803 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
804 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
805 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
806 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
807 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
808 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
809 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
810 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
811 OF THE POSSIBILITY OF SUCH DAMAGE.
812
813
814If you run on a non-BSD system, two files with different licenses might
815be required for building or installing.
816
817install-sh has a MIT BSD-like license:
818 Copyright 1991 by the Massachusetts Institute of Technology
819
820 Permission to use, copy, modify, distribute, and sell this software and its
821 documentation for any purpose is hereby granted without fee, provided that
822 the above copyright notice appear in all copies and that both that
823 copyright notice and this permission notice appear in supporting
824 documentation, and that the name of M.I.T. not be used in advertising or
825 publicity pertaining to distribution of the software without specific,
826 written prior permission. M.I.T. makes no representations about the
827 suitability of this software for any purpose. It is provided "as is"
828 without express or implied warranty.
829
830
831queue.h has a 4 clause BSD license:
832 Copyright (c) 1991, 1993
833 The Regents of the University of California. All rights reserved.
834
835 Redistribution and use in source and binary forms, with or without
836 modification, are permitted provided that the following conditions
837 are met:
838 1. Redistributions of source code must retain the above copyright
839 notice, this list of conditions and the following disclaimer.
840 2. Redistributions in binary form must reproduce the above copyright
841 notice, this list of conditions and the following disclaimer in the
842 documentation and/or other materials provided with the distribution.
843 3. All advertising materials mentioning features or use of this software
844 must display the following acknowledgement:
845 This product includes software developed by the University of
846 California, Berkeley and its contributors.
847 4. Neither the name of the University nor the names of its contributors
848 may be used to endorse or promote products derived from this software
849 without specific prior written permission.
850
851 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
852 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
853 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
854 ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
855 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
856 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
857 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
858 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
859 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
860 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
861 SUCH DAMAGE.
862
863
864The configure script has the following license:
865 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
866 Free Software Foundation, Inc.
867 This configure script is free software; the Free Software Foundation
868 gives unlimited permission to copy, distribute and modify it.
869
870
871If you use the 32 bit ABI on Solaris and have a large traffic, you will
872need the a workaround for stdio unability to use streams with associated
873file dexriptor above 255. The files implementing the workaround are
874fd_pool.c and fd_pool.h, and they have a 3 clause BSD license:
875 Copyright (c) 2007 Johann Klasek
876 All rights reserved.
877
878 Redistribution and use in source and binary forms, with or without
879 modification, are permitted provided that the following conditions
880 are met:
881 1. Redistributions of source code must retain the above copyright
882 notice, this list of conditions and the following disclaimer.
883 2. Redistributions in binary form must reproduce the above copyright
884 notice, this list of conditions and the following disclaimer in the
885 documentation and/or other materials provided with the distribution.
886 3. All advertising materials mentioning features or use of this software
887 must display the following acknowledgement:
888 This product includes software developed by Johann Klasek
889
890 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
891 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
892 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
893 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
894 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
895 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
896 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
897 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
898 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
899 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
900 OF THE POSSIBILITY OF SUCH DAMAGE.
901
902
903SpamAssassin binding requires the spamd.c file, which has a 3-clauses
904BSD licence:
905 Copyright (c) 2008 Manuel Badzong, Emmanuel Dreyfus
906 All rights reserved.
907
908 Redistribution and use in source and binary forms, with or without
909 modification, are permitted provided that the following conditions
910 are met:
911 1. Redistributions of source code must retain the above copyright
912 notice, this list of conditions and the following disclaimer.
913 2. Redistributions in binary form must reproduce the above copyright
914 notice, this list of conditions and the following disclaimer in the
915 documentation and/or other materials provided with the distribution.
916 3. All advertising materials mentioning features or use of this software
917 must display the following acknowledgement:
918 This product includes software developed by Manuel Badzong
919
920 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
921 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
922 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
923 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
924 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
925 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
926 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
927 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
928 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
929 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
930 OF THE POSSIBILITY OF SUCH DAMAGE.
931