]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1382] Set initial audit time to 2000-01-01
authorMarcin Siodelski <marcin@isc.org>
Mon, 17 Aug 2020 10:58:21 +0000 (12:58 +0200)
committerMarcin Siodelski <marcin@isc.org>
Mon, 17 Aug 2020 10:58:21 +0000 (12:58 +0200)
Modified the audit entry time from which initially incremental config
changes are fetched when the server boots up. Previously it was 1970-01-01,
however it caused issues for some MariaDB versions. MariaDB can only use
timestamps later than 1970-01-01 UTC.

src/lib/process/cb_ctl_base.h
src/lib/process/tests/cb_ctl_base_unittests.cc

index 456cb9dd740472c1b34fb3d70885960b6ebe4eaf..eb820b7294acf9d1ebf79141419e5471698ce543 100644 (file)
@@ -92,7 +92,7 @@ public:
 
     /// @brief Constructor.
     ///
-    /// Sets the time of the last fetched audit entry to Jan 1st, 1970,
+    /// Sets the time of the last fetched audit entry to Jan 1st, 2000,
     /// with id 0.
     CBControlBase()
         : last_audit_revision_time_(getInitialAuditRevisionTime()),
@@ -316,10 +316,10 @@ protected:
     /// @brief Convenience method returning initial timestamp to set the
     /// @c last_audit_revision_time_ to.
     ///
-    /// @return Returns 1970-Jan-01 00:00:00 in local time.
+    /// @return Returns 2000-Jan-01 00:00:00 in local time.
     static boost::posix_time::ptime getInitialAuditRevisionTime() {
         static boost::posix_time::ptime
-            initial_time(boost::gregorian::date(1970, boost::gregorian::Jan, 1));
+            initial_time(boost::gregorian::date(2000, boost::gregorian::Jan, 1));
         return (initial_time);
     }
 
index 03ac8c5ee6001e701fcdfe0fd6d80ef80ca67489..58d0aa065f9fc45cc6ba695126f1326d57b69aa1 100644 (file)
@@ -10,6 +10,7 @@
 #include <config_backend/base_config_backend_pool.h>
 #include <process/cb_ctl_base.h>
 #include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/date_time/gregorian/gregorian.hpp>
 #include <boost/shared_ptr.hpp>
 #include <gtest/gtest.h>
 #include <map>
@@ -419,6 +420,20 @@ TEST_F(CBControlBaseTest, getMgr) {
     EXPECT_EQ(TEST_INSTANCE_ID, mgr.getInstanceId());
 }
 
+// This test verifies that the initial audit revision time is set to
+// local time of 2000-01-01.
+TEST_F(CBControlBaseTest, getInitialAuditRevisionTime) {
+    auto initial_time = cb_ctl_.getInitialAuditRevisionTime();
+    ASSERT_FALSE(initial_time.is_not_a_date_time());
+    auto tm = boost::posix_time::to_tm(initial_time);
+    EXPECT_EQ(100, tm.tm_year);
+    EXPECT_EQ(0, tm.tm_mon);
+    EXPECT_EQ(0, tm.tm_yday);
+    EXPECT_EQ(0, tm.tm_hour);
+    EXPECT_EQ(0, tm.tm_min);
+    EXPECT_EQ(0, tm.tm_sec);
+}
+
 // This test verifies that last audit entry time is reset upon the
 // call to CBControlBase::reset().
 TEST_F(CBControlBaseTest, reset) {