Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 515836

Summary: sys-apps/net-tools: hostname -s gives 'hostname: Unknown host' when the FQDN does not resolve
Product: Gentoo Linux Reporter: Joshua Kinard <kumba>
Component: [OLD] Core systemAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED FIXED    
Severity: enhancement CC: daniel.goertzen
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
URL: http://sourceforge.net/p/net-tools/mailman/message/34645433/
See Also: https://bugzilla.redhat.com/show_bug.cgi?id=319981
https://bugzilla.redhat.com/show_bug.cgi?id=531702
http://bugs.debian.org/552482
https://bugs.gentoo.org/show_bug.cgi?id=526040
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Updated patch from RedHat to fix hostname -s
Updated patch for net-tools-1.60_p20141019041918

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.

Example:
# hostname foo.bar.baz
# hostname
foo.bar.baz
# hostname -s
hostname: Unknown host

After patch:
# hostname -s
foo

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.