]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#86,!152] DHCPv4 server performs case insensitive comparison of FQDN.
authorMarcin Siodelski <marcin@isc.org>
Tue, 4 Dec 2018 08:48:28 +0000 (09:48 +0100)
committerMarcin Siodelski <marcin@isc.org>
Tue, 4 Dec 2018 08:48:28 +0000 (09:48 +0100)
src/bin/dhcp4/tests/fqdn_unittest.cc
src/lib/dhcpsrv/lease.cc
src/lib/dhcpsrv/lease.h
src/lib/dhcpsrv/tests/lease_unittest.cc

index 8246987db228b46f401c1372866ccd3448d4392f..f5c0c510cefc0993313fdbeaf077ed3c51dea423 100644 (file)
@@ -883,8 +883,11 @@ TEST_F(NameDhcpv4SrvTest, createNameChangeRequestsNewLease) {
 TEST_F(NameDhcpv4SrvTest, createNameChangeRequestsRenewNoChange) {
     Lease4Ptr lease = createLease(IOAddress("192.0.2.3"), "myhost.example.com.",
                                   true, true);
+    // Comparison should be case insensitive, so turning some of the
+    // characters of the old lease hostname to upper case should not
+    // trigger NCRs.
     Lease4Ptr old_lease = createLease(IOAddress("192.0.2.3"),
-                                      "myhost.example.com.", true, true);
+                                      "Myhost.Example.Com.", true, true);
     old_lease->valid_lft_ += 100;
 
     ASSERT_NO_THROW(srv_->createNameChangeRequests(lease, old_lease));
index 6b50a3858f8a94daa13675f81462616bbc271a5a..b6a05b23300d45631be9d090bcb59afcb69df213 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <dhcpsrv/lease.h>
 #include <util/pointer_util.h>
+#include <boost/algorithm/string.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <sstream>
 #include <iostream>
@@ -112,7 +113,7 @@ Lease::getExpirationTime() const {
 
 bool
 Lease::hasIdenticalFqdn(const Lease& other) const {
-    return (hostname_ == other.hostname_ &&
+    return (boost::algorithm::iequals(hostname_, other.hostname_) &&
             fqdn_fwd_ == other.fqdn_fwd_ &&
             fqdn_rev_ == other.fqdn_rev_);
 }
index c42cfc9a9e0fd06d7ef510b61276fac5b5287ec9..fbac2cf35c5e7cd17e7951a66c09208d7b9dbdc3 100644 (file)
@@ -188,6 +188,8 @@ struct Lease : public isc::data::UserContext, public isc::data::CfgToElement {
 
     /// @brief Returns true if the other lease has equal FQDN data.
     ///
+    /// The comparison of the hostname is case insensitive.
+    ///
     /// @param other Lease which FQDN data is to be compared with our lease.
     ///
     /// @return Boolean value which indicates whether FQDN data of the other
index 8b3bac04f263a8f63bb8586e8df86051f5abfa55..39858e23e2fcc75a77ce999c0c55b4aaba35285c 100644 (file)
@@ -453,6 +453,9 @@ TEST_F(Lease4Test, hasIdenticalFqdn) {
     Lease4 lease = createLease4("myhost.example.com.", true, true);
     EXPECT_TRUE(lease.hasIdenticalFqdn(createLease4("myhost.example.com.",
                                                      true, true)));
+    // Case insensitive comparison.
+    EXPECT_TRUE(lease.hasIdenticalFqdn(createLease4("myHOst.ExamplE.coM.",
+                                                     true, true)));
     EXPECT_FALSE(lease.hasIdenticalFqdn(createLease4("other.example.com.",
                                                      true, true)));
     EXPECT_FALSE(lease.hasIdenticalFqdn(createLease4("myhost.example.com.",
@@ -1032,6 +1035,9 @@ TEST(Lease6Test, hasIdenticalFqdn) {
     Lease6 lease = createLease6("myhost.example.com.", true, true);
     EXPECT_TRUE(lease.hasIdenticalFqdn(createLease6("myhost.example.com.",
                                                     true, true)));
+    // Case insensitive comparison.
+    EXPECT_TRUE(lease.hasIdenticalFqdn(createLease6("myHOst.ExamplE.coM.",
+                                                    true, true)));
     EXPECT_FALSE(lease.hasIdenticalFqdn(createLease6("other.example.com.",
                                                      true, true)));
     EXPECT_FALSE(lease.hasIdenticalFqdn(createLease6("myhost.example.com.",