summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2016-12-06 10:38:33 +0545
committerRenato Botelho <renato@netgate.com>2016-12-06 10:10:41 -0200
commitcdcce1c44f77a76a4e8dc79eb430e385af487ac3 (patch)
tree90ebfad367fc36ede66584222105c4e8c5ad9245
parent74213edf66d656b23724f3e779409533d8a77f59 (diff)
downloadpfsense-cdcce1c44f77a76a4e8dc79eb430e385af487ac3.zip
pfsense-cdcce1c44f77a76a4e8dc79eb430e385af487ac3.tar.gz
Tidy input errors in services_ntpd_acls
1) If there are multiple rows with invalid IP addresses then the same message was displayed multiple times. We might as well let the use know which row(s) have the problem. 2) The section that checks is_subnet stuff was first using is_ipaddr() (redundantly given it is already in the else of !is_ipaddr() ), and then is_subnet() - these would have handled both the IPv4 and IPv6 cases, so the other IPv6 tests would never have happened. 3) I don't think we need to test function_exists("is_ipaddrv6") any more - it had better be there in master! Note: The front-end JS prevents entry of an invalid mask, so it is a bit hard for the user to actually generate the netmask error messages. (cherry picked from commit 7c7d360534c4aa6c88021247f1dc0b61d5816071)
-rw-r--r--src/usr/local/www/services_ntpd_acls.php19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/usr/local/www/services_ntpd_acls.php b/src/usr/local/www/services_ntpd_acls.php
index 11c4cc3..a1a5a93 100644
--- a/src/usr/local/www/services_ntpd_acls.php
+++ b/src/usr/local/www/services_ntpd_acls.php
@@ -70,7 +70,7 @@ if (!is_array($config['ntpd'])) {
if (is_array($config['ntpd']['restrictions']) && is_array($config['ntpd']['restrictions']['row'])) {
$networkacl = $config['ntpd']['restrictions']['row'];
-} else {
+} else {
$networkacl = array('0' => array('acl_network' => '', 'mask' => ''));
}
@@ -121,19 +121,14 @@ if ($_POST) {
if (isset($networkacl[$x]['notrap']) || isset($networkacl[$x]['kod']) || isset($networkacl[$x]['nomodify'])
|| isset($networkacl[$x]['noquery']) || isset($networkacl[$x]['nopeer']) || isset($networkacl[$x]['noserve'])) {
if (!is_ipaddr($networkacl[$x]['acl_network'])) {
- $input_errors[] = gettext("A valid IP address must be entered for each row under Networks.");
+ $input_errors[] = sprintf(gettext("A valid IP address must be entered for row %s under Networks."), $networkacl[$x]['acl_network']);
} else {
-
- if (is_ipaddr($networkacl[$x]['acl_network'])) {
- if (!is_subnet($networkacl[$x]['acl_network']."/".$networkacl[$x]['mask'])) {
- $input_errors[] = gettext("A valid IPv4 netmask must be entered for each IPv4 row under Networks.");
- }
- } else if (function_exists("is_ipaddrv6")) {
- if (!is_ipaddrv6($networkacl[$x]['acl_network'])) {
- $input_errors[] = gettext("A valid IPv6 address must be entered for {$networkacl[$x]['acl_network']}.");
- } else if (!is_subnetv6($networkacl[$x]['acl_network']."/".$networkacl[$x]['mask'])) {
- $input_errors[] = gettext("A valid IPv6 netmask must be entered for each IPv6 row under Networks.");
+ if (is_ipaddrv4($networkacl[$x]['acl_network'])) {
+ if (!is_subnetv4($networkacl[$x]['acl_network']."/".$networkacl[$x]['mask'])) {
+ $input_errors[] = sprintf(gettext("A valid IPv4 netmask must be entered for IPv4 row %s under Networks."), $networkacl[$x]['acl_network']);
}
+ } else if (!is_subnetv6($networkacl[$x]['acl_network']."/".$networkacl[$x]['mask'])) {
+ $input_errors[] = sprintf(gettext("A valid IPv6 netmask must be entered for IPv6 row %s under Networks."), $networkacl[$x]['acl_network']);
}
}
}
OpenPOWER on IntegriCloud