From 0141fd3928cc1f7254e6cfba2b58a9ac3964f2e2 Mon Sep 17 00:00:00 2001
From: xaver <xaver@ispconfig3>
Date: Fri, 09 Sep 2011 13:35:54 -0400
Subject: [PATCH] Fixed #1104 - Added imap,pop3-ssl ports, because programm is setuped in default insterlation
---
server/plugins-available/bind_plugin.inc.php | 80 ++++++++++++++++++++++++++++++++++------
1 files changed, 68 insertions(+), 12 deletions(-)
diff --git a/server/plugins-available/bind_plugin.inc.php b/server/plugins-available/bind_plugin.inc.php
index 6532920..9d67eda 100644
--- a/server/plugins-available/bind_plugin.inc.php
+++ b/server/plugins-available/bind_plugin.inc.php
@@ -105,8 +105,14 @@
$records = $app->db->queryAllRecords("SELECT * FROM dns_rr WHERE zone = ".$zone['id']." AND active = 'Y'");
$tpl->setLoop('zones',$records);
-
- $filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri.'.substr($zone['origin'],0,-1));
+ //TODO : change this when distribution information has been integrated into server record
+ if (file_exists('/etc/gentoo-release')) {
+ $filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri/'.substr($zone['origin'],0,-1));
+ }
+ else {
+ $filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri.'.substr($zone['origin'],0,-1));
+ }
+
$app->log("Writing BIND domain file: ".$filename,LOGLEVEL_DEBUG);
file_put_contents($filename,$tpl->grab());
chown($filename, escapeshellcmd($dns_config['bind_user']));
@@ -124,7 +130,14 @@
//* Delete old domain file, if domain name has been changed
if($data['old']['origin'] != $data['new']['origin']) {
- $filename = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
+ //TODO : change this when distribution information has been integrated into server record
+ if (file_exists('/etc/gentoo-release')) {
+ $filename = $dns_config['bind_zonefiles_dir'].'/pri/'.substr($data['old']['origin'],0,-1);
+ }
+ else {
+ $filename = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
+ }
+
if(is_file($filename)) unset($filename);
}
@@ -144,7 +157,14 @@
$this->write_named_conf($data,$dns_config);
//* Delete the domain file
- $zone_file_name = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
+ //TODO : change this when distribution information has been integrated into server record
+ if (file_exists('/etc/gentoo-release')) {
+ $zone_file_name = $dns_config['bind_zonefiles_dir'].'/pri/'.substr($data['old']['origin'],0,-1);
+ }
+ else {
+ $zone_file_name = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
+ }
+
if(is_file($zone_file_name)) unlink($zone_file_name);
$app->log("Deleting BIND domain file: ".$zone_file_name,LOGLEVEL_DEBUG);
@@ -177,7 +197,14 @@
//* Delete old domain file, if domain name has been changed
if($data['old']['origin'] != $data['new']['origin']) {
- $filename = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
+ //TODO : change this when distribution information has been integrated into server record
+ if (file_exists('/etc/gentoo-release')) {
+ $filename = $dns_config['bind_zonefiles_dir'].'/sec/'.substr($data['old']['origin'],0,-1);
+ }
+ else {
+ $filename = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
+ }
+
if(is_file($filename)) unset($filename);
}
@@ -198,7 +225,14 @@
$this->write_named_conf($data,$dns_config);
//* Delete the domain file
- $zone_file_name = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
+ //TODO : change this when distribution information has been integrated into server record
+ if (file_exists('/etc/gentoo-release')) {
+ $zone_file_name = $dns_config['bind_zonefiles_dir'].'/sec/'.substr($data['old']['origin'],0,-1);
+ }
+ else {
+ $zone_file_name = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
+ }
+
if(is_file($zone_file_name)) unlink($zone_file_name);
$app->log("Deleting BIND domain file for secondary zone: ".$zone_file_name,LOGLEVEL_DEBUG);
@@ -236,7 +270,7 @@
global $app, $conf;
//* Get the data of the soa and call soa_update
- $tmp = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$data['old']['zone']);
+ $tmp = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".intval($data['old']['zone']));
$data["new"] = $tmp;
$data["old"] = $tmp;
$this->action = 'update';
@@ -252,7 +286,27 @@
//* Only write the master file for the current server
$tmps = $app->db->queryAllRecords("SELECT origin, xfer, also_notify FROM dns_soa WHERE active = 'Y' AND server_id=".$conf["server_id"]);
$zones = array();
+
+ //* Check if the current zone that triggered this function has at least one NS record
+ $rec_num = $app->db->queryOneRecord("SELECT count(id) as ns FROM dns_rr WHERE type = 'NS' AND zone = ".intval($data['new']['id'])." AND active = 'Y'");
+ if($rec_num['ns'] == 0) {
+ $exclude_zone = $data['new']['origin'];
+ } else {
+ $exclude_zone = '';
+ }
+
+ //TODO : change this when distribution information has been integrated into server record
+ if (file_exists('/etc/gentoo-release')) {
+ $pri_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/pri/';
+ $sec_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/sec/';
+
+ }
+ else {
+ $pri_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/pri.';
+ $sec_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/slave/sec.';
+ }
+ //* Loop trough zones
foreach($tmps as $tmp) {
$options = '';
@@ -263,10 +317,12 @@
}
if(trim($tmp['also_notify']) != '') $options .= ' also-notify {'.str_replace(',',';',$tmp['also_notify']).";};\n";
- $zones[] = array( 'zone' => substr($tmp['origin'],0,-1),
- 'zonefile_path' => $dns_config['bind_zonefiles_dir'].'/pri.'.substr($tmp['origin'],0,-1),
- 'options' => $options
- );
+ if($tmp['origin'] != $exclude_zone) {
+ $zones[] = array( 'zone' => substr($tmp['origin'],0,-1),
+ 'zonefile_path' => $pri_zonefiles_path.substr($tmp['origin'],0,-1),
+ 'options' => $options
+ );
+ }
}
$tpl = new tpl();
@@ -288,7 +344,7 @@
$zones_sec[] = array( 'zone' => substr($tmp['origin'],0,-1),
- 'zonefile_path' => $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($tmp['origin'],0,-1),
+ 'zonefile_path' => $sec_zonefiles_path.substr($tmp['origin'],0,-1),
'options' => $options
);
--
Gitblit v1.9.1