Commit f3597390 authored by Franco Fichtner's avatar Franco Fichtner

src: fix a few crash reports

parent 4f5144f9
...@@ -73,24 +73,25 @@ function unbound_optimization() { ...@@ -73,24 +73,25 @@ function unbound_optimization() {
* Larger socket buffer for busy servers * Larger socket buffer for busy servers
* Check that it is set to 4MB (by default the OS has it configured to 4MB) * Check that it is set to 4MB (by default the OS has it configured to 4MB)
*/ */
foreach ($config['sysctl']['item'] as $tunable) { if (isset($config['sysctl']['item'])) {
if ($tunable['tunable'] == 'kern.ipc.maxsockbuf') { foreach ($config['sysctl']['item'] as $tunable) {
$so = floor(($tunable['value']/1024/1024)-1); if ($tunable['tunable'] == 'kern.ipc.maxsockbuf') {
// Check to ensure that the number is not a negative $so = floor(($tunable['value']/1024/1024)-1);
if ($so > 0) { // Check to ensure that the number is not a negative
$optimization['so_rcvbuf'] = "so-rcvbuf: {$so}m"; if ($so > 0) {
} else { $optimization['so_rcvbuf'] = "so-rcvbuf: {$so}m";
unset($optimization['so_rcvbuf']); } else {
unset($optimization['so_rcvbuf']);
}
} }
} }
} // Safety check in case kern.ipc.maxsockbuf is not available.
// Safety check in case kern.ipc.maxsockbuf is not available. if (!isset($optimization['so_rcvbuf'])) {
if (!isset($optimization['so_rcvbuf'])) { $optimization['so_rcvbuf'] = "#so-rcvbuf: 4m";
$optimization['so_rcvbuf'] = "#so-rcvbuf: 4m"; }
} }
return $optimization; return $optimization;
} }
function bootstrap_unbound_root() function bootstrap_unbound_root()
...@@ -701,7 +702,7 @@ function unbound_acls_config() { ...@@ -701,7 +702,7 @@ function unbound_acls_config() {
} }
// Configure the custom ACLs // Configure the custom ACLs
if (is_array($config['unbound']['acls'])) { if (isset($config['unbound']['acls'])) {
foreach($config['unbound']['acls'] as $unbound_acl) { foreach($config['unbound']['acls'] as $unbound_acl) {
$aclcfg .= "#{$unbound_acl['aclname']}\n"; $aclcfg .= "#{$unbound_acl['aclname']}\n";
foreach($unbound_acl['row'] as $network) { foreach($unbound_acl['row'] as $network) {
......
...@@ -34,6 +34,7 @@ require_once("interfaces.inc"); ...@@ -34,6 +34,7 @@ require_once("interfaces.inc");
function interfaces_carp_set_maintenancemode($carp_maintenancemode) function interfaces_carp_set_maintenancemode($carp_maintenancemode)
{ {
global $config; global $config;
if (isset($config["virtualip_carp_maintenancemode"]) && $carp_maintenancemode == false) { if (isset($config["virtualip_carp_maintenancemode"]) && $carp_maintenancemode == false) {
unset($config["virtualip_carp_maintenancemode"]); unset($config["virtualip_carp_maintenancemode"]);
write_config("Leave CARP maintenance mode"); write_config("Leave CARP maintenance mode");
...@@ -42,10 +43,12 @@ function interfaces_carp_set_maintenancemode($carp_maintenancemode) ...@@ -42,10 +43,12 @@ function interfaces_carp_set_maintenancemode($carp_maintenancemode)
write_config("Enter CARP maintenance mode"); write_config("Enter CARP maintenance mode");
} }
$viparr = &$config['virtualip']['vip']; if (isset($config['virtualip']['vip'])) {
foreach ($viparr as $vip) { $viparr = &$config['virtualip']['vip'];
if ($vip['mode'] == "carp") { foreach ($viparr as $vip) {
interface_carp_configure($vip); if ($vip['mode'] == 'carp') {
interface_carp_configure($vip);
}
} }
} }
} }
......
...@@ -212,9 +212,10 @@ function show_advanced_dns() { ...@@ -212,9 +212,10 @@ function show_advanced_dns() {
<option value="" <?php if (empty($pconfig['active_interface']) || empty($pconfig['active_interface'][0])) echo 'selected="selected"'; ?>>All</option> <option value="" <?php if (empty($pconfig['active_interface']) || empty($pconfig['active_interface'][0])) echo 'selected="selected"'; ?>>All</option>
<?php <?php
foreach ($interface_addresses as $laddr): foreach ($interface_addresses as $laddr):
$selected = ""; $selected = '';
if (in_array($laddr['value'], $pconfig['active_interface'])) if (!empty($pconfig['active_interface']) && in_array($laddr['value'], $pconfig['active_interface'])) {
$selected = 'selected="selected"'; $selected = 'selected="selected"';
}
?> ?>
<option value="<?=$laddr['value'];?>" <?=$selected;?>> <option value="<?=$laddr['value'];?>" <?=$selected;?>>
<?=htmlspecialchars($laddr['name']);?> <?=htmlspecialchars($laddr['name']);?>
...@@ -237,9 +238,10 @@ function show_advanced_dns() { ...@@ -237,9 +238,10 @@ function show_advanced_dns() {
<option value="" <?php if (empty($pconfig['outgoing_interface']) || empty($pconfig['outgoing_interface'][0])) echo 'selected="selected"'; ?>>All</option> <option value="" <?php if (empty($pconfig['outgoing_interface']) || empty($pconfig['outgoing_interface'][0])) echo 'selected="selected"'; ?>>All</option>
<?php <?php
foreach ($interface_addresses as $laddr): foreach ($interface_addresses as $laddr):
$selected = ""; $selected = '';
if (in_array($laddr['value'], $pconfig['outgoing_interface'])) if (!empty($pconfig['outgoing_interface']) && in_array($laddr['value'], $pconfig['outgoing_interface'])) {
$selected = 'selected="selected"'; $selected = 'selected="selected"';
}
?> ?>
<option value="<?=$laddr['value'];?>" <?=$selected;?>> <option value="<?=$laddr['value'];?>" <?=$selected;?>>
<?=htmlspecialchars($laddr['name']);?> <?=htmlspecialchars($laddr['name']);?>
......
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