Red Hat Bugzilla – Bug 8456
Problem with gethostid system call
Last modified: 2008-05-01 11:37:53 EDT
The gethostid system call returns the wrong host id. The default 6.1
version of the /etc/hosts file is different from the default version for
6.0 and earlier. If it is left alone, then the gethostid call returns
the wrong IP address (127.0.0.1). If it is rewritten to be the same
as version 6.0 and earlier then gethostid returns the correct value.
127.0.0.0 localhost.localdomain localhost myname
127.0.0.1 localhost localhost.localdomain
www.xxx.yyy.zzz myname.mydomain myname
Oddly enough if I use the 6.1 format on my 6.0 machine, gethostid works
Do you mean gethostid or (more likely) gethostbyname? If the latter,
simply edit /etc/hosts and configure it correctly. The installer
has heuristics that, depending on the hardware and how the questions
were answered, will lead to differences in the "default" /etc/hosts.
Gethostid on the other hand is a silly system call that simply returns
whatever was set by sethostid (so I don't think that's what you meant).
Sorry but I believe that this is a bug and the resolution provided is not
adequate. One of the primary uses for the gethostid call is to
return a unique id. The problem with the proposed resolution is that
unless somebody edits the /etc/hosts and changes the layout then
many systems will have the same hostid, i.e. based on 127.0.0.1.
The gethostid call is very often used for licensing software purposes on
other OS's such as Solaris. In fact the gethostid call returns the MAC
address on many OS's rather than the IP address. For vendors providing
software that uses licensing it makes life very difficult if they have to
ask the customer to edit system files to get a unique ID returned so
they can issue a licence. IMHO gethostid should return a MAC address
and not an IP since MAC addresses are unique (as far as I know) . If
this is not possible then at lease gethostid should return a IP that is not
the local loopback one.