Commit 197303ad authored by Franco Fichtner's avatar Franco Fichtner

src: fix recent crash reports

parent 220a27e3
...@@ -71,11 +71,12 @@ $openvpn_compression_modes = array( ...@@ -71,11 +71,12 @@ $openvpn_compression_modes = array(
'adaptive' => gettext("Enabled with Adaptive Compression"), 'adaptive' => gettext("Enabled with Adaptive Compression"),
'yes' => gettext("Enabled without Adaptive Compression")); 'yes' => gettext("Enabled without Adaptive Compression"));
function openvpn_create_key() { function openvpn_create_key()
{
$fp = popen("/usr/local/sbin/openvpn --genkey --secret /dev/stdout 2>/dev/null", "r"); $fp = popen("/usr/local/sbin/openvpn --genkey --secret /dev/stdout 2>/dev/null", "r");
if (!$fp) if (!$fp) {
return false; return false;
}
$rslt = stream_get_contents($fp); $rslt = stream_get_contents($fp);
pclose($fp); pclose($fp);
...@@ -83,18 +84,25 @@ function openvpn_create_key() { ...@@ -83,18 +84,25 @@ function openvpn_create_key() {
return $rslt; return $rslt;
} }
function openvpn_vpnid_used($vpnid) { function openvpn_vpnid_used($vpnid)
{
global $config; global $config;
if (is_array($config['openvpn']['openvpn-server'])) if (isset($config['openvpn']['openvpn-server'])) {
foreach ($config['openvpn']['openvpn-server'] as & $settings) foreach ($config['openvpn']['openvpn-server'] as &$settings) {
if ($vpnid == $settings['vpnid']) if ($vpnid == $settings['vpnid']) {
return true; return true;
}
}
}
if (is_array($config['openvpn']['openvpn-client'])) if (isset($config['openvpn']['openvpn-client'])) {
foreach ($config['openvpn']['openvpn-client'] as & $settings) foreach ($config['openvpn']['openvpn-client'] as &$settings) {
if ($vpnid == $settings['vpnid']) if ($vpnid == $settings['vpnid']) {
return true; return true;
}
}
}
return false; return false;
} }
......
...@@ -260,15 +260,14 @@ function restore_config_section_xmlrpc($new_config) ...@@ -260,15 +260,14 @@ function restore_config_section_xmlrpc($new_config)
$vipbackup = array(); $vipbackup = array();
$oldvips = array(); $oldvips = array();
if (isset($new_config['virtualip'])) { if (isset($config['virtualip']['vip'])) {
if (isset($config['virtualip']['vip'])) { foreach ($config['virtualip']['vip'] as $vipindex => $vip) {
foreach ($config['virtualip']['vip'] as $vipindex => $vip) { if ($vip['mode'] == "carp") {
if ($vip['mode'] == "carp") $oldvips["{$vip['interface']}_vip{$vip['vhid']}"] = "{$vip['password']}{$vip['advskew']}{$vip['subnet']}{$vip['subnet_bits']}{$vip['advbase']}";
$oldvips["{$vip['interface']}_vip{$vip['vhid']}"] = "{$vip['password']}{$vip['advskew']}{$vip['subnet']}{$vip['subnet_bits']}{$vip['advbase']}"; } elseif ($vip['mode'] == "ipalias" && (strstr($vip['interface'], "_vip") || strstr($vip['interface'], "lo0"))) {
else if ($vip['mode'] == "ipalias" && (strstr($vip['interface'], "_vip") || strstr($vip['interface'], "lo0"))) $oldvips[$vip['subnet']] = "{$vip['interface']}{$vip['subnet']}{$vip['subnet_bits']}";
$oldvips[$vip['subnet']] = "{$vip['interface']}{$vip['subnet']}{$vip['subnet_bits']}"; } elseif (($vip['mode'] == "ipalias" || $vip['mode'] == 'proxyarp') && !(strstr($vip['interface'], "_vip") || strstr($vip['interface'], "lo0"))) {
else if (($vip['mode'] == "ipalias" || $vip['mode'] == 'proxyarp') && !(strstr($vip['interface'], "_vip") || strstr($vip['interface'], "lo0"))) $vipbackup[] = $vip;
$vipbackup[] = $vip;
} }
} }
} }
...@@ -278,10 +277,10 @@ function restore_config_section_xmlrpc($new_config) ...@@ -278,10 +277,10 @@ function restore_config_section_xmlrpc($new_config)
/* Then add ipalias and proxyarp types already defined on the backup */ /* Then add ipalias and proxyarp types already defined on the backup */
if (is_array($vipbackup) && !empty($vipbackup)) { if (is_array($vipbackup) && !empty($vipbackup)) {
if (!is_array($config['virtualip'])) { if (!isset($config['virtualip'])) {
$config['virtualip'] = array(); $config['virtualip'] = array();
} }
if (!is_array($config['virtualip']['vip'])) { if (!isset($config['virtualip']['vip'])) {
$config['virtualip']['vip'] = array(); $config['virtualip']['vip'] = array();
} }
foreach ($vipbackup as $vip) { foreach ($vipbackup as $vip) {
...@@ -298,7 +297,7 @@ function restore_config_section_xmlrpc($new_config) ...@@ -298,7 +297,7 @@ function restore_config_section_xmlrpc($new_config)
* The real work on handling the vips specially * The real work on handling the vips specially
* This is a copy of intefaces_vips_configure with addition of not reloading existing/not changed carps * This is a copy of intefaces_vips_configure with addition of not reloading existing/not changed carps
*/ */
if (isset($new_config['virtualip']) && is_array($config['virtualip']) && is_array($config['virtualip']['vip'])) { if (isset($new_config['virtualip']['vip'])) {
$carp_setuped = false; $carp_setuped = false;
$anyproxyarp = false; $anyproxyarp = false;
foreach ($config['virtualip']['vip'] as $vip) { foreach ($config['virtualip']['vip'] as $vip) {
......
...@@ -747,7 +747,7 @@ include("head.inc"); ...@@ -747,7 +747,7 @@ include("head.inc");
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
<?php if (is_array($config['virtualip']['vip'])): <?php if (isset($config['virtualip']['vip'])):
foreach ($config['virtualip']['vip'] as $sn): foreach ($config['virtualip']['vip'] as $sn):
if (isset($sn['noexpand'])) if (isset($sn['noexpand']))
continue; continue;
......
...@@ -282,7 +282,7 @@ if ($_POST) { ...@@ -282,7 +282,7 @@ if ($_POST) {
} }
if (($_POST['ipprotocol'] <> "") && ($_POST['gateway'] <> "")) { if (($_POST['ipprotocol'] <> "") && ($_POST['gateway'] <> "")) {
if(is_array($config['gateways']['gateway_group'])) { if (isset($config['gateways']['gateway_group'])) {
foreach($config['gateways']['gateway_group'] as $gw_group) { foreach($config['gateways']['gateway_group'] as $gw_group) {
if($gw_group['name'] == $_POST['gateway']) { if($gw_group['name'] == $_POST['gateway']) {
$family = $a_gatewaygroups[$_POST['gateway']]['ipprotocol']; $family = $a_gatewaygroups[$_POST['gateway']]['ipprotocol'];
......
...@@ -33,9 +33,10 @@ require_once("guiconfig.inc"); ...@@ -33,9 +33,10 @@ require_once("guiconfig.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
require_once("filter.inc"); require_once("filter.inc");
if (!is_array($config['virtualip']['vip'])) { if (!isset($config['virtualip']['vip'])) {
$config['virtualip']['vip'] = array(); $config['virtualip']['vip'] = array();
} }
$a_vip = &$config['virtualip']['vip']; $a_vip = &$config['virtualip']['vip'];
if ($_POST) { if ($_POST) {
......
...@@ -30,8 +30,9 @@ ...@@ -30,8 +30,9 @@
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
if (!is_array($config['ifgroups']['ifgroupentry'])) if (!isset($config['ifgroups']['ifgroupentry'])) {
$config['ifgroups']['ifgroupentry'] = array(); $config['ifgroups']['ifgroupentry'] = array();
}
$a_ifgroups = &$config['ifgroups']['ifgroupentry']; $a_ifgroups = &$config['ifgroups']['ifgroupentry'];
......
...@@ -660,8 +660,9 @@ function step12_submitphpaction() { ...@@ -660,8 +660,9 @@ function step12_submitphpaction() {
$config['filter']['rule'][] = $rule; $config['filter']['rule'][] = $rule;
} }
if (!is_array($config['openvpn']['openvpn-server'])) if (!isset($config['openvpn']['openvpn-server'])) {
$config['openvpn']['openvpn-server'] = array(); $config['openvpn']['openvpn-server'] = array();
}
$config['openvpn']['openvpn-server'][] = $server; $config['openvpn']['openvpn-server'][] = $server;
...@@ -670,5 +671,3 @@ function step12_submitphpaction() { ...@@ -670,5 +671,3 @@ function step12_submitphpaction() {
header("Location: vpn_openvpn_server.php"); header("Location: vpn_openvpn_server.php");
exit; exit;
} }
?>
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