aboutsummaryrefslogtreecommitdiffstats
path: root/config/bind/bind.inc
diff options
context:
space:
mode:
authorMarcello Coutinho <marcellocoutinho@gmail.com>2013-10-10 19:21:28 -0300
committerMarcello Coutinho <marcellocoutinho@gmail.com>2013-10-10 19:21:28 -0300
commit6aea580bbd10faf6e19678de42f800f060c316c4 (patch)
treedd0981de93d691ef1de92f865a306c9594bc99ac /config/bind/bind.inc
parentb46cdd37023fccc545db507b939f70bf8af7f7a0 (diff)
downloadpfsense-packages-6aea580bbd10faf6e19678de42f800f060c316c4.tar.gz
pfsense-packages-6aea580bbd10faf6e19678de42f800f060c316c4.tar.bz2
pfsense-packages-6aea580bbd10faf6e19678de42f800f060c316c4.zip
bind - remove unused functions and change config result file
Diffstat (limited to 'config/bind/bind.inc')
-rw-r--r--config/bind/bind.inc119
1 files changed, 28 insertions, 91 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";