diff options
author | Renato Botelho <renato@netgate.com> | 2016-01-15 14:07:55 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-01-15 14:08:10 -0200 |
commit | 65cce9d728449da1c5243629b25ab3307acfff82 (patch) | |
tree | d6bac1dc070667c7f14a946563a00c68732787cd /src | |
parent | c3f962bab940051e9e3d0fd93f981c1ff8fd0cc2 (diff) | |
download | pfsense-65cce9d728449da1c5243629b25ab3307acfff82.zip pfsense-65cce9d728449da1c5243629b25ab3307acfff82.tar.gz |
Encode DHCP/DHCPv6 server additional BOOTP text options before save to XML to preserve data. It fixes #5623
Diffstat (limited to 'src')
-rw-r--r-- | src/etc/inc/globals.inc | 2 | ||||
-rw-r--r-- | src/etc/inc/services.inc | 8 | ||||
-rw-r--r-- | src/etc/inc/upgrade_config.inc | 29 | ||||
-rw-r--r-- | src/usr/local/www/services_dhcp.php | 4 | ||||
-rw-r--r-- | src/usr/local/www/services_dhcpv6.php | 4 |
5 files changed, 39 insertions, 8 deletions
diff --git a/src/etc/inc/globals.inc b/src/etc/inc/globals.inc index d0e0fd5..946cfe6 100644 --- a/src/etc/inc/globals.inc +++ b/src/etc/inc/globals.inc @@ -99,7 +99,7 @@ $g = array( "disablecrashreporter" => false, "crashreporterurl" => "https://crashreporter.pfsense.org/crash_reporter.php", "debug" => false, - "latest_config" => "13.6", + "latest_config" => "13.7", "nopkg_platforms" => array("cdrom"), "minimum_ram_warning" => "101", "minimum_ram_warning_text" => "128 MB", diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index 4945e8a..2ad38b2 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -958,10 +958,11 @@ EOD; $dhcpdconf .= "\n"; if ($dhcpifconf['numberoptions']['item']) { foreach ($dhcpifconf['numberoptions']['item'] as $itemidx => $item) { + $item_value = base64_decode($item['value']); if (empty($item['type']) || $item['type'] == "text") { - $dhcpdconf .= " option custom-{$dhcpif}-{$itemidx} \"{$item['value']}\";\n"; + $dhcpdconf .= " option custom-{$dhcpif}-{$itemidx} \"{$item_value}\";\n"; } else { - $dhcpdconf .= " option custom-{$dhcpif}-{$itemidx} {$item['value']};\n"; + $dhcpdconf .= " option custom-{$dhcpif}-{$itemidx} {$item_value};\n"; } } } @@ -1462,7 +1463,8 @@ EOD; $dhcpdv6conf .= "\n"; if ($dhcpv6ifconf['numberoptions']['item']) { foreach ($dhcpv6ifconf['numberoptions']['item'] as $itemv6idx => $itemv6) { - $dhcpdv6conf .= " option custom-{$dhcpv6if}-{$itemv6idx} \"{$itemv6['value']}\";\n"; + $itemv6_value = base64_decode($itemv6['value']); + $dhcpdv6conf .= " option custom-{$dhcpv6if}-{$itemv6idx} \"{$itemv6_value}\";\n"; } } diff --git a/src/etc/inc/upgrade_config.inc b/src/etc/inc/upgrade_config.inc index aa3ec70..dedab7c 100644 --- a/src/etc/inc/upgrade_config.inc +++ b/src/etc/inc/upgrade_config.inc @@ -4285,4 +4285,33 @@ function upgrade_135_to_136() { } } } + +function upgrade_136_to_137() { + global $config; + + if (is_array($config['dhcpd'])) { + foreach ($config['dhcpd'] as &$dhcpd) { + if (!is_array($dhcpd['numberoptions']['item'])) { + continue; + } + + foreach ($dhcpd['numberoptions']['item'] as &$item) { + $item['value'] = base64_encode($item['value']); + } + } + } + + if (is_array($config['dhcpdv6'])) { + foreach ($config['dhcpdv6'] as &$dhcpdv6) { + if (!is_array($dhcpdv6['numberoptions']['item'])) { + continue; + } + + foreach ($dhcpdv6['numberoptions']['item'] as &$item) { + $item['value'] = base64_encode($item['value']); + } + } + } +} + ?> diff --git a/src/usr/local/www/services_dhcp.php b/src/usr/local/www/services_dhcp.php index 4650051..d13305c 100644 --- a/src/usr/local/www/services_dhcp.php +++ b/src/usr/local/www/services_dhcp.php @@ -230,7 +230,7 @@ if (isset($_POST['submit'])) { $numbervalue = array(); $numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]); $numbervalue['type'] = htmlspecialchars($_POST["itemtype{$x}"]); - $numbervalue['value'] = str_replace('"', '"', htmlspecialchars($_POST["value{$x}"])); + $numbervalue['value'] = base64_encode($_POST["value{$x}"]); $numberoptions['item'][] = $numbervalue; } } @@ -1200,7 +1200,7 @@ $numrows = count($pconfig['numberoptions']['item']) -1; foreach ($pconfig['numberoptions']['item'] as $item) { $number = $item['number']; $itemtype = $item['type']; - $value = $item['value']; + $value = base64_decode($item['value']); $group = new Form_Group(($counter == 0) ? 'Option':null); $group->addClass('repeatable'); diff --git a/src/usr/local/www/services_dhcpv6.php b/src/usr/local/www/services_dhcpv6.php index dc58ba2..f455a9c 100644 --- a/src/usr/local/www/services_dhcpv6.php +++ b/src/usr/local/www/services_dhcpv6.php @@ -180,7 +180,7 @@ if ($_POST) { if (isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) { $numbervalue = array(); $numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]); - $numbervalue['value'] = htmlspecialchars($_POST["value{$x}"]); + $numbervalue['value'] = base64_encode($_POST["value{$x}"]); $numberoptions['item'][] = $numbervalue; } } @@ -852,7 +852,7 @@ if ($pconfig['numberoptions']) { 'value' . $counter, null, 'text', - $item['value'] + base64_decode($item['value']) ))->setHelp($counter == $last ? 'Value':null); $btn = new Form_Button( |