Skip to content

Commit 957aaf3

Browse files
committed
Fixed: FS#1317 - Do not store Zone files in BIND plugin that do not have a ns record
1 parent 06ce83d commit 957aaf3

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

server/plugins-available/bind_plugin.inc.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,16 @@ function write_named_conf($data, $dns_config) {
252252
//* Only write the master file for the current server
253253
$tmps = $app->db->queryAllRecords("SELECT origin, xfer, also_notify FROM dns_soa WHERE active = 'Y' AND server_id=".$conf["server_id"]);
254254
$zones = array();
255+
256+
//* Check if the current zone that triggered this function has at least one NS record
257+
$rec_num = $app->db->queryOneRecord("SELECT count(id) as ns FROM dns_rr WHERE type = 'NS' AND zone = ".$data['new']['id']." AND active = 'Y'");
258+
if($rec_num['ns'] == 0) {
259+
$exclude_zone = $data['new']['origin'];
260+
} else {
261+
$exclude_zone = '';
262+
}
255263

264+
//* Loop trough zones
256265
foreach($tmps as $tmp) {
257266

258267
$options = '';
@@ -263,10 +272,12 @@ function write_named_conf($data, $dns_config) {
263272
}
264273
if(trim($tmp['also_notify']) != '') $options .= ' also-notify {'.str_replace(',',';',$tmp['also_notify']).";};\n";
265274

266-
$zones[] = array( 'zone' => substr($tmp['origin'],0,-1),
267-
'zonefile_path' => $dns_config['bind_zonefiles_dir'].'/pri.'.substr($tmp['origin'],0,-1),
268-
'options' => $options
269-
);
275+
if($tmp['origin'] != $exclude_zone) {
276+
$zones[] = array( 'zone' => substr($tmp['origin'],0,-1),
277+
'zonefile_path' => $dns_config['bind_zonefiles_dir'].'/pri.'.substr($tmp['origin'],0,-1),
278+
'options' => $options
279+
);
280+
}
270281
}
271282

272283
$tpl = new tpl();

0 commit comments

Comments
 (0)