Skip to content

Commit

Permalink
perform "pdnssec secure-zone" for every new zone (if pdnssec_usage = …
Browse files Browse the repository at this point in the history
…true)
  • Loading branch information
Edmondas Girkantas committed Jun 21, 2012
1 parent 404a3cb commit e7971f5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
9 changes: 8 additions & 1 deletion add_zone_master.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@

require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");

echo " <script type=\"text/javascript\" src=\"inc/helper.js\"></script>";

global $pdnssec_use;

$owner = "-1";
if ((isset($_POST['owner'])) && (v_num($_POST['owner']))) {
$owner = $_POST['owner'];
Expand Down Expand Up @@ -70,7 +73,11 @@
// TODO: repopulate domain name(s) to the form if there was an error occured
$error = true;
} elseif (add_domain($domain, $owner, $dom_type, '', $zone_template)) {
success("<a href=\"edit.php?id=" . get_zone_id_from_name($domain) . "\">".$domain . " - " . SUC_ZONE_ADD.'</a>');
success("<a href=\"edit.php?id=" . get_zone_id_from_name($domain) . "\">".$domain . " - " . SUC_ZONE_ADD.'</a>');

if ($pdnssec_use) {
do_secure_zone($domain);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions inc/error.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@

/* PDNSSEC */
define("ERR_EXEC_PDNSSEC", _('Failed to call pdnssec utility.'));
define("ERR_EXEC_PDNSSEC_SECURE_ZONE", _('Failed to secure zone.'));
define("ERR_EXEC_PDNSSEC_RECTIFY_ZONE", _('Failed to rectify zone.'));

/* GOOD! */
Expand Down
21 changes: 21 additions & 0 deletions inc/record.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1587,4 +1587,25 @@ function do_rectify_zone ($domain_id) {
}
}

function do_secure_zone($domain_name) {
global $pdnssec_command;

if (!function_exists('exec')) { error(ERR_EXEC_NOT_ALLOWED); return false; }

if (!file_exists($pdnssec_command) || !is_executable($pdnssec_command)) {
error(ERR_EXEC_PDNSSEC);
return false;
}

$command = $pdnssec_command . " secure-zone " . $domain_name;
exec($command, $output, $return_code);

if ($return_code != 0) {
error(ERR_EXEC_PDNSSEC_SECURE_ZONE);
return false;
}

return true;
}

?>

0 comments on commit e7971f5

Please sign in to comment.