Match whitespace after $vhid when checking CARP status to avoid partial matches. Fixes #7638

While here, fix variable references with braces and combine the two calls to grep into a single pattern.

(cherry picked from commit fd4e14b885)
This commit is contained in:
jim-p 2017-06-20 10:48:44 -04:00
parent bae3b2be97
commit 8cb09b2953

View File

@ -740,7 +740,7 @@ function get_carp_interface_status($carpid) {
$vhid = $vip['vhid'];
$carp_query = '';
$_gb = exec("/sbin/ifconfig $interface | /usr/bin/grep carp: | /usr/bin/grep \"vhid $vhid\"", $carp_query);
$_gb = exec("/sbin/ifconfig {$interface} | /usr/bin/grep \"carp:.* vhid {$vhid} \"", $carp_query);
foreach ($carp_query as $int) {
if (stripos($int, "MASTER"))
return "MASTER";