usage of gethostname

Göran Hasse <[email protected]>
Newsgroups gmane.network.spread.user
Message-ID <CADGsKJFUth9r_yoYHrNHChrT4AXYWgj1jhCM-gFJb3+9y5oUKg@mail.gmail.com>
I gathered that there is a new release in pipeline and want to discuss a
small
issue.

In configuration.c there is a usage of gethostname

 /* Match my IP address to entry in configuration file */
    if( my_name == NULL ){
        gethostname(machine_name,sizeof(machine_name));
        host_ptr = gethostbyname(machine_name);

But I will argue that the hostname has nothing to do with *interface names*

Line of reasoning... (There is so many names around in a Unix system!).

First we have the KERNELNAME!

This is the current compiled kernel running in the system.
We get this with uname -a and typicaly gives us key information on the
kernel.
Linux fs487 2.6.38-13-generic #53-Ubuntu SMP Mon Nov 28 19:33:45 UTC 2011
x86_64 x86_64 x86_64 GNU/Linux

Then whe have INTERFACE NAMES!

A unix system could have a lot of interfaces
eth0
eth1
eth2

We give them IP-numbers

ifconfig eth0 inet 123.123.123.123 ...
ifconfig eth0:1 inet 234.234.234.234 ...
ifconfig eth1 inet 123.123.123.123 ....

And so on! To handle this long list of interface id we make a database
(DNS) or for convinience
make a small database in /etc/hosts. In this database we holds small
aliases for the interfaces.
/etc/hosts
123.123.123.123    road.to.perdition.org  perdition
234.234.234.234    road.to.paradise.org  paradise

Then we have the HOSTNAME

This is the name of the *hardware* on which we are running. This name
should NOT! be used in any way in association with the interface names. I
know that this is often so - but it should
not.

So I argue that the function *getaddrinfo* should be used instad. Not that
the manpage
of this function also mix the terminology "node" and "host" in a confusing
manner.

Cordially yours,
Göran Hasse


















-- 
[email protected]
Göran Hasse
Boo 229
715 91  ODENSBACKEN
Mob: 070-5530148

_______________________________________________
Spread-users mailing list
[email protected]
http://lists.spread.org/mailman/listinfo/spread-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.