2 messages in net.sourceforge.lists.courier-maildrop[maildropl] System wide spam Maildir
FromSent OnAttachments
Turbo FredrikssonMay 22, 2003 5:34 am 
Turbo FredrikssonMay 22, 2003 6:55 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[maildropl] System wide spam MaildirActions...
From:Turbo Fredriksson (tur@bayour.com)
Date:May 22, 2003 5:34:39 am
List:net.sourceforge.lists.courier-maildrop

I'm trying to stop spam to reach the user(s). I've successfully managed to put all spam in /var/mail/spam (which is a Maildir).

Problem is that the mail is owned by the user the mail was originally intended for, not the user owning the /var/mail/spam dir.

I've created a 'spam' user with group 'spam'. The Maildir is owned by spam.mail (dir/file mode 770/660) recursivly and mail storeage is '/var/mail/spam'.

Using the following maildroprc, 'everything' works:

----- s n i p ----- # Global maildrop filter file UMASK=007

import MAILDIR DEFAULT="$MAILDIR" DEFAULT_DEF="$MAILDIR"

import RECIPIENT import HOST import LOCAL

if ( $SIZE < 262144 ) { xfilter "/usr/bin/spamc -f -u $RECIPIENT"

if (/^X-Spam-Level: SSSSSSSSSS*/) { # SPAM scored higher than 10, so let's just toss it! to /dev/null exit }

if (/^X-Spam-Flag: *YES/) { to /var/mail/spam exit } } ----- s n i p -----

Qmail is started as 'qmail-lspawn |/usr/sbin/qmail-maildrop' and this (/usr/sbin/qmail-maildrop) contains:

----- s n i p ----- #!/bin/sh

MAILDIR=$PWD /usr/bin/preline /usr/bin/maildrop && exit 0

# check if maildrop returned EX_TEMPFAIL (75) [ $? = 75 ] && exit 111

# otherwise return a permanent error exit 100 ----- s n i p ----- (this file have not been 'optimized', so exit/return codes is probably wrong :)

The reason for the MAILDIR, is because the Maildir isn't in the users homedir, but in '/var/mail/DOMAIN/USER/' and qmail-local is doing a cd to this directory, hence the $PWD.

As said, everything works, exept that if a mail file isn't owned by the user, courier-imap won't see it. Setting the UMASK was an attempt to put the user in the 'mail' group, sgid'ing maildrop to 'mail'. Sure enough, the mail (file) should have been readable by courier-imap (mail file owner/modes: turbo.mail/ 660). But it seems courier-imap REQUIRE that the mail is owned by the user...

The 'funny' part is that the spam mail is written to new/, and when an attempt to view the mailbox (via IMAP), it is moved to cur/ (keeping it's owner/group bits).

Is this a problem in courier-imap or in courier-maildrop? Is it possible to have the file created by a specific user OR (maybe even better) don't deliver to FILE but to EMAIL. That is, doing a forward so that qmail-local can pick it up again, this time delivering it to the user (preferably without looping again because this user will ONLY get spam).