OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Subject: virtual domains and hacking smtp_addr.c
From: Jonathan Ellis (jellisadvocast.com)
Date: Thu Oct 05 2000 - 15:46:46 CDT


I'm trying to handle mail for multiple domains on our mailserver, thor. The
virtual table looks like this:

advocast.com foo
jellisadvocast.com jellisthor.advocast.com
(...other local users)
jbellisadvocast.com jbellishotmail.com
(...other forwarded addresses)
sfreview.org foo
webmastersfreview.org jellisadvocast.com

mydestination is set to thor.advocast.com,localhost.advocast.com

Here's the problem: due to our firewall (mis?)configuration, thor can't talk
to itself using it's "external" IP address. I.e. "telnet 209.140.77.226 25"
craps out, but "telnet localhost 25" works fine.

So, what is happening when mail comes in addressed to webmastersfreview.org
is that postfix looks up the MX for advocast.com, says, "Aha, it's
209.140.77.226," and defers it because it can't connect. (If I change the
line in virtual to
webmastersfreview.org jellisthor.advocast.com
it delivers fine.)

Is there a way to get postfix to double-check its virtual table in this
condition, and say, "wait a minute, I don't need to send this out again; I
handle it right here"? I can see that in degenerate cases this would be a
bad thing to do blindly, but is there a way to make exceptions?

Failing that, I have already tried to get postfix to use the value of
mail.advocast.com defined in /etc/hosts (its local IP), instead of looking
it up from DNS. In smtp_addr.c, I made the block in smtp_addr_one.c that is
commented, "use gethostbyname() when DNS is disabled" the default behavior,
falling through to the DNS code if no match is found. (Context diff
attached.) SOMEthing happened: the error messages read

connect to mail.advocast.com[209.140.77.226]: Connection timed out (port 25)
instead of

connect to www.advocast.com[209.140.77.226]: Connection timed out (port 25)

This probably has something to do with the DNS entries:
mail.advocast.com is a nickname for thor.advocast.com
thor.advocast.com is a nickname for www.advocast.com
www.advocast.com has address 209.140.77.226

Can someone point me to what I need to do? Am I in the wrong part of the
code entirely?

-Jonathan