Home | Scripts | How To's | About


Patching Maildrop To Create Directories

View Comments

When using maildrop in a virtual mail server setup, by default it will not create new directories, which makes the task up to the administrator when adding new accounts. However, there is a very simple way to modify Maildrop so that in the event it does not find a user's mailbox directory, will automatically create Maildir style folders.

Update! You can now do this directly in maildroprc without patching the source

Before the final mail delivery in maildroprc, add the following:
`test -d $HOME/$DEFAULT`
if ( $RETURNCODE == 1 )
{
    `mkdir -p $HOME/$DEFAULT`
    `rm -rf $HOME/$DEFAULT`
    `/usr/local/courier/bin/maildirmake $HOME/$DEFAULT`
}

Done!

The Source

The source file seems to not have changed throughout subsequent version updates, therefore this howto should apply to any new version.

Go to the maildrop source directory and then go one more level down to "maildrop." Once you are there, look for "maildir.C."

Patching

Look through the source for the "Maildir:IsMaildir" function.

After:
int     c;


Insert:
int     chkfail = 0;


In that same function you will find four if statements that check for the directory name, they will then return false. We need to change that.

Change:
return (0);

To:
chkfail == 1


Finally, add the if statement that will create the Maildirs. It goes at the very bottom of the function, right before it returns true.

Before:
return (1);


Add:
if (chkfail == 1)
{
    /* Get a valid directory string */
    newdir=dirname;
    newdir += '';

    /* Default permissions, maildrop will use this for the Maildir */
    dirperm=0700;

    mkdir(newdir, dirperm);
    chdir(newdir);
    mkdir("tmp", dirperm);
    mkdir("new", dirperm);
    mkdir("cur", dirperm);
}


Compile and you're done!
 


Comments (Last 10): [Show All]


SergeOctober 02nd, 2011 @ 12:33PM

Updated as of October 2, 2011. You can use a few lines in maildroprc without the need to patch the maildrop source.

 
Post Comment:

Use the following verification number: p7pogq74dnh

Name 
Comment 
Verification 



eBay Sniper