summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2016-08-17 00:23:42 +0930
committerRenato Botelho <renato@netgate.com>2016-08-29 15:05:00 -0300
commitdc13f5e06bcbb02c8f929caecf1acdc28c126bb4 (patch)
treef5a35e251cd0c167286925dd106189c518221d54 /src
parent959f2bb89f536b6d4bc4859cd81cb4fe0eed3d4d (diff)
downloadpfsense-dc13f5e06bcbb02c8f929caecf1acdc28c126bb4.zip
pfsense-dc13f5e06bcbb02c8f929caecf1acdc28c126bb4.tar.gz
Fix #6720 DHCP options by pool
It is a little bit tricky having to generate the unique "option custom-if-n-m code ..." lines at first where n = pool index and m = item index in the items of the pool. Then make sure to reference that later, getting the same pool index into the array of pools. The $all_pools array as the "overall" or "base" pool first (at index 0), followed by the user-specified pools at index 1, 2, 3,... - which are actually at indexes 0, 1, 2,... in the ordinary array of pools in the config. So the -1 at line 910 has to happen. But it works for me. (cherry picked from commit 285987208f31f38abe35b984b08645d43c11b001)
Diffstat (limited to 'src')
-rw-r--r--src/etc/inc/services.inc33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc
index 3a907e8..889b2cf 100644
--- a/src/etc/inc/services.inc
+++ b/src/etc/inc/services.inc
@@ -548,6 +548,20 @@ function services_dhcpdv4_configure() {
$custoptions .= "option custom-{$dhcpif}-{$itemidx} code {$item['number']} = {$itemtype};\n";
}
}
+ if (is_array($dhcpifconf['pool'])) {
+ foreach ($dhcpifconf['pool'] as $poolidx => $poolconf) {
+ if (is_array($poolconf['numberoptions']) && is_array($poolconf['numberoptions']['item'])) {
+ foreach ($poolconf['numberoptions']['item'] as $itemidx => $item) {
+ if (!empty($item['type'])) {
+ $itemtype = $item['type'];
+ } else {
+ $itemtype = "text";
+ }
+ $custoptions .= "option custom-{$dhcpif}-{$poolidx}-{$itemidx} code {$item['number']} = {$itemtype};\n";
+ }
+ }
+ }
+ }
}
$dhcpdconf = <<<EOD
@@ -786,7 +800,7 @@ EOPP;
$dhcpdconf .= "subnet {$subnet} netmask {$subnetmask} {\n";
// Setup pool options
- foreach ($all_pools as $poolconf) {
+ foreach ($all_pools as $all_pools_idx => $poolconf) {
if (!(ip_in_subnet($poolconf['range']['from'], "{$subnet}/{$ifcfgsn}") && ip_in_subnet($poolconf['range']['to'], "{$subnet}/{$ifcfgsn}"))) {
// If the user has changed the subnet from the interfaces page and applied,
// but has not updated the DHCP range, then the range to/from of the pool can be outside the subnet.
@@ -916,6 +930,23 @@ EOPP;
$dhcpdconf .= " option tftp-server-name \"{$poolconf['tftp']}\";\n";
}
+ // Handle pool-specific options
+ $dhcpdconf .= "\n";
+ // Ignore the first pool, which is the "overall" pool when $all_pools_idx is 0 - those are put outside the pool block later
+ if ($poolconf['numberoptions']['item'] && ($all_pools_idx > 0)) {
+ // Use the "real" pool index from the config, excluding the "overall" pool, and based from 0.
+ // This matches the way $poolidx was used when generating the $custoptions string earlier.
+ $poolidx = $all_pools_idx - 1;
+ foreach ($poolconf['numberoptions']['item'] as $itemidx => $item) {
+ $item_value = base64_decode($item['value']);
+ if (empty($item['type']) || $item['type'] == "text") {
+ $dhcpdconf .= " option custom-{$dhcpif}-{$poolidx}-{$itemidx} \"{$item_value}\";\n";
+ } else {
+ $dhcpdconf .= " option custom-{$dhcpif}-{$poolidx}-{$itemidx} {$item_value};\n";
+ }
+ }
+ }
+
// ldap-server
if (!empty($poolconf['ldap']) && ($poolconf['ldap'] != $dhcpifconf['ldap'])) {
$dhcpdconf .= " option ldap-server \"{$poolconf['ldap']}\";\n";
OpenPOWER on IntegriCloud