OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Procmail delivery to virtual users with SpamAssassin

From: John Locke (mailfreelock.com)
Date: Tue Apr 01 2003 - 13:52:49 CST


Hello,

I've been using Postfix for some time with the local and virtual (8)
delivery agents. I've compiled Postfix with MySQL support, and store all
the virtual account info in MySQL. The local delivery agent uses
Procmail to deliver to local users, who can have their own .procmailrc
files in their home directories to sort mail, and can call SpamAssassin
from a recipe.

I'd like to extend the sorting/filtering ability to my virtual users,
and I'm trying to come up with a good scheme to use. One constraint is
that I need to be able to disable spam filtering for particular virtual
users (for a spam training account, for example).

Here's my current plan of attack:

1. Set up 2 different versions of Procmail in the master.cf file with
pipe (8)--one that routes mail through SpamAssassin, and one that points
to a procmailrc file that includes a procmailrc in the same directory as
the user's Maildir.

2. Use MySQL to store user accounts, and create mysql maps for the
virtual_mailbox parameters.

3. Use filtering in Postfix to route mail through the SpamAssassin
Procmail, only for users that are in the SpamAssassin map, and add
SpamAssassin headers to the email.

4. Change the virtual_delivery_agent to the second procmail, running it
as the virtual_mailbox_uid user, delivering to ${mailbox}. All of these
are in MySQL, keyed to the email address.

Is this possible using Postfix configuration, or am I going to have to
write some sort of daemon/Procmail wrapper/script to get all of the
proper info for the user into Procmail, from MySQL?

For part #3, here's how I'm thinking to do this:
/etc/postfix/main.cf:
smtpd_recipient_restrictions = ...[other restrictions],
  reject_unauth_recipients,
  check_client_access mysql:/etc/postfix/sa_filter.cf

/etc/postfix/sa_filter.cf:
[ MySQL query that returns "FILTER saprocmail:dummy" for users that want
spam filtering, nothing for other users]

/etc/postfix/master.cf:
safilter unix - n n - - pipe
        flags=Rq user=filter argv=/usr/bin/procmail -t -m
USER=${recipient} /etc/procmailspamrc

/etc/procmailspamrc:
[ recipe that routes email through SpamAssassin, passing the recipient
address as a file name in a specific directory of SpamAssassin user
config files, and reinjects into Postfix using an alternate smtp defined
in master.cf on a different port with all UCE checks disabled. (not
quite sure how to set the reinjection up from procmail...)]

Comments?

Is there a better approach to what I'm trying to do?

Is there an alternative LDA that I should be looking at?

Thanks,
--
John Locke
Owner, Freelock, LLC
http://freelock.com
Just launched: http://teamcheckin.com