Selling cookie info to third-parties is a classic example of you can make money without doing evil.
RSS

Autowhitelist for Postfix

2005/03/21 filed under /linux, /software

At work, spam is a real problem (at home too, by the way). So I've installed some tight regulations, using multiple RBLs and other nice spam filtering goodies. The problem with this is, of course, the false positives these spam filters get; mail that we'd really like to see.

Postfix offers you to keep a whitelist through the check_sender_access option, but I'm really too lazy to type in all addresses I use, and to keep doing that in the future. So I wrote a little bash hack that will scan the maillog every 10 minutes (thanks, cron!) and grabs the none-local, delivered mail addresses. These addresses get dumped (with time stamp for reference) in a whitelist file, and get postmapped

#!/usr/local/bin/bash

DATE_INS=0
DATE=`date`

for LINE in `sed -ne 's/^.*to=<\([^>]*\)>,
relay=[^(local)].*status=sent.*$/\1/p' /var/log/maillog | sort -u`
do
   if grep -q $LINE /etc/postfix/whitelist
   then
      continue
   fi

   if grep -q $LINE /etc/postfix/autowhitelist
   then
      continue
   fi

   if [ $DATE_INS -lt 1 ]
   then
      echo "### $DATE" >> /etc/postfix/autowhitelist
      DATE_INS=1
   fi

   printf "%-77s OK\n" $LINE >> /etc/postfix/autowhitelist
done
/usr/local/sbin/postmap /etc/postfix/autowhitelist

This post is listed in the Linux category. I use FreeBSD on my servers, but I have no doubt this will work on Linux too ;)

Posted by: B10m | permanent link | comments (2)

Comments

BOK wrote at 2005-05-25 10:04:

Suggestion: how to bind these files in main.cf for those (not me) who don't know.

B10m wrote at 2005-05-25 12:15:

In your main.cf, you will have to add the following line to your smtpd_client_restrictions

check_sender_access hash:/etc/postfix/autowhitelist,

Also, make sure you grep case insensative ("grep -qi" instead of "grep -q") to prevent double listings.

Comments are closed for this story.
Trackbacks are closed for this story.
return-member