[comp.mail.sendmail] localhost!user

woods@ncar.ucar.edu (Greg Woods) (02/09/89)

I used to have a list of all our local hosts within the sendmail.cf file. I
have recently redone the cf file to eliminate this, as it was becoming a real
hassle to keep this list up to date, with the proliferation of single-user
hosts (like Sun workstations) around here. So, I changed the cf file to
simply assume that all unqualified host references are local. Along the lines 
of

R$+@$-	$1@$2.$D

Everything works, with one exception: there doesn't seem to be any way
to look at an address of the form host!user and determine whether or not
the host is local. Formerly I could just check the host against the list
of local hosts, but I can't do that any more. Ideally I'd like to use the
name server to do this, but the exact way to make it work eludes me. I am
trying things like

$-!$-	$[$1.$]!$2

and then checking to see if the trailing period disappears indicating a match.
On a Sun 4/280 running Sun OS SYS4-3.2 with a hacked sendmail 5.58, this
works as expected, but on another Sun 4/280 running Sun OS 4.0.1 and sendmail
5.59 (I can't get 5.59 to compile on the SYS 4-3.2 machine) the name server
queries fail. Turning on debugging shows that res_search fails, errno=0,
and h_errno=4 (NO_DATA of requested type; the query is for a CNAME).
THe question is: is there any way to determine, from inside the cf file,
given a single token, whether or not it corresponds to a local host name?
(Using 5.59 on the Sun 4/280, Sun OS 4.0.1)

--Greg

msir@uhura.cc.rochester.edu (Mark Sirota) (02/09/89)

In article <1377@ncar.ucar.edu> woods@ncar.UCAR.EDU (Greg Woods) writes:

> I used to have a list of all our local hosts within the sendmail.cf file. I
> have recently redone the cf file to eliminate this, as it was becoming a
> real hassle to keep this list up to date, with the proliferation of
> single-user hosts (like Sun workstations) around here. So, I changed the
> cf file to simply assume that all unqualified host references are local.

Good move, not keeping any lists in the cf.  However, why do you care if a
host is local or not?  I simply canonicalize each name in S3, and deliver
any local mail via TCP just as I would deliver foreign mail.

Is there anything wrong with doing it that way?  What reason is there for
differentiating between local and foreign mail?

> Everything works, with one exception: there doesn't seem to be any way to
> look at an address of the form host!user and determine whether or not the
> host is local. ... Ideally I'd like to use the name server to do this, but
> the exact way to make it work eludes me. I am trying things like
> 
> $-!$-	$[$1.$]!$2
> 
> and then checking to see if the trailing period disappears indicating a
> match.

Why not just canonicalize the name (what you've got without the trailing
dot) and then check to see if the address is now "$+.$D!$+"?  Will that do
what you're looking for?
-- 
Mark Sirota - University of Rochester, Rochester, NY
 Internet: msir@cc.rochester.edu
 Bitnet:   msir_ss@uordbv.bitnet
 UUCP:     ...!rochester!ur-cc!msir

karl@triceratops.cis.ohio-state.edu (Karl Kleinpaste) (02/09/89)

woods@ncar.ucar.edu (Greg Woods) writes:
   Everything works, with one exception: there doesn't seem to be any way
   to look at an address of the form host!user and determine whether
   or not the host is local....
   ...
   $-!$-	$[$1.$]!$2

The problem is probably that there are 2 lines in getmxrr() (discussed
here recently) which disable search-tree resolution.  The two lines
disable the search:

        _res.options &= ~(RES_DEFNAMES | RES_DNSRCH);           /* XXX */
	[...do lookups...]
        _res.options |= RES_DEFNAMES | RES_DNSRCH;      /* XXX */

Hence, resolutions requesting $[$1$] are guaranteed to fail in all
contexts.

Just out of curiosity, why are you supporting !ish addresses for local
network hosts?

--Karl

woods@ncar.ucar.edu (Greg Woods) (02/14/89)

In article <KARL.89Feb9094347@triceratops.cis.ohio-state.edu> karl@triceratops.cis.ohio-state.edu (Karl Kleinpaste) writes:

>The problem is probably that there are 2 lines in getmxrr() (discussed
>here recently) which disable search-tree resolution.  The two lines
>which disable the search:
>
>        _res.options &= ~(RES_DEFNAMES | RES_DNSRCH);           /* XXX */
>	[...do lookups...]
>        _res.options |= RES_DEFNAMES | RES_DNSRCH;      /* XXX */
>
>Hence, resolutions requesting $[$1$] are guaranteed to fail in all
>contexts.

   I commented out these lines, but the lookups still fail. I have tried

R$-!$-		$[$1]!$2

R$-!$-		$[$1.]!$2

R$-!$-		$[$1.UCAR.EDU.$]!$2

In the first case, I look to see if it got converted to $1.UCAR.EDU, and
in the second two cases I look to see if the trailing period got stripped.
In all cases, even after commenting out the above lines and recompiling,
the name server queries still always fail with errno=0, h_errno=4 (NO_DATA
of requested type). With sendmail5.58 on the older Sun system, all three of
these methods work as expected.

>Just out of curiosity, why are you supporting !ish addresses for local
>network hosts?

    Because some outside users with UUCP-only systems still want to mail to 
ncar!localhost!user. Some of our other local net sites also have independent
UUCP links, so I do need a general way to do this, and I need one that
does not depend on having a list of local hosts within the cf file.
It is tough to get them to switch to ncar!localhost.ucar.edu!user or better 
yet, a mail configuration that can deal with domain addresses in a sensible 
way (which would include just forwarding them to us for delivery, and some 
local UUCP sites are in fact doing just that).

--Greg

matt@oddjob.uchicago.edu (Matt Crawford) (02/15/89)

Regarding mapping short hostnames to full names with $[stuff$] or some
variation thereof:

The code for getmxrr() is not relevant.  $[stuff$] is evaluated in
parseaddr.c:rewrite() by invoking daemon.c:maphostname().  If the 
"stuff" is not a bracketed numeric address, then domain.c:getcanonname()
is called.  In 5.59 this always did a lookup for CNAME records.  If
there is no CNAME for "stuff", no substitution was done.

In 5.61, if you build sendmail with NO_WILDCARD_MX defined, it will look
for ANY type of domain system RR for the given stuff.  This will do what
you want.  A special flag is needed to enable or disable this because
some domains have an MX record for *.dom.ain, which would cause $[stuff$]
to expand to stuff.dom.ain for all values of stuff which have no other
data, defeating your purpose.

________________________________________________________
Matt Crawford	     		matt@oddjob.uchicago.edu

woods@ncar.ucar.edu (Greg Woods) (02/15/89)

In article <1835@tank.uchicago.edu> matt@oddjob.uchicago.edu (Matt Crawford) writes:
>In 5.61, if you build sendmail with NO_WILDCARD_MX defined, it will look
>for ANY type of domain system RR for the given stuff.  This will do what
>you want.

    Hmm. I had been told that there were no functional differences between
5.59 and 5.61 other than security fixes, but this is clearly incorrect. I
have verified that what Matt says here is true. I grabbed 5.61 from
Beserkeley, and sure enough, it works fine if I get rid of our wildcard
*.ucar.edu MX record (which I no longer need anyway since all of our hosts
are now attached to the Internet and hence have at least A records already).
Thanks to all who replied. My conclusion is simply that the way 5.59 handles
the name server lookups is brain damaged. If you are having similar problems,
junk 5.59 and get 5.61 (from ucbarpa.berkeley.edu, file 4.3/sendmail.tar.Z)

--Greg