RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 837069 - hostname -f may not return FQDN
Summary: hostname -f may not return FQDN
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: net-tools
Version: 6.5
Hardware: All
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: Jiri Popelka
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-07-02 16:22 UTC by Jim Pirzyk
Modified: 2012-07-03 13:22 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-07-03 13:22:12 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Jim Pirzyk 2012-07-02 16:22:48 UTC
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 13:01:23 UTC
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 13:13:24 UTC
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 13:22:12 UTC
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.