Author: Jonathan Hunter Date: To: exim-users Subject: [Exim] Matching GECOS field for mail delivery
Hi,
I hope there isn't a blindingly obvious solution to this - I couldn't see
one when I checked the FAQ and the docs.. :-)
I'm setting up a mail server for a company, and they want to have email
addresses in the form firstname.lastname@???. The actual UNIX
usernames on the server will be based on peoples' initials, but the GECOS
field in /etc/passwd will contain their full name.
I remember reading through the sendmail documentation a while ago, and
coming across a feature that it had whereby if the local_part wasn't matched
it would then attempt to match it using the GECOS fields from /etc/passwd.
My first question is, has anybody implemented this using Exim before?
There's no sense in my re-inventing the wheel if it's already been done. If
not, I'll try to write it myself and post it to the list when (if? :-)) it
works. I know it can be done using alias files, but that's not as elegant as
doing a "live" lookup on /etc/passwd. When a new user is added, their mail
should work straight away without editing alias files. And yes, I do know
the problems that can arise if two people of the same name join the
company - this company only has a small number of employees and that is not
a worry at the moment.
Where would be the best place to add this to Exim's configuration? I suppose
it could be done with a director that finds a match and passes it to
smartuser with the correct local part, but is this the "right" way of doing
it? Would using rewriting be a better method? Unfortunately I've not used
the rewriting features before, so I'm not 100% familiar with what they can
do.
As for the actual implementation of this, I originally thought of doing an
lsearch on /etc/passwd to find the user, but of course /etc/passwd starts
with the username (which is what we are trying to find), not with the GECOS
field (which is our lookup key). Is there something cunning that can be done
with regular expressions or string expansions to achieve the desired result?