OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
FILTER_README suggestions

From: Wietse Venema (wietseporcupine.org)
Date: Fri Sep 01 2006 - 09:53:49 CDT


Postfix's FILTER_README was written long before backscatter became
a problem. The first example (see below signature) has a warning
not to reject mail:

    Note: in this time of mail worms and spam, it is a BAD IDEA to
    send known viruses or spam back to the sender, because that
    address is likely to be forged. It is safer to discard known
    to be bad content and to quarantine suspicious content so that
    it can be inspected by a human being.

Unfortunately, the text gives no example of how one would implement
this advice. Personally, I use no external filter so I have a hard
time coming up with field-tested examples.

What do people use:

- Have the filter return a distinct exit status that says "discard"?

- Have the filter insert a "badness" indicator in a message header,
and dispose of bad mail with Postfix HOLD/DISCARD actions, maildrop
rules, cyrus sieves, or procmail filters?

- Something completely different? Maybe no-one uses the pipe+sendmail
example and we can drop it from the documentation.

        Wietse

 1 #!/bin/sh
 2
 3 # Simple shell-based filter. It is meant to be invoked as follows:
 4 # /path/to/script -f sender recipients...
 5
 6 # Localize these. The -G option does nothing before Postfix 2.3.
 7 INSPECT_DIR=/var/spool/filter
 8 SENDMAIL="/usr/sbin/sendmail -G -i" # NEVER NEVER NEVER use "-t" here.
 9
10 # Exit codes from <sysexits.h>
11 EX_TEMPFAIL=75
12 EX_UNAVAILABLE=69
13
14 # Clean up when done or when aborting.
15 trap "rm -f in.$$" 0 1 2 3 15
16
17 # Start processing.
18 cd $INSPECT_DIR || {
19 echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }
20
21 cat >in.$$ || {
22 echo Cannot save mail to file; exit $EX_TEMPFAIL; }
23
24 # Specify your content filter here.
25 # filter <in.$$ || {
26 # echo Message content rejected; exit $EX_UNAVAILABLE; }
27
28 $SENDMAIL "$" <in.$$
29
30 exit $?