Compute the year-ahead sqv policy date with a calendar
On 29 February the year-ahead date was 29 February of a year without one, which sqv rejects as a malformed timestamp, so every repository got a "Policy will reject signature within a year" warning that day. Fall back to the last day of February instead. Closes: #1150291
This commit is contained in:
1 parent
1a7c061cfd
commit
c4e3a38ee0
1 file changed
+7
-1
+7
-1
@@ -3,6 +3,7 @@
|
|||||||
#include "aptmethod.h"
|
#include "aptmethod.h"
|
||||||
#include <apt-pkg/gpgv.h>
|
#include <apt-pkg/gpgv.h>
|
||||||
#include <apt-pkg/strutl.h>
|
#include <apt-pkg/strutl.h>
|
||||||
|
#include <chrono>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
@@ -228,8 +229,13 @@ bool SQVMethod::VerifyGetSigners(const char *file, const char *outfile,
|
|||||||
_error->PushToStack();
|
_error->PushToStack();
|
||||||
auto time = std::time(nullptr);
|
auto time = std::time(nullptr);
|
||||||
auto tm = std::localtime(&time);
|
auto tm = std::localtime(&time);
|
||||||
|
using namespace std::chrono;
|
||||||
|
auto yearAhead = year_month_day{year{tm->tm_year + 1900}, month(tm->tm_mon + 1), day(tm->tm_mday)} + years{1};
|
||||||
|
// 29 February has no counterpart in the next year
|
||||||
|
if (not yearAhead.ok())
|
||||||
|
yearAhead = year_month_day_last{yearAhead.year(), month_day_last{yearAhead.month()}};
|
||||||
std::string yearAheadDate;
|
std::string yearAheadDate;
|
||||||
strprintf(yearAheadDate, "%d-%d-%d", tm->tm_year + 1900 + 1, tm->tm_mon + 1, tm->tm_mday);
|
strprintf(yearAheadDate, "%d-%u-%u", int(yearAhead.year()), unsigned(yearAhead.month()), unsigned(yearAhead.day()));
|
||||||
|
|
||||||
args.push_back("--policy-as-of");
|
args.push_back("--policy-as-of");
|
||||||
args.push_back(std::move(yearAheadDate));
|
args.push_back(std::move(yearAheadDate));
|
||||||
|
|||||||
Reference in new issue
Block a user