aboutsummaryrefslogtreecommitdiffstats
path: root/config/bind
diff options
context:
space:
mode:
Diffstat (limited to 'config/bind')
-rw-r--r--config/bind/bind.inc119
-rw-r--r--config/bind/bind_views.xml7
-rw-r--r--config/bind/bind_zones.xml60
3 files changed, 38 insertions, 148 deletions
diff --git a/config/bind/bind.inc b/config/bind/bind.inc
index 4e01214a..1f7f9d8b 100644
--- a/config/bind/bind.inc
+++ b/config/bind/bind.inc
@@ -3,7 +3,8 @@
/*
bind.inc
part of the Bind package for pfSense
- Copyright (C) 2013 Juliano Oliveira/Adriano Brancher
+ Copyright (C) 2013 Juliano Oliveira/Adriano Brancher
+ Copyright (C) 2013 Marcello Coutinho
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -59,8 +60,6 @@ define('CHROOT_LOCALBASE','/conf/named');
$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";
$bind_conf .= <<<EOD
@@ -149,13 +148,12 @@ $bind_conf .= <<<EOD
EOD;
}
-
#Config Zone domain
- if(is_array($config["installedpackages"]["bindacls"]))
- $bindacls = $config["installedpackages"]["bindacls"]["config"];
- else
- $bindacls =array();
-
+ if(!is_array($config["installedpackages"]["bindacls"]) || !is_array($config["installedpackages"]["bindacls"]["config"])){
+ $config["installedpackages"]["bindacls"]["config"][] =array("name"=>"any","description"=>"Default Access list","row" => array("value"=> "","description"=>""));
+ write_config();
+ }
+ $bindacls = $config["installedpackages"]["bindacls"]["config"];
for ($i=0; $i<sizeof($bindacls); $i++)
{
$aclname = $bindacls[$i]['name'];
@@ -202,9 +200,13 @@ EOD;
$bind_conf .="\t\tfile \"/etc/namedb/named.root\";\n";
$bind_conf .= "\t};\n\n";
- for ($x=0; $x<sizeof($config["installedpackages"]["bindzone"]["config"]); $x++)
+ if(is_array($config["installedpackages"]["bindzone"]))
+ $bindzone = $config["installedpackages"]["bindzone"]["config"];
+ else
+ $bindzone =array();
+ for ($x=0; $x<sizeof($bindzone); $x++)
{
- $zone = $config["installedpackages"]["bindzone"]["config"][$x];
+ $zone = $bindzone[$x];
$zonename = $zone['name'];
$zonetype = $zone['type'];
@@ -248,7 +250,7 @@ EOD;
if ($zonetype == "master"){
$zonetll = $zone['tll'];
- $zonemail = $zone['mail'];
+ $zonemail = preg_replace("/@/",".",$zone['mail']);
$zoneserial = $zone['serial'];
$zonerefresh = $zone['refresh'];
$zoneretry = $zone['retry'];
@@ -268,20 +270,21 @@ EOD;
if($zone['allowtransfer'] == '')
$zoneallowtransfer = "none";
else
- $zoneallowtransfer = str_replace(',','; ',$zone['allowtransfer']);
- $zone_conf = ";$zonename\n";
- $zone_conf .= "\$TTL $zonetll\n\n";
-
+ $zoneallowtransfer = str_replace(',','; ',$zone['allowtransfer']);
+ $zone_conf .= "\$TTL $zonetll\n;\n";
+ $zone_conf .= ";\tDatabase file {$zonename}.DB for {$zonename} zone.\n";
+ $zone_conf .= ";\tZone version {$zoneserial}\n;\n";
if($zonereverso == "on")
$zone_conf .= "@\t IN SOA $zonenameserver. \t $zonemail. (\n";
else
$zone_conf .= "$zonename.\t IN SOA $zonenameserver. \t $zonemail. (\n";
- $zone_conf .= "\t$zoneserial\n";
- $zone_conf .= "\t$zonerefresh\n";
- $zone_conf .= "\t$zoneretry\n";
- $zone_conf .= "\t$zoneexpire\n";
- $zone_conf .= "\t$zoneminimum)\n\n";
+ $zone_conf .= "\t\t$zoneserial ; serial\n";
+ $zone_conf .= "\t\t$zonerefresh ; refresh\n";
+ $zone_conf .= "\t\t$zoneretry ; retry\n";
+ $zone_conf .= "\t\t$zoneexpire ; expire\n";
+ $zone_conf .= "\t\t$zoneminimum)\n\n";
+ $zone_conf .= ";\n; Zone Records\n;\n";
if($zonereverso == "on")
$zone_conf .= "\t IN NS \t\t$zonenameserver.\n";
@@ -291,9 +294,11 @@ EOD;
}
for ($y=0; $y<sizeof($zone['row']); $y++)
{
- $hostname = $zone['row'][$y]['hostname'];
+ $hostname = (preg_match("/(MX|NS)/",$zone['row'][$y]['hosttype'])?"@":$zone['row'][$y]['hostname']);
$hosttype = $zone['row'][$y]['hosttype'];
$hostdst = $zone['row'][$y]['hostdst'];
+ if (preg_match("/[a-zA-Z]/",$hostdst) && $hosttype !="TXT")
+ $hostdst .= ".";
$hostvalue = $zone['row'][$y]['hostvalue'];
$zone_conf .= "$hostname \t IN $hosttype $hostvalue \t$hostdst\n";
@@ -302,9 +307,7 @@ EOD;
mkdir(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview",0755,true);
}
file_put_contents(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview/$zonename.DB", $zone_conf);
-
- #reader file domain zone
- #reader file host definition
+
}
}
}
@@ -375,72 +378,6 @@ function bind_print_javascript_type_zone2(){
print("<script language=\"JavaScript\">on_type_zone_changed()</script>\n");
}
-# Carregar o campo com os dados da views
-# -----------------------------------------------------------------------------
-
-function get_bind_conf_items_list($data_group, $fieldname) {
- global $config;
- $res = '';
- if (is_array($config["installedpackages"][$data_group])){
- $conf = $config["installedpackages"][$data_group]["config"];
- if (is_array($conf))
- foreach($conf as $cf) $res[] = $cf[$fieldname];
- }
- return $res;
-}
-
-# Carregar o campo com os dados da views
-# -----------------------------------------------------------------------------
-
-function bind_views_before_form_dest($pkg,$data_group,$fieldname,$dest) {
-
- $destination_items = get_bind_conf_items_list($data_group,$fieldname);
- $i=0;
- if (is_array($pkg['fields']['field']))
- foreach($pkg['fields']['field'] as $field) {
- #
- if ($field['fieldname'] == $dest) {
- $fld = &$pkg['fields']['field'][$i];
- if (is_array($destination_items))
- foreach($destination_items as $nmkey => $nm)
- $fld['options']['option'][] = array('name'=>ucfirst(strtolower($nm)), 'value'=>strtolower($nm));
- }
- $i++;
- }
-}
-
-# check zone serial number
-# -----------------------------------------------------------------------------
-
-function get_bind_conf_serial($data_group, $fieldname) {
- global $config;
- $res = '';
- if (is_array($config["installedpackages"][$data_group])){
- $conf = $config["installedpackages"][$data_group]["config"];
- if (is_array($conf))
- foreach($conf as $cf) $res[] = $cf[$fieldname];
- }
- return $res;
-}
-
-# load data into fields
-# -----------------------------------------------------------------------------
-
-function bind_zone_before_form_dest($pkg,$data_group,$fieldname,$dest) {
-
- $destination_items = get_bind_conf_serial($data_group,$fieldname);
- $i=0;
- if (is_array($pkg['fields']['field']))
- foreach($pkg['fields']['field'] as $field) {
- #
- if ($field['fieldname'] == $dest) {
- $fld = &$pkg['fields']['field'][$i];
- $fld['default_value'] = date("YmdHis");
- #$fld['value'] = date("Ymdhms")."boa";
- }
- $i++;
- }
-}
function bind_write_rcfile() {
$rc = array();
$BIND_LOCALBASE = "/usr/local";
diff --git a/config/bind/bind_views.xml b/config/bind/bind_views.xml
index 2ff19c85..2d620e0c 100644
--- a/config/bind/bind_views.xml
+++ b/config/bind/bind_views.xml
@@ -50,7 +50,6 @@
<version>0.1.0</version>
<title>Bind: Views Settings</title>
<include_file>/usr/local/pkg/bind.inc</include_file>
- <!-- Menu is where this packages menu will appear -->
<menu>
<name>Bind Server</name>
<tooltiptext></tooltiptext>
@@ -80,8 +79,6 @@
<url>/pkg_edit.php?xml=bind_sync.xml</url>
</tab>
</tabs>
-<!-- configpath gets expanded out automatically and config items will be
- stored in that location -->
<configpath>['installedpackages']['bindviews']['config']</configpath>
<adddeleteeditpagefields>
<columnitem>
@@ -94,8 +91,6 @@
</columnitem>
<movable>on</movable>
</adddeleteeditpagefields>
- <!-- fields gets invoked when the user adds or edits a item. the following items
- will be parsed and rendered for the user as a gui with input, and selectboxes. -->
<fields>
<field>
<fielddescr>View Name</fielddescr>
@@ -157,8 +152,6 @@
</field>
</fields>
<custom_php_command_before_form>
- bind_views_before_form_dest(&amp;$pkg,"bindacls","name","match-clients");
- bind_views_before_form_dest(&amp;$pkg,"bindacls","name","allow-recursion");
</custom_php_command_before_form>
<custom_delete_php_command>
</custom_delete_php_command>
diff --git a/config/bind/bind_zones.xml b/config/bind/bind_zones.xml
index bef8781b..810fef89 100644
--- a/config/bind/bind_zones.xml
+++ b/config/bind/bind_zones.xml
@@ -50,7 +50,6 @@
<version>none</version>
<title>Bind: Zones Settings</title>
<include_file>/usr/local/pkg/bind.inc</include_file>
- <!-- Menu is where this packages menu will appear -->
<menu>
<name>Bind Server</name>
<tooltiptext></tooltiptext>
@@ -80,8 +79,6 @@
<url>/pkg_edit.php?xml=bind_sync.xml</url>
</tab>
</tabs>
- <!-- configpath gets expanded out automatically and config items will be
- stored in that location -->
<configpath>['installedpackages']['bindzone']['config']</configpath>
<adddeleteeditpagefields>
<columnitem>
@@ -102,8 +99,6 @@
</columnitem>
<movable>on</movable>
</adddeleteeditpagefields>
- <!-- fields gets invoked when the user adds or edits a item. the following items
- will be parsed and rendered for the user as a gui with input, and selectboxes. -->
<fields>
<field>
<type>listtopic</type>
@@ -298,46 +293,16 @@
<description>Select Type Host</description>
<type>select</type>
<options>
- <option>
- <name>A</name>
- <value>A</value>
- </option>
- <option>
- <name>AAAA</name>
- <value>AAAA</value>
- </option>
- <option>
- <name>DNAME</name>
- <value>DNAME</value>
- </option>
- <option>
- <name>MX</name>
- <value>MX</value>
- </option>
- <option>
- <name>CNAME</name>
- <value>CNAME</value>
- </option>
- <option>
- <name>NS</name>
- <value>NS</value>
- </option>
- <option>
- <name>LOC</name>
- <value>LOC</value>
- </option>
- <option>
- <name>SRV</name>
- <value>SRV</value>
- </option>
- <option>
- <name>PTR</name>
- <value>PTR</value>
- </option>
- <option>
- <name>TXT</name>
- <value>TXT</value>
- </option>
+ <option><name>A</name><value>A</value></option>
+ <option><name>AAAA</name><value>AAAA</value></option>
+ <option><name>DNAME</name><value>DNAME</value></option>
+ <option><name>MX</name><value>MX</value></option>
+ <option><name>CNAME</name><value>CNAME</value></option>
+ <option><name>NS</name><value>NS</value></option>
+ <option><name>LOC</name><value>LOC</value></option>
+ <option><name>SRV</name><value>SRV</value></option>
+ <option><name>PTR</name><value>PTR</value></option>
+ <option><name>TXT</name><value>TXT</value></option>
</options>
</rowhelperfield>
<rowhelperfield>
@@ -364,11 +329,6 @@
bind_print_javascript_type_zone();
</custom_php_after_head_command>
<custom_php_command_before_form>
- bind_views_before_form_dest(&amp;$pkg,"bindacls","name","allowtransfer");
- bind_views_before_form_dest(&amp;$pkg,"bindacls","name","allowquery");
- bind_views_before_form_dest(&amp;$pkg,"bindacls","name","allowupdate");
- bind_views_before_form_dest(&amp;$pkg,"bindviews","name","view");
- bind_zone_before_form_dest(&amp;$pkg,"bindzone","name","serial");
</custom_php_command_before_form>
<custom_php_validation_command>
$_POST['serial']=(date("U")+ 1000000000);