mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
When delete a filter rule that is associated with a nat rule, cleanup the association
This commit is contained in:
parent
664742f78d
commit
673d29c002
@ -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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user