Archive for Linux

Maildrop + Postfix

Our server runs Postfix as MTA: it’s a very powerful mail server, highly configurable, and extremely efficient when used in combination with amavis, spamassassin, mysql, cyrus-sasl and courier-imap.

Spamassassin is really THE indispensable tool in today’s internet environment, where about 80% of e-mails are spams!

Before using spamassassin, I simply couldn’t dissociate abusive e-mails from real ones (of course, words like viagra or pe*is elongation in the subject were clear hints 😉 ). Then, once spamassassin has been put in place (through the use of amavis), detected spams were marked with “***SPAM***” in the subject. It was then simply a matter of setting a rule in Thunderbird in order to get rid of those fu***in spam e-mails.

But still, a problem remains when using a webmail: spam e-mails were simply displayed in the Inbox folder, which really irritated me in the end. So I looked for a solution to automatically sort e-mail at reception time… That’s where maildrop appears!

Maildrop is normally delivered with the courier MTA, but as we are using Postfix, we had to emerge it:

# emerge maildrop -va

Some postfix adaptation is needed so that it uses maildrop to deliver the mail instead of the postfix/virtual process (when using virtual users of course). Add or adapt the following in /etc/postfix/main.cf

virtual_transport = maildrop
maildrop_destination_recipient_limit = 1
mailbox_command = /usr/bin/maildrop

Then make sure to have a line like the following in /etc/postfix/master.cf (of course, the user vmail has to exist on your system):

maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -w 90 -d ${user}@${nexthop} \
${user} ${nexthop} ${sender}

All mail users being stored in a database, simply replace the “virtual:” in the destination field of the transport table by “maildrop:” for the domains you want to serve using maildrop. The others will simply continue to perform as before.

The last thing to do is to create either a /etc/maildroprc or a ~/.mailfilter file (or both of course). The former defines rules to be applied to all accounts, while the latter does the same but only for the accounts that belongs to a specific user. Here is what such a file may look like to automatically move detected spam to a Spam folder (and create it if necessary):

`test -d $DEFAULT`
if( $RETURNCODE == 1 )
{
`/usr/bin/mkdir -p $DEFAULT`
`/usr/bin/rmdir $DEFAULT`
`/usr/bin/maildirmake $DEFAULT`
}
if ((/^X-Spam-Status: YES/))
{
`test -d $DEFAULT/.Spam`
if( $RETURNCODE == 1 )
{
`/usr/bin/maildirmake $DEFAULT/.Spam`
`echo "INBOX.Spam" >> $DEFAULT/courierimapsubscribed`
}
to "$DEFAULT/.Spam/"
}

Make sure the permission on that file is 600, and that the file is owned by that specific user.

Those steps have made the internet a better and safer place to live with 😉

Once again…

As you may know (and if you don’t, you may want to read this), I’m using Gentoo on my main workstation, and Ubuntu on my laptop. But I always felt that the default Ubuntu was too heavy: it takes so long to boot, a lot of unnecessary processes are started, the gnome environment is too slow, …

So once again, I decided to install Debian… I like distributions that allows you to decide from the beginning on what you are going to install or not (the main reason why I stick to Gentoo when enough compilation power is available). But once again, I was really disappointed by Debian: you only get very old stuff with the default repositories, and starting to add custom reps is an open door to configuration problems.

So I looked for alternatives, and I decided to try the server version of Ubuntu… The installation went smooth, but the first boot didn’t… I just received some “unknown interrupt or fault”, and it seemed I wasn’t the only one.

My last attempt at installing Ubuntu was using the 6-10 alternate image…. And that is what I should have done since the beginning!!!! You can choose to install a Command Line Only system, and then build your customized system upon it! It is just the right choice between Debian and the default Ubuntu: the freedom of choice that Debian offers, with the latest packages built for Ubuntu.

My laptop now boots in less than 30sec, is fast as hell, and is provided with the latest packages (firefox 2, kernel 2.6.17-10, …).

You should really give it a try!

Catastrophic disk failure…

Last thursday, our server suffered from a catastrophic hard drives failure. We were using software RAID on two SATA disks, but because of our stupid datacenter’s team (DigitalRoot not to name it…) shutting down the server by removing the power plug to move it to another location, the RAID setup became unstable. However, we continued to use it…

BAD IDEA!!!! After some weeks, it totally broke up. We lost everything… :grr: Good occasion to test our backup system. After a rapid re-install (from scratch), we recovered all backed-up data from the backup server, and we were up and running some hours later… :stress:

Lessons Learned:

  • Perform an image of the base system – to do
  • Perform backup of: /etc, /home, /databases – OK
  • DO NOT USE software raid – OK (sata raid controller installed)
  • Backup: perform periodic “copy and delete” sync. By that, I mean not only copy all modified files to the backup server, but also remove them from it when they are removed on the production server. Indeed, after the data recovery, I had a lot of unread e-mails… When I read and deleted them, some of them were in fact already backed up. :dead: