From 3ca9a66fcb42bb8cc078cd4c7ceef694fe9db821 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Wed, 06 Oct 2010 08:46:46 -0400
Subject: [PATCH] Fixed: FS#1347 - Firewall ports get reset on update
---
server/plugins-available/bind_plugin.inc.php | 24 ++++++++++++++++++------
1 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/server/plugins-available/bind_plugin.inc.php b/server/plugins-available/bind_plugin.inc.php
index 2e4e334..7a8c6cd 100644
--- a/server/plugins-available/bind_plugin.inc.php
+++ b/server/plugins-available/bind_plugin.inc.php
@@ -109,7 +109,8 @@
$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());
- exec('chown '.escapeshellcmd($dns_config['bind_user']).':'.escapeshellcmd($dns_config['bind_group']).' '.$filename);
+ chown($filename, escapeshellcmd($dns_config['bind_user']));
+ chgrp($filename, escapeshellcmd($dns_config['bind_group']));
unset($tpl);
unset($records);
unset($records_out);
@@ -235,7 +236,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';
@@ -251,7 +252,16 @@
//* 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 = '';
+ }
+ //* Loop trough zones
foreach($tmps as $tmp) {
$options = '';
@@ -262,10 +272,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' => $dns_config['bind_zonefiles_dir'].'/pri.'.substr($tmp['origin'],0,-1),
+ 'options' => $options
+ );
+ }
}
$tpl = new tpl();
--
Gitblit v1.9.1