Skip to content

Commit 47a77fe

Browse files
author
A. Täffner
committed
DNSSEC-Switch: Server modifications
1 parent 9261ee9 commit 47a77fe

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

server/plugins-available/bind_plugin.inc.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,15 @@ function soa_update($event_name, $data) {
145145
unset($records_out);
146146
unset($zone);
147147
}
148-
148+
149+
//* DNSSEC-Implementation
150+
if($data['old']['origin'] != $data['new']['origin']) {
151+
if (@$data['old']['dnssec_initialized'] == 'Y' && strlen(@$data['old']['origin']) > 3) exec('/usr/local/ispconfig/server/scripts/dnssec-delete.sh '.escapeshellcmd($data['old']['origin'])); //delete old keys
152+
if ($data['new']['dnssec_wanted'] == 'Y') exec('/usr/local/ispconfig/server/scripts/dnssec-create.sh '.escapeshellcmd($data['new']['origin'])); //Create new keys for new origin
153+
}
154+
if ($data['new']['dnssec_wanted'] == 'Y' AND $data['new']['dnssec_initialized'] == 'N') if ($data['new']['dnssec_wanted'] == 'Y') exec('/usr/local/ispconfig/server/scripts/dnssec-create.sh '.escapeshellcmd($data['new']['origin'])); //Create new keys for new origin
155+
else if ($data['old']['dnssec_wanted'] == 'Y') exec('/usr/local/ispconfig/server/scripts/dnssec-update.sh '.escapeshellcmd($data['new']['origin']));
156+
149157
//* rebuild the named.conf file if the origin has changed or when the origin is inserted.
150158
//if($this->action == 'insert' || $data['old']['origin'] != $data['new']['origin']) {
151159
$this->write_named_conf($data, $dns_config);
@@ -163,15 +171,9 @@ function soa_update($event_name, $data) {
163171

164172
if(is_file($filename)) unlink($filename);
165173
if(is_file($filename.'.err')) unlink($filename.'.err');
166-
167-
//* DNSSEC-Implementation
168-
if (strlen($data['old']['origin']) > 3) exec('/usr/local/ispconfig/server/scripts/dnssec-delete.sh '.$data['old']['origin']); //delete old keys
169-
exec('/usr/local/ispconfig/server/scripts/dnssec-create.sh '.$data['new']['origin']); //Create new keys for new origin
174+
if(is_file($filename.'.signed')) unlink($filename.'.signed');
170175
}
171176

172-
//* DNSSEC-Implementation
173-
exec('/usr/local/ispconfig/server/scripts/dnssec-update.sh '.$data['new']['origin']);
174-
175177
//* Restart bind nameserver if update_acl is not empty, otherwise reload it
176178
if($data['new']['update_acl'] != '') {
177179
$app->services->restartServiceDelayed('bind', 'restart');
@@ -205,7 +207,7 @@ function soa_delete($event_name, $data) {
205207
$app->log("Deleting BIND domain file: ".$zone_file_name, LOGLEVEL_DEBUG);
206208

207209
//* DNSSEC-Implementation
208-
exec('/usr/local/ispconfig/server/scripts/dnssec-delete.sh '.$data['old']['origin']); //delete keys
210+
if ($data['old']['dnssec_initialized'] == 'Y') exec('/usr/local/ispconfig/server/scripts/dnssec-delete.sh '.$data['old']['origin']); //delete keys
209211

210212
//* Reload bind nameserver
211213
$app->services->restartServiceDelayed('bind', 'reload');
@@ -333,7 +335,7 @@ function write_named_conf($data, $dns_config) {
333335
global $app, $conf;
334336

335337
//* Only write the master file for the current server
336-
$tmps = $app->db->queryAllRecords("SELECT origin, xfer, also_notify, update_acl FROM dns_soa WHERE active = 'Y' AND server_id=?", $conf["server_id"]);
338+
$tmps = $app->db->queryAllRecords("SELECT origin, xfer, also_notify, update_acl, dnssec_initialized FROM dns_soa WHERE active = 'Y' AND server_id=?", $conf["server_id"]);
337339
$zones = array();
338340

339341
//* Check if the current zone that triggered this function has at least one NS record
@@ -352,7 +354,8 @@ function write_named_conf($data, $dns_config) {
352354
//* Loop trough zones
353355
foreach($tmps as $tmp) {
354356

355-
$zone_file = $pri_zonefiles_path.str_replace("/", "_", substr($tmp['origin'], 0, -1)).'.signed'; //.signed is for DNSSEC-Implementation
357+
$zone_file = $pri_zonefiles_path.str_replace("/", "_", substr($tmp['origin'], 0, -1));
358+
if ($tmp['dnssec_initialized'] == 'Y') $zone_file .= '.signed' //.signed is for DNSSEC-Implementation
356359

357360
$options = '';
358361
if(trim($tmp['xfer']) != '') {

0 commit comments

Comments
 (0)