Commit 08524d5e authored by Franco Fichtner's avatar Franco Fichtner

config: make sure that we're not iterating over empty interfaces

parent 39689a70
......@@ -62,7 +62,7 @@ function is_bogonsv6_used() {
global $config, $g;
# Only use bogonsv6 table if IPv6 Allow is on, and at least 1 enabled interface also has "blockbogons" enabled.
$usebogonsv6 = false;
if (isset($config['system']['ipv6allow'])) {
if (isset($config['system']['ipv6allow']) && isset($config['interfaces'])) {
foreach ($config['interfaces'] as $ifacedata) {
if(isset($ifacedata['enable']) && isset($ifacedata['blockbogons'])) {
$usebogonsv6 = true;
......
......@@ -723,12 +723,16 @@ function get_configured_interface_list($only_opt = false, $withdisabled = false)
$iflist = array();
/* if list */
if (isset($config['interfaces'])) {
foreach($config['interfaces'] as $if => $ifdetail) {
if ($only_opt && ($if == "wan" || $if == "lan"))
if ($only_opt && ($if == "wan" || $if == "lan")) {
continue;
if (isset($ifdetail['enable']) || $withdisabled == true)
}
if (isset($ifdetail['enable']) || $withdisabled == true) {
$iflist[$if] = $if;
}
}
}
return $iflist;
}
......@@ -740,6 +744,7 @@ function get_configured_interface_list_by_realif($only_opt = false, $withdisable
$iflist = array();
/* if list */
if (isset($config['interfaces'])) {
foreach($config['interfaces'] as $if => $ifdetail) {
if ($only_opt && ($if == "wan" || $if == "lan"))
continue;
......@@ -749,6 +754,7 @@ function get_configured_interface_list_by_realif($only_opt = false, $withdisable
$iflist[$tmpif] = $if;
}
}
}
return $iflist;
}
......@@ -760,6 +766,7 @@ function get_configured_interface_with_descr($only_opt = false, $withdisabled =
$iflist = array();
/* if list */
if (isset($config['interfaces'])) {
foreach($config['interfaces'] as $if => $ifdetail) {
if ($only_opt && ($if == "wan" || $if == "lan"))
continue;
......@@ -770,6 +777,7 @@ function get_configured_interface_with_descr($only_opt = false, $withdisabled =
$iflist[$if] = strtoupper($ifdetail['descr']);
}
}
}
return $iflist;
}
......@@ -921,10 +929,11 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "")
$toput['ipaddr'] = $aip[1];
}
}
if (is_array($config['interfaces'])) {
foreach($config['interfaces'] as $name => $int)
if (isset($config['interfaces'])) {
foreach($config['interfaces'] as $name => $int) {
if($int['if'] == $ifname) $friendly = $name;
}
}
switch($keyby) {
case "physical":
if($friendly != "") {
......@@ -1410,7 +1419,7 @@ function is_interface_mismatch()
$do_assign = false;
$i = 0;
if (is_array($config['interfaces'])) {
if (isset($config['interfaces'])) {
foreach ($config['interfaces'] as $ifname => $ifcfg) {
if (preg_match("/^enc|^cua|^tun|^tap|^l2tp|^pptp|^ppp|^ovpn|^gif|^gre|^lagg|^bridge|vlan|_wlan/i", $ifcfg['if'])) {
/* Do not check these interfaces */
......
......@@ -41,6 +41,12 @@ $machine = trim(`uname -m`);
print "\n*** Welcome to {$product} {$version} ({$machine}) on {$hostname} ***\n";
$iflist = get_configured_interface_with_descr(false, true);
if (empty($iflist)) {
printf("\n\tNo network interfaces are assigned.\n");
return;
}
foreach($iflist as $ifname => $friendly) {
/* point to this interface's config */
$ifconf = $config['interfaces'][$ifname];
......
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