summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2006-12-28 22:47:25 +0000
committerScott Ullrich <sullrich@pfsense.org>2006-12-28 22:47:25 +0000
commit9841743e44ab43bddd2c863f0d93aa1e27c4d476 (patch)
tree01588431d737b6facb31fb1f7b3bf2e14e88cdb2 /etc/inc
parent2d402242649f48e996680776011c23e9dd6e3baf (diff)
downloadpfsense-9841743e44ab43bddd2c863f0d93aa1e27c4d476.zip
pfsense-9841743e44ab43bddd2c863f0d93aa1e27c4d476.tar.gz
Renumber, assign and delete rules as needed.
Observed-by: Vacum via irc
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/pfsense-utils.inc42
1 files changed, 36 insertions, 6 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 80dcfa7..a320e8c 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -1640,23 +1640,53 @@ function sync_webgui_passwords() {
* none
******/
function cleanup_opt_interfaces_after_removal($opt_interface_num) {
- global $config;
+ /* move all the interfaces up. for example:
+ * opt1 --> opt1
+ * opt2 --> delete
+ * opt3 --> opt2
+ * opt4 --> opt3
+ */
+ global $g, $config;
config_lock();
conf_mount_rw();
- unlink_if_exists("/tmp/config.cache");
+ unlink_if_exists("{$g['tmp_path']}/config.cache");
$config_file = file_get_contents("/cf/conf/config.xml");
+ /* loop through and reassign deleted items */
+ for ($i = 500; isset ($config['interfaces']['opt' . $i]); $i--) {
+ if ($i < $opt_interface_num)
+ break;
+ if ($i == $opt_interface_num) {
+ /* item should be deleted */
+ str_replace("opt" . $i, "optXXXX", $config_file);
+ }
+ }
/* loop through and reassign optional items */
- for ($i = 255; isset($config['interfaces']['opt' . $i]); $i--) {
- if($i < $opt_interface_num)
+ for ($i = 500; isset ($config['interfaces']['opt' . $i]); $i--) {
+ if ($i < $opt_interface_num)
break;
/* replace opt$i with $i -1 */
- str_replace("opt" . $i, "opt" . ($i-1), $config_file);
+ str_replace("opt" . $i, "opt" . ($i -1), $config_file);
}
- conf_mount_rw();
$fd = fopen("/cf/conf/config.xml", "w");
fwrite($fd, $config_file);
fclose($fd);
$config = parse_config(true);
+ /* loop through and delete old rules */
+ $num_rules = array_count($config['filter']['rule']);
+ for($x = $num_rules; $x > 0; $x--) {
+ if($config['filter']['rule'][$x]['interface'] == "optXXXX")
+ unset($config['filter']['rule'][$x]['interface']);
+ }
+ $num_rules = array_count($config['nat']['advancedoutbound']['rule']);
+ for($x = $num_rules; $x > 0; $x--) {
+ if($config['nat']['advancedoutbound']['rule'][$x]['interface'] == "optXXXX")
+ unset($config['nat']['advancedoutbound']['rule'][$x]['interface']);
+ }
+ $num_rules = array_count($config['nat']['rule']);
+ for($x = $num_rules; $x > 0; $x--) {
+ if($config['nat']['rule'][$x]['interface'] == "optXXXX")
+ unset($config['nat']['rule'][$x]['interface']);
+ }
conf_mount_ro();
config_unlock();
return true;
OpenPOWER on IntegriCloud