@@ -87,7 +87,7 @@ function soa_dnssec_create(&$data) {
8787 $ dns_config = $ app ->getconf ->get_server_config ($ conf ["server_id " ], 'dns ' );
8888
8989 $ domain = substr ($ data ['new ' ]['origin ' ], 0 , strlen ($ data ['new ' ]['origin ' ])-1 );
90- if (!file_exists ($ dns_config ['bind_zonefiles_dir ' ].'/ ' .$ this -> zone_file_prefix () .$ domain )) return false ;
90+ if (!file_exists ($ dns_config ['bind_zonefiles_dir ' ].'/ ' .$ dns_config [ ' bind_zonefiles_masterprefix ' ] .$ domain )) return false ;
9191
9292 //* Check Entropy
9393 if (file_get_contents ('/proc/sys/kernel/random/entropy_avail ' ) < 400 ) {
@@ -136,7 +136,7 @@ function soa_dnssec_sign(&$data) {
136136 //* load the server configuration options
137137 $ dns_config = $ app ->getconf ->get_server_config ($ conf ["server_id " ], 'dns ' );
138138
139- $ filespre = $ this -> zone_file_prefix () ;
139+ $ filespre = $ dns_config [ ' bind_zonefiles_masterprefix ' ] ;
140140 $ domain = substr ($ data ['new ' ]['origin ' ], 0 , strlen ($ data ['new ' ]['origin ' ])-1 );
141141 if (!file_exists ($ dns_config ['bind_zonefiles_dir ' ].'/ ' .$ filespre .$ domain )) return false ;
142142
@@ -202,7 +202,7 @@ function soa_dnssec_update(&$data, $new=false) {
202202 //* load the server configuration options
203203 $ dns_config = $ app ->getconf ->get_server_config ($ conf ["server_id " ], 'dns ' );
204204
205- $ filespre = $ this -> zone_file_prefix () ;
205+ $ filespre = $ dns_config [ ' bind_zonefiles_masterprefix ' ] ;
206206 $ domain = substr ($ data ['new ' ]['origin ' ], 0 , strlen ($ data ['new ' ]['origin ' ])-1 );
207207 if (!file_exists ($ dns_config ['bind_zonefiles_dir ' ].'/ ' .$ filespre .$ domain )) return false ;
208208
@@ -241,7 +241,7 @@ function soa_dnssec_delete(&$data) {
241241 foreach ($ key_files as $ file ) {
242242 unlink ($ file );
243243 }
244- unlink ($ dns_config ['bind_zonefiles_dir ' ].'/ ' .$ this -> zone_file_prefix () .$ domain .'.signed ' );
244+ unlink ($ dns_config ['bind_zonefiles_dir ' ].'/ ' .$ dns_config [ ' bind_zonefiles_masterprefix ' ] .$ domain .'.signed ' );
245245 unlink ($ dns_config ['bind_keyfiles_dir ' ].'/dsset- ' .$ domain .'. ' );
246246
247247 if ($ app ->dbmaster !== $ app ->db ) $ app ->dbmaster ->query ('UPDATE dns_soa SET dnssec_info= \'\', dnssec_initialized= \'N \' WHERE id=? ' , intval ($ data ['new ' ]['id ' ]));
@@ -325,7 +325,7 @@ function soa_update($event_name, $data) {
325325 }
326326 $ tpl ->setLoop ('zones ' , $ records );
327327
328- $ filename = $ dns_config ['bind_zonefiles_dir ' ].'/ ' . $ this -> zone_file_prefix () . str_replace ("/ " , "_ " , substr ($ zone ['origin ' ], 0 , -1 ));
328+ $ filename = $ dns_config ['bind_zonefiles_dir ' ].'/ ' . $ dns_config [ ' bind_zonefiles_masterprefix ' ] . str_replace ("/ " , "_ " , substr ($ zone ['origin ' ], 0 , -1 ));
329329
330330 $ old_zonefile = @file_get_contents ($ filename );
331331 file_put_contents ($ filename , $ tpl ->grab ());
@@ -371,7 +371,7 @@ function soa_update($event_name, $data) {
371371 } elseif ($ data ['new ' ]['dnssec_wanted ' ] == 'Y ' && $ data ['old ' ]['dnssec_initialized ' ] == 'N ' ) {
372372 $ this ->soa_dnssec_create ($ data );
373373 } elseif ($ data ['new ' ]['dnssec_wanted ' ] == 'N ' && $ data ['old ' ]['dnssec_initialized ' ] == 'Y ' ) { //delete old signed file if dnssec is no longer wanted
374- $ filename = $ dns_config ['bind_zonefiles_dir ' ].'/ ' . $ this -> zone_file_prefix () . str_replace ("/ " , "_ " , substr ($ data ['old ' ]['origin ' ], 0 , -1 ));
374+ $ filename = $ dns_config ['bind_zonefiles_dir ' ].'/ ' . $ dns_config [ ' bind_zonefiles_masterprefix ' ] . str_replace ("/ " , "_ " , substr ($ data ['old ' ]['origin ' ], 0 , -1 ));
375375 if (is_file ($ filename .'.signed ' )) unlink ($ filename .'.signed ' );
376376 } elseif ($ data ['new ' ]['dnssec_wanted ' ] == 'Y ' ) {
377377 $ this ->soa_dnssec_update ($ data );
@@ -385,7 +385,7 @@ function soa_update($event_name, $data) {
385385
386386 //* Delete old domain file, if domain name has been changed
387387 if ($ data ['old ' ]['origin ' ] != $ data ['new ' ]['origin ' ]) {
388- $ filename = $ dns_config ['bind_zonefiles_dir ' ].'/ ' . $ this -> zone_file_prefix () . str_replace ("/ " , "_ " , substr ($ data ['old ' ]['origin ' ], 0 , -1 ));
388+ $ filename = $ dns_config ['bind_zonefiles_dir ' ].'/ ' . $ dns_config [ ' bind_zonefiles_masterprefix ' ] . str_replace ("/ " , "_ " , substr ($ data ['old ' ]['origin ' ], 0 , -1 ));
389389
390390 if (is_file ($ filename )) unlink ($ filename );
391391 if (is_file ($ filename .'.err ' )) unlink ($ filename .'.err ' );
@@ -412,7 +412,7 @@ function soa_delete($event_name, $data) {
412412 $ this ->write_named_conf ($ data , $ dns_config );
413413
414414 //* Delete the domain file
415- $ zone_file_name = $ dns_config ['bind_zonefiles_dir ' ].'/ ' . $ this -> zone_file_prefix () . str_replace ("/ " , "_ " , substr ($ data ['old ' ]['origin ' ], 0 , -1 ));
415+ $ zone_file_name = $ dns_config ['bind_zonefiles_dir ' ].'/ ' . $ dns_config [ ' bind_zonefiles_masterprefix ' ] . str_replace ("/ " , "_ " , substr ($ data ['old ' ]['origin ' ], 0 , -1 ));
416416 if (is_file ($ zone_file_name )) unlink ($ zone_file_name );
417417 if (is_file ($ zone_file_name .'.err ' )) unlink ($ zone_file_name .'.err ' );
418418 $ app ->log ("Deleting BIND domain file: " .$ zone_file_name , LOGLEVEL_DEBUG );
@@ -452,12 +452,12 @@ function slave_update($event_name, $data) {
452452
453453 //* Delete old domain file, if domain name has been changed
454454 if ($ data ['old ' ]['origin ' ] != $ data ['new ' ]['origin ' ]) {
455- $ filename = $ dns_config ['bind_zonefiles_dir ' ].'/ ' . $ this -> zone_file_prefix () . str_replace ("/ " , "_ " , substr ($ data ['old ' ]['origin ' ], 0 , -1 ));
455+ $ filename = $ dns_config ['bind_zonefiles_dir ' ].'/ ' . $ dns_config [ ' bind_zonefiles_masterprefix ' ] . str_replace ("/ " , "_ " , substr ($ data ['old ' ]['origin ' ], 0 , -1 ));
456456 if (is_file ($ filename )) unset($ filename );
457457 }
458458
459459 //* Ensure that the named slave directory is writable by the named user
460- $ slave_record_dir = $ dns_config ['bind_zonefiles_dir ' ].'/ ' .$ this -> slave_zone_file_prefix () ;
460+ $ slave_record_dir = $ dns_config ['bind_zonefiles_dir ' ].'/ ' .$ dns_config [ ' bind_zonefiles_slaveprefix ' ] ;
461461 if (!@is_dir ($ slave_record_dir )) mkdir ($ slave_record_dir , 0770 );
462462 chown ($ slave_record_dir , $ dns_config ['bind_user ' ]);
463463 chgrp ($ slave_record_dir , $ dns_config ['bind_group ' ]);
@@ -479,7 +479,7 @@ function slave_delete($event_name, $data) {
479479 $ this ->write_named_conf ($ data , $ dns_config );
480480
481481 //* Delete the domain file
482- $ zone_file_name = $ dns_config ['bind_zonefiles_dir ' ].'/ ' . $ this -> slave_zone_file_prefix () . str_replace ("/ " , "_ " , substr ($ data ['old ' ]['origin ' ], 0 , -1 ));
482+ $ zone_file_name = $ dns_config ['bind_zonefiles_dir ' ].'/ ' . $ dns_config [ ' bind_zonefiles_slaveprefix ' ] . str_replace ("/ " , "_ " , substr ($ data ['old ' ]['origin ' ], 0 , -1 ));
483483 if (is_file ($ zone_file_name )) unlink ($ zone_file_name );
484484 $ app ->log ("Deleting BIND domain file for secondary zone: " .$ zone_file_name , LOGLEVEL_DEBUG );
485485
@@ -536,8 +536,8 @@ function write_named_conf($data, $dns_config) {
536536
537537 //* Check if the current zone that triggered this function has at least one NS record
538538
539- $ pri_zonefiles_path = $ dns_config ['bind_zonefiles_dir ' ].'/ ' .$ this -> zone_file_prefix () ;
540- $ sec_zonefiles_path = $ dns_config ['bind_zonefiles_dir ' ].'/ ' .$ this -> slave_zone_file_prefix () ;
539+ $ pri_zonefiles_path = $ dns_config ['bind_zonefiles_dir ' ].'/ ' .$ dns_config [ ' bind_zonefiles_masterprefix ' ] ;
540+ $ sec_zonefiles_path = $ dns_config ['bind_zonefiles_dir ' ].'/ ' .$ dns_config [ ' bind_zonefiles_slaveprefix ' ] ;
541541
542542 //* Loop trough zones
543543 foreach ($ tmps as $ tmp ) {
@@ -600,20 +600,6 @@ function write_named_conf($data, $dns_config) {
600600 unset($ tmps );
601601
602602 }
603-
604-
605- function zone_file_prefix () {
606- //TODO : change this when distribution information has been integrated into server record
607- return (file_exists ('/etc/gentoo-release ' )) ? 'pri/ ' : 'pri. ' ;
608- }
609- function slave_zone_file_prefix () {
610- //TODO : change this when distribution information has been integrated into server record
611- return (file_exists ('/etc/gentoo-release ' )) ? 'sec/ ' : 'slave/sec. ' ;
612- }
613-
614-
615-
616-
617603} // end class
618604
619605?>
0 commit comments