summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorRenato Botelho <renato.botelho@bluepex.com>2010-04-09 14:46:48 -0300
committerRenato Botelho <renato.botelho@bluepex.com>2010-04-09 14:46:48 -0300
commit673d29c002b54d8a415e604cd2b14f6bc4ec845f (patch)
tree6de699d2e36b027915878202eb9ae681101dc66e /usr
parent664742f78d25b4efec55f8011d2c14310dd7d264 (diff)
downloadpfsense-673d29c002b54d8a415e604cd2b14f6bc4ec845f.zip
pfsense-673d29c002b54d8a415e604cd2b14f6bc4ec845f.tar.gz
When delete a filter rule that is associated with a nat rule, cleanup the association
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/firewall_rules.php28
1 files changed, 22 insertions, 6 deletions
diff --git a/usr/local/www/firewall_rules.php b/usr/local/www/firewall_rules.php
index 57869da..24dfb2c 100755
--- a/usr/local/www/firewall_rules.php
+++ b/usr/local/www/firewall_rules.php
@@ -70,6 +70,16 @@ function check_for_advaned_options(&$item) {
return $item_set;
}
+function delete_nat_association(&$a_nat, $id) {
+ if (!$id || !is_array($a_nat))
+ return;
+
+ for ($pos = 0; $pos < sizeof($a_nat); $pos++) {
+ if ($a_nat[$pos]['associated-rule-id'] == $id)
+ $a_nat[$pos]['associated-rule-id'] = '';
+ }
+}
+
if (!is_array($config['filter']['rule'])) {
$config['filter']['rule'] = array();
}
@@ -135,19 +145,25 @@ if ($_POST) {
}
if ($_GET['act'] == "del") {
- if ($a_filter[$_GET['id']]) {
- unset($a_filter[$_GET['id']]);
- write_config();
+ if ($a_filter[$_GET['id']]) {
+ if (!empty($a_filter[$_GET['id']]['associated-rule-id'])) {
+ $a_nat = &$config['nat']['rule'];
+ delete_nat_association($a_nat, $a_filter[$_GET['id']]['associated-rule-id']);
+ }
+ unset($a_filter[$_GET['id']]);
+ write_config();
mark_subsystem_dirty('filter');
- header("Location: firewall_rules.php?if={$if}");
- exit;
- }
+ header("Location: firewall_rules.php?if={$if}");
+ exit;
+ }
}
if (isset($_POST['del_x'])) {
/* delete selected rules */
if (is_array($_POST['rule']) && count($_POST['rule'])) {
+ $a_nat = &$config['nat']['rule'];
foreach ($_POST['rule'] as $rulei) {
+ delete_nat_association($a_nat, $a_filter[$rulei]['associated-rule-id']);
unset($a_filter[$rulei]);
}
write_config();
OpenPOWER on IntegriCloud