]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
Finishing generation of named.conf
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 8 Aug 2017 11:30:33 +0000 (13:30 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 8 Aug 2017 11:30:33 +0000 (13:30 +0200)
pp_lib/config_named_app.py

index 15c9e3bb6fc2e049b5d2967b5416d8ad608f6bbd..dd78cd517b313371bc45b4113055765c1e1c698f 100644 (file)
@@ -39,7 +39,7 @@ from .cfg_app import PpCfgAppError, PpConfigApplication
 
 from .pidfile import PidFileError, InvalidPidFileError, PidFileInUseError, PidFile
 
-__version__ = '0.5.5'
+__version__ = '0.5.6'
 LOG = logging.getLogger(__name__)
 
 
@@ -999,7 +999,8 @@ class PpConfigNamedApp(PpConfigApplication):
                 self.exit(8)
         elif not os.path.isfile(self.rndc_config_file):
             LOG.error("File {!r} is not a regular file.".format(self.rndc_config_file))
-            self.exit(8)
+            if not self.simulate:
+                self.exit(8)
         content += '\n// Managed Keys of RNDC\n'
         content += 'include "{}";\n'.format(self.rndc_config_file)
         content += '\ncontrols {\n'
@@ -1014,6 +1015,52 @@ class PpConfigNamedApp(PpConfigApplication):
         content += '\n// logging configuration\n'
         content += 'include "{}";\n'.format(self.named_log_cfg_file)
 
+        # Defining root zone file
+        if not os.path.exists(self.named_root_zone_file_abs):
+            LOG.error("File {!r} does not exists.".format(self.named_root_zone_file_abs))
+            if not self.simulate:
+                self.exit(8)
+        elif not os.path.isfile(self.named_root_zone_file_abs):
+            LOG.error("File {!r} is not a regular file.".format(self.named_root_zone_file_abs))
+            if not self.simulate:
+                self.exit(8)
+        fname = self.named_root_zone_file_rel
+        if os.path.isabs(fname):
+            fname_rel = os.path.relpath(fname, self.named_basedir)
+            if not fname_rel.startswith('../'):
+                fname = fname_rel
+        content += '\nzone "." {\n'
+        content += '\ttype hint;\n'
+        content += '\tfile "{}";\n'.format(fname)
+        content += '};\n'
+
+        # Including zone definitions for default zones
+        if not os.path.exists(self.named_def_zones_file):
+            LOG.error("File {!r} does not exists.".format(self.named_def_zones_file))
+            if not self.simulate:
+                self.exit(8)
+        elif not os.path.isfile(self.named_def_zones_file):
+            LOG.error("File {!r} is not a regular file.".format(self.named_def_zones_file))
+            if not self.simulate:
+                self.exit(8)
+        content += '\n// Default zones per RFC 1912\n'
+        content += 'include "{}";\n'.format(self.named_def_zones_file)
+
+        # Including root keys for DNSSEC
+        if not os.path.exists(self.named_rootkeys_file):
+            LOG.error("File {!r} does not exists.".format(self.named_rootkeys_file))
+            if not self.simulate:
+                self.exit(8)
+        elif not os.path.isfile(self.named_rootkeys_file):
+            LOG.error("File {!r} is not a regular file.".format(self.named_rootkeys_file))
+            if not self.simulate:
+                self.exit(8)
+        content += '\n// Including root keys for DNSSEC\n'
+        content += 'include "{}";\n'.format(self.named_rootkeys_file)
+
+        content += '\n// Including definitions of all slave zones\n'
+        content += 'include "{}";\n'.format(self.named_zones_cfg_file)
+
         content += '\n// vim: ts=8 filetype=named noet noai\n'
 
         with open(self.temp_named_conf, 'w', **self.open_args) as fh: