> On Fri, Jan 09, 2015 at 22:02, Theo de Raadt wrote:
> >> There is something funny though. parse.y is checking host() for -1,
> >> but the function never returns that. I think the return (0) is wrong,
> >> and that's what should be changed. Or change parse.y to check for 0.
> > 
> > Nope -- you guys aren't testing your work.
> 
> OK. Like this then. No functional change.

[diff removed]

Yes, I just wrote the exact same diff.

During early development, IP address parsing & hostname resolution was
done at startup.  This function used to return an error if translation
failed.

Nowadays, IP address parsing is done at startup, but if the string is
not an address, it is instead saved as a name, and DNS resolution
happens later.

Why?  Say you boot your laptop in an airplane.  The servers you
identify by DNS name cannot be found (ie "pool.ntp.org"), because you
have no network (should fly better planes).  ntpd will start anyway
will occasionally try to resolve the names.  Eventually after you land
and find network, ntpd will succeed at DNS resolution, and start
talking to those servers.

And the DNS lookups are even priviledge seperated... I am a bit sad
that people don't read this wonderful code.

Anyways, the return value from this function is simply a left over
from before the above DNS magic was added.

(And honestly people who travel with their laptops should take a
close look at how ntpd behaves.  Pretty cool stuff).

Reply via email to