From MAILER-DAEMON Fri May 02 11:08:33 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WgF4j-0000Oy-52
	for mharc-commit-inetutils@gnu.org; Fri, 02 May 2014 11:08:33 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:40827)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1WgF4f-0000LL-VL
	for commit-inetutils@gnu.org; Fri, 02 May 2014 11:08:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1WgF4e-00042D-Fv
	for commit-inetutils@gnu.org; Fri, 02 May 2014 11:08:29 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:33719)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1WgF4e-000426-CR
	for commit-inetutils@gnu.org; Fri, 02 May 2014 11:08:28 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1WgF4d-0008F6-NC
	for commit-inetutils@gnu.org; Fri, 02 May 2014 15:08:27 +0000
Date: Fri, 02 May 2014 15:08:27 +0000
Message-Id: <E1WgF4d-0008F6-NC@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_2-20-gb4e8076
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 547bb31ef5a971fcd310b741a20cbe1b0959770a
X-Git-Newrev: b4e8076826838934bf518b8d0dbc86c37b8af6e8
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 02 May 2014 15:08:31 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  b4e8076826838934bf518b8d0dbc86c37b8af6e8 (commit)
      from  547bb31ef5a971fcd310b741a20cbe1b0959770a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=b4e8076826838934bf518b8d0dbc86c37b8af6e8


commit b4e8076826838934bf518b8d0dbc86c37b8af6e8
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Tue Apr 29 22:56:40 2014 +0200

    hostname: Degenerate cases.
    
    Better replies when name resolution fails.

diff --git a/ChangeLog b/ChangeLog
index d0b8bd4..03ec4f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2014-04-29  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	hostname: Degenerate cases.
+	Better replies when name resolution fails.
+
+	* configure.ac: Remove check for gethostname in libresolv.
+	If hstrerror is missing, check for it in libresolv.
+	(LIBRESOLV): New variable published using AC_SUBST.
+
+	* src/Makefile.am (hostname_LDADD): New variable.
+
+	* src/hostname.c (get_name): Call puts() only if NAME
+	carries some content.  Will, most importantly, reply
+	with an empty string, not an empty line, when no aliases
+	are found.
+	(get_aliases): Return an empty string when the host's
+	name cannot be resolved.
+	(get_fqdn): Fall back to the system reported hostname
+	when name resolution fails.
+	[HAVE_HSTRERROR] (get_ip_addresses): Exit with an error
+	when name resolution fails.
+
+	* tests/hostname.sh: Check availability of mktemp.
+	(posttest): New function, used as trap.
+	<root execution>: New test case with switch '-F'.
+
 2014-04-26  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	libinetutils: Skeletal preparations for Heimdal.
diff --git a/configure.ac b/configure.ac
index 3915b8e..54fab00 100644
--- a/configure.ac
+++ b/configure.ac
@@ -154,7 +154,6 @@ gl_INIT
 
 ### Checks for libraries.
 AC_SEARCH_LIBS([inet_ntoa], [nsl])
-AC_SEARCH_LIBS([gethostname], [resolv])
 AC_SEARCH_LIBS([getpeername], [socket])
 
 # See if a termcap library is available (under one of several names)
@@ -795,7 +794,14 @@ if test "$ac_cv_func_strerror" = no; then
 fi
 
 # See if the system has hstrerror, and replace it if not
+save_LIBS=$LIBS
+
 AC_CHECK_FUNC(hstrerror)
+if test "$ac_cv_func_hstrerror" != yes; then
+  # Is hstrerror contained in a separate library?
+  AC_CHECK_LIB([resolv], [hstrerror], LIBRESOLV=-lresolv)
+  LIBS="$LIBRESOLV $LIBS"
+fi
 if test "$ac_cv_func_hstrerror" = yes; then
   AC_CHECK_DECL(hstrerror, , , [#include <netdb.h>])
 else
@@ -814,6 +820,8 @@ if test "$ac_cv_func_hstrerror" = yes \
   # `Host lookup error N'.
   AC_DEFINE([HAVE_HSTRERROR], 1, [Define to one if you have hstrerror.])
 fi
+LIBS=$save_LIBS
+AC_SUBST(LIBRESOLV)
 
 # OpenSolaris does not provide an external reference.
 AC_CHECK_DECLS(telcmds, , ,
diff --git a/src/Makefile.am b/src/Makefile.am
index 0cc6e4f..26c8252 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -44,6 +44,7 @@ EXTRA_PROGRAMS =
 
 bin_PROGRAMS += $(hostname_BUILD)
 hostname_SOURCES = hostname.c
+hostname_LDADD = $(LDADD) $(LIBRESOLV)
 EXTRA_PROGRAMS += hostname
 
 bin_PROGRAMS += $(dnsdomainname_BUILD)
diff --git a/src/hostname.c b/src/hostname.c
index 95a2698..13886fd 100644
--- a/src/hostname.c
+++ b/src/hostname.c
@@ -212,7 +212,8 @@ get_name (const hostname_arguments *const args)
         error (EXIT_FAILURE, errno, "strdup");
     }
 
-  puts (name);
+  if (name && *name)
+    puts (name);
 
   free (name);
   free (sname);
@@ -257,7 +258,7 @@ get_aliases (const char *const host_name)
 
   ht = gethostbyname (host_name);
   if (ht == NULL)
-    strcpy (aliases, "(none)");
+    strcpy (aliases, "");	/* Be honest about missing aliases.  */
   else
     {
       for (i = 0; ht->h_aliases[i] != NULL; i++)
@@ -288,7 +289,7 @@ get_fqdn (const char *const host_name)
 
   ht = gethostbyname (host_name);
   if (ht == NULL)
-    fqdn = strdup ("(none)");
+    fqdn = strdup (host_name);	/* Fall back to system name.  */
   else
     fqdn = strdup (ht->h_name);
 
@@ -313,7 +314,11 @@ get_ip_addresses (const char *const host_name)
 
   ht = gethostbyname (host_name);
   if (ht == NULL)
+#if HAVE_HSTRERROR
+    error (EXIT_FAILURE, 0, "gethostbyname: %s", hstrerror (h_errno));
+#else
     strcpy (addresses, "(none)");
+#endif
   else
     {
       for (i = 0; ht->h_addr_list[i] != NULL; i++)
diff --git a/tests/hostname.sh b/tests/hostname.sh
index 7ba0d29..a12b7fb 100755
--- a/tests/hostname.sh
+++ b/tests/hostname.sh
@@ -21,10 +21,12 @@
 #
 #  * Shell: SVR3 Bourne shell, or newer.
 #
-#  * id(1), uname(1).
+#  * id(1), mktemp(1), uname(1).
 
 . ./tools.sh
 
+$need_mktemp || exit_no_mktemp
+
 hostname=${hostname:-../src/hostname$EXEEXT}
 
 if [ $VERBOSE ]; then
@@ -34,22 +36,43 @@ fi
 
 errno=0
 
+posttest () {
+    test -n "$NAMEFILE" && test -r "$NAMEFILE" && rm "$NAMEFILE"
+}
+
 $hostname || errno=$?
 test $errno -eq 0 || echo "Failed to get hostname." >&2
 test $errno -eq 0 || exit $errno
 
 test `$hostname` = `uname -n` || errno=$?
-test $errno -eq 0 || echo "Failed to get hostname." >&2
+test $errno -eq 0 || echo "Failed to get same hostname as uname does." >&2
 test $errno -eq 0 || exit $errno
 
-if [ `func_id_uid` != 0 ]; then
+if test `func_id_uid` != 0; then
     echo "hostname: skipping tests to set host name"
 else
     # Only run this if hostname succeeded...
-    if [ $errno -eq 0 ]; then
+    if test $errno -eq 0; then
 	$hostname `$hostname` || errno=$?
 	test $errno -eq 0 || echo "Failed to set hostname." >&2
 	test $errno -eq 0 || exit $errno
+
+	NAMEFILE=`$MKTEMP tmp.XXXXXXXXXX` || errno=$?
+	test $errno -eq 0 || echo >&2 'Cannot create test file.'
+	test $errno -eq 0 || exit $errno
+
+	trap posttest 0 1 2 3 15
+
+	SAVEDNAME=`hostname` || errno=$?
+	echo $SAVEDNAME > $NAMEFILE
+
+	if test $errno -eq 0 && test -s $NAMEFILE; then
+	    $hostname -F $NAMEFILE || errno=$?
+	    test $errno -eq 0 || echo >&2 'Failed to set hostname.'
+
+	    # Attempt to rescue name using the first method.
+	    test $errno -eq 0 || $hostname "$SAVEDNAME" || errno=$?
+	fi
     fi
 fi
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog         |   26 ++++++++++++++++++++++++++
 configure.ac      |   10 +++++++++-
 src/Makefile.am   |    1 +
 src/hostname.c    |   11 ++++++++---
 tests/hostname.sh |   31 +++++++++++++++++++++++++++----
 5 files changed, 71 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


From MAILER-DAEMON Fri May 16 17:20:45 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WlPYb-0003nv-T5
	for mharc-commit-inetutils@gnu.org; Fri, 16 May 2014 17:20:45 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52387)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1WlPYZ-0003nO-Au
	for commit-inetutils@gnu.org; Fri, 16 May 2014 17:20:44 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1WlPYY-0006do-46
	for commit-inetutils@gnu.org; Fri, 16 May 2014 17:20:43 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:39698)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <gnu@gisladisker.se>) id 1WlPYY-0006dk-0l
	for commit-inetutils@gnu.org; Fri, 16 May 2014 17:20:42 -0400
Received: from meand by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <gnu@gisladisker.se>) id 1WlPYW-00074F-Qe
	for commit-inetutils@gnu.org; Fri, 16 May 2014 21:20:41 +0000
Date: Fri, 16 May 2014 21:20:40 +0000
Message-Id: <E1WlPYW-00074F-Qe@vcs.savannah.gnu.org>
To: commit-inetutils@gnu.org
Subject: [SCM] GNU Inetutils  branch, master,
	updated. inetutils-1_9_2-21-ga776a60
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: b4e8076826838934bf518b8d0dbc86c37b8af6e8
X-Git-Newrev: a776a603369e644f031eee771bf388ab0edb3b91
From: Mats Erik Andersson <gnu@gisladisker.se>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-inetutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: CVS commit notices for the GNU Internet utilities
	<commit-inetutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-inetutils>
List-Post: <mailto:commit-inetutils@gnu.org>
List-Help: <mailto:commit-inetutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-inetutils>,
	<mailto:commit-inetutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 16 May 2014 21:20:44 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  a776a603369e644f031eee771bf388ab0edb3b91 (commit)
      from  b4e8076826838934bf518b8d0dbc86c37b8af6e8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=a776a603369e644f031eee771bf388ab0edb3b91


commit a776a603369e644f031eee771bf388ab0edb3b91
Author: Mats Erik Andersson <gnu@gisladisker.se>
Date:   Fri May 16 22:30:29 2014 +0200

    ftp: Size multipliers for hash increments.

diff --git a/ChangeLog b/ChangeLog
index 03ec4f1..f3a0470 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-05-16  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	ftp: Size multipliers for hash increments.
+
+	* ftp/cmds.c (sethash): New variable P.  Detect and
+	apply multipliers when setting the increment size for
+	hash markers, i.e., allow commands like "hash 32m".
+
 2014-04-29  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	hostname: Degenerate cases.
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index b2b48a8..aff02e9 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -1572,7 +1572,9 @@ subtree, then making certain that @command{ftp} uses binary mode.
 @item hash [@var{size}]
 Toggle hash-sign (@samp{#}) printing for each data block transferred.
 The size of a data block can optionally be specified.  If not given,
-it defaults to 1024 bytes.
+it defaults to 1024 bytes.  The size can be written with multipliers
+'k', 'K', 'm', 'M', and 'g', 'G', to specify kilobytes, megabytes,
+or gigabytes.
 
 @item help [@var{command}]
 @itemx ? [@var{command}]
diff --git a/ftp/cmds.c b/ftp/cmds.c
index ece6ef5..471cd86 100644
--- a/ftp/cmds.c
+++ b/ftp/cmds.c
@@ -1198,12 +1198,39 @@ settrace (int argc _GL_UNUSED_PARAMETER, char **argv _GL_UNUSED_PARAMETER)
 
 /*
  * Toggle hash mark printing during transfers.
+ *
+ * Parse multipliers 'k', 'K', 'm', 'M', and
+ * 'g', 'G' to simplify the size step.
  */
 void
 sethash (int argc _GL_UNUSED_PARAMETER, char **argv)
 {
+  char *p = argv[1];
+
+  /* P is NULL when no argument was passed with `hash'.  */
+  while (p && isdigit (*p))
+    p++;
+
   if (argv[1] != NULL)
     sscanf (argv[1], "%d", &hashbytes);
+
+  /* Apply a multiplier only if a numerical part exixts.  */
+  if (argv[1] && isdigit (*argv[1]))
+    {
+      switch (*p)
+	{
+	case 'g':
+	case 'G':
+	  hashbytes *= 1024;	/* Cascaded multiplication!  */
+	case 'm':
+	case 'M':
+	  hashbytes *= 1024;
+	case 'k':
+	case 'K':
+	  hashbytes *= 1024;
+	}
+    }
+
   if (hashbytes <= 0)
     hashbytes = 1024;
   hash = !hash;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog          |    8 ++++++++
 doc/inetutils.texi |    4 +++-
 ftp/cmds.c         |   27 +++++++++++++++++++++++++++
 3 files changed, 38 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 


