From: Peter van Dijk Date: Wed, 26 Jan 2022 12:24:25 +0000 (+0100) Subject: auth lmdb: add a UUID to newly created databases X-Git-Tag: auth-4.6.2^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=99cc0f125197578660d4e55948a7dd4faa31f01e;p=thirdparty%2Fpdns.git auth lmdb: add a UUID to newly created databases (cherry picked from commit ba731a422ab3eb3c31d85d3683338abadb5a800b, backport of #11241) --- 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 004c8becfe..93fc707127 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 \ zoneparser-tng.cc pdnsutil_LDFLAGS = \