Commit 8067e9bd authored by Ad Schellevis's avatar Ad Schellevis

legacy_interfaces_details() switch to exec()

parent d3a69604
......@@ -207,11 +207,15 @@ function legacy_interfaces_details($intf=null)
} else {
$tmp_intf = "";
}
$process = proc_open('/sbin/ifconfig -m ' . $tmp_intf , array(array("pipe", "r"), array("pipe", "w")), $pipes);
if (is_resource($process)) {
$cmd = '/sbin/ifconfig -m ' . $tmp_intf;
exec($cmd . ' 2>&1', $ifconfig_data, $ret);
if ($ret) {
log_error('The command `' . $cmd . '\' failed to execute ' . implode(' ', $ifconfig_data) );
return array();
}
$current_interface = null;
$ifconfig_data = stream_get_contents($pipes[1]);
foreach (explode("\n", $ifconfig_data) as $line) {
foreach ($ifconfig_data as $line) {
$line_parts = explode(' ', $line);
if (strpos(trim($line), 'flags=') !== false) {
$current_interface = explode(':', $line)[0];
......@@ -264,9 +268,7 @@ function legacy_interfaces_details($intf=null)
}
}
fclose($pipes[1]);
proc_close($process);
}
return $result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment