]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: document file extension of zone forward file and do not accept empty list of... 15194/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 11 Feb 2025 14:42:54 +0000 (15:42 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 21 Feb 2025 09:02:36 +0000 (10:02 +0100)
The YAML code already disallows an empty forwarders list. The added
case mainly covers the case when an old-style forward file is parsed
as if it's YAML. This now generated an error:

Feb 21 09:57:39 msg="Fatal error" error="empty list of forwarders for domain '- zone: example.com\"on line 1 of tmp/f.conf" subsystem="config" level="0" prio="Critical" tid="0" ts="1740128259.137" exception="PDNSException"

This hopefully makes admins realize rec is trying to parse YAML
content, but is expecting old-style as the file does not end in
in .yml.

pdns/recursordist/rec-rust-lib/table.py
pdns/recursordist/reczones.cc

index e07e176a65f3e2b4b19cf435e6f1c71b9c5e38c1..f38cf0ba0ee6213207a6e161ffacea0fe570d6e4 100644 (file)
@@ -1140,6 +1140,7 @@ The DNSSEC notes from :ref:`setting-forward-zones` apply here as well.
  ''',
     'doc-new' : '''
         Same as :ref:`setting-forward-zones`, parsed from a file as a sequence of `Forward Zone`_.
+        The filename MUST end in ``.yml`` for the content to be parsed as YAML.
 
 .. code-block:: yaml
 
index 0fee5470355deca1b9f7c25e8a4047c3532a6a03..6129f21aa094c76d08dc817516366c45a60eef7c 100644 (file)
@@ -65,6 +65,9 @@ static void convertServersForAD(const std::string& zone, const std::string& inpu
 {
   vector<string> servers;
   stringtok(servers, input, sepa);
+  if (servers.empty()) {
+    throw PDNSException("empty list of forwarders for domain '" + zone + '"');
+  }
   authDomain.d_servers.clear();
 
   vector<string> addresses;
@@ -413,6 +416,9 @@ static void processForwardZonesFile(shared_ptr<SyncRes::domainmap_t>& newMap, sh
       try {
         convertServersForAD(domain, instructions, authDomain, ",; ", log, false);
       }
+      catch (const PDNSException& e) {
+        throw PDNSException(e.reason + "on line " + std::to_string(linenum) + " of " + filename);
+      }
       catch (...) {
         throw PDNSException("Conversion error parsing line " + std::to_string(linenum) + " of " + filename);
       }