From 89df0fdb6a4fa4c8ec350d0b201fbe0753a0b5d6 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Wed, 11 Jun 2025 11:19:22 +0200 Subject: [PATCH] Try harder to have valid domain id values. This makes sure the domain id in struct DomainInfo always gets set to something (i.e. UnknownDomainID when the backend can't figure out a meaningful value). Fixes: #551 --- modules/bindbackend/bindbackend2.cc | 2 +- modules/ldapbackend/native.cc | 2 +- modules/lua2backend/lua2api2.hh | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/bindbackend/bindbackend2.cc b/modules/bindbackend/bindbackend2.cc index 675a372fa9..48869cf49b 100644 --- a/modules/bindbackend/bindbackend2.cc +++ b/modules/bindbackend/bindbackend2.cc @@ -889,7 +889,7 @@ void Bind2Backend::doEmptyNonTerminals(std::shared_ptr& records void Bind2Backend::loadConfig(string* status) // NOLINT(readability-function-cognitive-complexity) 13379 https://github.com/PowerDNS/pdns/issues/13379 Habbie: zone2sql.cc, bindbackend2.cc: reduce complexity { - static int domain_id = 1; + static domainid_t domain_id = 1; if (!getArg("config").empty()) { BindParser BP; diff --git a/modules/ldapbackend/native.cc b/modules/ldapbackend/native.cc index 6e8ffb1674..4ac7ea33c4 100644 --- a/modules/ldapbackend/native.cc +++ b/modules/ldapbackend/native.cc @@ -426,7 +426,7 @@ bool LdapBackend::getDomainInfo(const ZoneName& domain, DomainInfo& info, bool / if (result.count("PdnsDomainId") && !result["PdnsDomainId"].empty()) info.id = static_cast(std::stoll(result["PdnsDomainId"][0])); else - info.id = 0; + info.id = UnknownDomainID; info.serial = sd.serial; info.zone = domain; diff --git a/modules/lua2backend/lua2api2.hh b/modules/lua2backend/lua2api2.hh index d53384d7c7..660f117b8a 100644 --- a/modules/lua2backend/lua2api2.hh +++ b/modules/lua2backend/lua2api2.hh @@ -256,6 +256,7 @@ public: void parseDomainInfo(const domaininfo_result_t& row, DomainInfo& di) { + di.id = UnknownDomainID; for (const auto& item : row) { if (item.first == "account") di.account = boost::get(item.second); @@ -293,6 +294,7 @@ public: if (!getAuth(domain, &sd)) return false; + di.id = sd.domain_id; di.zone = domain; di.backend = this; di.serial = sd.serial; -- 2.47.3