From 3b85d6f4b833f5e157b6fe4b324684a21f993ec6 Mon Sep 17 00:00:00 2001 From: Jiří Popelka Date: Oct 29 2009 11:29:42 +0000 Subject: - Make "hostname -s" display host name cut at the first dot (no matter if the host name resolves or not) (bug #531702) --- diff --git a/net-tools-1.60-hostname-short.patch b/net-tools-1.60-hostname-short.patch new file mode 100644 index 0000000..d9772e6 --- /dev/null +++ b/net-tools-1.60-hostname-short.patch @@ -0,0 +1,38 @@ +diff -up net-tools-1.60/hostname.c.hostname-short net-tools-1.60/hostname.c +--- net-tools-1.60/hostname.c.hostname-short 2009-09-30 17:44:21.000000000 +0200 ++++ net-tools-1.60/hostname.c 2009-09-08 11:55:03.000000000 +0200 +@@ -176,11 +176,6 @@ static void showhname(char *hname, int c + case 'f': + printf("%s\n", hp->h_name); + break; +- case 's': +- if (p != NULL) +- *p = '\0'; +- printf("%s\n", hp->h_name); +- break; + default: + ; + } +@@ -270,6 +265,7 @@ int main(int argc, char **argv) + char myname[MAXHOSTNAMELEN + 1] = + {0}; + char *file = NULL; ++ char *p; + + static const struct option long_options[] = + { +@@ -370,7 +366,13 @@ int main(int argc, char **argv) + if (!type) + printf("%s\n", myname); + else +- showhname(myname, type); ++ if (type == 's') { ++ if (p = strchr(myname, '.')) ++ *p = '\0'; ++ printf("%s\n", myname); ++ } ++ else ++ showhname(myname, type); + break; + case 3: + if (file) { diff --git a/net-tools-1.60-hostname_man.patch b/net-tools-1.60-hostname_man.patch index 84a4051..6ce8b8a 100644 --- a/net-tools-1.60-hostname_man.patch +++ b/net-tools-1.60-hostname_man.patch @@ -1,14 +1,14 @@ --- net-tools-1.60/man/en_US/hostname.1.gethostbyname 2005-10-14 11:33:41.000000000 +0200 +++ net-tools-1.60/man/en_US/hostname.1 2005-10-15 11:46:14.646697600 +0200 -@@ -99,6 +99,32 @@ +@@ -99,6 +99,33 @@ complete FQDN of the system is returned with .BR "hostname \-\-fqdn" . +.LP +The function +.BR gethostname(2) -+is used to get the hostname. Only when the -+.BR "hostname \-s" ++is used to get the hostname. When the ++.BR "hostname \-a, \-d, \-f or \-i" +is called will +.BR gethostbyname(3) +be called. The difference in @@ -25,7 +25,8 @@ +.IR /etc/sysconfig/network +or +.IR /etc/hosts -+. To add another dimension to this, ++ ++To add another dimension to this, +the +.B hostname +is also set when the network interface is brought up. diff --git a/net-tools.spec b/net-tools.spec index 33d69c2..7453452 100644 --- a/net-tools.spec +++ b/net-tools.spec @@ -3,7 +3,7 @@ Summary: Basic networking tools Name: net-tools Version: 1.60 -Release: 93%{?dist} +Release: 94%{?dist} License: GPL+ Group: System Environment/Base URL: http://net-tools.berlios.de/ @@ -83,6 +83,7 @@ Patch69: net-tools-1.60-clear-flag.patch Patch70: net-tools-1.60-metric-tunnel-man.patch Patch71: net-tools-1.60-netstat-probe.patch Patch72: net-tools-1.60-scanf-format.patch +Patch73: net-tools-1.60-hostname-short.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Requires(post): /sbin/chkconfig @@ -166,6 +167,7 @@ ifconfig, netstat, route, and others. %patch70 -p1 -b .metric-tunnel-man %patch71 -p1 -b .probe %patch72 -p1 -b .scanf-format +%patch73 -p1 -b .hostname-short cp %SOURCE2 ./config.h cp %SOURCE3 ./config.make @@ -281,6 +283,10 @@ exit 0 %{_sysconfdir}/rc.d/init.d/netplugd %changelog +* Thu Oct 29 2009 Jiri Popelka - 1.60-94 +- Make "hostname -s" display host name cut at the first dot (no + matter if the host name resolves or not) (bug #531702) + * Wed Jul 8 2009 Jiri Popelka - 1.60-93 - scanf format length fix (non exploitable?) from Fabian Hugelshofer - URL tag changed to http://net-tools.berlios.de/