Bug 837069 - hostname -f may not return FQDN
hostname -f may not return FQDN
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: net-tools (Show other bugs)
6.5
All Linux
unspecified Severity high
: rc
: ---
Assigned To: Jiri Popelka
qe-baseos-daemons
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-02 12:22 EDT by Jim Pirzyk
Modified: 2012-07-03 09:22 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-07-03 09:22:12 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jim Pirzyk 2012-07-02 12:22:48 EDT
Description of problem:

the 'hostname -f' output may actually be a short hostname output, i.e. the same as the output of 'hostname -s'.

Version-Release number of selected component (if applicable): 1.60-110.el6_2


How reproducible:  Ever time with a config change.


Steps to Reproduce:
1. edit /etc/hosts to not have the FQDN as the first hostname for the IP
2. run 'hostname -f' command, compare to output of 'hostname -s' and 'hostname'
3.
  
Actual results:

pirzyk@centos:~
2>hostname
centos.home.pirzyk.org
pirzyk@centos:~
3>hostname -f
centos
pirzyk@centos:~
4>hostname -s
centos
pirzyk@centos:~
5>g centos /etc/hosts
192.168.1.15	centos centos.home.pirzyk.org centos


Expected results:

Hostname should detect that the output of 'hostname -f' is the same length as 'hostname -s'.  Once this is detected it *could* do one of at least 2 things:

1) Throw an error (return non-zero to the shell) and complain about the configuration error.

2) use other heuristics to find the FQDN, like in the example using the output of 'hostname' command.

Additional info:

MacOSX, FreeBSD and Solaris are immune from this configuration error causing 'hostname -f' to fail.  Solaris does not actually support the -f option and the other 2 just silently ignore it.  They all expect hostname to be set to FQDN.
Comment 2 Jiri Popelka 2012-07-03 09:01:23 EDT
Yes, the '-f' option depends on configuration (/etc/hosts).
See the 'THE FQDN' section in hostname(1).

Try -A,--all-fqdns instead.
Comment 3 Jim Pirzyk 2012-07-03 09:13:24 EDT
Can we get the documentation then fixed that -f will not return fqdn if there is a configuration error?

the man page and -h help both say that FQDN will be returned with -f.  The code can determine that -f will *not* return fqdn, because it is the same result as -s.

       -f, --fqdn, --long
              Display  the FQDN (Fully Qualified Domain Name). A FQDN consists


    -f, --fqdn, --long    long host name (FQDN)


This may be working as designed, but I am asking for the design bug to be resolved.
Comment 4 Jiri Popelka 2012-07-03 09:22:12 EDT
The description of the '-f' option also says:
"See the warnings in section THE FQDN above, and avoid using this option; use hostname --all-fqdns instead."

Note You need to log in before you can comment on or make changes to this bug.