From 2b81eb361ef2074d8ce60484e4a41a426be2ab23 Mon Sep 17 00:00:00 2001 From: Stuart Wyatt Date: Tue, 7 Apr 2015 13:29:45 -0700 Subject: BIND package code clean up Code cleanup to reflect coding style guidelines and consistency Tabs only, always uses braces, spacing C/C++ style comments Use array_key_exists instead of key_exists $config[] keys are always enclosed in quotes and use single quotes for literals --- config/bind/bind.inc | 1140 +++++++++++++++++++++++-------------------- config/bind/bind.widget.php | 94 ++-- config/bind/bind.xml | 540 ++++++++++---------- config/bind/bind_acls.xml | 112 ++--- config/bind/bind_sync.xml | 38 +- config/bind/bind_views.xml | 128 ++--- config/bind/bind_zones.xml | 308 ++++++------ 7 files changed, 1229 insertions(+), 1131 deletions(-) (limited to 'config/bind') diff --git a/config/bind/bind.inc b/config/bind/bind.inc index 54d536d0..dc4a9de9 100644 --- a/config/bind/bind.inc +++ b/config/bind/bind.inc @@ -36,107 +36,124 @@ require_once('util.inc'); require_once('pfsense-utils.inc'); require_once('pkg-utils.inc'); require_once('service-utils.inc'); -if(!function_exists("filter_configure")) +if (!function_exists("filter_configure")) { require_once("filter.inc"); +} + +$pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3); +if ($pf_version > 2.0) { + define('BIND_LOCALBASE', '/usr/pbi/bind-'.php_uname("m")); +} else { + define('BIND_LOCALBASE', '/usr/local'); +} -$pf_version=substr(trim(file_get_contents("/etc/version")),0,3); -if ($pf_version > 2.0) - define('BIND_LOCALBASE', '/usr/pbi/bind-' . php_uname("m")); -else - define('BIND_LOCALBASE','/usr/local'); +define('CHROOT_LOCALBASE', '/cf/named'); -define('CHROOT_LOCALBASE','/cf/named'); +function bind_zone_validate($post, &$input_errors) +{ + if (array_key_exists("mail", $_POST)) { + $_POST['mail'] = preg_replace("/@/", ".", $post['mail']); + } -function bind_zone_validate($post, &$input_errors){ - if (key_exists("mail",$_POST)) - $_POST['mail']=preg_replace("/@/",".",$post['mail']); - - switch ($_POST['type']){ + switch ($_POST['type']) { case 'slave': - if( $_POST['slaveip'] == "") + if ($_POST['slaveip'] == "") { $input_errors[] = 'The field \'Master Zone IP\' is required for slave zones.'; - break; + } + break; case 'forward': - if( $_POST['forwarders'] == "") - $input_errors[] = 'The field \'Forwarders\' is required for forward zones.'; - break; + if ($_POST['forwarders'] == "") { + $input_errors[] = 'The field \'Forwarders\' is required for forward zones.'; + } + break; case 'redirect': - $_POST['tll']=300; - $_POST['refresh']=0; - $_POST['serial']=0; - $_POST['retry']=0; - $_POST['expire']=0; - $_POST['minimum']=0; - if($_POST['mail']=='') + $_POST['tll'] = 300; + $_POST['refresh'] = 0; + $_POST['serial'] = 0; + $_POST['retry'] = 0; + $_POST['expire'] = 0; + $_POST['minimum'] = 0; + if ($_POST['mail'] == '') { $input_errors[] = "The field 'Mail Admin Zone' is required for {$_POST['type']} zones."; - + } default: - if($_POST['nameserver']=='') + if ($_POST['nameserver'] == '') { $input_errors[] = "The field 'Name server' is required for {$_POST['type']} zones."; - for ($i=0;$i < count($_POST);$i++){ - if (key_exists("hostname$i",$_POST)){ - if ($_POST['reverso']=="on"){ - $_POST["hostvalue$i"]=""; - if (!preg_match("/(PTR|NS)/",$_POST["hosttype$i"])) + } + for ($i = 0; $i < count($_POST); $i++) { + if (array_key_exists("hostname$i", $_POST)) { + if ($_POST['reverso'] == "on") { + $_POST["hostvalue$i"] = ""; + if (!preg_match("/(PTR|NS)/", $_POST["hosttype$i"])) { $input_errors[] = 'On reverse zones, valid record types are NS or PTR'; } - if (preg_match("/(MX|NS)/",$_POST["hosttype$i"])) - $_POST["hostname$i"]=""; - if (!preg_match("/(MX|NS)/",$_POST["hosttype$i"]) && $_POST["hostname$i"]=="") + } + if (preg_match("/(MX|NS)/", $_POST["hosttype$i"])) { + $_POST["hostname$i"] = ""; + } + if (!preg_match("/(MX|NS)/", $_POST["hosttype$i"]) && $_POST["hostname$i"] == "") { $input_errors[] = 'Record cannot be empty for '.$_POST["hosttype$i"].' type '; - if ($_POST["hosttype$i"]=="MX" && $_POST["hostvalue$i"]=="") - $_POST["hostvalue$i"]="10"; - if ($_POST["hosttype$i"]!="MX" && $_POST["hostvalue$i"]!="") - $_POST["hostvalue$i"]=""; - if ($_POST["hostdst$i"]=="") + } + if ($_POST["hosttype$i"] == "MX" && $_POST["hostvalue$i"] == "") { + $_POST["hostvalue$i"] = "10"; + } + if ($_POST["hosttype$i"] != "MX" && $_POST["hostvalue$i"] != "") { + $_POST["hostvalue$i"] = ""; + } + if ($_POST["hostdst$i"] == "") { $input_errors[] = 'Alias or IP address cannot be empty.'; + } } } - } + break; + } } -function bind_sync(){ +function bind_sync() +{ global $config; conf_mount_rw(); //create rndc - $rndc_confgen="/usr/local/sbin/rndc-confgen"; - if (!file_exists(BIND_LOCALBASE."/etc/rndc-confgen.pfsense") && file_exists($rndc_confgen)){ - exec("$rndc_confgen ",$rndc_conf); - foreach($rndc_conf as $line) - $confgen_file.="$line\n"; - file_put_contents(BIND_LOCALBASE."/etc/rndc-confgen.pfsense",$confgen_file); + $rndc_confgen = "/usr/local/sbin/rndc-confgen"; + if (!file_exists(BIND_LOCALBASE."/etc/rndc-confgen.pfsense") && file_exists($rndc_confgen)) { + exec("$rndc_confgen ", $rndc_conf); + foreach ($rndc_conf as $line) { + $confgen_file .= "$line\n"; } - if (file_exists(BIND_LOCALBASE."/etc/rndc-confgen.pfsense")){ - $rndc_conf=file(BIND_LOCALBASE."/etc/rndc-confgen.pfsense"); - $confgen="rndc.conf"; - $rndc_bindconf=""; - foreach ($rndc_conf as $line){ - if ($confgen =="rndc.conf"){ - if (!preg_match ("/^#/",$line)) - $rndc_file.=$line; - } - else{ - if (!preg_match ("/named.conf/",$line)) - $rndc_bindconf.=preg_replace('/#/',"",$line); + file_put_contents(BIND_LOCALBASE."/etc/rndc-confgen.pfsense", $confgen_file); + } + if (file_exists(BIND_LOCALBASE."/etc/rndc-confgen.pfsense")) { + $rndc_conf = file(BIND_LOCALBASE."/etc/rndc-confgen.pfsense"); + $confgen = "rndc.conf"; + $rndc_bindconf = ""; + foreach ($rndc_conf as $line) { + if ($confgen == "rndc.conf") { + if (!preg_match("/^#/", $line)) { + $rndc_file .= $line; } - if (preg_match("/named.conf/",$line)){ - $confgen="named.conf"; - file_put_contents(BIND_LOCALBASE."/etc/rndc.conf",$rndc_file); + } else { + if (!preg_match("/named.conf/", $line)) { + $rndc_bindconf .= preg_replace('/#/', "", $line); } + } + if (preg_match("/named.conf/", $line)) { + $confgen = "named.conf"; + file_put_contents(BIND_LOCALBASE."/etc/rndc.conf", $rndc_file); + } } } - - $bind = $config["installedpackages"]["bind"]["config"][0]; + + $bind = $config['installedpackages']['bind']['config'][0]; $bind_enable = $bind['enable_bind']; $bind_forwarder = $bind['bind_forwarder']; $forwarder_ips = $bind['bind_forwarder_ips']; - $ram_limit = ($bind['bind_ram_limit']?$bind['bind_ram_limit']:"256M"); + $ram_limit = ($bind['bind_ram_limit'] ? $bind['bind_ram_limit'] : "256M"); $hide_version = $bind['bind_hide_version']; $bind_notify = $bind['bind_notify']; $custom_options = base64_decode($bind['bind_custom_options']); $bind_logging = $bind['bind_logging']; - $bind_conf ="#Bind pfsense configuration\n"; - $bind_conf .="#Do not edit this file!!!\n\n"; + $bind_conf = "#Bind pfsense configuration\n"; + $bind_conf .= "#Do not edit this file!!!\n\n"; $bind_conf .= "$rndc_bindconf\n"; $bind_conf .= <<$bind_listenonv6 $bind_listenon"; - if (key_exists("ipv6allow",$config['system'])){ - $bind_conf .="\t\tlisten-on-v6 { $bind_listenonv6 };\n"; - } - $bind_conf .="\t\tlisten-on { $bind_listenon };\n"; + $bind_listenonv6 = ($bind_listenonv6 == "" ? "none;" : $bind_listenonv6); + $bind_listenon = ($bind_listenon == "" ? "none;" : $bind_listenon); + // print "
$bind_listenonv6 $bind_listenon";
+	if (array_key_exists("ipv6allow", $config['system'])) {
+		$bind_conf .= "\t\tlisten-on-v6 { $bind_listenonv6 };\n";
+	}
+	$bind_conf .= "\tlisten-on { $bind_listenon };\n";
 
-	#forwarder config
-	if ($bind_forwarder == on)
-		$bind_conf .="\t\tforwarders { $forwarder_ips };\n";
-	if ($bind_notify == on)
-		$bind_conf .="\t\tnotify yes;\n"; 
-	if ($hide_version == on)
-		$bind_conf .="\t\tversion none;\n";
+	// forwarder config
+	if ($bind_forwarder == 'on') {
+		$bind_conf .= "\t\tforwarders { $forwarder_ips };\n";
+	}
+	if ($bind_notify == 'on') {
+		$bind_conf .= "\t\tnotify yes;\n";
+	}
+	if ($hide_version == 'on') {
+		$bind_conf .= "\t\tversion none;\n";
+	}
 
-	$bind_conf .= preg_replace("/^/m","\t\t",$custom_options); 
+	$bind_conf .= preg_replace("/^/m", "\t", $custom_options);
 	$bind_conf .= "\n\t};\n\n";
-	
-	if ($bind_logging == on){
+
+	if ($bind_logging == 'on') {
 		//check if bind is included on syslog
-		$syslog_files=array("/etc/inc/system.inc","/var/etc/syslog.conf");
-		$restart_syslog=0;
-		foreach ($syslog_files as $syslog_file){
-			$syslog_file_data=file_get_contents($syslog_file);
-			if ( !preg_match("/dnsmasq,named,filterdns/",$syslog_file_data) || !preg_match("/'dnsmasq','named','filterdns'/",$syslog_file_data) ) {
-				$syslog_file_data=preg_replace("/dnsmasq,filterdns/","dnsmasq,named,filterdns",$syslog_file_data);
-				$syslog_file_data=preg_replace("/'dnsmasq','filterdns'/","'dnsmasq','named','filterdns'",$syslog_file_data);
-				file_put_contents($syslog_file,$syslog_file_data);
+		$syslog_files = array("/etc/inc/system.inc", "/var/etc/syslog.conf");
+		$restart_syslog = 0;
+		foreach ($syslog_files as $syslog_file) {
+			$syslog_file_data = file_get_contents($syslog_file);
+			if (!preg_match("/dnsmasq,named,filterdns/", $syslog_file_data) || !preg_match("/'dnsmasq','named','filterdns'/", $syslog_file_data)) {
+				$syslog_file_data = preg_replace("/dnsmasq,filterdns/", "dnsmasq,named,filterdns", $syslog_file_data);
+				$syslog_file_data = preg_replace("/'dnsmasq','filterdns'/", "'dnsmasq','named','filterdns'", $syslog_file_data);
+				file_put_contents($syslog_file, $syslog_file_data);
 				$restart_syslog++;
-				}
 			}
-		if ($restart_syslog > 0){
+		}
+		if ($restart_syslog > 0) {
 			system("/usr/bin/killall -HUP syslogd");
 		}
-		$log_categories=explode(",",$bind['log_options']);
-		$log_severity=($bind['log_severity']?$bind['log_severity']:'default');
-		if (sizeof($log_categories) > 0 && $log_categories[0]!=""){
+		$log_categories = explode(",", $bind['log_options']);
+		$log_severity = ($bind['log_severity'] ? $bind['log_severity'] : 'default');
+		if (sizeof($log_categories) > 0 && $log_categories[0] != "") {
 			$bind_conf .= <<"none","description"=>"BIND Built-in ACL","row"=>array("value"=>"","description"=>""));
-		$config["installedpackages"]["bindacls"]["config"][] =
-			array("name"=>"any","description"=>"BIND Built-in ACL","row"=>array("value"=>"","description"=>""));
-		$config["installedpackages"]["bindacls"]["config"][] =
-			array("name"=>"localhost","description"=>"BIND Built-in ACL","row"=>array("value"=>"","description"=>""));
-		$config["installedpackages"]["bindacls"]["config"][] =
-			array("name"=>"localnets","description"=>"BIND Built-in ACL","row"=>array("value"=>"","description"=>""));
-		write_config("Create BIND Built-in ACLs");
+			foreach ($log_categories as $category) {
+				$bind_conf .= "\t\t\tcategory $category\t{custom;};\n";
+			}
+			$bind_conf .= "\t\t};\n\n";
 		}
-	$bindacls = $config["installedpackages"]["bindacls"]["config"];
-	for ($i=0; $i "none", "description" => "BIND Built-in ACL", "row" => array("value" => "", "description" => ""));
+		$config['installedpackages']['bindacls']['config'][] =
+			array("name" => "any", "description" => "BIND Built-in ACL", "row" => array("value" => "", "description" => ""));
+		$config['installedpackages']['bindacls']['config'][] =
+			array("name" => "localhost", "description" => "BIND Built-in ACL", "row" => array("value" => "", "description" => ""));
+		$config['installedpackages']['bindacls']['config'][] =
+			array("name" => "localnets", "description" => "BIND Built-in ACL", "row" => array("value" => "", "description" => ""));
+		write_config("Create BIND Built-in ACLs");
+	}
+	$bindacls = $config['installedpackages']['bindacls']['config'];
+	for ($i = 0; $i < sizeof($bindacls); $i++) {
 		$aclname = $bindacls[$i]['name'];
 		$aclhost = $bindacls[$i]['row'];
-		if($aclname != "none" && $aclname != "any" && $aclname != "localhost" && $aclname != "localnets"){
-			$bind_conf .= "acl \"$aclname\" {\n";	
-			for ($u=0; $u $dhcpifconf) {
-								if (!isset($dhcpifconf['enable']) || !is_array($dhcpifconf['staticmap']))  {
+								if (!isset($dhcpifconf['enable']) || !is_array($dhcpifconf['staticmap'])) {
 									continue;
 								}
 								foreach ($dhcpifconf['staticmap'] as $host) {
@@ -463,20 +511,20 @@ EOD;
 									} else {
 										continue;
 									}
-									if (!is_hostname($host['hostname']) || !is_ipaddr($host['ipaddr']))  {
+									if (!is_hostname($host['hostname']) || !is_ipaddr($host['ipaddr'])) {
 										continue;
 									}
 									if ($zonereverso == "on") {
-										$parts = explode('.',$host['ipaddr']);
-										$intersect = array_intersect_assoc($parts,$zoneparts);
+										$parts = explode('.', $host['ipaddr']);
+										$intersect = array_intersect_assoc($parts, $zoneparts);
 										if (count($zoneparts) == count($intersect)) {
-											$diff = array_diff_assoc($parts,$zoneparts);
-											$shortaddr = implode('.',array_reverse($diff));
+											$diff = array_diff_assoc($parts, $zoneparts);
+											$shortaddr = implode('.', array_reverse($diff));
 											$zone_conf .= "{$shortaddr}\tIN PTR\t{$host['hostname']}.{$domain}.\n";
 										}
 									} else {
-										$parts = array_reverse(explode('.',$domain));
-										$diff = array_diff_assoc($parts,$zoneparts);
+										$parts = array_reverse(explode('.', $domain));
+										$diff = array_diff_assoc($parts, $zoneparts);
 										if (count($diff) == 0) {
 											$zone_conf .= "{$host['hostname']}\tIN A\t{$host['ipaddr']}\n";
 										}
@@ -485,173 +533,184 @@ EOD;
 							}
 						}
 
-						if ($zone['customzonerecords']!=""){
+						// Add custom zone records
+						if ($zone['customzonerecords'] != "") {
 							$zone_conf .= "\n\n;\n;custom zone records\n;\n".base64_decode($zone['customzonerecords'])."\n";
 						}
+
+						// Save zone configuration DB file
 						file_put_contents(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview/$zonename.DB", $zone_conf);
-						$config["installedpackages"]["bindzone"]["config"][$x][resultconfig]=base64_encode($zone_conf);
+
+						$config['installedpackages']['bindzone']['config'][$x]['resultconfig'] = base64_encode($zone_conf);
 						$write_config++;
 						//check dnssec keys creation for master zones
-        				if($zone['dnssec']=="on"){
-	        				$zone_found=0;
-	        				foreach (glob(CHROOT_LOCALBASE."/etc/namedb/keys/*{$zonename}*key",GLOB_NOSORT) as $filename){
+						if ($zone['dnssec'] == "on") {
+							$zone_found = 0;
+							foreach (glob(CHROOT_LOCALBASE."/etc/namedb/keys/*{$zonename}*key", GLOB_NOSORT) as $filename) {
 								$zone_found++;
-	        					}
-							if ($zone_found==0){
-								$key_restored=0;
-								if(is_array($config['installedpackages']['dnsseckeys']) && is_array($config['installedpackages']['dnsseckeys']['config'])){
-									foreach ($config['installedpackages']['dnsseckeys']['config']as $filer)
-										if (preg_match ("/K$zonename\.+/",$filer['fullfile'])){
-											file_put_contents($filer['fullfile'],base64_decode($filer['filedata']),LOCK_EX);
-											chmod($filer['fullfile'],0700);
-											chown($filer['fullfile'],"bind");
+							}
+							if ($zone_found == 0) {
+								$key_restored = 0;
+								if (is_array($config['installedpackages']['dnsseckeys']) && is_array($config['installedpackages']['dnsseckeys']['config'])) {
+									foreach ($config['installedpackages']['dnsseckeys']['config'] as $filer) {
+										if (preg_match("/K$zonename\.+/", $filer['fullfile'])) {
+											file_put_contents($filer['fullfile'], base64_decode($filer['filedata']), LOCK_EX);
+											chmod($filer['fullfile'], 0700);
+											chown($filer['fullfile'], "bind");
 											$key_restored++;
-											}
 										}
-								if ($key_restored > 0){
+									}
+								}
+								if ($key_restored > 0) {
 									log_error("[bind] {$key_restored} DNSSEC keys restored from XML backup for {$zonename} zone.");
+								}
+								$dnssec_bin = "/usr/local/sbin/dnssec-keygen";
+								if (file_exists($dnssec_bin) && $key_restored == 0) {
+									exec("{$dnssec_bin} -K ".CHROOT_LOCALBASE."/etc/namedb/keys {$zonename}", $kout);
+									exec("{$dnssec_bin} -K ".CHROOT_LOCALBASE."/etc/namedb/keys -fk {$zonename}", $kout);
+									foreach ($kout as $filename) {
+										chown(CHROOT_LOCALBASE."/etc/namedb/keys/{$filename}.key", "bind");
+										chown(CHROOT_LOCALBASE."/etc/namedb/keys/{$filename}.private", "bind");
 									}
-								$dnssec_bin="/usr/local/sbin/dnssec-keygen";
-								if (file_exists($dnssec_bin) && $key_restored==0){
-									exec("{$dnssec_bin} -K ".CHROOT_LOCALBASE."/etc/namedb/keys {$zonename}",$kout);
-									exec("{$dnssec_bin} -K ".CHROOT_LOCALBASE."/etc/namedb/keys -fk {$zonename}",$kout);
-									foreach($kout as $filename){
-										chown(CHROOT_LOCALBASE."/etc/namedb/keys/{$filename}.key","bind");
-										chown(CHROOT_LOCALBASE."/etc/namedb/keys/{$filename}.private","bind");
-										}
 									log_error("[bind] DNSSEC keys for {$zonename} created.");
-									}
-	        					}
-	        				//get ds keys
-	        				$dsfromkey="/usr/local/sbin/dnssec-dsfromkey";
-	        				foreach (glob(CHROOT_LOCALBASE."/etc/namedb/keys/*{$zonename}*key",GLOB_NOSORT) as $filename) {
-	        						$zone_key=file_get_contents($filename);
-	        						if (preg_match("/IN DNSKEY 257 /",$zone_key) && file_exists($dsfromkey)){
-	        							exec("$dsfromkey $filename",$dsset);
-	        							$config["installedpackages"]["bindzone"]["config"][$x]['dsset']=base64_encode(array_pop($dsset)."\n".array_pop($dsset));
-	        							$write_config++;
-	        							}
 								}
-							//save dnssec keys to xml
-							
-							if($zone['backupkeys']=="on"){
-								$dnssec_keys=0;
-								foreach (glob(CHROOT_LOCALBASE."/etc/namedb/keys/*{$zonename}*",GLOB_NOSORT) as $filename){
-									$file_found=0;
-									if(is_array($config['installedpackages']['dnsseckeys']) && is_array($config['installedpackages']['dnsseckeys']['config'])){
-										foreach ($config['installedpackages']['dnsseckeys']['config']as $filer){
-											if ($filer['fullfile']==$filename)
+							}
+							// get ds keys
+							$dsfromkey = "/usr/local/sbin/dnssec-dsfromkey";
+							foreach (glob(CHROOT_LOCALBASE."/etc/namedb/keys/*{$zonename}*key", GLOB_NOSORT) as $filename) {
+								$zone_key = file_get_contents($filename);
+								if (preg_match("/IN DNSKEY 257 /", $zone_key) && file_exists($dsfromkey)) {
+									exec("$dsfromkey $filename", $dsset);
+									$config['installedpackages']['bindzone']['config'][$x]['dsset'] = base64_encode(array_pop($dsset)."\n".array_pop($dsset));
+									$write_config++;
+								}
+							}
+
+							// save dnssec keys to xml
+							if ($zone['backupkeys'] == "on") {
+								$dnssec_keys = 0;
+								foreach (glob(CHROOT_LOCALBASE."/etc/namedb/keys/*{$zonename}*", GLOB_NOSORT) as $filename) {
+									$file_found = 0;
+									if (is_array($config['installedpackages']['dnsseckeys']) && is_array($config['installedpackages']['dnsseckeys']['config'])) {
+										foreach ($config['installedpackages']['dnsseckeys']['config'] as $filer) {
+											if ($filer['fullfile'] == $filename) {
 												$file_found++;
 											}
 										}
-									if ($file_found==0){
-										$config['installedpackages']['dnsseckeys']['config'][]=array('fullfile'=> $filename,
-																								'description'=> "bind {$zonename} DNSSEC backup file",
-																								'filedata'=> base64_encode(file_get_contents($filename)));
+									}
+									if ($file_found == 0) {
+										$config['installedpackages']['dnsseckeys']['config'][] = array('fullfile' => $filename,
+											'description' => "bind {$zonename} DNSSEC backup file",
+											'filedata' => base64_encode(file_get_contents($filename)));
 										$write_config++;
 										$dnssec_keys++;
-										}
-									}
-									if($dnssec_keys>0){
-										log_error("[bind] {$dnssec_keys} DNSSEC keys for {$zonename} zone saved on XML config.");
 									}
 								}
-        					}
-					break;
-					case "slave":
-					//check/update slave dir permission
-					chown(CHROOT_LOCALBASE."/etc/namedb/$zonetype","bind");
-					chown(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview","bind");
-					//check if exists slave zone file
-					$rsconfig="";
-					if ($zone['dnssec']=="on"){
-						if (file_exists(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview/$zonename.DB.signed"))
-						exec("/usr/local/sbin/named-checkzone -D -f raw -o - {$zonename} ".CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview/$zonename.DB.signed",$slave_file);
+								if ($dnssec_keys > 0) {
+									log_error("[bind] {$dnssec_keys} DNSSEC keys for {$zonename} zone saved on XML config.");
+								}
+							}
 						}
-					else{
-						if (file_exists(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview/$zonename.DB"))
-							$slave_file=file(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview/$zonename.DB");
+						break;
+					case 'slave':
+						// check/update slave dir permission
+						chown(CHROOT_LOCALBASE."/etc/namedb/$zonetype", "bind");
+						chown(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview", "bind");
+						// check if exists slave zone file
+						$rsconfig = "";
+						if ($zone['dnssec'] == "on") {
+							if (file_exists(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview/$zonename.DB.signed")) {
+								exec("/usr/local/sbin/named-checkzone -D -f raw -o - {$zonename} ".CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview/$zonename.DB.signed", $slave_file);
+							}
+						} else {
+							if (file_exists(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview/$zonename.DB")) {
+								$slave_file = file(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview/$zonename.DB");
+							}
 						}
-					if (is_array($slave_file)){
-					foreach ($slave_file as $zfile)
-						$rsconfig.= $zfile;
-					$config["installedpackages"]["bindzone"]["config"][$x][resultconfig]=base64_encode($rsconfig);
-					$write_config++;
-					}
-					break;
-					}
+						// TODO is is_array() the best test to use?  is it only checking for existence?
+						if (is_array($slave_file)) {
+							foreach ($slave_file as $zfile) {
+								$rsconfig .= $zfile;
+							}
+						}
+						$config['installedpackages']['bindzone']['config'][$x]['resultconfig'] = base64_encode($rsconfig);
+						$write_config++;
+						break;
 				}
+			}
 		}
-		if (!$custom_root_zone[$i]){
-			$bind_conf .="\tzone \".\" {\n";
-			$bind_conf .="\t\ttype hint;\n";
-			$bind_conf .="\t\tfile \"/etc/namedb/named.root\";\n";
+		if (!$custom_root_zone[$i]) {
+			$bind_conf .= "\tzone \".\" {\n";
+			$bind_conf .= "\t\ttype hint;\n";
+			$bind_conf .= "\t\tfile \"/etc/namedb/named.root\";\n";
 			$bind_conf .= "\t};\n\n";
-			}
-		if($write_config > 0){
+		}
+		if ($write_config > 0) {
 			write_config("save result config file for zone on xml");
 		}
 		$bind_conf .= "};\n";
 	}
-	$dirs=array("/etc/namedb/keys","/var/run/named","/var/dump","/var/log","/var/stats","/dev");
-	foreach ($dirs as $dir){
-		if (!is_dir(CHROOT_LOCALBASE .$dir))
-			mkdir(CHROOT_LOCALBASE .$dir,0755,true);
+	$dirs = array("/etc/namedb/keys", "/var/run/named", "/var/dump", "/var/log", "/var/stats", "/dev");
+	foreach ($dirs as $dir) {
+		if (!is_dir(CHROOT_LOCALBASE.$dir)) {
+			mkdir(CHROOT_LOCALBASE.$dir, 0755, true);
 		}
-	//dev dirs for chroot
-	$bind_dev_dir=CHROOT_LOCALBASE."/dev";
-	if (!file_exists("$bind_dev_dir/random")){
-		$dev_dirs=array("null","zero","random","urandom");
-		exec("/sbin/mount -t devfs devfs {$bind_dev_dir}",$dout);
-		exec("/sbin/devfs -m {$bind_dev_dir} ruleset 1",$dout);
-		exec("/sbin/devfs -m {$bind_dev_dir} rule add hide",$dout);
-		foreach ($dev_dirs as $dev_dir)
-			exec("/sbin/devfs -m {$bind_dev_dir} rule add path $dev_dir unhide",$dout);
-		exec("/sbin/devfs -m {$bind_dev_dir} rule applyset",$dout);
-	}
-	//http://www.unixwiz.net/techtips/bind9-chroot.html
-    file_put_contents(CHROOT_LOCALBASE.'/etc/namedb/named.conf', $bind_conf);
-    file_put_contents(CHROOT_LOCALBASE.'/etc/namedb/rndc.conf', $rndc_file);
-    
-	if (!file_exists(CHROOT_LOCALBASE."/etc/namedb/named.root")){
-		//dig +tcp @a.root-servers.net > CHROOT_LOCALBASE."/etc/namedb/named.root"
-		$named_root=file_get_contents("http://www.internic.net/domain/named.root");
-		file_put_contents(CHROOT_LOCALBASE."/etc/namedb/named.root",$named_root,LOCK_EX);
-	}
-	if (!file_exists(CHROOT_LOCALBASE."/etc/localtime")){
+	}
+	// dev dirs for chroot
+	$bind_dev_dir = CHROOT_LOCALBASE."/dev";
+	if (!file_exists("$bind_dev_dir/random")) {
+		$dev_dirs = array("null", "zero", "random", "urandom");
+		exec("/sbin/mount -t devfs devfs {$bind_dev_dir}", $dout);
+		exec("/sbin/devfs -m {$bind_dev_dir} ruleset 1", $dout);
+		exec("/sbin/devfs -m {$bind_dev_dir} rule add hide", $dout);
+		foreach ($dev_dirs as $dev_dir) {
+			exec("/sbin/devfs -m {$bind_dev_dir} rule add path $dev_dir unhide", $dout);
+		}
+		exec("/sbin/devfs -m {$bind_dev_dir} rule applyset", $dout);
+	}
+	// http://www.unixwiz.net/techtips/bind9-chroot.html
+	file_put_contents(CHROOT_LOCALBASE.'/etc/namedb/named.conf', $bind_conf);
+	file_put_contents(CHROOT_LOCALBASE.'/etc/namedb/rndc.conf', $rndc_file);
+
+	if (!file_exists(CHROOT_LOCALBASE."/etc/namedb/named.root")) {
+		// dig +tcp @a.root-servers.net > CHROOT_LOCALBASE."/etc/namedb/named.root"
+		$named_root = file_get_contents("http://www.internic.net/domain/named.root");
+		file_put_contents(CHROOT_LOCALBASE."/etc/namedb/named.root", $named_root, LOCK_EX);
+	}
+	if (!file_exists(CHROOT_LOCALBASE."/etc/localtime")) {
 		copy("/etc/localtime", CHROOT_LOCALBASE."/etc/localtime");
 	}
-	
+
 	bind_write_rcfile();
-	chown(CHROOT_LOCALBASE."/etc/namedb/keys","bind");
-	chown(CHROOT_LOCALBASE."/etc/namedb","bind");
-	chown(CHROOT_LOCALBASE."/var/log","bind");
-	chown(CHROOT_LOCALBASE."/var/run/named","bind");
-	chgrp(CHROOT_LOCALBASE."/var/log","bind");
-	$bind_sh="/usr/local/etc/rc.d/named.sh";
- 	if($bind_enable == "on"){
- 		chmod ($bind_sh,0755);
- 		mwexec("{$bind_sh} restart");
- 		}
- 	elseif (is_service_running('named')){
- 		mwexec("{$bind_sh} stop");
-		chmod ($bind_sh,0644); 		
- 		}
- 	//sync to backup servers
- 	bind_sync_on_changes();
- 	conf_mount_ro();
+	chown(CHROOT_LOCALBASE."/etc/namedb/keys", "bind");
+	chown(CHROOT_LOCALBASE."/etc/namedb", "bind");
+	chown(CHROOT_LOCALBASE."/var/log", "bind");
+	chown(CHROOT_LOCALBASE."/var/run/named", "bind");
+	chgrp(CHROOT_LOCALBASE."/var/log", "bind");
+	$bind_sh = "/usr/local/etc/rc.d/named.sh";
+	if ($bind_enable == "on") {
+		chmod($bind_sh, 0755);
+		mwexec("{$bind_sh} restart");
+	} elseif (is_service_running('named')) {
+		mwexec("{$bind_sh} stop");
+		chmod($bind_sh, 0644);
+	}
+	// sync to backup servers
+	bind_sync_on_changes();
+	conf_mount_ro();
 }
 
-function bind_print_javascript_type_zone(){
-?>
-        
-
+	
+	on_type_zone_changed();document.iform.resultconfig.disabled = 1;document.iform.dsset.disabled = 1;\n");
+function bind_print_javascript_type_zone2()
+{
+	print("\n");
 }
 
-function bind_write_rcfile() {
-        $rc = array();
-        $BIND_LOCALBASE = "/usr/local";
-        $rc['file'] = 'named.sh';
-        $rc['start'] = <</dev/null
-sleep 2
+function bind_write_rcfile()
+{
+	$rc = array();
+	$BIND_LOCALBASE = "/usr/local";
+	$rc['file'] = 'named.sh';
+	$rc['start'] = <</dev/null
-         	sleep 3	
-        	{$BIND_LOCALBASE}/sbin/named -c /etc/namedb/named.conf -u bind -t /cf/named/
-        fi
-
+		sleep 2
+EOD;
+	$rc['restart'] = <</dev/null
+		        sleep 3
+			{$BIND_LOCALBASE}/sbin/named -c /etc/namedb/named.conf -u bind -t /cf/named/
+		fi
 EOD;
-        conf_mount_rw();
-        write_rcfile($rc);
-        conf_mount_ro();
+	conf_mount_rw();
+	write_rcfile($rc);
+	conf_mount_ro();
 }
 
 /* Uses XMLRPC to synchronize the changes to a remote node */
-function bind_sync_on_changes() {
+function bind_sync_on_changes()
+{
 	global $config, $g;
-	if (is_array($config['installedpackages']['bindsync']['config'])){
-		$bind_sync=$config['installedpackages']['bindsync']['config'][0];
+	if (is_array($config['installedpackages']['bindsync']['config'])) {
+		$bind_sync = $config['installedpackages']['bindsync']['config'][0];
 		$synconchanges = $bind_sync['synconchanges'];
 		$synctimeout = $bind_sync['synctimeout'];
-		$master_zone_ip=$bind_sync['masterip'];
-		switch ($synconchanges){
-			case "manual":
-				if (is_array($bind_sync[row])){
-					$rs=$bind_sync[row];
-					}
-				else{
+		$master_zone_ip = $bind_sync['masterip'];
+		switch ($synconchanges) {
+			case 'manual':
+				if (is_array($bind_sync['row'])) {
+					$rs = $bind_sync['row'];
+				} else {
 					log_error("[bind] xmlrpc sync is enabled but there is no hosts to push on bind config.");
 					return;
-					}
+				}
+				break;
+			case 'auto':
+				if (is_array($config['hasync'])) {
+					$hasync = $config['hasync'][0];
+					$rs[0]['ipaddress'] = $hasync['synchronizetoip'];
+					$rs[0]['username'] = $hasync['username'];
+					$rs[0]['password'] = $hasync['password'];
+				} else {
+					log_error("[bind] xmlrpc sync is enabled but there is no system backup hosts to push bind config.");
+					return;
+				}
 				break;
-			case "auto":
-					if (is_array($config['hasync'])){
-						$hasync=$config['hasync'][0];
-						$rs[0]['ipaddress']=$hasync['synchronizetoip'];
-						$rs[0]['username']=$hasync['username'];
-						$rs[0]['password']=$hasync['password'];
-					}
-					else{
-						log_error("[bind] xmlrpc sync is enabled but there is no system backup hosts to push bind config.");
-						return;
-					}
-				break;			
 			default:
 				return;
-			break;
+				break;
 		}
-		if (is_array($rs)){
+		if (is_array($rs)) {
 			log_error("[bind] xmlrpc sync is starting.");
-			foreach($rs as $sh){
+			foreach ($rs as $sh) {
 				$sync_to_ip = $sh['ipaddress'];
 				$password = $sh['password'];
-				if($sh['username'])
+				if ($sh['username']) {
 					$username = $sh['username'];
-				else
+				} else {
 					$username = 'admin';
-				if($password && $sync_to_ip)
-					bind_do_xmlrpc_sync($sync_to_ip, $username, $password,$synctimeout,$master_zone_ip);
 				}
-			log_error("[bind] xmlrpc sync is ending.");
+				if ($password && $sync_to_ip) {
+					bind_do_xmlrpc_sync($sync_to_ip, $username, $password, $synctimeout, $master_zone_ip);
+				}
 			}
- 		}
+			log_error("[bind] xmlrpc sync is ending.");
+		}
+	}
 }
+
 /* Do the actual XMLRPC sync */
-function bind_do_xmlrpc_sync($sync_to_ip, $username, $password, $synctimeout,$master_zone_ip) {
+function bind_do_xmlrpc_sync($sync_to_ip, $username, $password, $synctimeout, $master_zone_ip)
+{
 	global $config, $g;
 
-	if(!$username)
+	if (!$username) {
 		return;
-		
-	if(!$password)
+	}
+
+	if (!$password) {
 		return;
+	}
 
-	if(!$sync_to_ip)
+	if (!$sync_to_ip) {
 		return;
+	}
+
+	if (!$synctimeout) {
+		$synctimeout = 25;
+	}
+
 
-	if(!$synctimeout)
-		$synctimeout=25;
-		
-		
 	$xmlrpc_sync_neighbor = $sync_to_ip;
-    if($config['system']['webgui']['protocol'] != "") {
+	if ($config['system']['webgui']['protocol'] != "") {
 		$synchronizetoip = $config['system']['webgui']['protocol'];
 		$synchronizetoip .= "://";
-    }
-    $port = $config['system']['webgui']['port'];
-    /* if port is empty lets rely on the protocol selection */
-    if($port == "") {
-		if($config['system']['webgui']['protocol'] == "http") 
+	}
+	$port = $config['system']['webgui']['port'];
+	/* if port is empty lets rely on the protocol selection */
+	if ($port == "") {
+		if ($config['system']['webgui']['protocol'] == "http") {
 			$port = "80";
-		else 
+		} else {
 			$port = "443";
-    }
+		}
+	}
 	$synchronizetoip .= $sync_to_ip;
 
 	/* xml will hold the sections to sync */
@@ -847,17 +916,19 @@ function bind_do_xmlrpc_sync($sync_to_ip, $username, $password, $synctimeout,$ma
 	$xml['bindacls'] = $config['installedpackages']['bindacls'];
 	$xml['bindviews'] = $config['installedpackages']['bindviews'];
 	$xml['bindzone'] = $config['installedpackages']['bindzone'];
-	if (is_array($config['installedpackages']['dnsseckeys']))
-		$xml['dnsseckeys']=$config['installedpackages']['dnsseckeys'];
+	if (is_array($config['installedpackages']['dnsseckeys'])) {
+		$xml['dnsseckeys'] = $config['installedpackages']['dnsseckeys'];
+	}
 	//change master zone to slave on backup servers
-	if(is_array($xml['bindzone']["config"])) 
-		for ($x=0; $xsetCredentials($username, $password);
-	if($g['debug'])
+	if ($g['debug']) {
 		$cli->setDebug(1);
+	}
 	/* send our XMLRPC message and timeout after defined sync timeout value*/
 	$resp = $cli->send($msg, $synctimeout);
-	if(!$resp) {
+	if (!$resp) {
 		$error = "A communications error occurred while attempting BIND XMLRPC sync with {$url}:{$port}.";
 		log_error($error);
 		file_notice("sync_settings", $error, "bind Settings Sync", "");
-	} elseif($resp->faultCode()) {
+	} elseif ($resp->faultCode()) {
 		$cli->setDebug(1);
 		$resp = $cli->send($msg, $synctimeout);
-		$error = "An error code was received while attempting BIND XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+		$error = "An error code was received while attempting BIND XMLRPC sync with {$url}:{$port} - Code ".$resp->faultCode().": ".$resp->faultString();
 		log_error($error);
 		file_notice("sync_settings", $error, "bind Settings Sync", "");
 	} else {
 		log_error("[bind] XMLRPC sync successfully completed with {$url}:{$port}.");
 	}
-	
+
 	/* tell bind to reload our settings on the destination sync host. */
 	$method = 'pfsense.exec_php';
-	$execcmd  = "require_once('/usr/local/pkg/bind.inc');\n";
+	$execcmd = "require_once('/usr/local/pkg/bind.inc');\n";
 	$execcmd .= "bind_sync('yes');";
 	/* assemble xmlrpc payload */
 	$params = array(
 		XML_RPC_encode($password),
 		XML_RPC_encode($execcmd)
 	);
-	
+
 	log_error("[bind] XMLRPC reload data {$url}:{$port}.");
 	$msg = new XML_RPC_Message($method, $params);
 	$cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
 	$cli->setCredentials($username, $password);
 	$resp = $cli->send($msg, $synctimeout);
-	if(!$resp) {
+	if (!$resp) {
 		$error = "A communications error occurred while attempting BIND XMLRPC sync with {$url}:{$port} (pfsense.exec_php).";
 		log_error($error);
 		file_notice("sync_settings", $error, "Bind Settings Sync", "");
-	} elseif($resp->faultCode()) {
+	} elseif ($resp->faultCode()) {
 		$cli->setDebug(1);
 		$resp = $cli->send($msg, $synctimeout);
-		$error = "[Bind] An error code was received while attempting BIND XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+		$error = "[Bind] An error code was received while attempting BIND XMLRPC sync with {$url}:{$port} - Code ".$resp->faultCode().": ".$resp->faultString();
 		log_error($error);
 		file_notice("sync_settings", $error, "bind Settings Sync", "");
 	} else {
 		log_error("BIND XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php).");
 	}
-	
 }
+
 ?>
diff --git a/config/bind/bind.widget.php b/config/bind/bind.widget.php
index dc6b3bf0..1e8c0cc8 100644
--- a/config/bind/bind.widget.php
+++ b/config/bind/bind.widget.php
@@ -1,4 +1,4 @@
-";
-	echo"  ";
+	echo "  ";
 }
-function close_table(){
-	echo"  ";
-	echo"";
-	
+
+function close_table()
+{
+	echo "  ";
+	echo "";
+
 }
 
-$pfb_table=array();
-$img['Sick']="";
-$img['Healthy']="";
+$pfb_table = array();
+$img['Sick'] = "";
+$img['Healthy'] = "";
 
 
 #var_dump($pfb_table);
 #exit;
-?>
+
".ucfirst($fields[0])."\n"; - print "{$fields[1]}\n"; + open_table(); + foreach ($status as $line) { + $fields = explode(":", $line); + print "" . ucfirst($fields[0]) . "\n"; + print "{$fields[1]}\n"; } -close_table(); -echo"
"; + close_table(); + echo "
"; -?> - + function activitycallback_bind(transport) { + $('bind').innerHTML = transport.responseText; + setTimeout('getstatus_postfix()', 5000); + } + getstatus_bind(); + diff --git a/config/bind/bind.xml b/config/bind/bind.xml index 37c13017..b64ba256 100644 --- a/config/bind/bind.xml +++ b/config/bind/bind.xml @@ -2,8 +2,8 @@ - - + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. - bind - 1.0 - Bind: Domain Named Settings - /usr/local/pkg/bind.inc - - BIND Server - Modify BIND settings -
Services
- /pkg_edit.php?xml=bind.xml -
- - named - named.sh - named - Domain Name Service - - - - Settings - /pkg_edit.php?xml=bind.xml - - - - ACLs - /pkg.php?xml=bind_acls.xml - - - Views - /pkg.php?xml=bind_views.xml - - - Zones - /pkg.php?xml=bind_zones.xml - - - Sync - /pkg_edit.php?xml=bind_sync.xml - + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. + bind + 1.0 + Bind: Domain Named Settings + /usr/local/pkg/bind.inc + + BIND Server + Modify BIND settings +
Services
+ /pkg_edit.php?xml=bind.xml +
+ + named + named.sh + named + Domain Name Service + + + + Settings + /pkg_edit.php?xml=bind.xml + + + + ACLs + /pkg.php?xml=bind_acls.xml + + + Views + /pkg.php?xml=bind_views.xml + + + Zones + /pkg.php?xml=bind_zones.xml + + + Sync + /pkg_edit.php?xml=bind_sync.xml + - - - - /usr/local/pkg/ - 0755 - https://packages.pfsense.org/packages/config/bind/bind.xml - - - /usr/local/pkg/ - 0755 - https://packages.pfsense.org/packages/config/bind/bind_views.xml - - - /usr/local/pkg/ - 0755 - https://packages.pfsense.org/packages/config/bind/bind_zones.xml - - - /usr/local/pkg/ - 0755 - https://packages.pfsense.org/packages/config/bind/bind_acls.xml - - - /usr/local/pkg/ - 0755 - https://packages.pfsense.org/packages/config/bind/bind.inc - - - /usr/local/pkg/ - 0755 - https://packages.pfsense.org/packages/config/bind/bind_sync.xml - - - /usr/local/www/shortcuts/ - 0755 - https://packages.pfsense.org/packages/config/bind/pkg_bind.inc - - - /usr/local/www/widgets/widgets/ - 0755 - https://packages.pfsense.org/packages/config/bind/bind.widget.php - - - - listtopic - Daemon Settings - temp01 - - - Enable BIND - enable_bind - +
+ + + /usr/local/pkg/ + 0755 + https://packages.pfsense.org/packages/config/bind/bind.xml + + + /usr/local/pkg/ + 0755 + https://packages.pfsense.org/packages/config/bind/bind_views.xml + + + /usr/local/pkg/ + 0755 + https://packages.pfsense.org/packages/config/bind/bind_zones.xml + + + /usr/local/pkg/ + 0755 + https://packages.pfsense.org/packages/config/bind/bind_acls.xml + + + /usr/local/pkg/ + 0755 + https://packages.pfsense.org/packages/config/bind/bind.inc + + + /usr/local/pkg/ + 0755 + https://packages.pfsense.org/packages/config/bind/bind_sync.xml + + + /usr/local/www/shortcuts/ + 0755 + https://packages.pfsense.org/packages/config/bind/pkg_bind.inc + + + /usr/local/www/widgets/widgets/ + 0755 + https://packages.pfsense.org/packages/config/bind/bind.widget.php + + + + listtopic + Daemon Settings + temp01 + + + Enable BIND + enable_bind + Disable DNS Forwarder and Resolver services on selected interfaces before enabling BIND.]]> - checkbox - - - - Listen on - listenon - - interfaces_selection - - - - - - Enable Notify - bind_notify - Notify slave server after any update on master. - checkbox - - - Hide Version - bind_hide_version - Hide the version of BIND (ignore queries for version.bind). - checkbox - - - Limit Memory use - bind_ram_limit - Limits RAM use for DNS server, recommend 256M - input - 10 - 256M - - - listtopic - Logging options - temp01 - - - Enable logging - bind_logging - System logs, Resolver tab.]]> - checkbox - - - Logging serverity - log_severity - - The value 'dynamic' means assume the global level defined by either the command line parameter -d or by running rndc trace.]]> - select - - - - - - - - - - - - - - Logging options - log_options - - use CTRL+click to select/unselect.]]> - select - - - - - - - - - - - - - - - - - - - - - 18 - - - listtopic - Response Rate Limit - temp01 - - - Rate limit - rate_enabled - - Limit/rate response queries to prevent DOS attack.]]> - checkbox - rate_limit,log_only - - - Limit Action - log_only - Select what to do when a query reaches a limit. - select - - - - - - - limit - rate_limit - Set rate limit. Default to 15. - input - 10 - - - - listtopic - Forwarder Config - temp01 - - - Enable Forwarding - bind_forwarder - Enable forwarding queries to other DNS servers listed below rather than this server performing its own recursion. - checkbox - bind_forwarder_ips - - - Forwarder IPs - bind_forwarder_ips - Enter IPs of DNS servers to use for recursion. Separate by semi-colons (;). Applies only if Enable Forwarding is chosen. - input - 80 - - - listtopic - custom Options - temp01 - - - Custom Options - bind_custom_options - - They'll be added to the configuration. They need to be named.conf native options.]]> - - textarea - 65 - 5 - base64 - - - - - - - - - - - - bind_sync(); - - - bind_write_rcfile(); + checkbox + + + + Listen on + listenon + + interfaces_selection + + + + + + Enable Notify + bind_notify + Notify slave server after any update on master. + checkbox + + + Hide Version + bind_hide_version + Hide the version of BIND (ignore queries for version.bind). + checkbox + + + Limit Memory Use + bind_ram_limit + Limits RAM use for DNS server, recommend 256M + input + 10 + 256M + + + listtopic + Logging options + temp01 + + + Enable Logging + bind_logging + System logs, Resolver tab.]]> + checkbox + + + Logging Serverity + log_severity + + The value 'dynamic' means assume the global level defined by either the command line parameter -d or by running rndc trace.]]> + select + + + + + + + + + + + + + + Logging Options + log_options + + use CTRL+click to select/unselect.]]> + select + + + + + + + + + + + + + + + + + + + + + 18 + + + listtopic + Response Rate Limit + temp01 + + + Rate Limit + rate_enabled + + Limit/rate response queries to prevent DOS attack.]]> + checkbox + rate_limit,log_only + + + Limit Action + log_only + Select what to do when a query reaches a limit. + select + + + + + + + Limit + rate_limit + Set rate limit. Default to 15. + input + 10 + + + listtopic + Forwarder Config + temp01 + + + Enable Forwarding + bind_forwarder + Enable forwarding queries to other DNS servers listed below rather than this server + performing its own recursion. + + checkbox + bind_forwarder_ips + + + Forwarder IPs + bind_forwarder_ips + Enter IPs of DNS servers to use for recursion. Separate by semi-colons (;). Applies + only if Enable Forwarding is chosen. + + input + 80 + + + listtopic + Custom Options + temp01 + + + Custom Options + bind_custom_options + + + They'll be added to the configuration. They need to be named.conf native options.]]> + + textarea + 65 + 5 + base64 + + + + + + + + + + + + bind_sync(); + + + bind_write_rcfile(); - - - + + +
diff --git a/config/bind/bind_acls.xml b/config/bind/bind_acls.xml index c9b49f47..49794a69 100644 --- a/config/bind/bind_acls.xml +++ b/config/bind/bind_acls.xml @@ -2,8 +2,8 @@ - - + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. bindacls 0.1.0 BIND: ACLs Settings @@ -56,29 +56,29 @@
Services
bind.xml - - - Settings - /pkg_edit.php?xml=bind.xml - - - ACLs - /pkg.php?xml=bind_acls.xml - - - - Views - /pkg.php?xml=bind_views.xml - - - Zones - /pkg.php?xml=bind_zones.xml - - - Sync - /pkg_edit.php?xml=bind_sync.xml - - + + + Settings + /pkg_edit.php?xml=bind.xml + + + ACLs + /pkg.php?xml=bind_acls.xml + + + + Views + /pkg.php?xml=bind_views.xml + + + Zones + /pkg.php?xml=bind_zones.xml + + + Sync + /pkg_edit.php?xml=bind_sync.xml + + ['installedpackages']['bindacls']['config'] @@ -92,7 +92,7 @@ on + will be parsed and rendered for the user as a gui with input, and selectboxes. --> ACL Name @@ -107,32 +107,32 @@ Enter the description for this ACL. input - - Enter IP or range block network. - Leave blank to allow All - none - rowhelper - - - Value - value - input - 20 - - - Description - description - input - 20 - - - + + Enter IP or range block network. + Leave blank to allow All + none + rowhelper + + + Value + value + input + 20 + + + Description + description + input + 20 + + + - - + + - - - bind_sync(); - + + + bind_sync(); +
diff --git a/config/bind/bind_sync.xml b/config/bind/bind_sync.xml index d2f9c95b..97fdad81 100644 --- a/config/bind/bind_sync.xml +++ b/config/bind/bind_sync.xml @@ -3,7 +3,7 @@ - Zone Master IP masterip - All master zones will be configured as backup on slave servers.]]> + All master zones will be configured as backup on slave servers.]]> input 20 @@ -115,24 +115,24 @@ none rowhelper Do not forget to:
-      Create firewall rules to allow zone transfer between master and slave servers.
-      Create a acls with these slave servers.
-      Include created acl on allow-transfer option on zone config.]]> +      Create firewall rules to allow zone transfer between master and slave servers.
+      Create a acls with these slave servers.
+      Include created acl on allow-transfer option on zone config.]]> - - IP Address - ipaddress - IP Address of remote server - input - 20 - - - Password - password - Password for remote server. - password - 20 - + + IP Address + ipaddress + IP Address of remote server + input + 20 + + + Password + password + Password for remote server. + password + 20 + diff --git a/config/bind/bind_views.xml b/config/bind/bind_views.xml index 505f2b0d..7d38f481 100644 --- a/config/bind/bind_views.xml +++ b/config/bind/bind_views.xml @@ -2,8 +2,8 @@ - - + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. +
+ Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. bindviews 0.1.0 Bind: Views Settings @@ -56,29 +56,29 @@
Services
bind.xml - - - Settings - /pkg_edit.php?xml=bind.xml - - - ACLs - /pkg.php?xml=bind_acls.xml - - - Views - /pkg.php?xml=bind_views.xml - - - - Zones - /pkg.php?xml=bind_zones.xml - - - Sync - /pkg_edit.php?xml=bind_sync.xml - - + + + Settings + /pkg_edit.php?xml=bind.xml + + + ACLs + /pkg.php?xml=bind_acls.xml + + + Views + /pkg.php?xml=bind_views.xml + + + + Zones + /pkg.php?xml=bind_zones.xml + + + Sync + /pkg_edit.php?xml=bind_sync.xml + + ['installedpackages']['bindviews']['config'] @@ -106,19 +106,26 @@ input - Recursion - recursion - A recursive query occurs when your DNS server is queried for a domain that it currently knows nothing about, in which case it will try to resolve the given host by performing further queries (eg by starting at the root servers and working out, or by simply passing the request to yet another DNS server). - select - - - - + Recursion + recursion + A recursive query occurs when your DNS server is queried for a domain that it + currently knows nothing about, in which case it will try to resolve the given host by + performing further queries (eg by starting at the root servers and working out, or by + simply passing the request to yet another DNS server). + + select + + + + Match-clients match-clients - If either or both of match-clients are missing they default to any (all hosts match). The match-clients statement defines the address_match_list for the source IP address of the incoming messages. + If either or both of match-clients are missing they default to any (all hosts + match). The match-clients statement defines the address_match_list for the source IP + address of the incoming messages. + select_source name @@ -129,8 +136,10 @@ Allow-recursion allow-recursion - For example, if you have one DNS server serving your local network, you may want all of your local computers to use your DNS server. - select_source + For example, if you have one DNS server serving your local network, you may want + all of your local computers to use your DNS server. + + select_source name name @@ -138,25 +147,26 @@ 03 - listtopic - Custom Views - temp - - - Custom Options - bind_custom_options - You can put your own custom options here, separated by semi-colons (;). - textarea - 65 - 8 - base64 - + listtopic + Custom Views + temp + + + Custom Options + bind_custom_options + You can put your own custom options here, separated by semi-colons (;). + + textarea + 65 + 8 + base64 + - - + + - - - bind_sync(); - + + + bind_sync(); +
diff --git a/config/bind/bind_zones.xml b/config/bind/bind_zones.xml index 1576cd79..a62c1aaf 100644 --- a/config/bind/bind_zones.xml +++ b/config/bind/bind_zones.xml @@ -2,8 +2,8 @@ - - + - - Describe your package here - Describe your package requirements here - Currently there are no FAQ items provided. + + Describe your package here + Describe your package requirements here + Currently there are no FAQ items provided. bindzone none BIND: Zones Settings @@ -56,47 +56,47 @@
Services
bind.xml - - - Settings - /pkg_edit.php?xml=bind.xml - - - ACLs - /pkg.php?xml=bind_acls.xml - - - Views - /pkg.php?xml=bind_views.xml - - - Zones - /pkg.php?xml=bind_zones.xml&id=0 - - - - Sync - /pkg_edit.php?xml=bind_sync.xml - - + + + Settings + /pkg_edit.php?xml=bind.xml + + + ACLs + /pkg.php?xml=bind_acls.xml + + + Views + /pkg.php?xml=bind_views.xml + + + Zones + /pkg.php?xml=bind_zones.xml&id=0 + + + + Sync + /pkg_edit.php?xml=bind_sync.xml + + ['installedpackages']['bindzone']['config'] - status + Status disabled Disabled Enabled - Zone Name + Name name - Zone Type + Type type - View Name + View(s) view @@ -111,9 +111,9 @@ - listtopic - Domain Zone Configuration - temp01 + listtopic + Domain Zone Configuration + temp01 Disable this zone @@ -141,21 +141,21 @@ Zone Type type - select - - - - - - - on_type_zone_changed() + select + + + + + + + on_type_zone_changed() View view - - select_source + + select_source name name @@ -204,20 +204,21 @@ base64 - listtopic - Slave Zone Configuration - temp04 + listtopic + Slave Zone Configuration + temp04 Master Zone IP slaveip - If this is a slave zone, enter the IP address of the master DNS server. + If this is a slave zone, enter the IP address of the master DNS server. + input - listtopic - Forward Zone Configuration - temp04 + listtopic + Forward Zone Configuration + temp04 Forwarders @@ -228,14 +229,15 @@ - listtopic - Master Zone Configuration - temp03 + listtopic + Master Zone Configuration + temp03 TLL tll - Default expiration time of all resource records without their own TTL value + Default expiration time of all resource records without their own TTL value + input @@ -267,35 +269,35 @@ refresh Slave refresh (1 day) input - 1d + 1d Retry retry Slave retry time in case of a problem (2 hours) input - 2h + 2h Expire expire Slave expiration time (4 weeks) input - 4w + 4w Minimum minimum Maximum caching time in case of failed lookups (1 hour) input - 1h + 1h Allow-update allowupdate - Allow-update defines a match list eg IP address(es) that are allowed to submit dynamic updates for 'master' zones ie it enables Dynamic DNS (DDNS).]]> - select_source + Allow-update defines a match list eg IP address(es) that are allowed to submit dynamic updates for 'master' zones, ie it enables Dynamic DNS (DDNS).]]> + select_source name name @@ -306,7 +308,7 @@ Allow-query allowquery - Allow-query defines an match list of IP address(es) which are allowed to issue queries to the server.]]> + Allow-query defines an match list of IP address(es) which are allowed to issue queries to the server.]]> select_source name @@ -319,7 +321,7 @@ allowtransfer Allow-transfer defines a match list eg IP address(es) that are allowed to transfer (copy) the zone information from the server (master or slave for the zone). While on its face this may seem an excessively friendly default, DNS data is essentially public (that's why its there) and the bad guys can get all of it anyway. However if the thought of anyone being able to transfer your precious zone file is repugnant, or (and this is far more significant) you are concerned about possible DoS attack initiated by XFER requests, then use the following policy.]]> - select_source + select_source name name @@ -327,69 +329,72 @@ 03 - listtopic - Zone Domain records - temp02 - - - Enter Domain records. - "Record"
is the name or last octet of IP. Example: www or pop
- "Type" is the type of the record Sample: A CNAME MX NS
- "Priority" in used only in mx records to define its priority
- "Alias or IP address" is the destination host or ip address.

- You can order elements on this list with drag and drop between columns.]]> - none - rowhelper - - - Record - hostname - Enter the Host Name (ex: www) - input - 10 - - - Type - hosttype - Select Type Host - select - - - - - - - - - - - - - - - - Priority - hostvalue - MX 10 or 20 - input - 3 - - - Alias or IP address - hostdst - Enter the IP address or FQDN destination for domain MX (ex: 10.31.11.1 or mail.example.com) - input - 35 - - on - - + listtopic + Zone Domain records + temp02 + + + Enter Domain records. + "Record"
is the name or last octet of IP. Example: www or pop
+ "Type" is the type of the record Sample: A CNAME MX NS
+ "Priority" in used only in mx records to define its priority
+ "Alias or IP address" is the destination host or ip address.

+ You can order elements on this list with drag and drop between columns.]]> + none + rowhelper + + + Record + hostname + Enter the Host Name (ex: www) + input + 10 + + + Type + hosttype + Select Type Host + select + + + + + + + + + + + + + + + + Priority + hostvalue + MX 10 or 20 + input + 3 + + + Alias or IP address + hostdst + Enter the IP address or FQDN destination for domain MX (ex: 10.31.11.1 or mail.example.com) + + input + 35 + + on + + regdhcpstatic Register DHCP static mappings - If this option is set, then DHCP static mappings will be registered in DNS, so that their name can be resolved. + If this option is set, then DHCP static mappings will be registered in DNS, so that + their name can be resolved. + checkbox - + listtopic Custom Zone Domain records @@ -399,13 +404,13 @@ customzonerecords - This can be used for a fast migration setup.]]> - textarea - 84 - 10 - base64 - - + This can be used for a fast migration setup.]]> + textarea + 84 + 10 + base64 + + listtopic @@ -415,31 +420,32 @@ resultconfig Resulting BIND config file for this zone. - textarea - 84 - 15 - base64 - - + textarea + 84 + 15 + base64 + + - - bind_print_javascript_type_zone2(); - - - bind_print_javascript_type_zone(); - - - + + bind_print_javascript_type_zone2(); + + + bind_print_javascript_type_zone(); + + + - if ($_POST['type']=="master" and $_POST['serial']=="") + if ($_POST['type']=="master" and $_POST['serial']=="") { $_POST['serial']=(date("U")+ 1000000000); + } bind_zone_validate($_POST, $input_errors); - bind_sync(); - - - bind_sync(); - + bind_sync(); + + + bind_sync(); + -- cgit v1.2.3