From 8edb37042c071ef601fc62296d0d8d34c0cd6eb8 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 18 Jul 2022 09:16:11 +0200 Subject: [PATCH] interfaces: remove inconsistencies regarding ping utility --- src/opnsense/scripts/firmware/connection.sh | 4 ++-- src/opnsense/scripts/shell/ping.php | 16 ++++------------ src/sbin/ping_hosts.sh | 4 ++-- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/opnsense/scripts/firmware/connection.sh b/src/opnsense/scripts/firmware/connection.sh index 5b914fa60..0d4b055e2 100755 --- a/src/opnsense/scripts/firmware/connection.sh +++ b/src/opnsense/scripts/firmware/connection.sh @@ -47,7 +47,7 @@ echo "Currently running $(opnsense-version) at $(date)" >> ${LOCKFILE} if [ -n "${IPV4}" -a -z "${IPV4%%*.*}" ]; then echo "Checking connectivity for host: ${HOST} -> ${IPV4}" | ${TEE} ${LOCKFILE} - (ping ${POPT} ${IPV4} 2>&1) | ${TEE} ${LOCKFILE} + (ping -4 ${POPT} ${IPV4} 2>&1) | ${TEE} ${LOCKFILE} echo "Checking connectivity for repository (IPv4): ${URL}" | ${TEE} ${LOCKFILE} (pkg -4 update -f 2>&1) | ${TEE} ${LOCKFILE} else @@ -56,7 +56,7 @@ fi if [ -n "${IPV6}" -a -z "${IPV6%%*:*}" ]; then echo "Checking connectivity for host: ${HOST} -> ${IPV6}" | ${TEE} ${LOCKFILE} - (ping6 ${POPT} ${IPV6} 2>&1) | ${TEE} ${LOCKFILE} + (ping -6 ${POPT} ${IPV6} 2>&1) | ${TEE} ${LOCKFILE} echo "Checking connectivity for repository (IPv6): ${URL}" | ${TEE} ${LOCKFILE} (pkg -6 update -f 2>&1) | ${TEE} ${LOCKFILE} else diff --git a/src/opnsense/scripts/shell/ping.php b/src/opnsense/scripts/shell/ping.php index ba868aed8..5f91b24f7 100755 --- a/src/opnsense/scripts/shell/ping.php +++ b/src/opnsense/scripts/shell/ping.php @@ -35,16 +35,8 @@ $fp = fopen('php://stdin', 'r'); echo "\nEnter a host name or IP address: "; $pinghost = chop(fgets($fp)); -if (is_ipaddrv4($pinghost) || is_hostname($pinghost)) { - $command = "ping"; -} elseif (is_ipaddrv6($pinghost)) { - $command = "ping6"; -} -if ($command) { - echo "\n"; - passthru("/sbin/{$command} -c 3 -n " . escapeshellarg($pinghost)); - echo "\nPress ENTER to continue.\n"; - fgets($fp); -} - +echo "\n"; +passthru("/sbin/ping -c 3 -n " . escapeshellarg($pinghost)); +echo "\nPress ENTER to continue.\n"; +fgets($fp); fclose($fp); diff --git a/src/sbin/ping_hosts.sh b/src/sbin/ping_hosts.sh index 6b606cc57..6751fdbb5 100755 --- a/src/sbin/ping_hosts.sh +++ b/src/sbin/ping_hosts.sh @@ -62,9 +62,9 @@ for TOPING in $PINGHOSTS ; do WANTHRESHOLD=`echo $TOPING | cut -d"|" -f7` AF=`echo $TOPING | cut -d"|" -f8` if [ "$AF" == "inet6" ]; then - PINGCMD=ping6 + PINGCMD="ping -6" else - PINGCMD=ping + PINGCMD="ping -4" fi echo Processing $DSTIP # Look for a service being down