From f8bf3fe860c63b0a4f02093fe15e2874f8e52156 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 18 Jan 2016 22:03:53 +0545 Subject: Fix #5778 do not save changes if interface description matches an alias name See https://redmine.pfsense.org/issues/5778 for details of how to reproduce the problem. Note that similar code to make the "Sorry, an alias with the name XXX already exists" message is also at the top of interfaces.inc - it compares the current interface descr from the config with the currently existing alias names. That check would help warn the user if someone managed to add an alias name that matched the interface name. I guess it was there from some time in the past when the alias edit code did not cross-validate the alias name with the interface descriptions. I have left that check there - it does no harm to have it "just in case". The new code that I added checks the proposed interface description in $_POST against the existing alias names and will give an input_error if there is a match. --- src/usr/local/www/interfaces.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/usr/local/www/interfaces.php b/src/usr/local/www/interfaces.php index 0d82dd5..f25bbeb 100644 --- a/src/usr/local/www/interfaces.php +++ b/src/usr/local/www/interfaces.php @@ -540,6 +540,16 @@ if ($_POST['apply']) { break; } } + + /* Is the description already used as an alias name? */ + if (is_array($config['aliases']['alias'])) { + foreach ($config['aliases']['alias'] as $alias) { + if ($alias['name'] == $_POST['descr']) { + $input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."), $_POST['descr']); + } + } + } + if (is_numeric($_POST['descr'])) { $input_errors[] = gettext("The interface description cannot contain only numbers."); } -- cgit v1.1 From 7d5b2133856a2e4530b09689331f79ce938a24c3 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 18 Jan 2016 22:20:13 +0545 Subject: Use current interface description for breadcrumb If you enter invalid stuff in the interface description - e.g. "123" - and press save, then you get a warning about it, but the breadcrumb changes to "Interfaces: 123" - the wrongly entered description (that was not applied). If you enter a valid string for 'descr' then by this point $wancfg has the new value anyway and so the breadcrumb will change correctly if you make a valid entry in 'descr' and save. --- src/usr/local/www/interfaces.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/usr/local/www/interfaces.php b/src/usr/local/www/interfaces.php index f25bbeb..3a7e85c 100644 --- a/src/usr/local/www/interfaces.php +++ b/src/usr/local/www/interfaces.php @@ -1640,7 +1640,7 @@ foreach ($mediaopts as $mediaopt) { } } -$pgtitle = array(gettext("Interfaces"), $pconfig['descr']); +$pgtitle = array(gettext("Interfaces"), $wancfg['descr']); $shortcut_section = "interfaces"; $types4 = array("none" => gettext("None"), "staticv4" => gettext("Static IPv4"), "dhcp" => gettext("DHCP"), "ppp" => gettext("PPP"), "pppoe" => gettext("PPPoE"), "pptp" => gettext("PPTP"), "l2tp" => gettext("L2TP")); -- cgit v1.1