OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: A question about advanced filtering

From: D.Walsh (infodaleenterprise.com)
Date: Sat Apr 02 2005 - 05:10:37 CST


On Apr 02, 2005, at 04:54, Laurent Darrambide wrote:

>
> As none as answered, maybe my question was stupid, unclear or
> interesting.
>
> I try it in a different way.
> In the advanced filter setup, is there a way to discard a mail under
> certain conditions.
>
> Example: in the simple filter setup, I do virus scanning via clamav.
> as return code, which discards the mail.
>
> AV="`${CLAMAV} --disable-summary --stdout - < in.$$`"
> RESULT=$?
> if [ ${RESULT} = 1 ];then
> echo "Virus trouve: " >> /tmp/virus
> exit 0
> fi
>
>
> It doesn't work in the advanced filter setup, because I receive
> an unwanted mail via port 10026 anyway.
>
> Thanks for reading and helping as return code, which discards the
> mail.
>
>
> --
> Laurent Darrambide, France

I thought it was supposed to be something like this.

in main cf

_________________________________________________________

pickup fifo n - n 60 1 pickup
   -o content_filter=clam_scan
   -o content_filter=alter_mime

clam_scan unix - n n - - pipe
     flags=Rq user=cyrus argv=/etc/postfix/clam_scan -f ${sender} --
${recipient}
alter_mime unix - n n - - pipe
     flags=Rq user=cyrus argv=/etc/postfix/alter_mime -f ${sender} --
${recipient}

filename clam_scan:
_________________________________________________________

#!/bin/sh
#

# Localize these.
INSPECT_DIR=/var/virus/filter
SENDMAIL=/usr/sbin/sendmail
CLAMAV=/usr/bin/clamscan

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

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

# Start processing.
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit
$EX_TEMPFAIL; }
cat >in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; }

$CLAMAV --infected --no-summary in.$$ || { echo "Virus trouve: " >>
/tmp/virus; exit $EX_UNAVAILABLE; }

$SENDMAIL "$" <in.$$

exit $?
_________________________________________________________

filename alter_mime:
_________________________________________________________

#!/bin/sh
# Localize these.
INSPECT_DIR=/var/spool/filter
SENDMAIL=/usr/sbin/sendmail

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

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

# Start processing.
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit
$EX_TEMPFAIL; }

cat >in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; }

/usr/bin/altermime --verbose --input=in.$$ \
                    --xheader="X-Copyrighted-Material: Dale Enterprise
L.L.C." || \
                      { echo Message content rejected; exit
$EX_UNAVAILABLE; }

/usr/bin/altermime --verbose --input=in.$$ \
                    --xheader="X-Fax-Number: (727) 321-3426"|| \
                      { echo Message content rejected; exit
$EX_UNAVAILABLE; }

#/usr/bin/altermime --input=in.$$ \
# --disclaimer=/etc/postfix/disclaimer.txt \
# --disclaimer-html=/etc/postfix/disclaimer.txt \
# --xheader="X-Copyrighted-Material: Dale Enterprise
L.L.C." || \
# { echo Message content rejected; exit
$EX_UNAVAILABLE; }

$SENDMAIL "$" <in.$$

exit $?
_________________________________________________________