Subject: bin/4388: sendmail uses dns even if told not to do so
To: None <>
From: Martin Husemann <>
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
>Originator:     Martin Husemann
UP-Vision Computergrphik GmbH, Bad Arolsen
>Release:        Oct 28
System: NetBSD 1.3_ALPHA NetBSD 1.3_ALPHA (RUMOLT) #0: Tue Oct 28 20:12:27 MET 1997 i386


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:[]) or even simpler a
FEATURE(nullclient, []) and a /etc/service.switch file
which contains

hosts	files
aliases	files

and /etc/hosts of course includes "mailhost" as well as "".
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 "" - 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.

Code inspection/gdb in a setup as described above.

Add another alias to /etc/hosts with trailing dot.
Fix sendmail.
Make gethostbyname ignore trailing dots when searching /etc/hosts.