OT: Dynamically updating /etc/mail/access

Andrew M. Hoying andrewh at CQG.COM
Wed Jan 8 22:40:32 GMT 2003


Here is what I'm using basically, I run this hourly:

#!/bin/bash

# Should probably use mktemp here
cd /tmp
rm -rf accessdb
mkdir accessdb
cd accessdb

# access.manual contains entries that are maintained locally
cp /etc/mail/access.manual /tmp/accessdb

# download the latest spamlist update
wget -q http://basic.wirehub.nl/spamlist-extended.txt

# combine into temp access file
cat /tmp/accessdb/spamlist-extended.txt /tmp/accessdb/access.manual >
/tmp/accessdb/access.tmp

# Hash new access file and add duplicate lines to a sed script
/usr/bin/makemap hash access < access.tmp 2>&1 |awk '{print $4}'|sort -n
-r|sed 's/:/d/g' > /tmp/accessdb/script.sed

# Run sed script to remove dups and remove the lines 
# which are in spamlist that you don't want
cat /tmp/accessdb/access.tmp|sed -f /tmp/accessdb/script.sed| \ 
  grep -v -i zmail.ru > /tmp/accessdb/access

# Rerun hash, output errors
/usr/bin/makemap hash access < access 2>&1 > /tmp/accessdb/errors.txt

# Verify that there were no errors. If there are, mail them. 
x=$?
if [ $x -ne 0 ]
then
echo "Makemap of new access.db failed with an exit code of "$x". Errors
are `/bin/cat /tmp/accessdb/errors.txt`"| \
  mail -s "Makemap failed on `/bin/hostname`" youremail at domain.com >
/dev/null
exit $x

# If there aren't update the master access.db
else
cp /tmp/accessdb/access /etc/mail/access
cp /tmp/accessdb/access.db /etc/mail/access.db
fi

exit 0



> -----Original Message-----
> From: Daniel Zajd [mailto:daniel at ZAJD.COM] 
> Sent: Wednesday, January 08, 2003 3:31 PM
> To: MAILSCANNER at JISCMAIL.AC.UK
> Subject: Re: OT: Dynamically updating /etc/mail/access
> 
> 
> Is it possible to get a copy of your script to have as a base?
> 
> > I implemented this and a few other things in a script and now we are
> > blocking 80%  of incoming spam without having to bother 
> MailScanner or
> > SpamAssassin with processing it.
> >
> > Spam Caught / Total Incoming E-mail:
> > 444 / 3103
> > High Scoring Spam:177
> > Spam blocked by sendmail:1748
> >
> >> -----Original Message-----
> >> From: Ben C. O. Grimm [mailto:mailscanner-sub at WIREHUB.NET]
> >> Sent: Tuesday, January 07, 2003 4:03 PM
> >> To: MAILSCANNER at JISCMAIL.AC.UK
> >> Subject: Re: OT: Dynamically updating /etc/mail/access
> >>
> >>
> >> On 7 Jan 2003 00:50:03 +0100, Stewart Lawler
> >> <slawler at SYDNEY.NII.COM.AU>
> >> wrote:
> >>
> >>> this looks like a great solution - but what is the
> >> performance impact?
> >>> The relay machine i'm running mailscanner on at the moment
> >> is rather old
> >>> and might not cope with being given much more to do. :-)
> >>
> >> The only performance impact will be hashing the database when
> >> using the
> >> full list. Shouldn't be too much work though. You don't have
> >> to worry about
> >> the size of the resulting db; hash lookups are blazingly fast. Our
> >> access.db is >20 MB in size (we put a lot of extra
> >> information in it), and
> >> it gets called at least 2 times per second. I sleep well.
> >>
> >> --
> >> - Ben C. O. Grimm ----------------- Ben.Grimm at wirehub.net -
> >> - Wirehub! Internet Engineering - http://www.wirehub.net/ -
> >> - Private Ponderings ----------- http://www.bengrimm.net/ -
> >> - Wirehub! Internet ----------- part of easynet Group plc -
> >>
> >
> >
> 




More information about the MailScanner mailing list