]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Try harder to have valid domain id values.
authorMiod Vallat <miod.vallat@powerdns.com>
Wed, 11 Jun 2025 09:19:22 +0000 (11:19 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Wed, 11 Jun 2025 09:31:10 +0000 (11:31 +0200)
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
modules/ldapbackend/native.cc
modules/lua2backend/lua2api2.hh

index 675a372fa9b969695d382b0e20d783fd55d7f102..48869cf49bfa649156a5defb024ab9b1666c9600 100644 (file)
@@ -889,7 +889,7 @@ void Bind2Backend::doEmptyNonTerminals(std::shared_ptr<recordstorage_t>& 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;
index 6e8ffb1674e4bcbb1869b931c007219b1d9acd28..4ac7ea33c4dd8247989447892e605884db7b4374 100644 (file)
@@ -426,7 +426,7 @@ bool LdapBackend::getDomainInfo(const ZoneName& domain, DomainInfo& info, bool /
     if (result.count("PdnsDomainId") && !result["PdnsDomainId"].empty())
       info.id = static_cast<domainid_t>(std::stoll(result["PdnsDomainId"][0]));
     else
-      info.id = 0;
+      info.id = UnknownDomainID;
 
     info.serial = sd.serial;
     info.zone = domain;
index d53384d7c7f5e1f824f90eeee28871c36f24789e..660f117b8aa1da1ed73cedb5a6e89d6f2d576c1a 100644 (file)
@@ -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<string>(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;