diff options
author | jim-p <jimp@pfsense.org> | 2017-04-04 08:34:30 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2017-04-04 08:34:30 -0400 |
commit | 24c7680a5a784ade23098d250711c6c7e7e81d2d (patch) | |
tree | d1e987cb0e4438d9c98e6b300dcd98597ec58bcd /src | |
parent | 7d039bc6138910a90da3c070d21cf93c7c4fbace (diff) | |
parent | e250fcab5c085db34e2d51fe4bd602ad7bc22b9e (diff) | |
download | pfsense-24c7680a5a784ade23098d250711c6c7e7e81d2d.zip pfsense-24c7680a5a784ade23098d250711c6c7e7e81d2d.tar.gz |
Merge pull request #3683 from luckman212/dhcprejectfrom-patch-1
Diffstat (limited to 'src')
-rw-r--r-- | src/etc/inc/interfaces.inc | 23 | ||||
-rwxr-xr-x | src/usr/local/www/interfaces.php | 7 |
2 files changed, 26 insertions, 4 deletions
diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 40e5c27..d50aab8 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -38,6 +38,27 @@ function interfaces_bring_up($interface) { } /* + * Validate comma-separated list of IPv4 addresses + */ +function validate_ipv4_list($value) { + $value = trim($value); + + if (empty($value)) { + return false; + } + + $list = explode(',', $value); + + foreach ($list as $ip) { + if (!is_ipaddrv4($ip)) { + return false; + } + } + + return true; +} + +/* * Return the interface array */ function get_interface_arr($flush = false) { @@ -4509,7 +4530,7 @@ initial-interval 1; script "/usr/local/sbin/pfSense-dhclient-script"; EOD; - if (is_ipaddrv4($wancfg['dhcprejectfrom'])) { + if (validate_ipv4_list($wancfg['dhcprejectfrom'])) { $dhclientconf .= <<<EOD reject {$wancfg['dhcprejectfrom']}; diff --git a/src/usr/local/www/interfaces.php b/src/usr/local/www/interfaces.php index fd9965b..d47df92 100755 --- a/src/usr/local/www/interfaces.php +++ b/src/usr/local/www/interfaces.php @@ -764,8 +764,8 @@ if ($_POST['apply']) { if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) { $input_errors[] = gettext("A valid alias subnet bit count must be specified."); } - if ($_POST['dhcprejectfrom'] && !is_ipaddrv4($_POST['dhcprejectfrom'])) { - $input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from."); + if ($_POST['dhcprejectfrom'] && !validate_ipv4_list($_POST['dhcprejectfrom'])) { + $input_errors[] = gettext("An invalid IP address was detected in the 'Reject leases from' field."); } if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) { $match = false; @@ -1965,7 +1965,8 @@ $section->addInput(new Form_Input( 'Reject leases from', 'text', $pconfig['dhcprejectfrom'] -))->setHelp('To make the DHCP client reject leases from an undesirable DHCP server, place the IP address of the DHCP server here. ' . +))->setHelp('To have the DHCP client reject offers from specific DHCP servers, enter their IP addresses here ' . + '(separate multiple entries with a comma). ' . 'This is useful for rejecting leases from cable modems that offer private IP addresses when they lose upstream sync.'); $group = new Form_Group('Protocol timing'); |