summaryrefslogtreecommitdiffstats
path: root/usr/local/www/system_gateways_edit.php
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-07-05 23:18:04 +0545
committerPhil Davis <phil.davis@inf.org>2015-07-05 23:18:04 +0545
commit028ff8f8a3d7c09ee5604d6f3eadcdaaef1610c7 (patch)
tree72779176aa19f00e7019e1fd84ce2e86e535f9b0 /usr/local/www/system_gateways_edit.php
parent5af646023e447cb386a2bcbeb2900985adce2321 (diff)
downloadpfsense-028ff8f8a3d7c09ee5604d6f3eadcdaaef1610c7.zip
pfsense-028ff8f8a3d7c09ee5604d6f3eadcdaaef1610c7.tar.gz
Fix #4813 validation of enable/disable of gateways and static routes
1) A disabled gateway can always be enabled - no extra validation needed. 2) When disabling an enabled gateway, check to see that the gateway is not used in any gateway group or enabled static route (similar tests to what is already checked before deleting a gateway). 3) A static route can always be disabled - no extra checks needed. 4) When enabling a static route, check that the selected gateway is enabled - you cannot have a static route enabled on a disabled gateway. 5) Do the address family cross-check between static route and gateway even when the static route is disabled - we do not want to save mismatched IP address families in any case. This covers all the cases I can see to ensure that the enable/disable status combinations of Gateways and Static Routes is always valid.
Diffstat (limited to 'usr/local/www/system_gateways_edit.php')
-rw-r--r--usr/local/www/system_gateways_edit.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/usr/local/www/system_gateways_edit.php b/usr/local/www/system_gateways_edit.php
index 483e102..b80b2bf 100644
--- a/usr/local/www/system_gateways_edit.php
+++ b/usr/local/www/system_gateways_edit.php
@@ -126,6 +126,33 @@ if ($_POST) {
}
if (!is_validaliasname($_POST['name'])) {
$input_errors[] = gettext("The gateway name must not contain invalid characters.");
+ } else {
+ if (isset($_POST['disabled'])) {
+ // We have a valid gateway name that the user wants to mark as disabled.
+ // Check if the gateway name is used in any gateway group.
+ if (is_array($config['gateways']['gateway_group'])) {
+ foreach ($config['gateways']['gateway_group'] as $group) {
+ foreach ($group['item'] as $item) {
+ $items = explode("|", $item);
+ if ($items[0] == $_POST['name']) {
+ $input_errors[] = sprintf(gettext("Gateway '%s' cannot be disabled because it is in use on Gateway Group '%s'"), $_POST['name'], $group['name']);
+ }
+ }
+ }
+ }
+
+ // Check if the gateway name is used in any enabled Static Route.
+ if (is_array($config['staticroutes']['route'])) {
+ foreach ($config['staticroutes']['route'] as $route) {
+ if ($route['gateway'] == $_POST['name']) {
+ if (!isset($route['disabled'])) {
+ // There is a static route that uses this gateway and is enabled (not disabled).
+ $input_errors[] = sprintf(gettext("Gateway '%s' cannot be disabled because it is in use on Static Route '%s'"), $_POST['name'], $route['network']);
+ }
+ }
+ }
+ }
+ }
}
/* skip system gateways which have been automatically added */
if (($_POST['gateway'] && (!is_ipaddr($_POST['gateway'])) && ($_POST['attribute'] !== "system")) && ($_POST['gateway'] != "dynamic")) {
OpenPOWER on IntegriCloud