mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 00:54:41 +00:00
util: make dmesg probing optional #1135
While there, turn the probing upside down for general sanity: o Only pull dmesg output once o Pattern-match one pattern only o Anchor the match to the line start
This commit is contained in:
parent
c77dd450ac
commit
720acc9e1d
@ -59,7 +59,7 @@ function set_networking_interfaces_ports($probe = false)
|
||||
/* kernel messages clobber stty probing on ifconfig up */
|
||||
mute_kernel_msgs();
|
||||
|
||||
$iflist = get_interface_list();
|
||||
$iflist = get_interface_list(false, true);
|
||||
|
||||
if ($probe) {
|
||||
echo PHP_EOL . gettext('Press any key to start the manual interface assignment: ');
|
||||
|
||||
@ -876,12 +876,21 @@ function get_configured_ipv6_addresses()
|
||||
*
|
||||
* $only_active = false -- interfaces that are available in the system
|
||||
* true -- interfaces that are physically connected
|
||||
*
|
||||
* $include_dmesg = false -- skip probing dmesg for more information
|
||||
* true -- probe dmesg for more information
|
||||
*/
|
||||
function get_interface_list($only_active = false)
|
||||
function get_interface_list($only_active = false, $include_dmesg = false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$dmesg_arr = array();
|
||||
$iflist = array();
|
||||
|
||||
if ($include_dmesg) {
|
||||
exec('/sbin/dmesg', $dmesg_arr);
|
||||
}
|
||||
|
||||
/* list of virtual interface types */
|
||||
$vfaces = array(
|
||||
'_vlan',
|
||||
@ -935,25 +944,22 @@ function get_interface_list($only_active = false)
|
||||
$toput = array(
|
||||
'up' => in_array($ifname, $ifnames_up),
|
||||
'ipaddr' => !empty($ifdata['ipaddr']) ? $ifdata['ipaddr'] : null,
|
||||
'mac' => $ifdata['macaddr']
|
||||
'mac' => $ifdata['macaddr'],
|
||||
'dmesg' => '',
|
||||
);
|
||||
|
||||
if (isset($config['interfaces'])) {
|
||||
foreach (legacy_config_get_interfaces(array("virtual" => false)) as $name => $int) {
|
||||
if ($int['if'] == $ifname) {
|
||||
$toput['friendly'] = $name;
|
||||
break;
|
||||
}
|
||||
foreach (legacy_config_get_interfaces(array('virtual' => false)) as $name => $int) {
|
||||
if ($int['if'] == $ifname) {
|
||||
$toput['friendly'] = $name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$dmesg_arr = array();
|
||||
$toput['dmesg'] = null;
|
||||
exec("/sbin/dmesg |grep $ifname", $dmesg_arr);
|
||||
if (count($dmesg_arr) > 0) {
|
||||
preg_match_all("/<(.*?)>/i", $dmesg_arr[0], $dmesg);
|
||||
if (isset($dmesg[1][0])) {
|
||||
$toput['dmesg'] = $dmesg[1][0];
|
||||
foreach ($dmesg_arr as $dmesg_line) {
|
||||
$dmesg = array();
|
||||
if (preg_match("/^{$ifname}: <(.*?)>/i", $dmesg_line, $dmesg) == 1) {
|
||||
$toput['dmesg'] = $dmesg[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user