diff options
author | Phil Davis <phil.davis@inf.org> | 2017-01-22 18:15:08 +0545 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-01-24 10:24:09 -0200 |
commit | 318f514f510ccf05e2645b8375e6852c8be64f75 (patch) | |
tree | 3be24b13d8f7347224f1e14a63fb30eaa9a05249 /src/usr | |
parent | 99a90e92277e750a2683535151f25cc19c119004 (diff) | |
download | pfsense-318f514f510ccf05e2645b8375e6852c8be64f75.zip pfsense-318f514f510ccf05e2645b8375e6852c8be64f75.tar.gz |
Interface description should be required
I was blanking out stuff to see what input error messages came about fields that are required. I was surprised that the Interface Description would save empty. The system did not immediately explode (I was playing with a bonus interface I had created in a VM) but I don't think it is desirable to have interfaces with no description.
The change here also only does the other checks on the description if it has actualy been entered - no point checking a whole lot of other dependent stuff if the description is not even entered.
(cherry picked from commit f57a3d9051f904f7b915db0bc0b64849503f8647)
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/local/www/interfaces.php | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/src/usr/local/www/interfaces.php b/src/usr/local/www/interfaces.php index 24192d3..fafc0b9 100644 --- a/src/usr/local/www/interfaces.php +++ b/src/usr/local/www/interfaces.php @@ -518,36 +518,43 @@ if ($_POST['apply']) { unset($_POST['pppoe_resetdate']); unset($_POST['pppoe_pr_preset_val']); } - /* description unique? */ - foreach ($ifdescrs as $ifent => $ifdescr) { - if ($if != $ifent && (strcasecmp($ifdescr, $_POST['descr']) == 0)) { - $input_errors[] = gettext("An interface with the specified description already exists."); - break; + /* input validation */ + $reqdfields = explode(" ", "descr"); + $reqdfieldsn = array(gettext("Description")); + do_input_validation($_REQUEST, $reqdfields, $reqdfieldsn, $input_errors); + + if (!$input_errors) { + /* description unique? */ + foreach ($ifdescrs as $ifent => $ifdescr) { + if ($if != $ifent && (strcasecmp($ifdescr, $_POST['descr']) == 0)) { + $input_errors[] = gettext("An interface with the specified description already exists."); + break; + } } - } - /* Is the description already used as an alias name? */ - if (is_array($config['aliases']['alias'])) { - foreach ($config['aliases']['alias'] as $alias) { - if (strcasecmp($alias['name'], $_POST['descr']) == 0) { - $input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."), $_POST['descr']); + /* Is the description already used as an alias name? */ + if (is_array($config['aliases']['alias'])) { + foreach ($config['aliases']['alias'] as $alias) { + if (strcasecmp($alias['name'], $_POST['descr']) == 0) { + $input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."), $_POST['descr']); + } } } - } - /* Is the description already used as an interface group name? */ - if (is_array($config['ifgroups']['ifgroupentry'])) { - foreach ($config['ifgroups']['ifgroupentry'] as $ifgroupentry) { - if (strcasecmp($ifgroupentry['ifname'], $_POST['descr']) == 0) { - $input_errors[] = sprintf(gettext("Sorry, an interface group with the name %s already exists."), $wancfg['descr']); + /* Is the description already used as an interface group name? */ + if (is_array($config['ifgroups']['ifgroupentry'])) { + foreach ($config['ifgroups']['ifgroupentry'] as $ifgroupentry) { + if (strcasecmp($ifgroupentry['ifname'], $_POST['descr']) == 0) { + $input_errors[] = sprintf(gettext("Sorry, an interface group with the name %s already exists."), $wancfg['descr']); + } } } - } - if (is_numeric($_POST['descr'])) { - $input_errors[] = gettext("The interface description cannot contain only numbers."); + if (is_numeric($_POST['descr'])) { + $input_errors[] = gettext("The interface description cannot contain only numbers."); + } } - /* input validation */ + if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable'])) { if (!preg_match("/^staticv4/", $_POST['type'])) { $input_errors[] = gettext("The DHCP Server is active " . |