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