Erlang/OTP Forums

Author Message

<  Erlang bugs mailing list  ~  resolver ... again

klacke at bluetail.com
Posted: Fri Jun 06, 2003 11:09 am Reply with quote
Guest
Howdy,

The code in inet_config.erl is not quite right.
On linux, the code in the inet_config:init/0
reads /etc/hosts.conf (only)

The glibc resolver reads both the /etc/host.conf aswell
as /etc/nsswitch.conf

A very old system

[root_at_rall /root]# cat /etc/redhat-release
Red Hat Linux release 6.2 (Zoot)
[root_at_rall /root]# strace ping -c 1 www.erlang.org 2>&1 | grep '/etc/.*.conf'
open("/etc/resolv.conf", O_RDONLY) = 4
open("/etc/nsswitch.conf", O_RDONLY) = 4
read(4, "#
# /etc/nsswitch.conf
#
# An ex"..., 4096) = 1767
open("/etc/host.conf", O_RDONLY) = 4


Slightly newer ....

# cat /etc/redhat-release
Red Hat Linux release 7.3 (Valhalla)
# strace ping -c 1 www.erlang.org 2>&1 | grep '/etc/.*.conf'
open("/etc/resolv.conf", O_RDONLY) = 3
open("/etc/nsswitch.conf", O_RDONLY) = 3
read(3, "#
# /etc/nsswitch.conf
#
# An ex"..., 4096) = 1682
open("/etc/host.conf", O_RDONLY) = 3


And then to the boring part:

tita root # uname -a
Linux tita 2.4.20-gentoo-r5-1 #1 SMP Wed Jun 4 16:51:01 CEST 2003 i686 Intel(R) Pentium(R) 4 CPU 2.20GHz GenuineIntel GNU/Linux
tita root # strace ping -c 1 www.erlang.org 2>&1 | grep '/etc/.*.conf'
open("/etc/nsswitch.conf", O_RDONLY) = 3
read(3, "# /etc/nsswitch.conf:
# $Header:"..., 4096) = 498
open("/etc/resolv.conf", O_RDONLY) = 4
open("/etc/host.conf", O_RDONLY) = -1 ENOENT (No such file or directory)



Gentoo doesn't have the /etc/host.conf file.
This does indeed make sence, having two _different_ files
controling the behaviour of the resolver is broken.

The erlang code _only_ reads the /etc/host.conf file, in order to

a) work on gentoo
b) be more glibc like

We should at least also read the /etc/nsswitch.conf file.
Preferable we should first read /etc/nsswitch.conf and then
if that fails read /etc/host.conf

The /etc/hosts.conf file is an old BSDism and I think that
very few tools (except OTP then Smile works with that file.


Here's a possible patch, reading /etc/hosts.conf first and then
/etc/nsswitch.conf
But as I wrote, even better would be to read nsswitch before hosts.
People are probably more accustomed to changing the nsswitch
file than the host file.


Enjoy.



/klacke



--
Claes Wikstrom -- Caps lock is nowhere and
Alteon WebSystems -- everything is under control
http://www.bluetail.com/~klacke
cellphone: +46 70 2097763


Post generated using Mail2Forum (http://m2f.sourceforge.net)

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum