From: Miod Vallat Date: Wed, 11 Jun 2025 09:19:22 +0000 (+0200) Subject: Try harder to have valid domain id values. X-Git-Tag: dnsdist-2.0.0-beta1~28^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=89df0fdb6a4fa4c8ec350d0b201fbe0753a0b5d6;p=thirdparty%2Fpdns.git 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 --- 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;