summaryrefslogtreecommitdiffstats
path: root/usr/local
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2010-04-30 21:29:24 +0000
committerErmal <eri@pfsense.org>2010-04-30 21:29:24 +0000
commitf78302e8849550f04dc873cb3823a24f90a3ca5c (patch)
tree50b917eb68027704e5c82dfdb9bd1bc1a18d0f56 /usr/local
parentec313443f408caddab8725fc0cb5072459277cc4 (diff)
downloadpfsense-f78302e8849550f04dc873cb3823a24f90a3ca5c.zip
pfsense-f78302e8849550f04dc873cb3823a24f90a3ca5c.tar.gz
Add gateways validation code before deleteing. This prevents footshooting especially with Gateway Groups.
Diffstat (limited to 'usr/local')
-rwxr-xr-xusr/local/www/system_gateway_groups.php4
-rwxr-xr-xusr/local/www/system_gateways.php47
-rwxr-xr-xusr/local/www/system_gateways_edit.php2
3 files changed, 41 insertions, 12 deletions
diff --git a/usr/local/www/system_gateway_groups.php b/usr/local/www/system_gateway_groups.php
index 484066d..ac99235 100755
--- a/usr/local/www/system_gateway_groups.php
+++ b/usr/local/www/system_gateway_groups.php
@@ -74,6 +74,10 @@ if ($_GET['act'] == "del") {
if ($a_gateway_groups[$_GET['id']]) {
$changedesc .= "removed gateway group {$_GET['id']}";
unset($a_gateway_groups[$_GET['id']]);
+ foreach ($config['filter']['rule'] as $idx => $rule) {
+ if ($rule['gateway'] == $a_gateway_groups[$_GET['id']]['name'])
+ unset($config['filter']['rule'][$idx]['gateway']);
+ }
write_config($changedesc);
mark_subsystem_dirty('staticroutes');
header("Location: system_gateway_groups.php");
diff --git a/usr/local/www/system_gateways.php b/usr/local/www/system_gateways.php
index 38df88a..5e21014 100755
--- a/usr/local/www/system_gateways.php
+++ b/usr/local/www/system_gateways.php
@@ -46,9 +46,8 @@ require_once("shaper.inc");
$a_gateways = return_gateways_array(true);
$a_gateways_arr = array();
-foreach($a_gateways as $gw) {
+foreach ($a_gateways as $gw)
$a_gateways_arr[] = $gw;
-}
$a_gateways = $a_gateways_arr;
if (!is_array($config['gateways']['gateway_item']))
@@ -81,15 +80,40 @@ if ($_GET['act'] == "del") {
if ($a_gateways[$_GET['id']]) {
/* remove the real entry */
$realid = $a_gateways[$_GET['id']]['attribute'];
-
- if ($config['interfaces'][$a_gateways[$_GET['id']]['friendlyiface']]['gateway'] == $a_gateways[$_GET['id']]['name'])
- unset($config['interfaces'][$a_gateways[$_GET['id']]['friendlyiface']]['gateway']);
- $changedesc .= "removed gateway {$realid}";
- unset($a_gateway_item[$realid]);
- write_config($changedesc);
- mark_subsystem_dirty('staticroutes');
- header("Location: system_gateways.php");
- exit;
+ $remove = true;
+ if (is_array($config['gateways']['gateway_group'])) {
+ foreach ($config['gateways']['gateway_group'] as $group) {
+ foreach ($group['item'] as $item) {
+ $items = explode("|", $item);
+ if ($items[0] == $a_gateways[$_GET['id']]['name']) {
+ $input_errors[] = "Gateway cannot be deleted because it is in use on Gateway Group '{$group['name']}'";
+ $remove = false;
+ break;
+ }
+
+ }
+ }
+ }
+ if (is_array($config['staticroutes']['route'])) {
+ foreach ($config['staticroutes']['route'] as $route) {
+ if ($route['gateway'] == $a_gateways[$_GET['id']]['name']) {
+ $input_errors[] = "Gateway cannot be deleted because it is in use on Static Routes '{$route['network']}'";
+ $remove = false;
+ break;
+ }
+ }
+ }
+ if ($remove == true) {
+ var_dump($config['interfaces']);
+ if ($config['interfaces'][$a_gateways[$_GET['id']]['friendlyiface']]['gateway'] == $a_gateways[$_GET['id']]['name'])
+ unset($config['interfaces'][$a_gateways[$_GET['id']]['friendlyiface']]['gateway']);
+ $changedesc .= "removed gateway {$realid}";
+ unset($a_gateway_item[$realid]);
+ write_config($changedesc);
+ mark_subsystem_dirty('staticroutes');
+ header("Location: system_gateways.php");
+ exit;
+ }
}
}
@@ -101,6 +125,7 @@ include("head.inc");
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
<form action="system_gateways.php" method="post">
<input type="hidden" name="y1" value="1">
<?php if ($savemsg) print_info_box($savemsg); ?>
diff --git a/usr/local/www/system_gateways_edit.php b/usr/local/www/system_gateways_edit.php
index 689397b..8872a48 100755
--- a/usr/local/www/system_gateways_edit.php
+++ b/usr/local/www/system_gateways_edit.php
@@ -149,7 +149,7 @@ if ($_POST) {
if (!$input_errors) {
$reloadif = false;
/* if we are processing a system gateway only save the monitorip */
- if(($_POST['attribute'] == "system" && empty($_POST['defaultgw'])) || (empty($_POST['interface']) && empty($_POST['gateway']) && empty($_POST['defaultgw']))) {
+ if($_POST['weight'] == 1 && (($_POST['attribute'] == "system" && empty($_POST['defaultgw'])) || (empty($_POST['interface']) && empty($_POST['gateway']) && empty($_POST['defaultgw'])))) {
if (is_ipaddr($_POST['monitor'])) {
if (empty($_POST['interface']))
$interface = $pconfig['friendlyiface'];
OpenPOWER on IntegriCloud