Archive for 15th July 2007

Virtual accounts with exim and dovecot

A few people commented on my last post asking for details about how I configured exim and dovecot to have the fake scott+canonical account and separate Maildir tree.

exim4 router configuration

The first key part of the configuration is to configure exim4 to split the local part into a user name and a suffix. This allows a local part such as “scott+canonical” to be split into the user name “scott” and the suffix “+canonical”.

This is configured by adding the following two options to the appropriate routers in your exim4.conf:

local_part_suffix = +*
local_part_suffix_optional

The first option defines the suffix; normal practice appears to be to use both “+” and “-”, but since I’d previously used “-” with qmail I opted to use “+” only so that I didn’t confuse myself during the transition.

The second option allows the suffix to be optional, so that mail to “scott” is still delivered normally.

Now mail to “scott+canonical” will be delivered to the “scott” user.

Forwarding configuration

The next task is to ensure that mail is actually forwarded to this address; for me this was a configuration performed by the Canonical sysadmins to ensure that my work e-mail is actually delivered to scott+canonical on my own mail server.

Filtering configuration

Since both personal and work e-mail are now both being delivered to the same user account on my home mail server, I need to filter the mail into separate folders.

This can be done by checking the $localpartsuffix variable in Exim filter .forward files, e.g.:

# Exim filter

if $local_part_suffix is "+canonical"
then
    save Maildir/Canonical/
endif

Now incoming work e-mail is filtered into a different mail folder, while personal mail is delivered into the primary one.

I’ve used similar filter instructions for mailing lists, mailman messages, Launchpad mails, etc. to filter into appropriate folders.

Where the mail is personal, it is filtered into (e.g.) Maildir/.Lists/upstart-devel/

Where the mail is for work, I add /Canonical/ to the path, (e.g.) Maildir/Canonical/.Lists/linux-hotplug-devel/

This means that the Maildir/ directory is my personal INBOX, with sub-folders immediately under that and beginning with a period; and the Maildir/Canonical/ directory is my work INBOX, with sub-folders immediately under that and beginning with a period.

This defines two trees in a manner compatible with dovecot. There’s no particular reason that Maildir/Canonical/ has to be under Maildir/, it could have been Maildir-Canonical/ and this would still work. I simply wanted them in one place to ease backups.

Dovecot configuration

Now we need to configure dovecot to permit login by a fake (”virtual”) user, with a different Maildir tree, so that I can configure them as two separate accounts.

The first set of changes is to dovecot.conf to add an additional authentication source. Modify the “auth default” block to add a new “passwd-file” passdb in addition to the “pam” passdb (or whatever your system is using).

passdb passwd-file {
  args = /etc/dovecot/passwd
}

This lets us authenticate virtual users, but we also want to set their attributes, so we can use the same file as a userdb in the same “auth” block.

userdb passwd-file {
  args = /etc/dovecot/passwd
}

Dovecot will now check both PAM and this file for user information.

We now simply need to add a line to this file to specify the virtual user and set up the alternate Maildir tree.

scott+canonical:PASSWORD:1000:1000::/home/scott::userdb_mail=maildir:/home/scott/Maildir/Canonical

The format is that of an ordinary passwd file; the first two parts give the passdb authentication credentials and the rest give the userdb information.

I’ve set this user to have the same uid, gid and home directory as my real “scott” user.

The final part changes the mail environment for this virtual user, instead rooting it at Maildir/Canonical/

Client configuration

The mail client will need two accounts adding; one for “scott” and the other for “scott+canonical”. It will see two separate folder trees for each account.

An unexpected bonus is that the reply account is now automatically set for me, since I’m replying from the specific account rather than from a single general one.

Trial Flight

I’d spent the entire month since making the booking preparing myself for the disappointment of it being cancelled due to weather, and having to rebook and wait another few weeks.

The weather report the day before wasn’t too bad, and the weather outside looked pretty nice. A fair amount of high fluffy cloud, but good visibility and nothing too low to worry about.

So I was even more nervous when I phoned up to find out whether the flight would be going ahead. “A bit of a cross-wind, but a couple of guys have been up already with no problem” was the report. It was still on!

Had I been lucky enough to pick, four weeks ago, one of the only good days for flying so far?

We set off for the airfield, and I couldn’t help but keep an eye on the weather all the way there. At one point, a pretty nasty cloud appeared ahead and my heart sank, but then we turned away from it and there was blue sky ahead with the wind coming towards us.

As we got nearer, we started to see aircraft flying around. It turns out that all that worrying was for nothing, the weather for miles around the airfield was beautiful with nothing more than a bit of wind.

We’d intended to stop off for a pub lunch on the way, but had left a little later than we intended. Therefore we arrived early, but without enough time to stop off for something to eat.

Popped into the club to let them know we were there, and paid for the flight. Since this was my first flight, my partner was paying for it as my birthday present; and it would be in a 4-seater Piper Warrior so he could come along too and ride in the back.

The instructor was out with another student, so we opted to have something to eat at the airfield’s busy “Touchdown Cafe”; and sat on the decking outside the club afterwards watching the planes and waiting for the instructor to return.

The plane I was to fly in was G-GYTO, a seven year old PA28 Piper Warrior. Someone had taken it out that morning, so it was briefly checked for fuel before the briefing.

I was very happy to discover that my instructor would be the same man who had shown us round the aircraft on my first visit to the airfield. His relaxed and patient style had left me with a really good impression of the club, and I was delighted that he would also be taking me up in the air for the first time.

The briefing covered the aircraft’s controls with a cute little meccano model, headsets were picked up and then it was time to walk out to “Tango Oscar”.

David got settled in the back while I climbed into the left seat, through the Piper’s single left door. Headsets were plugged in and the volume checked, engine was checked and started, and then we were taxying out to the hold for the runway.

Along the way I got a chance to swerve the plane left and right a bit with the pedals, until we reached the holding point where we turned into the wind and performed the final pre-flight checks.

We were held as a couple of other aircraft landed, and then it was our turn; “Tango Oscar, Wellesbourne Information, take off at your discretion” … “Take off, Tango Oscar”.

The power went up, and so did my nerves, as we accelerated down the runway. John (the instructor) talked through each of the movements he did along the way, and then we were up in the air and flying through the crosswind and turbulence.

Noticed very quickly that the smaller aircraft was much more at the mercy of the elements than the commercial jets, and needed more input; or maybe it’s just that I was now sitting in the front and could actually see everything.

Once we were up to 1,500ft; we levelled off and I had control.

The first task was understanding the effect of the controls. The pedals yawed the aircraft, and finished up with a bit of roll. The control column rolled and pitched the aircraft.

My next task was to keep the aircraft straight and level while we flew towards Long Marston airfield. All of my concentration was taken up just trying to keep the plane going in one direction.

The nose wanted to turn in all sorts of directions, and it needed continual input to try and keep it going where I wanted.

We then tried some turns, and I was amazed by how hesitant I was to seriously bank the aircraft. It felt uncomfortable to do anything too tight; and it wasn’t until I was on the ground that I remembered that rudder correction can solve that.

Throughout the flight, John was pointing out various landmarks along the way; and David was happily taking photos in the back, but I was entirely occupied for keeping us in something like a straight line.

He only took control once when David spotted a glider, to get out of its way, and returned control to me afterwards.

Somewhere along the way John introduced the trim wheel, since I was obviously pulling on the column to keep it level. I found this quite hard to sort out at first, turning the wheel didn’t seem to make much difference, but eventually I think I got it somewhat in trim.

After Long Marston, we turned towards Birmingham, and tracked towards that keeping it on the horizon. We then turned right towards Stratford-upon-avon, “and ok, we’ll descend a little as well” John cheerfully added as I failed to hold the nose up during the turn.

All too quickly I was heading over Stratford and had Wellesbourne in sight ahead; John called them on the Radio, and took control for the join, approach and landing. And then we were on the ground and taxying back to the school.

For the rest of the day, I was grinning like a child and making “neyowm” noises to myself.

After a light snack, we visited a little nursery we’d seen on the way in to look at some plants. Every time a plane flew overhead, I looked up; and for one of them, my heart leaped even more when I saw that it was Tango Oscar.

P/UT Hours Today 0:30, Total 0:30