safely handle failure to open hosts, services, resolv.conf files
authorRich Felker <dalias@aerifal.cx>
Mon, 26 Oct 2015 22:42:22 +0000 (18:42 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 26 Oct 2015 22:42:22 +0000 (18:42 -0400)
commit2683e267fa6c20d2e7a498a85f79a1dfc4301f23
tree27b7c8e3e3888b65dd788e6919a30a5b2deca3d5
parentb114190b29417fff6f701eea3a3b3b6030338280
safely handle failure to open hosts, services, resolv.conf files

previously, transient failures like fd exhaustion or other
resource-related errors were treated the same as non-existence of
these files, leading to fallbacks or false-negative results. in
particular:

- failure to open hosts resulted in fallback to dns, possibly yielding
  EAI_NONAME for a hostname that should be defined locally, or an
  unwanted result from dns that the hosts file was intended to
  replace.

- failure to open services resulted in EAI_SERVICE.

- failure to open resolv.conf resulted in querying localhost rather
  than the configured nameservers.

now, only permanent errors trigger the fallback behaviors above; all
other errors are reportable to the caller as EAI_SYSTEM.
src/network/lookup_name.c
src/network/lookup_serv.c
src/network/res_msend.c