Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 515836 - sys-apps/net-tools: hostname -s gives 'hostname: Unknown host' when the FQDN does not resolve
Summary: sys-apps/net-tools: hostname -s gives 'hostname: Unknown host' when the FQDN ...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Gentoo's Team for Core System packages
Depends on:
Reported: 2014-06-30 09:28 UTC by Joshua Kinard
Modified: 2016-01-09 17:09 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---

Updated patch from RedHat to fix hostname -s (rh-bug-319981.patch,994 bytes, patch)
2014-06-30 09:28 UTC, Joshua Kinard
Details | Diff
Updated patch for net-tools-1.60_p20141019041918 (1003_net-tools-1.60-hostname-s-fix.patch,995 bytes, patch)
2014-10-20 11:30 UTC, Joshua Kinard
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Kinard gentoo-dev 2014-06-30 09:28:45 UTC
Created attachment 379970 [details, diff]
Updated patch from RedHat to fix hostname -s

hostname -s will always give "Unknown Host" if the hostname FQDN cannot be resolved in DNS or in /etc/hosts.  According to RedHat bug 319981, this is different behavior than on AIX, MacOS X, and FreeBSD.  RedHat net-tools maintainers applied a minor patch to always make hostname -s return the short-form of the hostname regardless if it can be fully resolved or not.

# hostname
# hostname
# hostname -s
hostname: Unknown host

After patch:
# hostname -s

Per the RH bug comment #11, Debian is also fine with this change.  I re-diffed the patch against net-tools-1.60_p20130513023548 to get it to apply and tested it out to make sure the expected behavior works.
Comment 1 Joshua Kinard gentoo-dev 2014-09-11 09:24:13 UTC
If this patch could get pushed upstream too, that'd be great.  See the referenced RedHat and Debian bugs for concurrence on this issue.
Comment 2 Joshua Kinard gentoo-dev 2014-10-20 11:30:34 UTC
Created attachment 387044 [details, diff]
Updated patch for net-tools-1.60_p20141019041918
Comment 3 SpanKY gentoo-dev 2015-11-24 23:20:47 UTC
sent a patch upstream
Comment 4 SpanKY gentoo-dev 2015-11-25 03:40:57 UTC
i've landed this in upstream now.  it'll be in the next snapshot.
Comment 5 Daniel Goertzen 2016-01-09 16:53:27 UTC
The newest ebuild (net-tools-1.60_p20151124144947) has a non-working "hostname -s".  Any workarounds on getting this working?  I'm using some scripts that depend on it.
Comment 6 Daniel Goertzen 2016-01-09 17:09:46 UTC
Never mind, I added my hostname to /etc/hosts and it seems to work now.