Quoting Alan W. Rateliff, II ([EMAIL PROTECTED]):
> I wrote a hook for IMP/Horde which scans through my Sendmail virtuser file
> to resolve an email address to a local user name, then use that username to
> log into the system.
>
> I would like to write a similar patch for QPopper, but I'm not very
> proficient in C, especially with using dbm. Could anyone here offer some
> help to get me started?
DBM is pretty ancient, I've used Berkeley DB for all things
map since 1993 or so.
That said, LDAP is here and solid and very valuable for keeping
maps in. I make a change in LDAP, and 3 MTAs see it right away
(same as with Hesiod when I used that in the early-mid 90s).
LDAP is independant of sendmail and can be queried.
The right and easy answer would be if sendmail used a LIBRARY
for these map lookups (and things like readcf() so you could query
a library routine for, say, the value of Class W or a option
setting or a list of queue directories).
But they don't.
An easy hook, that would be map type indendant, would be to write
a rule, say "Scheck_virtusertable" and have it just return the
virtusertable lookup. Nothing within sendmail would call that rule,
so no harm. But YOU could do the C or perl equiv of:
echo "check_virtusertable [EMAIL PROTECTED]" | sendmail -bt
and sendmail would emit the final info.
I snagged from the stanza below Sparse1 (handle virtusers) until the Recurse
line (all one para) into "check_vut" which emits the full email triple
(mailer, host, username).
First, send the input through rule 3:
Scheck_vut
R$* $: $>3 $1 #get focus on domain/normalize
BigBlobOfVirtuserHere
Then it would be just a little work to replace that last line
(recurse) with a "if domain is a virtual domain, call self again"
then clean it up.
Without much testing:
R <$+ @ $={VirtHost} > $+<$+> $> check_vut $1 @ $2
R <$+ @ $+ > $+<$+> $: [EMAIL PROTECTED]
So
echo "[EMAIL PROTECTED]" |sendmail -bt | tail -1
gives me:
check_vut returns: user @ my . realhost . domain
Who calls sendmail ugly :)
It's not pretty, but it's portable enough that virtusertable
can be multiple files, LDAP, db, dbm, HESIOD, SQL, or combinations.
It what sendmail would get.
Just my $0.04