Subject: bin/4388: sendmail uses dns even if told not to do so
To: None <gnats-bugs@gnats.netbsd.org>
From: Martin Husemann <martin@rumolt.teuto.de>
List: netbsd-bugs
Date: 10/29/1997 19:59:40
>Number:         4388
>Category:       bin
>Synopsis:       sendmail queries dns even if configured not to do it
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 29 11:20:03 1997
>Last-Modified:
>Originator:     Martin Husemann
>Organization:
UP-Vision Computergrphik GmbH, Bad Arolsen
>Release:        Oct 28
>Environment:
	
System: NetBSD rumolt.teuto.de 1.3_ALPHA NetBSD 1.3_ALPHA (RUMOLT) #0: Tue Oct 28 20:12:27 MET 1997 root@hwart.teuto.de:/usr/src/sys-local/arch/i386/compile/RUMOLT i386


>Description:

In a setup where DNS queries should be avoided (e.g. DNS behind dial-up link)
and a sendmail configuration forwarding all mail uncanonicalized to a smart
hub via define(`SMART_HOST', esmtp:[mailhost.my.do.main]) or even simpler a
FEATURE(nullclient, [mailhost.my.do.main]) and a /etc/service.switch file
which contains

hosts	files
aliases	files

and /etc/hosts of course includes "mailhost" as well as "mailhost.my.do.main".
Send a mail. Watch ps -ax show sendmail in "user open" state for about 
60 seconds, then the mail rush through in another few seconds.

Looking in the sendmail source, there is the sm_gethostbyname function
called for the "mailhost.my.do.main." - note the trailing dot. This functions
first does a gethostbyname from this name, waits 60 seconds until it fails
and then proceeds with the "home made" service switch functions to look up
the name again in the order specified by /etc/service.switch. In that process
it strips everything after the first dot and looks up the short name, in the
order given by service.switch, and of course succeeds at once.

>How-To-Repeat:
Code inspection/gdb in a setup as described above.

>Fix:
Add another alias to /etc/hosts with trailing dot.
Fix sendmail.
Make gethostbyname ignore trailing dots when searching /etc/hosts.
>Audit-Trail:
>Unformatted: