Commit 90daae43 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(legacy) some more code fixes

parent 4ea0d90d
...@@ -1716,7 +1716,7 @@ function filter_nat_rules_generate() { ...@@ -1716,7 +1716,7 @@ function filter_nat_rules_generate() {
$natrules .= filter_nat_rules_generate_if($a_out['interface'], $natrules .= filter_nat_rules_generate_if($a_out['interface'],
$a_out['source']['network'], $a_out['source']['network'],
$a_out['sourceport'], $a_out['sourceport'],
$a_out['destination']['address'], isset($a_out['destination']['address']) ? $a_out['destination']['address'] : null,
$a_out['dstport'], $a_out['dstport'],
$a_out['target'], $a_out['target'],
$a_out['natport'], $a_out['natport'],
...@@ -2254,12 +2254,12 @@ function filter_generate_user_rule($rule) ...@@ -2254,12 +2254,12 @@ function filter_generate_user_rule($rule)
} }
/* check for unresolvable aliases */ /* check for unresolvable aliases */
if($rule['source']['address'] && !alias_expand($rule['source']['address'])) { if(isset($rule['source']['address']) && !alias_expand($rule['source']['address'])) {
$error_text = "Unresolvable source alias '{$rule['source']['address']}' for rule '{$rule['descr']}'"; $error_text = "Unresolvable source alias '{$rule['source']['address']}' for rule '{$rule['descr']}'";
file_notice("Filter_Reload", $error_text); file_notice("Filter_Reload", $error_text);
return "# {$error_text}"; return "# {$error_text}";
} }
if($rule['destination']['address'] && !alias_expand($rule['destination']['address'])) { if(isset($rule['destination']['address']) && !alias_expand($rule['destination']['address'])) {
$error_text = "Unresolvable destination alias '{$rule['destination']['address']}' for rule '{$rule['descr']}'"; $error_text = "Unresolvable destination alias '{$rule['destination']['address']}' for rule '{$rule['descr']}'";
file_notice("Filter_Reload", $error_text); file_notice("Filter_Reload", $error_text);
return "# {$error_text}"; return "# {$error_text}";
...@@ -2370,6 +2370,7 @@ function filter_generate_user_rule($rule) ...@@ -2370,6 +2370,7 @@ function filter_generate_user_rule($rule)
default: $aline['dscp'] = " dscp " . $rule['dscp'] . " "; break; default: $aline['dscp'] = " dscp " . $rule['dscp'] . " "; break;
} }
} }
$aline['allowopts'] = "";
if ($type == "pass") { if ($type == "pass") {
if (isset($rule['allowopts'])) if (isset($rule['allowopts']))
$aline['allowopts'] = " allow-opts "; $aline['allowopts'] = " allow-opts ";
...@@ -2858,7 +2859,7 @@ EOD; ...@@ -2858,7 +2859,7 @@ EOD;
} }
break; break;
default: default:
if ((is_array($config['dhcpdv6'][$on]) && isset($config['dhcpdv6'][$on]['enable'])) || isset($oc['track6-interface']) if (isset($config['dhcpdv6'][$on]['enable']) || isset($oc['track6-interface'])
|| (is_array($config['dhcrelay6']) && !empty($config['dhcrelay6']['interface']) && in_array($on, explode(',', $config['dhcrelay6']['interface'])))) { || (is_array($config['dhcrelay6']) && !empty($config['dhcrelay6']['interface']) && in_array($on, explode(',', $config['dhcrelay6']['interface'])))) {
$ipfrules .= <<<EOD $ipfrules .= <<<EOD
# allow access to DHCPv6 server on {$oc['descr']} # allow access to DHCPv6 server on {$oc['descr']}
......
...@@ -953,8 +953,9 @@ function openvpn_resync_all($interface = '') ...@@ -953,8 +953,9 @@ function openvpn_resync_all($interface = '')
openvpn_create_dirs(); openvpn_create_dirs();
if (!is_array($config['openvpn'])) if (!isset($config['openvpn']) || !is_array($config['openvpn'])) {
$config['openvpn'] = array(); return;
}
if ($interface <> "") if ($interface <> "")
log_error("Resyncing OpenVPN instances for interface " . convert_friendly_interface_to_friendly_descr($interface) . "."); log_error("Resyncing OpenVPN instances for interface " . convert_friendly_interface_to_friendly_descr($interface) . ".");
......
...@@ -368,7 +368,7 @@ function enable_rrd_graphing() ...@@ -368,7 +368,7 @@ function enable_rrd_graphing()
$rrdupdatesh .= "END {print b4pi \":\" b4po \":\" b4bi \":\" b4bo \":\" b6pi \":\" b6po \":\" b6bi \":\" b6bo};'`\n"; $rrdupdatesh .= "END {print b4pi \":\" b4po \":\" b4bi \":\" b4bo \":\" b6pi \":\" b6po \":\" b6bi \":\" b6bo};'`\n";
/* WIRELESS, set up the rrd file */ /* WIRELESS, set up the rrd file */
if($config['interfaces'][$ifname]['wireless']['mode'] == "bss") { if(isset($config['interfaces'][$ifname]['wireless']['mode']) && $config['interfaces'][$ifname]['wireless']['mode'] == "bss") {
if (!file_exists("$rrddbpath$ifname$wireless")) { if (!file_exists("$rrddbpath$ifname$wireless")) {
$rrdcreate = "$rrdtool create $rrddbpath$ifname$wireless --step $rrdwirelessinterval "; $rrdcreate = "$rrdtool create $rrddbpath$ifname$wireless --step $rrdwirelessinterval ";
$rrdcreate .= "DS:snr:GAUGE:$wirelessvalid:0:1000 "; $rrdcreate .= "DS:snr:GAUGE:$wirelessvalid:0:1000 ";
......
...@@ -1376,7 +1376,7 @@ function services_igmpproxy_configure() { ...@@ -1376,7 +1376,7 @@ function services_igmpproxy_configure() {
/* kill any running igmpproxy */ /* kill any running igmpproxy */
killbyname("igmpproxy"); killbyname("igmpproxy");
if (!is_array($config['igmpproxy']['igmpentry']) || (count($config['igmpproxy']['igmpentry']) == 0)) if (!isset($config['igmpproxy']['igmpentry']) || !is_array($config['igmpproxy']['igmpentry']) || (count($config['igmpproxy']['igmpentry']) == 0))
return 1; return 1;
$iflist = get_configured_interface_list(); $iflist = get_configured_interface_list();
...@@ -1727,24 +1727,27 @@ function services_dyndns_configure($int = '') ...@@ -1727,24 +1727,27 @@ function services_dyndns_configure($int = '')
{ {
global $config, $g; global $config, $g;
$dyndnscfg = $config['dyndnses']['dyndns']; if (isset($config['dyndnses']['dyndns'])) {
$gwgroups = return_gateway_groups_array(); $dyndnscfg = $config['dyndnses']['dyndns'];
if (is_array($dyndnscfg)) {
if (file_exists("/var/run/booting")) $gwgroups = return_gateway_groups_array();
echo gettext("Starting DynDNS clients..."); if (is_array($dyndnscfg)) {
if (file_exists("/var/run/booting"))
foreach ($dyndnscfg as $dyndns) { echo gettext("Starting DynDNS clients...");
if ((empty($int)) || ($int == $dyndns['interface']) || (is_array($gwgroups[$dyndns['interface']]))) {
$dyndns['verboselog'] = isset($dyndns['verboselog']); foreach ($dyndnscfg as $dyndns) {
$dyndns['curl_ipresolve_v4'] = isset($dyndns['curl_ipresolve_v4']); if ((empty($int)) || ($int == $dyndns['interface']) || (is_array($gwgroups[$dyndns['interface']]))) {
$dyndns['curl_ssl_verifypeer'] = isset($dyndns['curl_ssl_verifypeer']); $dyndns['verboselog'] = isset($dyndns['verboselog']);
services_dyndns_configure_client($dyndns); $dyndns['curl_ipresolve_v4'] = isset($dyndns['curl_ipresolve_v4']);
sleep(1); $dyndns['curl_ssl_verifypeer'] = isset($dyndns['curl_ssl_verifypeer']);
services_dyndns_configure_client($dyndns);
sleep(1);
}
} }
}
if (file_exists("/var/run/booting")) if (file_exists("/var/run/booting"))
echo gettext("done.") . "\n"; echo gettext("done.") . "\n";
}
} }
return 0; return 0;
...@@ -2157,7 +2160,7 @@ function services_dnsupdate_process($int = '', $updatehost = '', $forced = false ...@@ -2157,7 +2160,7 @@ function services_dnsupdate_process($int = '', $updatehost = '', $forced = false
global $config, $g; global $config, $g;
/* Dynamic DNS updating active? */ /* Dynamic DNS updating active? */
if (is_array($config['dnsupdates']['dnsupdate'])) { if (isset($config['dnsupdates']['dnsupdate']) && is_array($config['dnsupdates']['dnsupdate'])) {
$notify_text = ""; $notify_text = "";
foreach ($config['dnsupdates']['dnsupdate'] as $i => $dnsupdate) { foreach ($config['dnsupdates']['dnsupdate'] as $i => $dnsupdate) {
if (!isset($dnsupdate['enable'])) if (!isset($dnsupdate['enable']))
......
...@@ -111,7 +111,7 @@ function system_resolvconf_generate($dynupdate = false) ...@@ -111,7 +111,7 @@ function system_resolvconf_generate($dynupdate = false)
$resolvconf .= "nameserver $nameserver\n"; $resolvconf .= "nameserver $nameserver\n";
} }
} }
if (is_array($syscfg['dnsserver'])) { if (isset($syscfg['dnsserver']) && is_array($syscfg['dnsserver'])) {
foreach ($syscfg['dnsserver'] as $ns) { foreach ($syscfg['dnsserver'] as $ns) {
if ($ns) if ($ns)
$resolvconf .= "nameserver $ns\n"; $resolvconf .= "nameserver $ns\n";
...@@ -276,7 +276,7 @@ function system_hosts_generate() ...@@ -276,7 +276,7 @@ function system_hosts_generate()
} }
if (isset($dnsmasqcfg['enable'])) { if (isset($dnsmasqcfg['enable'])) {
if (!is_array($dnsmasqcfg['hosts'])) if (!isset($dnsmasqcfg['hosts']) || !is_array($dnsmasqcfg['hosts']))
$dnsmasqcfg['hosts'] = array(); $dnsmasqcfg['hosts'] = array();
foreach ($dnsmasqcfg['hosts'] as $host) { foreach ($dnsmasqcfg['hosts'] as $host) {
...@@ -1328,7 +1328,7 @@ function system_ntp_configure($start_ntpd = true) ...@@ -1328,7 +1328,7 @@ function system_ntp_configure($start_ntpd = true)
@mkdir($statsdir, 0755); @mkdir($statsdir, 0755);
if (!is_array($config['ntpd'])) { if (!isset($config['ntpd']) || !is_array($config['ntpd'])) {
$config['ntpd'] = array(); $config['ntpd'] = array();
} }
...@@ -1387,7 +1387,7 @@ function system_ntp_configure($start_ntpd = true) ...@@ -1387,7 +1387,7 @@ function system_ntp_configure($start_ntpd = true)
/* End PPS configuration */ /* End PPS configuration */
/* Add GPS configuration */ /* Add GPS configuration */
if (!empty($config['ntpd']['gps'] && !empty($config['ntpd']['gps']['port'])) if (isset($config['ntpd']['gps']['port'])
&& file_exists('/dev/'.$config['ntpd']['gps']['port']) && file_exists('/dev/'.$config['ntpd']['gps']['port'])
&& system_ntp_setup_gps($config['ntpd']['gps']['port'])) { && system_ntp_setup_gps($config['ntpd']['gps']['port'])) {
$ntpcfg .= "\n"; $ntpcfg .= "\n";
...@@ -1462,8 +1462,8 @@ function system_ntp_configure($start_ntpd = true) ...@@ -1462,8 +1462,8 @@ function system_ntp_configure($start_ntpd = true)
/* foreach through ntp servers and write out to ntpd.conf */ /* foreach through ntp servers and write out to ntpd.conf */
foreach (explode(' ', $config['system']['timeservers']) as $ts) { foreach (explode(' ', $config['system']['timeservers']) as $ts) {
$ntpcfg .= "server {$ts} iburst maxpoll 9"; $ntpcfg .= "server {$ts} iburst maxpoll 9";
if (substr_count($config['ntpd']['prefer'], $ts)) $ntpcfg .= ' prefer'; if (isset($config['ntpd']['prefer']) && substr_count($config['ntpd']['prefer'], $ts)) $ntpcfg .= ' prefer';
if (substr_count($config['ntpd']['noselect'], $ts)) $ntpcfg .= ' noselect'; if (isset($config['ntpd']['noselect']) && substr_count($config['ntpd']['noselect'], $ts)) $ntpcfg .= ' noselect';
$ntpcfg .= "\n"; $ntpcfg .= "\n";
} }
unset($ts); unset($ts);
......
...@@ -1388,7 +1388,7 @@ function mute_kernel_msgs() ...@@ -1388,7 +1388,7 @@ function mute_kernel_msgs()
{ {
global $config; global $config;
if ($config['system']['enableserial']) { if (isset($config['system']['enableserial'])) {
return; return;
} }
......
...@@ -45,8 +45,11 @@ if (file_exists('/var/run/booting')) { ...@@ -45,8 +45,11 @@ if (file_exists('/var/run/booting')) {
} }
/* Interface IP address has changed */ /* Interface IP address has changed */
$argument = str_replace("\n", "", $argv[1]); if (isset($argv[1])) {
$argument = str_replace("\n", "", $argv[1]);
} else {
$argument = null;
}
log_error("rc.newwanip: Informational is starting {$argument}."); log_error("rc.newwanip: Informational is starting {$argument}.");
if (empty($argument)) { if (empty($argument)) {
...@@ -128,21 +131,23 @@ if (!empty($bridgetmp)) ...@@ -128,21 +131,23 @@ if (!empty($bridgetmp))
system_hosts_generate(); system_hosts_generate();
/* check tunneled IPv6 interface tracking */ /* check tunneled IPv6 interface tracking */
switch($config['interfaces'][$interface]['ipaddrv6']) { if (isset($config['interfaces'][$interface]['ipaddrv6'])) {
case "6to4": switch($config['interfaces'][$interface]['ipaddrv6']) {
interface_6to4_configure($interface, $config['interfaces'][$interface]); case "6to4":
break; interface_6to4_configure($interface, $config['interfaces'][$interface]);
case "6rd": break;
interface_6rd_configure($interface, $config['interfaces'][$interface]); case "6rd":
break; interface_6rd_configure($interface, $config['interfaces'][$interface]);
case "dhcp6": break;
if (isset($config['interfaces'][$interface]['dhcp6usev4iface'])) case "dhcp6":
interface_dhcpv6_configure($interface, $config['interfaces'][$interface]); if (isset($config['interfaces'][$interface]['dhcp6usev4iface']))
break; interface_dhcpv6_configure($interface, $config['interfaces'][$interface]);
break;
}
} }
/* Check Gif tunnels */ /* Check Gif tunnels */
if(is_array($config['gifs']['gif'])){ if(isset($config['gifs']['gif']) && is_array($config['gifs']['gif'])){
foreach($config['gifs']['gif'] as $gif) { foreach($config['gifs']['gif'] as $gif) {
if($gif['if'] == $interface) { if($gif['if'] == $interface) {
foreach($config['interfaces'] as $ifname => $ifparent) { foreach($config['interfaces'] as $ifname => $ifparent) {
......
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