[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Showstopping bug: gethostname() behaving incorrectly

Randolph Chung <tausq@debian.org> writes:

> > According to info docs and precedent, it should return a FQDN.  All
> > other systems, including other Linux systems, behave this way.  The
> > libc info docs say it should behave this way.  But it does not.
> Not quite sure which info docs you are refering to, but....

info libc, search for gethostname.  It says:

Namespace::.  The host name should always be a fully qualified domain
name, like `crispy-wheats-n-chicken.ai.mit.edu', not a simple name like
just `crispy-wheats-n-chicken'.

> Many other linux distros put the FQDN in /etc/hostname. Debian doesn't do
> that. As the man page points out, gethostname behaves like uname -n, which
> in turn just reads the value set by hostname.


> There has been some debate about whether the fqdn should go into
> /etc/hostname; however, if programs need to get a fqdn, the correct way to
> do it seems to be to first do a gethostname() call followed by a
> gethostbyname() call to retrieve the real FQDN. That's how "hostname -f"
> works iirc.


> randolph
> -- 
> Debian Developer <tausq@debian.org>
> http://www.TauSq.org/

John Goerzen   Linux, Unix consulting & programming   jgoerzen@complete.org |
Developer, Debian GNU/Linux (Free powerful OS upgrade)       www.debian.org |
The 578,706th digit of pi is 6.

Reply to: