Skip to content

Commit

Permalink
Fixing #5661: Ping6 Not found
Browse files Browse the repository at this point in the history
On Linux and *NIX variants Cacti is unable to find ping6 as it's not in the path
  • Loading branch information
TheWitness committed Feb 3, 2024
1 parent 6ec29a8 commit ad92b3f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Cacti CHANGELOG
-issue#5648: Fractional time offsets can cause huge webserver error-logs
-issue#5649: Inapprorpiate use of PHP_OS in lib/ping.php on Windows Platform
-issue#5655: Function get_allowed_devices can returns incorrect device list if session user_id variable is not set
-issue#5661: On Linux and *NIX variants Cacti is unable to find ping6 as it's not in the path

1.2.26
-security#GHSA-xwqc-7jc4-xm73: XSS vulnerability when importing a template file
Expand Down
6 changes: 3 additions & 3 deletions lib/ping.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function ping_icmp() {
$result = shell_exec('ping -t ' . ceil($this->timeout/1000) . ' -c ' . $this->retries . ' ' . $this->host['hostname']);
} elseif (substr_count(strtolower(PHP_OS), 'freebsd')) {
if (strpos($host_ip, ':') !== false) {
$result = shell_exec('ping6 -x ' . $this->timeout . ' -c ' . $this->retries . ' ' . $this->host['hostname']);
$result = shell_exec('/usr/sbin/ping6 -x ' . $this->timeout . ' -c ' . $this->retries . ' ' . $this->host['hostname']);
} else {
$result = shell_exec('ping -W ' . $this->timeout . ' -c ' . $this->retries . ' ' . $this->host['hostname']);
}
Expand All @@ -186,11 +186,11 @@ function ping_icmp() {
* as it now tries to open an ICMP socket and fails
* $result will be empty, then. */
if (strpos($host_ip, ':') !== false) {
$result = shell_exec('ping6 -W ' . ceil($this->timeout/1000) . ' -c ' . $this->retries . ' -p ' . $pattern . ' ' . $this->host['hostname']);
$result = shell_exec('/usr/sbin/ping6 -W ' . ceil($this->timeout/1000) . ' -c ' . $this->retries . ' -p ' . $pattern . ' ' . $this->host['hostname']);
} else {
$result = shell_exec('ping -W ' . ceil($this->timeout/1000) . ' -c ' . $this->retries . ' -p ' . $pattern . ' ' . $this->host['hostname'] . ' 2>&1');
if ((strpos($result, 'unknown host') !== false || strpos($result, 'Address family') !== false) && file_exists('/bin/ping6')) {
$result = shell_exec('ping6 -W ' . ceil($this->timeout/1000) . ' -c ' . $this->retries . ' -p ' . $pattern . ' ' . $this->host['hostname']);
$result = shell_exec('/usr/sbin/ping6 -W ' . ceil($this->timeout/1000) . ' -c ' . $this->retries . ' -p ' . $pattern . ' ' . $this->host['hostname']);
}
}
}
Expand Down

0 comments on commit ad92b3f

Please sign in to comment.