diff -uNr ispconfig3_install-3.0.5.4p1/server/cron_daily.php ispconfig3_install/server/cron_daily.php
--- ispconfig3_install-3.0.5.4p1/server/cron_daily.php 2014-04-25 18:04:10.000000000 +0200
+++ ispconfig3_install/server/cron_daily.php 2014-05-01 16:49:15.678497551 +0200
@@ -369,11 +369,20 @@
}
if(!is_file($awstats_website_conf_file)) {
- $awstats_conf_file_content = 'Include "'.$awstats_conf_dir.'/awstats.conf"
+ if (is_file($awstats_conf_dir."/awstats.conf")) {
+ $include_file = $awstats_conf_dir."/awstats.conf";
+ } elseif (is_file($awstats_conf_dir."/awstats.model.conf")) {
+ $include_file = $awstats_conf_dir."/awstats.model.conf";
+ }
+ $awstats_conf_file_content = 'Include "'.$include_file.'"
LogFile="/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log"
SiteDomain="'.$domain.'"
HostAliases="www.'.$domain.' localhost 127.0.0.1'.$aliasdomain.'"';
- file_put_contents($awstats_website_conf_file, $awstats_conf_file_content);
+ if (isset($include_file)) {
+ file_put_contents($awstats_website_conf_file, $awstats_conf_file_content);
+ } else {
+ $app->log("No awstats base config found. Either awstats.conf or awstats.model.conf must exist in ".$awstats_conf_dir.".", LOGLEVEL_WARN);
+ }
}
if(!@is_dir($statsdir)) mkdir($statsdir);
diff -uNr ispconfig3_install-3.0.5.4p1/server/plugins-available/apache2_plugin.inc.php ispconfig3_install/server/plugins-available/apache2_plugin.inc.php
--- ispconfig3_install-3.0.5.4p1/server/plugins-available/apache2_plugin.inc.php 2014-04-25 18:04:10.000000000 +0200
+++ ispconfig3_install/server/plugins-available/apache2_plugin.inc.php 2014-05-01 16:37:57.410526561 +0200
@@ -2565,13 +2565,22 @@
}
$content = '';
- $content .= "Include \"".$awstats_conf_dir."/awstats.conf\"\n";
+ if (is_file($awstats_conf_dir."/awstats.conf")) {
+ $include_file = $awstats_conf_dir."/awstats.conf";
+ } elseif (is_file($awstats_conf_dir."/awstats.model.conf")) {
+ $include_file = $awstats_conf_dir."/awstats.model.conf";
+ }
+ $content .= "Include \"".$include_file."\"\n";
$content .= "LogFile=\"/var/log/ispconfig/httpd/".$data['new']['domain']."/access.log\"\n";
$content .= "SiteDomain=\"".$data['new']['domain']."\"\n";
$content .= "HostAliases=\"www.".$data['new']['domain']." localhost 127.0.0.1\"\n";
- $app->system->file_put_contents($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', $content);
- $app->log('Created AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', LOGLEVEL_DEBUG);
+ if (isset($include_file)) {
+ $app->system->file_put_contents($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', $content);
+ $app->log('Created AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', LOGLEVEL_DEBUG);
+ } else {
+ $app->log("No awstats base config found. Either awstats.conf or awstats.model.conf must exist in ".$awstats_conf_dir.".", LOGLEVEL_WARN);
+ }
}
if(is_file($data['new']['document_root']."/" . $web_folder . "/stats/index.html")) $app->system->unlink($data['new']['document_root']."/" . $web_folder . "/stats/index.html");
diff -uNr ispconfig3_install-3.0.5.4p1/server/plugins-available/maildeliver_plugin.inc.php ispconfig3_install/server/plugins-available/maildeliver_plugin.inc.php
--- ispconfig3_install-3.0.5.4p1/server/plugins-available/maildeliver_plugin.inc.php 2014-04-25 18:04:10.000000000 +0200
+++ ispconfig3_install/server/plugins-available/maildeliver_plugin.inc.php 2014-05-01 16:40:22.605096664 +0200
@@ -98,8 +98,9 @@
$app->log("Mailfilter config has been changed", LOGLEVEL_DEBUG);
$sieve_file = $data["new"]["maildir"].'/.sieve';
+ $sieve_file_isp = $data["new"]["maildir"].'/sieve/ispconfig.sieve';
if(is_file($sieve_file)) unlink($sieve_file) or $app->log("Unable to delete file: $sieve_file", LOGLEVEL_WARN);
-
+ if(is_file($sieve_file_isp)) unlink($sieve_file_isp) or $app->log("Unable to delete file: $sieve_file_isp", LOGLEVEL_WARN);
$app->load('tpl');
//* Select sieve filter file for dovecot version
@@ -211,7 +212,20 @@
$tpl->setVar('addresses', $address_str);
- file_put_contents($sieve_file, $tpl->grab());
+ if ( ! is_dir($data["new"]["maildir"].'/sieve/') ) {
+ $app->system->mkdirpath($data["new"]["maildir"].'/sieve/', 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']);
+ }
+
+ file_put_contents($sieve_file_isp, $tpl->grab());
+ chown($sieve_file_isp,$mail_config['mailuser_name']);
+ chgrp($sieve_file_isp,$mail_config['mailuser_group']);
+ chdir($data["new"]["maildir"]);
+ //* create symlink to activate sieve script
+ symlink("sieve/ispconfig.sieve", ".sieve") or $app->log("Unable to create symlink to active sieve filter", LOGLEVEL_WARN);
+ if (is_link(".sieve")) {
+ lchown(".sieve",$mail_config['mailuser_name']);
+ lchgrp(".sieve",$mail_config['mailuser_group']);
+ }
exec('chown '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($sieve_file));
unset($tpl);
@@ -223,7 +237,9 @@
global $app, $conf;
$sieve_file = $data["old"]["maildir"].'/.sieve';
+ $sieve_file_isp = $data["old"]["maildir"].'/sieve/ispconfig.sieve';
if(is_file($sieve_file)) unlink($sieve_file) or $app->log("Unable to delete file: $sieve_file", LOGLEVEL_WARN);
+ if(is_file($sieve_file_isp)) unlink($sieve_file_isp) or $app->log("Unable to delete file: $sieve_file_isp", LOGLEVEL_WARN);
}
diff -uNr ispconfig3_install-3.0.5.4p1/server/plugins-available/nginx_plugin.inc.php ispconfig3_install/server/plugins-available/nginx_plugin.inc.php
--- ispconfig3_install-3.0.5.4p1/server/plugins-available/nginx_plugin.inc.php 2014-04-25 18:04:10.000000000 +0200
+++ ispconfig3_install/server/plugins-available/nginx_plugin.inc.php 2014-05-01 16:37:57.410526561 +0200
@@ -2263,13 +2263,22 @@
}
$content = '';
- $content .= "Include \"".$awstats_conf_dir."/awstats.conf\"\n";
+ if (is_file($awstats_conf_dir."/awstats.conf")) {
+ $include_file = $awstats_conf_dir."/awstats.conf";
+ } elseif (is_file($awstats_conf_dir."/awstats.model.conf")) {
+ $include_file = $awstats_conf_dir."/awstats.model.conf";
+ }
+ $content .= "Include \"".$include_file."\"\n";
$content .= "LogFile=\"/var/log/ispconfig/httpd/".$data['new']['domain']."/access.log\"\n";
$content .= "SiteDomain=\"".$data['new']['domain']."\"\n";
$content .= "HostAliases=\"www.".$data['new']['domain']." localhost 127.0.0.1\"\n";
- $app->system->file_put_contents($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', $content);
- $app->log('Created AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', LOGLEVEL_DEBUG);
+ if (isset($include_file)) {
+ $app->system->file_put_contents($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', $content);
+ $app->log('Created AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', LOGLEVEL_DEBUG);
+ } else {
+ $app->log("No awstats base config found. Either awstats.conf or awstats.model.conf must exist in ".$awstats_conf_dir.".", LOGLEVEL_WARN);
+ }
}
if(is_file($data['new']['document_root']."/" . $web_folder . "/stats/index.html")) $app->system->unlink($data['new']['document_root']."/" . $web_folder . "/stats/index.html");
diff -uNr ispconfig3_install-3.0.5.4p1/server/plugins-available/powerdns_plugin.inc.php ispconfig3_install/server/plugins-available/powerdns_plugin.inc.php
--- ispconfig3_install-3.0.5.4p1/server/plugins-available/powerdns_plugin.inc.php 2014-04-25 18:04:10.000000000 +0200
+++ ispconfig3_install/server/plugins-available/powerdns_plugin.inc.php 2014-05-01 16:37:57.414526632 +0200
@@ -144,14 +144,17 @@
if($ns == '') $ns = $origin;
$hostmaster = substr($data["new"]["mbox"], 0, -1);
- $content = $ns.' '.$hostmaster.' 0';
+ $content = $ns.' '.$hostmaster.' '.$data["new"]["serial"].' '.$data["new"]["refresh"].' '.$data["new"]["retry"].' '.$data["new"]["expire"].' '.$data["new"]["minimum"];
$ttl = $data["new"]["ttl"];
$app->db->query("INSERT INTO powerdns.records (domain_id, name, type, content, ttl, prio, change_date, ispconfig_id) VALUES ($zone_id, '$origin', 'SOA', '$content', $ttl, 0, ".time().", $ispconfig_id)");
- //* Reload powerdns nameserver
- $app->services->restartServiceDelayed('powerdns', 'reload');
-
+ //* tell pdns to rediscover zones in DB
+ $this->zoneRediscover();
+ //* tell pdns to use 'pdnssec rectify' on the new zone
+ $this->rectifyZone($data);
+ //* tell pdns to send notify to slave
+ $this->notifySlave($data);
}
function soa_update($event_name, $data) {
@@ -161,13 +164,10 @@
if($data["old"]["active"] != 'Y') return;
$this->soa_delete($event_name, $data);
} else {
- if($data["old"]["active"] == 'Y'){
+ $exists = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ".$data["new"]["id"]);
+ if($data["old"]["active"] == 'Y' && is_array($exists)){
$origin = substr($data["new"]["origin"], 0, -1);
$ispconfig_id = $data["new"]["id"];
- $serial = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$ispconfig_id);
- $serial_id = $serial["serial"];
- //$app->db->query("UPDATE powerdns.domains SET name = '$origin', notified_serial = $serial_id WHERE ispconfig_id = $ispconfig_idi AND type = 'MASTER'");
- //$app->db->query("UPDATE powerdns.domains SET name = '$origin' WHERE ispconfig_id = $ispconfig_id AND type = 'MASTER'");
if(substr($data["new"]["ns"], -1) == '.'){
$ns = substr($data["new"]["ns"], 0, -1);
@@ -177,15 +177,14 @@
if($ns == '') $ns = $origin;
$hostmaster = substr($data["new"]["mbox"], 0, -1);
- //$content = $ns.' '.$hostmaster.' 0';
- $content = $ns.' '.$hostmaster.' '.$serial_id.'';
+ $content = $ns.' '.$hostmaster.' '.$data["new"]["serial"].' '.$data["new"]["refresh"].' '.$data["new"]["retry"].' '.$data["new"]["expire"].' '.$data["new"]["minimum"];
$ttl = $data["new"]["ttl"];
$app->db->query("UPDATE powerdns.records SET name = '$origin', content = '$content', ttl = $ttl, change_date = ".time()." WHERE ispconfig_id = ".$data["new"]["id"]." AND type = 'SOA'");
- //* Reload powerdns nameserver
- $app->services->restartServiceDelayed('powerdns', 'reload');
-
-
+ //* tell pdns to use 'pdnssec rectify' on the new zone
+ $this->rectifyZone($data);
+ //* tell pdns to send notify to slave
+ $this->notifySlave($data);
} else {
$this->soa_insert($event_name, $data);
$ispconfig_id = $data["new"]["id"];
@@ -197,10 +196,12 @@
$this->rr_insert("dns_rr_insert", $data);
}
}
-
+ //* tell pdns to use 'pdnssec rectify' on the new zone
+ $this->rectifyZone($data);
+ //* tell pdns to send notify to slave
+ $this->notifySlave($data);
}
}
-
}
function soa_delete($event_name, $data) {
@@ -210,10 +211,6 @@
$zone_id = $zone["id"];
$app->db->query("DELETE FROM powerdns.records WHERE domain_id = $zone_id");
$app->db->query("DELETE FROM powerdns.domains WHERE id = $zone_id");
-
- //* Reload powerdns nameserver
- $app->services->restartServiceDelayed('powerdns', 'reload');
-
}
function slave_insert($event_name, $data) {
@@ -227,12 +224,10 @@
$app->db->query("INSERT INTO powerdns.domains (name, type, master, ispconfig_id) VALUES ('$origin', 'SLAVE', '$master_ns', $ispconfig_id)");
- //$app->db->query("INSERT INTO powerdns.domains (name, type, ispconfig_id) VALUES ('$origin', 'NATIVE', $ispconfig_id)");
$zone_id = $app->db->insertID();
- //* Reload powerdns nameserver
- $app->services->restartServiceDelayed('powerdns', 'reload');
-
+ //* tell pdns to fetch zone from master server
+ $this->fetchFromMaster($data);
}
function slave_update($event_name, $data) {
@@ -249,15 +244,14 @@
$master_ns = $data["new"]["ns"];
$app->db->query("UPDATE powerdns.domains SET name = '$origin', type = 'SLAVE', master = '$master_ns' WHERE ispconfig_id=$ispconfig_id AND type = 'SLAVE'");
- //$app->db->query("INSERT INTO powerdns.domains (name, type, ispconfig_id) VALUES ('$origin', 'NATIVE', $ispconfig_id)");
$zone_id = $app->db->insertID();
$zone = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ".$ispconfig_id." AND type = 'SLAVE'");
$zone_id = $zone["id"];
$app->db->query("DELETE FROM powerdns.records WHERE domain_id = $zone_id AND ispconfig_id = 0");
- //* Reload powerdns nameserver
- $app->services->restartServiceDelayed('powerdns', 'reload');
+ //* tell pdns to fetch zone from master server
+ $this->fetchFromMaster($data);
} else {
$this->slave_insert($event_name, $data);
@@ -274,15 +268,13 @@
$zone_id = $zone["id"];
$app->db->query("DELETE FROM powerdns.records WHERE domain_id = $zone_id");
$app->db->query("DELETE FROM powerdns.domains WHERE id = $zone_id");
-
- //* Reload powerdns nameserver
- $app->services->restartServiceDelayed('powerdns', 'reload');
-
}
function rr_insert($event_name, $data) {
global $app, $conf;
if($data["new"]["active"] != 'Y') return;
+ $exists = $app->db->queryOneRecord("SELECT * FROM powerdns.records WHERE ispconfig_id = ".$data["new"]["id"]);
+ if ( is_array($exists) ) return;
$zone = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$data["new"]["zone"]);
$origin = substr($zone["origin"], 0, -1);
@@ -337,6 +329,8 @@
$app->db->query("INSERT INTO powerdns.records (domain_id, name, type, content, ttl, prio, change_date, ispconfig_id) VALUES ($zone_id, '$name', '$type', '$content', $ttl, $prio, $change_date, $ispconfig_id)");
+ //* tell pdns to use 'pdnssec rectify' on the new zone
+ $this->rectifyZone($data);
}
function rr_update($event_name, $data) {
@@ -346,7 +340,8 @@
if($data["old"]["active"] != 'Y') return;
$this->rr_delete($event_name, $data);
} else {
- if($data["old"]["active"] == 'Y'){
+ $exists = $app->db->queryOneRecord("SELECT * FROM powerdns.records WHERE ispconfig_id = ".$data["new"]["id"]);
+ if($data["old"]["active"] == 'Y' && is_array($exists)){
$zone = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$data["new"]["zone"]);
$origin = substr($zone["origin"], 0, -1);
$powerdns_zone = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ".$data["new"]["zone"]." AND type = 'MASTER'");
@@ -397,14 +392,14 @@
$prio = $data["new"]["aux"];
$change_date = time();
$ispconfig_id = $data["new"]["id"];
- //echo "UPDATE powerdns.records SET name = '$name', type = '$type', content = '$content', ttl = $ttl, prio = $prio, change_date = ".time()." WHERE id = $record_id";
$app->db->query("UPDATE powerdns.records SET name = '$name', type = '$type', content = '$content', ttl = $ttl, prio = $prio, change_date = ".time()." WHERE ispconfig_id = $ispconfig_id AND type != 'SOA'");
+ //* tell pdns to use 'pdnssec rectify' on the new zone
+ $this->rectifyZone($data);
} else {
$this->rr_insert($event_name, $data);
}
}
-
}
function rr_delete($event_name, $data) {
@@ -412,9 +407,80 @@
$ispconfig_id = $data["old"]["id"];
$app->db->query("DELETE FROM powerdns.records WHERE ispconfig_id = $ispconfig_id AND type != 'SOA'");
+ }
+
+ function find_pdns_control() {
+ $output = array();
+ $retval = '';
+ exec("type -p pdns_control", $output, $retval);
+ if ($retval == 0 && is_file($output[0])){
+ return $output[0];
+ } else {
+ return false;
+ }
+ }
+ function find_pdns_pdnssec() {
+ $output = array();
+ $retval = '';
+ exec("type -p pdnssec", $output, $retval);
+ if ($retval == 0 && is_file($output[0])){
+ return $output[0];
+ } else {
+ return false;
+ }
}
+ function zoneRediscover() {
+ $pdns_control = $this->find_pdns_control();
+ if ( $pdns_control != false ) {
+ exec($pdns_control . ' rediscover');
+ }
+ }
+
+ function notifySlave($data) {
+ $pdns_control = $this->find_pdns_control();
+ if ( $pdns_control != false ) {
+ exec($pdns_control . ' notify ' . rtrim($data["new"]["origin"],"."));
+ }
+ }
+
+ function fetchFromMaster($data) {
+ $pdns_control = $this->find_pdns_control();
+ if ( $pdns_control != false ) {
+ exec($pdns_control . ' retrieve ' . rtrim($data["new"]["origin"],"."));
+ }
+ }
+
+ function get_pdns_version() {
+ $pdns_control = $this->find_pdns_control();
+ if ( $pdns_control != false ) {
+ $output=array();
+ $retval='';
+ exec($pdns_control . ' version',$output,$retval);
+ return $output[0];
+ } else {
+ //* fallback to version 2
+ return 2;
+ }
+ }
+
+ function rectifyZone($data) {
+ global $app, $conf;
+ if ( preg_match('/^3/',$this->get_pdns_version()) ) {
+ $pdns_pdnssec = $this->find_pdns_pdnssec();
+ if ( $pdns_pdnssec != false ) {
+ if (isset($data["new"]["origin"])) {
+ //* data has origin field only for SOA recordtypes
+ exec($pdns_pdnssec . ' rectify-zone ' . rtrim($data["new"]["origin"],"."));
+ } else {
+ // get origin from DB for all other recordtypes
+ $zn = $app->db->queryOneRecord("SELECT d.name AS name FROM powerdns.domains d, powerdns.records r WHERE r.ispconfig_id=".$data["new"]["id"]." AND r.domain_id = d.id");
+ exec($pdns_pdnssec . ' rectify-zone ' . trim($zn["name"]));
+ }
+ }
+ }
+ }
} // end class