Fix #3268 - avoid pf table names conflict:

. Create a list of reserved table names for the hardcoded ones
. Use this list to validate aliases and load balance pool names
. Check if alias names don't conflict with LB pool names and vice-versa
This commit is contained in:
Renato Botelho 2013-10-16 09:16:00 -03:00
parent c858a03512
commit c48fdaa40e
3 changed files with 29 additions and 5 deletions

View File

@ -58,6 +58,18 @@ $filterdns = array();
/* Used for aliases and interface macros */
$aliases = "";
/* Reserved table names to avoid colision */
$reserved_table_names = array(
"bogons",
"bogonsv6",
"negate_networks",
"snort2c",
"sshlockout",
"tonatsubnets",
"virusprot",
"vpn_networks",
"webConfiguratorlockout");
function is_bogonsv6_used() {
global $config, $g;
# Only use bogonsv6 table if IPv6 Allow is on, and at least 1 enabled interface also has "blockbogons" enabled.

View File

@ -44,10 +44,6 @@
##|*MATCH=firewall_aliases_edit.php*
##|-PRIV
// Keywords not allowed in names
$reserved_keywords = array("all", "pass", "block", "out", "queue", "max", "min", "pptp", "pppoe", "L2TP", "OpenVPN", "IPsec");
require("guiconfig.inc");
require_once("functions.inc");
require_once("filter.inc");
@ -55,8 +51,16 @@ require_once("shaper.inc");
$pgtitle = array(gettext("Firewall"),gettext("Aliases"),gettext("Edit"));
// Keywords not allowed in names
$reserved_keywords = array("all", "pass", "block", "out", "queue", "max", "min", "pptp", "pppoe", "L2TP", "OpenVPN", "IPsec");
// Add all Load balance names to resrved_keywords
if (is_array($config['load_balancer']['lbpool']))
foreach ($config['load_balancer']['lbpool'] as $lbpool)
$reserved_keywords[] = $lbpool['name'];
$reserved_ifs = get_configured_interface_list(false, true);
$reserved_keywords = array_merge($reserved_keywords, $reserved_ifs);
$reserved_keywords = array_merge($reserved_keywords, $reserved_ifs, $reserved_table_names);
if (!is_array($config['aliases']['alias']))
$config['aliases']['alias'] = array();

View File

@ -40,6 +40,8 @@
##|-PRIV
require("guiconfig.inc");
require_once("filter.inc");
require_once("util.inc");
if (!is_array($config['load_balancer']['lbpool'])) {
$config['load_balancer']['lbpool'] = array();
@ -85,6 +87,12 @@ if ($_POST) {
if (strpos($_POST['name'], " ") !== false)
$input_errors[] = gettext("You cannot use spaces in the 'name' field.");
if (in_array($_POST['name'], $reserved_table_names))
$input_errors[] = sprintf(gettext("The name '%s' is a reserved word and cannot be used."), $_POST['name']);
if (is_alias($_POST['name']))
$input_errors[] = sprintf(gettext("Sorry, an alias is already named %s."), $_POST['name']);
if (!is_portoralias($_POST['port']))
$input_errors[] = gettext("The port must be an integer between 1 and 65535, or a port alias.");