mail filter in python?

Thomas Wouters thomas at xs4all.net
Mon Feb 7 11:52:23 EST 2000


On Mon, Feb 07, 2000 at 05:01:56PM +0100, Gerrit Holl wrote:
> File locking isn't hard to implement, what kind of security checks do you
> mean? Python is portable so that's not a problem.

File locking _is_ hard to implement, in a portable, secure, race-proof
manner. flock()/lockf()/O_EXCL are the easiest ways of locking, but are not
very portable, and are likely not to work on some filesystems (like NFS).
Also, some NFS servers and clients do their best to do NFS locking in a
secure way, but most do not succeed, or succeed at the cost of stability and
speed.

There is a fairly portable way of locking, even over NFS, using hard links
between lockfiles, but it is tricky to implement. See the mailman-developers
archive on www.python.org/pipermail/mailman-developers, there should be a
few recent postings by me about locking.

> >    It would be hard to reimplement all that from scratch :(
> 
> I don't think so. Security is not an issue, the command runs under the
> right uid.

That depends on how/where you install it. It usually has to run with
mail-gid permissions, for instance. All in all, i think you're better off
with a frontend to procmail, which creates a procmailrc to your liking. Or
perhaps you can use the powers of procmail to make it start a python script
to do the filtering, and accepts the action from it -- it would then take
care of locking, security and the mailbox format itself.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list