Bug 1308470

Summary: hostname man page is not clear on FQDN and needs review
Product: Red Hat Enterprise Linux 6 Reporter: Stephen Wadeley <swadeley>
Component: net-toolsAssignee: Jiri Popelka <jpopelka>
Status: CLOSED NOTABUG QA Contact: qe-baseos-daemons
Severity: low Docs Contact:
Priority: low    
Version: 6.7CC: msvistun
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-15 12:19:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Stephen Wadeley 2016-02-15 10:00:21 UTC
Description of problem:

man hostname for RHEL6.7 says:

Technically: The FQDN is the name gethostbyname(2) returns for the host
       name returned by gethostname(2).  The DNS domain name is the part after
       the first dot.

This does not make sense so I checked in Fedora 22 and it says:

       Technically: The FQDN is the name getaddrinfo(3) returns for the host name returned by gethostname(2).  The DNS domain name is the part after the first dot.

Can you please check and update man page.

Version-Release number of selected component (if applicable):

[root@RHEL6-7-WS ~]# hostname -V
net-tools 1.60
hostname 1.100 (2001-04-14)


A review of other differences in the RHEL6.7 vs. Fedora hostname man page would be a welcome bonus.

Thank you

Comment 1 Stephen Wadeley 2016-02-15 10:02:38 UTC
In RHEL6.7 hostname man page:

The difference in gethostname(2) and gethostbyname(3) is that  gethost-
       byname(3)  is  network  aware,  so  it  consults /etc/nsswitch.conf and
       /etc/host.conf   to   decide   whether   to   read    information    in
       /etc/sysconfig/network or /etc/hosts

Is /etc/hostname missing from that list? or does gethostbyname(3 not read /etc/hostname ?

Thank you

Comment 3 Jiri Popelka 2016-02-15 11:06:43 UTC
(In reply to Stephen Wadeley from comment #0)
> man hostname for RHEL6.7 says:
> 
> Technically: The FQDN is the name gethostbyname(2) returns for the host name > returned by gethostname(2). The DNS domain name is the part after the first dot.

Just to be sure: have you noticed that gethostbyname(2) and gethostname(2) are different functions ?

It basically first calls gethostname() and then calls gethostbyname() on the result of the first one.
gethostname() = get hostname
gethostbyname() = get more info about a hostname

> This does not make sense so I checked in Fedora 22 and it says:
> 
>        Technically: The FQDN is the name getaddrinfo(3) returns for the host
> name returned by gethostname(2).  The DNS domain name is the part after the
> first dot.

Here getaddrinfo() is just a successor of gethostbyname().

Comment 4 Stephen Wadeley 2016-02-15 12:13:33 UTC
(In reply to Jiri Popelka from comment #3)
> (In reply to Stephen Wadeley from comment #0)
> > man hostname for RHEL6.7 says:
> > 
> > Technically: The FQDN is the name gethostbyname(2) returns for the host name > returned by gethostname(2). The DNS domain name is the part after the first dot.
> 
> Just to be sure: have you noticed that gethostbyname(2) and gethostname(2)
> are different functions ?
Oh, no, sorry!

I was reading too many man pages at once I think (in RHEL6 VM and Fedora host). 

> 
> It basically first calls gethostname() and then calls gethostbyname() on the
> result of the first one.
> gethostname() = get hostname
> gethostbyname() = get more info about a hostname
> 
> > This does not make sense so I checked in Fedora 22 and it says:
> > 
> >        Technically: The FQDN is the name getaddrinfo(3) returns for the host
> > name returned by gethostname(2).  The DNS domain name is the part after the
> > first dot.
> 
> Here getaddrinfo() is just a successor of gethostbyname().

Thank you

Comment 5 Stephen Wadeley 2016-02-15 12:17:47 UTC
(In reply to Stephen Wadeley from comment #1)
> In RHEL6.7 hostname man page:
> 
> The difference in gethostname(2) and gethostbyname(3) is that  gethost-
>        byname(3)  is  network  aware,  so  it  consults /etc/nsswitch.conf
> and
>        /etc/host.conf   to   decide   whether   to   read    information   
> in
>        /etc/sysconfig/network or /etc/hosts
> 
> Is /etc/hostname missing from that list? or does gethostbyname(3 not read
> /etc/hostname ?
> 
after checking I see there is no /etc/hostname file in RHEL6.7 by default.


So, we can close this as NOTABUG I think.