]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: allow_notify should be processed for forward_zones and forward_zones_recurse 14506/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 18 Jul 2024 07:48:12 +0000 (09:48 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 7 Oct 2024 11:00:00 +0000 (13:00 +0200)
For ForwardZones it was only processed if reading from a forward_zones_file.

pdns/recursordist/settings/cxxsupport.cc
pdns/recursordist/settings/docs-new-preamble-in.rst
pdns/recursordist/settings/table.py
regression-tests.recursor-dnssec/test_Notify.py

index 1a4d59d9f5388ad2fe57a3f693c0abfcebddf658..f8345b4918975e53c1b043e5aea54fc271e08238 100644 (file)
@@ -310,6 +310,15 @@ void pdns::settings::rec::processAPIDir(const string& includeDirOnCommandLine, p
   possiblyConvertForwardsandAuths(includeDir, apiDir, log);
 }
 
+static void addToAllowNotifyFor(Recursorsettings& settings, const rust::Vec<::pdns::rust::settings::rec::ForwardZone>& vec)
+{
+  for (const auto& item : vec) {
+    if (item.notify_allowed) {
+      settings.incoming.allow_notify_for.emplace_back(item.zone);
+    }
+  }
+}
+
 pdns::settings::rec::YamlSettingsStatus pdns::settings::rec::readYamlSettings(const std::string& configname, const std::string& includeDirOnCommandLine, Recursorsettings& settings, std::string& msg, Logr::log_t log)
 {
   auto file = ifstream(configname);
@@ -328,6 +337,11 @@ pdns::settings::rec::YamlSettingsStatus pdns::settings::rec::readYamlSettings(co
     for (const auto& yamlfile : yamlFiles) {
       mergeYamlSubFile(yamlfile, yamlstruct, false, log);
     }
+    // Add the zones with notify_allowed to allow_notify_for. For a forward_zones_file that will be
+    // taken care of elsewhere.  One drawback: the zones will be shown in allow_notify_for if you
+    // run --config, while they aren't actually there in any config file.
+    addToAllowNotifyFor(yamlstruct, yamlstruct.recursor.forward_zones);
+    addToAllowNotifyFor(yamlstruct, yamlstruct.recursor.forward_zones_recurse);
     yamlstruct.validate();
     settings = std::move(yamlstruct);
     return YamlSettingsStatus::OK;
index df5a08ae5b685ae543dc152a34b780c177b6d012..94aa4a222a3f0139485ad4da3a68003b9a7be7b3 100644 (file)
@@ -160,7 +160,7 @@ A forward zone is defined as:
     - Socket Address
     - ...
   recurse: Boolean, default false
-  allow_notify:  Boolean, default false
+  allow_notify: Boolean, default false
 
 An example of a ``forward_zones`` entry, which consists of a sequence of `Forward Zone`_ entries:
 
index 1262b5113209817fe41fb15a9d4a6d3487a55bca..f3060219c56caabaa5d656144ed41e34e28430dd 100644 (file)
@@ -1084,6 +1084,7 @@ To prevent this, add a Negative Trust Anchor (NTA) for this zone in the :ref:`se
 If this forwarded zone is signed, instead of adding NTA, add the DS record to the :ref:`setting-lua-config-file`.
 See the :doc:`dnssec` information.
  ''',
+        'versionchanged' : ('5.2.0',  'Zones having ``notify_allowed`` set will be added to :ref:`setting-yaml-incoming.allow_notify_for`.')
     },
     {
         'name' : 'forward_zones_file',
index 7b65e1dda432187ae703d0d690ea756f0c9c11cc..2caf99c501cd58984a668ea3c2e88d63557abd33 100644 (file)
@@ -20,18 +20,25 @@ class NotifyTest(RecursorTest):
     _wsPassword = 'secretpassword'
     _apiKey = 'secretapikey'
     _config_template = """
-    disable-packetcache=yes
-    auth-zones=example=configs/%s/example.zone
-    allow-notify-from=127.0.0.1
-    allow-notify-for=example
-    quiet=no
-    loglevel=9
-    webserver=yes
-    webserver-port=%d
-    webserver-address=127.0.0.1
-    webserver-password=%s
-    api-key=%s
-    """ % (_confdir, _wsPort, _wsPassword, _apiKey)
+packetcache:
+    disable: true
+recursor:
+    auth_zones:
+    - zone: example
+      file: configs/%s/example.zone
+incoming:
+    allow_notify_from: [127.0.0.1]
+    allow_notify_for: ['example']
+logging:
+    quiet: false
+    loglevel: 9
+webservice:
+    webserver: true
+    port: %d
+    address: 127.0.0.1
+    password: %s
+    api_key: %s
+""" % (_confdir, _wsPort, _wsPassword, _apiKey)
 
     @classmethod
     def generateRecursorConfig(cls, confdir):
@@ -46,7 +53,7 @@ d 3600 IN A 192.0.2.42
 e 3600 IN A 192.0.2.42
 f 3600 IN CNAME f            ; CNAME loop: dirty trick to get a ServFail in an authzone
 """.format(soa=cls._SOA))
-        super(NotifyTest, cls).generateRecursorConfig(confdir)
+        super(NotifyTest, cls).generateRecursorYamlConfig(confdir)
 
     def checkRecordCacheMetrics(self, expectedHits, expectedMisses):
         headers = {'x-api-key': self._apiKey}