diff options
author | sullrich <sullrich@pfsense.org> | 2009-09-21 11:33:14 -0400 |
---|---|---|
committer | sullrich <sullrich@pfsense.org> | 2009-09-21 11:33:14 -0400 |
commit | bca2d8ad649027f80aa5fb6e3d4b06b2f9e93f08 (patch) | |
tree | 2737fec3bdc87d558414886d844beda89dfecad9 | |
parent | 09be0c7611a0ba5b594324a943659e467d757a52 (diff) | |
download | pfsense-bca2d8ad649027f80aa5fb6e3d4b06b2f9e93f08.zip pfsense-bca2d8ad649027f80aa5fb6e3d4b06b2f9e93f08.tar.gz |
Check for interfaces with same name as alias. Ticket #92
-rw-r--r-- | etc/inc/pfsense-utils.inc | 30 | ||||
-rwxr-xr-x | usr/local/www/diag_backup.php | 18 |
2 files changed, 48 insertions, 0 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 497fcd2..889575c 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -3870,5 +3870,35 @@ function is_fqdn($fqdn) { return($hostname); } +function update_alias_names_upon_change($section, $subsection, $fielda, $fieldb, $new_alias_name) { + global $g, $config, $pconfig, $origname, $debug; + if(!$origname) + return; + + if($debug) $fd = fopen("{$g['tmp_path']}/print_r", "a"); + if($debug) fwrite($fd, print_r($pconfig, true)); + + if($fieldb) { + if($debug) fwrite($fd, "fieldb exists\n"); + for ($i = 0; isset($config["$section"]["$subsection"][$i]["$fielda"]); $i++) { + if($debug) fwrite($fd, "$i\n"); + if($config["$section"]["$subsection"][$i]["$fielda"]["$fieldb"] == $origname) { + if($debug) fwrite($fd, "Setting old alias value $origname to $new_alias_name\n"); + $config["$section"]["$subsection"][$i]["$fielda"]["$fieldb"] = $new_alias_name; + } + } + } else { + if($debug) fwrite($fd, "fieldb does not exist\n"); + for ($i = 0; isset($config["$section"]["$subsection"][$i]["$fielda"]); $i++) { + if($config["$section"]["$subsection"][$i]["$fielda"] == $origname) { + $config["$section"]["$subsection"][$i]["$fielda"] = $new_alias_name; + if($debug) fwrite($fd, "Setting old alias value $origname to $new_alias_name\n"); + } + } + } + + if($debug) fclose($fd); + +} ?>
\ No newline at end of file diff --git a/usr/local/www/diag_backup.php b/usr/local/www/diag_backup.php index 4d63e55..88fdeea 100755 --- a/usr/local/www/diag_backup.php +++ b/usr/local/www/diag_backup.php @@ -204,6 +204,24 @@ if ($_POST) { if(is_array($ifdescrs)) foreach($ifdescrs as $iface) $config['interfaces'][$iface]['descr'] = remove_bad_chars($config['interfaces'][$iface]['descr']); + /* check for interface names with an alias */ + if(is_array($ifdescrs)) { + foreach($ifdescrs as $iface) { + if(is_alias($config['interfaces'][$iface]['descr'])) { + // Firewall rules + $origname = $config['interfaces'][$iface]['descr']; + $newname = $config['interfaces'][$iface]['descr'] . "Alias"; + update_alias_names_upon_change('filter', 'rule', 'source', 'address', $newname); + update_alias_names_upon_change('filter', 'rule', 'destination', 'address', $newname); + // NAT Rules + update_alias_names_upon_change('nat', 'rule', 'target', '', $newname); + update_alias_names_upon_change('nat', 'rule', 'external-port', '', $newname); + update_alias_names_upon_change('nat', 'rule', 'local-port', '', $newname); + // Alias in an alias + update_alias_names_upon_change('aliases', 'alias', 'address', '', $newname); + } + } + } unlink_if_exists("/tmp/config.cache"); write_config(); add_base_packages_menu_items(); |