summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2016-08-17 00:23:42 +0930
committerGitHub <noreply@github.com>2016-08-17 00:23:42 +0930
commit285987208f31f38abe35b984b08645d43c11b001 (patch)
tree8eab3e6f6d47c91253d61d518c478fcd6adf6d6a /src
parentea8e683a311869b78a4f85851977365a84621a46 (diff)
downloadpfsense-285987208f31f38abe35b984b08645d43c11b001.zip
pfsense-285987208f31f38abe35b984b08645d43c11b001.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.
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 542ccc7..a4726e2 100644
--- a/src/etc/inc/services.inc
+++ b/src/etc/inc/services.inc
@@ -516,6 +516,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
@@ -754,7 +768,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.
@@ -887,6 +901,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