From: Frank Brehm Date: Tue, 8 Aug 2017 11:30:33 +0000 (+0200) Subject: Finishing generation of named.conf X-Git-Tag: 0.1.2~134 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=8c53156eec04ef1e48e85f9502e9f7580748faca;p=pixelpark%2Fadmin-tools.git Finishing generation of named.conf --- diff --git a/pp_lib/config_named_app.py b/pp_lib/config_named_app.py index 15c9e3b..dd78cd5 100644 --- a/pp_lib/config_named_app.py +++ b/pp_lib/config_named_app.py @@ -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: