mailing list of musl libc
 help / color / mirror / code / Atom feed
* domain name resolution issues
@ 2014-01-23 16:53 Szabolcs Nagy
  2014-01-27  1:05 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Szabolcs Nagy @ 2014-01-23 16:53 UTC (permalink / raw)
  To: musl

getaddrinfo fails to parse /etc/hosts entries if they are
whitespace prefixed (not sure if that's legit, but glibc
can parse it)

and only the first match is returned, eg.

	getaddrinfo("localhost", 0, 0, &ai);

only gives one result (127.0.0.1) eventhough /etc/hosts says

	127.0.0.1  localhost
	::1        localhost ip6-localhost ip6-loopback

then if i do a name lookup on the returned address with

	getnameinfo(ai->ai_addr, ai->ai_addrlen, host, sizeof host, serv, sizeof serv, 0);

it seems to do a complete dns query to the nameserver,
i wonder if it might worth to do a local /etc/hosts
search first

(i see now that the test system should run in a sandboxed
environment otherwise such interfaces are not possible to
test)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: domain name resolution issues
  2014-01-23 16:53 domain name resolution issues Szabolcs Nagy
@ 2014-01-27  1:05 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2014-01-27  1:05 UTC (permalink / raw)
  To: musl

On Thu, Jan 23, 2014 at 05:53:56PM +0100, Szabolcs Nagy wrote:
> getaddrinfo fails to parse /etc/hosts entries if they are
> whitespace prefixed (not sure if that's legit, but glibc
> can parse it)
> 
> and only the first match is returned, eg.
> 
> 	getaddrinfo("localhost", 0, 0, &ai);
> 
> only gives one result (127.0.0.1) eventhough /etc/hosts says
> 
> 	127.0.0.1  localhost
> 	::1        localhost ip6-localhost ip6-loopback

Are you sure that this isn't just it short-circuiting out after
finding the first result?

> then if i do a name lookup on the returned address with
> 
> 	getnameinfo(ai->ai_addr, ai->ai_addrlen, host, sizeof host, serv, sizeof serv, 0);
> 
> it seems to do a complete dns query to the nameserver,
> i wonder if it might worth to do a local /etc/hosts
> search first

It doesn't even do the /etc/hosts search at all for reverse lookups,
as far as I remember.

> (i see now that the test system should run in a sandboxed
> environment otherwise such interfaces are not possible to
> test)

Yes, this is part of why I'd like a way to override resolv.conf and
hosts on a per-user basis...

Anyway, all of these are semi-known issues I want to address in the
resolver overhaul after 1.0. Perhaps we should put the resolver
overhaul at high priority and do it in the 1.0.x series, before
starting 1.1.x, rather than in the 1.1.x series. Or, we could do it
early in 1.1.x with the intent of backporting it to 1.0.x.

Rich


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-27  1:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-23 16:53 domain name resolution issues Szabolcs Nagy
2014-01-27  1:05 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).