[CMake] What exactly does SITE_NAME() return?

Marcel Loose loose at astron.nl
Mon Feb 1 10:13:44 EST 2010


Hi David,

I need the short name (i.e. the output of 'hostname -s'). The systems
I've tried site_name() on all returned the short name. However, I don't
want to rely on that trial-and-error assessment alone. That's why I
asked, because the documentation is not clear (enough) about this.
So, maybe, CMake should use 'hostname -s', instead of 'hostname'?

BTW, if you are calling the program 'hostname', the output is not
uniquely defined. On Linux, 'hostname' uses gethostname(), which in turn
uses uname(), and returns the nodename field. 

The man pages on uname(2) are very reassuring (pun intended). From these
pages:

char nodename[]; /* Name within "some implementation-defined network" */

On the other hand, the field nodename is  meaningless: it gives the name
of the present machine in some undefined network, but typically
machines are in more than one network and have several names. 

Unfortunately, the output of 'hostname -s' is just as badly defined. On
Linux, 'hostname -s' uses gethostbyname(). Quoting from the man pages
gethostbyname(3):

The domain name queries carried out by gethostbyname() and
gethostbyaddr() use a combination of any or all of the name server
named(8), a broken out line from /etc/hosts, and the Network Information
Service (NIS or YP), depending upon the contents of the order line
in /etc/host.conf. The default action is to query named(8), followed
by /etc/hosts.

Yippie!

Best regards,
Marcel Loose.


On Mon, 2010-02-01 at 09:08 -0500, David Cole wrote:
> Looks to me, from CMake/Source/cmSiteNameCommand.cxx that we simply
> call "hostname" with no arguments and then use a regular expression to
> parse out the name of the host from that output.
> 
> Are you encountering a problem with it that leads to unexpected
> results or would you just like better documentation?
> 
> 
> 
> On Mon, Feb 1, 2010 at 4:15 AM, Marcel Loose <loose at astron.nl> wrote:
>         Hi all,
>         
>         What exactly does SITE_NAME() return? Is it the short
>         hostname, or the
>         fully qualified domain name?
>         
>         The docs are not clear about this:
>         
>          site_name
>               Set the given variable to the name of the computer.
>         
>         And the ChangeLog.txt is confusing me:
>         
>         2001-10-18 18:01  barre
>         
>                * Source/cmSiteNameCommand.cxx: SITE_NAME should return
>         the most
>                  qualified name of the host. If nslookup works, now
>         the domain
>         is
>                  appended to the hostname (whereas it *replaced* the
>         host name
>                  before)
>         
>         Tests that I have run on a number of different systems all
>         seem to be
>         doing the equivalent of 'hostname -s', i.e. return the short
>         hostname,
>         but the ChangeLog.txt appears to suggest that it should do the
>         equivalent of 'hostname -f', i.e. return the fully qualified
>         domain
>         name. Which is correct?
>         
>         Best regards,
>         Marcel Loose.
>         
>         
>         
>         
>         _______________________________________________
>         Powered by www.kitware.com
>         
>         Visit other Kitware open-source projects at
>         http://www.kitware.com/opensource/opensource.html
>         
>         Please keep messages on-topic and check the CMake FAQ at:
>         http://www.cmake.org/Wiki/CMake_FAQ
>         
>         Follow this link to subscribe/unsubscribe:
>         http://www.cmake.org/mailman/listinfo/cmake
> 
> 




More information about the CMake mailing list