From: Marcin Siodelski Date: Mon, 17 Aug 2020 10:58:21 +0000 (+0200) Subject: [#1382] Set initial audit time to 2000-01-01 X-Git-Tag: Kea-1.8.0~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c902a77f6219b96a877bc24e4bfea5ca05d37cc;p=thirdparty%2Fkea.git [#1382] Set initial audit time to 2000-01-01 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. --- diff --git a/src/lib/process/cb_ctl_base.h b/src/lib/process/cb_ctl_base.h index 456cb9dd74..eb820b7294 100644 --- a/src/lib/process/cb_ctl_base.h +++ b/src/lib/process/cb_ctl_base.h @@ -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); } diff --git a/src/lib/process/tests/cb_ctl_base_unittests.cc b/src/lib/process/tests/cb_ctl_base_unittests.cc index 03ac8c5ee6..58d0aa065f 100644 --- a/src/lib/process/tests/cb_ctl_base_unittests.cc +++ b/src/lib/process/tests/cb_ctl_base_unittests.cc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -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) {