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.7.0-alpha1~45^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F11241%2Fhead;p=thirdparty%2Fpdns.git auth lmdb: add a UUID to newly created databases --- 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