From ba731a422ab3eb3c31d85d3683338abadb5a800b Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Wed, 26 Jan 2022 13:24:25 +0100 Subject: [PATCH] auth lmdb: add a UUID to newly created databases --- modules/lmdbbackend/lmdbbackend.cc | 9 +++++++++ pdns/Makefile.am | 1 + 2 files changed, 10 insertions(+) diff --git a/modules/lmdbbackend/lmdbbackend.cc b/modules/lmdbbackend/lmdbbackend.cc index 03b3fb38a8..7c3173a174 100644 --- a/modules/lmdbbackend/lmdbbackend.cc +++ b/modules/lmdbbackend/lmdbbackend.cc @@ -34,11 +34,13 @@ #include "pdns/version.hh" #include "pdns/arguments.hh" #include "pdns/lock.hh" +#include "pdns/uuid-utils.hh" #include #include #include #include #include +#include #include @@ -115,6 +117,13 @@ LMDBBackend::LMDBBackend(const std::string& suffix) txn->put(pdnsdbi, "shards", s_shards); } + MDBOutVal gotuuid; + if (txn->get(pdnsdbi, "uuid", gotuuid)) { + const auto uuid = getUniqueID(); + const string uuids(uuid.begin(), uuid.end()); + txn->put(pdnsdbi, "uuid", uuids); + } + txn->commit(); if (schemaversion < 3) { diff --git a/pdns/Makefile.am b/pdns/Makefile.am index 431ff8cfd6..43656a7d41 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -378,6 +378,7 @@ pdnsutil_SOURCES = \ tsigutils.hh tsigutils.cc \ ueberbackend.cc \ unix_utility.cc \ + uuid-utils.hh uuid-utils.cc \ zonemd.hh zonemd.cc \ zoneparser-tng.cc -- 2.47.2