procmail
[Top] [All Lists]

Re: hashed MAILDIR with procmail filter mode

1999-07-30 12:10:33
On Jul 17, 20:46, Philip Guenther wrote:
Subject: Re: hashed MAILDIR with procmail filter mode
"Juergen Georgi" <georgi(_at_)belwue(_dot_)de> writes:
[...]

I imagine something like

MAILDIR=/var/pop    # Mailspool
MAILDIRHASH=2            # $MAILDIR/f/o/foobar
FROM=$1             # Sender (in case we do forwarding)
DEFAULT=$2          # Recipient

which a) automatically delivers to "f/o/foobar" when DEFAULT is set
to "foobar" and b) creates missing directories in MAILDIR on the fly.

Can you live with precreating all but one level of the heirarchy, and then
the cost of a fork/exec?

      SPOOLDIR = /var/pop
      FROM = $1
      RCPT = $2
[...]

Thanks for the recipe. I wanted it in C, so I followed your advice
and modified authenticate.c to lookup the user from a Berkeley DB
password database. In case the user is found, a getpwnam(virtualuser)
call is done, where 'virtualuser' is the owner of the password database
and the mailspool directory. Before the passwd structure is returned,
pw->pw_name is set to the looked-up username. This way procmail
is happy and can even process the virtualuser's $HOME/.procmailrc.

A large part of the code was taken from the cucipop source (including 
sdb.h). In order to support cucipop's concept of 'virtual host system 
mailboxes', the virtual host name can be passed with the '-a argument' 
mechanism. Calling 'procmail -a virtual.dom.ain -d foobar' will lookup
virtual.dom.ain/foobar in the password database and delivers to 
'/var/pop/virtual.dom.ain/f/o/foobar'. Just calling 'procmail -d foobar'
will lookup 'foobar' and delivers to '/var/pop/f/o/foobar'.
Note: standard cucipop looks for '/var/pop/v/i/virtual.dom.ain/foobar'
when compiled with MAILSPOOLHASH 2 and VIRTUALSERVER. I didn't like
this, so I modified cucipop's auth_mailboxname() to accomodate hashing 
on the username level.

I didn't implement mailbox autocreation after I realized that
the procmail standard MAILSPOOLHASH feature doesn't do so either.

Not being a code warrier, I'm sure there are bugs that I don't see. 
Any pointers and hints for fixing are greately appreciated.

TIA 
Juergen Georgi

Attachment: vpop.patch
Description: Text

<Prev in Thread] Current Thread [Next in Thread>