hey everybody on the list,

i use postfix on my mailserver, ans spamassassin for marking spammails, it work's really great except
one aspect:


postfix uses the filter.sh which gives the mail to spamassassin.
my only problem is, that every mail is beeing scanned, even
if they are bigger (e.g. > 2mb). the most spam is smaller then
100k so the actuall setup isn't good for the ressources on the
server.

*cut from master.cf'
filter unix - n n - - pipe
flags=Rq user=filter argv=/usr/local/filter/filter.sh -f ${sender} -- ${recipient}


*end*

the filter.sh looks like follows:

---------------------------------------------------------
cat /usr/local/filter/filter.sh

#!/bin/sh
#
# filter.sh
#
# Simple filter to plug Anomy Sanitizer and SpamAssassin
# into the Postfix MTA
#
# From http://advosys.ca/papers/postfix-filtering.html
# Advosys Consulting Inc., Ottawa
#
# For use with:
#    Postfix 20010228 or later
#    Anomy Sanitizer revision 1.49 or later
#    SpamAssassin 2.42 or later
#
# Note: Modify the file locations to match your particular
#       server and installation of SpamAssassin.

# File locations:
# (CHANGE AS REQUIRED TO MATCH YOUR SERVER)
INSPECT_DIR=/var/spool/filter
SENDMAIL="/usr/sbin/sendmail -i"
ANOMY=/usr/anomy
SANITIZER=/usr/anomy/bin/sanitizer.pl
ANOMY_CONF=/usr/anomy/anomy.conf
ANOMY_LOG=/dev/null
SPAMASSASSIN=/usr/bin/spamassassin

export ANOMY

# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69

cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }

# Clean up when done or when aborting.
trap "rm -f out.$$" 0 1 2 3 15

#cat | $SPAMASSASSIN -P | $SANITIZER \
#   $ANOMY_CONF 2>>$ANOMY_LOG > out.$$ || \
#   { echo Message content rejected; exit $EX_UNAVAILABLE; }

cat | $SPAMASSASSIN > out.$$ || { echo Message content rejected; exit $EX_UNAVAILABLE; }

$SENDMAIL "$@" < out.$$

exit $?
--------------------------------------------------------------------------------------------------------------------

my idea ist to modify the filter.sh that only mails smaller then 100k are given
to spamassassin, the rest shouldn't :/


i modified the script several times but finally don't get it working.


my skript: ---------------------------------------------------------------------------------------------------------------------- #!/bin/sh


INSPECT_DIR=/var/spool/filter SENDMAIL="/usr/sbin/sendmail -i" ANOMY=/usr/anomy SANITIZER=/usr/anomy/bin/sanitizer.pl ANOMY_CONF=/usr/anomy/anomy.conf ANOMY_LOG=/dev/null SPAMASSASSIN=/usr/bin/spamassassin

export ANOMY

# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }


# Clean up when done or when aborting. SIZE="/usr/bin/du -hsk out.$$|awk '{$1}'" echo $SIZE trap "rm -f out.$$" 0 1 2 3 15

if [ "$SIZE" <= "100" ]
then
cat | $SPAMASSASSIN > out.$$ || { echo Message content rejected; exit $EX_UNAVAILABLE; }
$SENDMAIL "$@" < out.$$
exit $?
else
cat > out.$$ || { echo Message content rejected; exit $EX_UNAVAILABLE; }
$SENDMAIL "$@" < out.$$
exit $?
fi
------------------------------------------------------------------------------------------------------------------------------


any ideas on how to implement a sizecheck into the skript. i'm really stuck with it
so any kind of help is appreciated.


kind regards,
werner detter
















Reply via email to