]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#86,!152] Case insensitive hostname option comparison.
authorMarcin Siodelski <marcin@isc.org>
Tue, 4 Dec 2018 09:10:30 +0000 (10:10 +0100)
committerMarcin Siodelski <marcin@isc.org>
Tue, 4 Dec 2018 09:10:30 +0000 (10:10 +0100)
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/tests/fqdn_unittest.cc

index 7aa26f2faf953109fed8649d28d767db479e5d33..d619f7c95c4a99cc3234dbdf75a26c68899bfdd6 100644 (file)
@@ -62,7 +62,7 @@
 #endif
 #include <dhcpsrv/memfile_lease_mgr.h>
 
-#include <boost/algorithm/string/join.hpp>
+#include <boost/algorithm/string.hpp>
 #include <boost/bind.hpp>
 #include <boost/foreach.hpp>
 #include <boost/pointer_cast.hpp>
@@ -1721,9 +1721,12 @@ Dhcpv4Srv::processHostnameOption(Dhcpv4Exchange& ex) {
         // send back a hostname option, send this option with a reserved
         // name for this client.
         if (should_send_hostname) {
-            const std::string& hostname =
-                d2_mgr.qualifyName(ctx->currentHost()->getHostname(),
-                                                             false);
+            std::string hostname =
+                d2_mgr.qualifyName(ctx->currentHost()->getHostname(), false);
+
+            // Convert hostname to lower case.
+            boost::algorithm::to_lower(hostname);
+
             LOG_DEBUG(ddns4_logger, DBG_DHCP4_DETAIL_DATA,
                       DHCP4_RESERVED_HOSTNAME_ASSIGNED)
                 .arg(ex.getQuery()->getLabel())
@@ -1813,6 +1816,9 @@ Dhcpv4Srv::processHostnameOption(Dhcpv4Exchange& ex) {
             hostname = sanitizer->scrub(hostname);
         }
 
+        // Convert hostname to lower case.
+        boost::algorithm::to_lower(hostname);
+
         if (label_count == 2) {
             // If there are two labels, it means that the client has specified
             // the unqualified name. We have to concatenate the unqualified name
index f5c0c510cefc0993313fdbeaf077ed3c51dea423..575020ea2118a5c9b27268cac38258bc3bd19125 100644 (file)
@@ -1070,7 +1070,8 @@ TEST_F(NameDhcpv4SrvTest, processTwoRequestsHostname) {
     IfaceMgrTestConfig test_config(true);
     IfaceMgr::instance().openSockets4();
 
-    Pkt4Ptr req1 = generatePktWithHostname(DHCPREQUEST, "myhost.example.com.");
+    // Case in a hostname should be ignored.
+    Pkt4Ptr req1 = generatePktWithHostname(DHCPREQUEST, "Myhost.Example.Com.");
 
     // Set interface for the incoming packet. The server requires it to
     // generate client id.
@@ -1145,11 +1146,11 @@ TEST_F(NameDhcpv4SrvTest, processRequestRenewFqdn) {
                             "965B68B6D438D98E680BF10B09F3BCF",
                             time(NULL), subnet_->getValid(), true);
 
-    // Create another Request message with the same FQDN. Server
-    // should generate no NameChangeRequests.
+    // Create another Request message with the same FQDN. Case changes in the
+    // hostname should be ignored. Server should generate no NameChangeRequests.
     Pkt4Ptr req2 = generatePktWithFqdn(DHCPREQUEST, Option4ClientFqdn::FLAG_S |
                                        Option4ClientFqdn::FLAG_E,
-                                       "myhost.example.com.",
+                                       "Myhost.Example.Com.",
                                        Option4ClientFqdn::FULL, true);
 
     ASSERT_NO_THROW(reply = srv_->processRequest(req2));
@@ -1186,9 +1187,9 @@ TEST_F(NameDhcpv4SrvTest, processRequestRenewHostname) {
                             "965B68B6D438D98E680BF10B09F3BCF",
                             time(NULL), subnet_->getValid(), true);
 
-    // Create another Request message with the same Hostname. Server
-    // should generate no NameChangeRequests.
-    Pkt4Ptr req2 = generatePktWithHostname(DHCPREQUEST, "myhost.example.com.");
+    // Create another Request message with the same Hostname. Case changes in the
+    // hostname should be ignored. Server should generate no NameChangeRequests.
+    Pkt4Ptr req2 = generatePktWithHostname(DHCPREQUEST, "Myhost.Example.Com.");
 
     // Set interface for the incoming packet. The server requires it to
     // generate client id.