from .pidfile import PidFileError, InvalidPidFileError, PidFileInUseError, PidFile
-__version__ = '0.5.2'
+__version__ = '0.5.3'
LOG = logging.getLogger(__name__)
"""The file for configuration of all own zones."""
return os.path.join(self.named_conf_dir, self._named_zones_cfg_file)
+ # -------------------------------------------
+ @property
+ def rndc_config_file(self):
+ """The config file for RNDC (included in named.conf)"""
+ return os.path.join(self.named_conf_dir, 'rndc.key')
+
# -------------------------------------------
@property
def named_pidfile(self):
res['named_def_zones_file'] = self.named_def_zones_file
res['named_log_cfg_file'] = self.named_log_cfg_file
res['named_zones_cfg_file'] = self.named_zones_cfg_file
+ res['rndc_config_file'] = self.rndc_config_file
res['named_dump_dir'] = self.named_dump_dir
res['named_dump_file'] = self.named_dump_file
res['named_stats_dir'] = self.named_stats_dir
cur_date = datetime.datetime.now().isoformat(' ')
- stats_dir = os.path.join(self.named_basedir, 'stats')
- stats_file = os.path.join(stats_dir, 'named.stats')
-
lines = []
lines.append('###############################################################')
lines.append('')
option_lines.append('\tpid-file "{}";'.format(self.named_pidfile))
option_lines.append('\tdump-file "{}";'.format(self.named_dump_file))
option_lines.append('\tstatistics-file "{}";'.format(self.named_stats_file))
+ option_lines.append('\tsession-keyfile "{}";'.format(self.named_session_keyfile))
option_lines.append('')
option_lines.append('\t// DNSSEC')
option_lines.append('\tdnssec-enable yes;')
option_lines.append('\tdnssec-validation yes;')
+ option_lines.append('')
+ option_lines.append('\t// Path to ISC DLV key')
+ option_lines.append('\tbindkeys-file "{}";'.format(self.named_bindkeys_file))
+
+ option_lines.append('')
+ option_lines.append('\tmanaged-keys-directory "{}";'.format(self.named_managed_keysdir))
+
option_lines.append('')
option_lines.append('\tallow-transfer {')
option_lines.append('\t\tallow-transfer;')
option_lines.append('};')
content += '\n' + '\n'.join(option_lines) + '\n'
+ if not os.path.exists(self.rndc_config_file):
+ LOG.error("File {!r} does not exists, please generate it with `rndc-confgen`.".format(
+ self.rndc_config_file))
+ if not self.simulate:
+ 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)
+ content += '\n// Managed Keys of RNDC\n'
+ content += 'include "{}";\n'.format(self.rndc_config_file)
+ content += '\ncontrols {\n'
+ content += '\tinet 127.0.0.1 port 953 allow {\n'
+ content += '\t\t127.0.0.1;\n'
+ content += '\t\t::1/128;\n'
+ content += '\t} keys {\n'
+ content += '\t\t"rndc-key";\n'
+ content += '\t};\n'
+ content += '};\n'
+
content += '\n// vim: ts=8 filetype=named noet noai\n'
with open(self.temp_named_conf, 'w', **self.open_args) as fh: