From 110c67f7b2014721e233b53029627153cece5538 Mon Sep 17 00:00:00 2001
From: Mats Erik Andersson <gnu@gisladisker.se>
Date: Tue, 29 Dec 2015 12:31:59 +0100
Subject: [PATCH 13/60] tests/ftp-localhost.sh: Incomplete error handling.

Catch an unintended exception state.
---
 ChangeLog              | 14 ++++++++++++++
 tests/ftp-localhost.sh | 12 ++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 113e5246..f9c72ba8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2015-12-29  Mats Erik Andersson  <gnu@gisladisker.se>
+
+	tests/ftp-localhost.sh: Incomplete error handling.
+	The use of sysctl(8) with option `set -e` active during
+	script execution needs a robust exception handler.
+	Reported by Ingo Brückl in
+	http://lists.gnu.org/archive/html/bug-inetutils/2015-12/msg00000.html
+
+	* tests/ftp-localhost.sh: Locate sysctl(8) using `command`
+	with an augmented search path.  When computing VALUE_V6ONLY
+	in a subshell, add a short circuit with `true` to prevent
+	interruption of the test script.
+	(SYSCTL): New variable.
+
 2015-10-08  Mats Erik Andersson  <gnu@gisladisker.se>
 
 	syslogd: Redefine faulty macro LOG_MAKEPRI whenever needed.
diff --git a/tests/ftp-localhost.sh b/tests/ftp-localhost.sh
index f5895494..256b7904 100755
--- a/tests/ftp-localhost.sh
+++ b/tests/ftp-localhost.sh
@@ -517,7 +517,7 @@ fi # TEST_IPV6
 # Availability of IPv4-mapped IPv6 addresses.
 #
 # These are impossible on OpenBSD, so a flexible test
-# is implemented using sysctl(1) as tool.
+# is implemented using sysctl(8) as tool.
 
 # Helpers tp catch relevant execution path.
 have_sysctl=false
@@ -531,8 +531,12 @@ test `uname -s` = 'SunOS' && have_address_mapping=true
 if $have_address_mapping; then
     :
 else
-    # Do we have sysctl(1) available?
-    if sysctl -a >/dev/null 2>&1; then
+    # Do we have sysctl(8) available?
+    # It need not be present with the default search path,
+    # so locally augment PATH!
+    SYSCTL=`PATH="$PATH":/usr/sbin:/sbin command -v sysctl`
+
+    if test -n "$SYSCTL"; then
 	have_sysctl=true
     else
 	echo "Warning: Not testing IPv4-mapped addresses." >&2
@@ -548,7 +552,7 @@ elif $have_sysctl; then
     # or
     #    net.inet6.ip6.v6only (BSD).
     #
-    value_v6only=`sysctl -a 2>/dev/null | $GREP v6only`
+    value_v6only=`$SYSCTL -a 2>/dev/null | $GREP v6only || true`
     if test -n "$value_v6only"; then
 	value_v6only=`echo $value_v6only | $SED 's/^.*[=:] *//'`
 	if test "$value_v6only" -eq 0; then
-- 
2.26.0.292.g33ef6b2f38

