aboutsummaryrefslogtreecommitdiffstats
path: root/config/bind
diff options
context:
space:
mode:
authordoktornotor <notordoktor@gmail.com>2015-08-22 06:51:51 +0200
committerdoktornotor <notordoktor@gmail.com>2015-08-22 06:51:51 +0200
commit6a850c2d7d68fbe561b3ad2627d9ea39ae260a4e (patch)
treeadb6e3ae7797660c532443dbc3730f686a26be79 /config/bind
parent0fae8c137386a7c73b41e3c538ab0e4790cbcbda (diff)
downloadpfsense-packages-6a850c2d7d68fbe561b3ad2627d9ea39ae260a4e.tar.gz
pfsense-packages-6a850c2d7d68fbe561b3ad2627d9ea39ae260a4e.tar.bz2
pfsense-packages-6a850c2d7d68fbe561b3ad2627d9ea39ae260a4e.zip
bind - code style fixes
- Fix copyright header - Code style fixes - Use safe_mkdir and {stop,restart}_service()
Diffstat (limited to 'config/bind')
-rw-r--r--config/bind/bind.inc222
1 files changed, 107 insertions, 115 deletions
diff --git a/config/bind/bind.inc b/config/bind/bind.inc
index 7b5b773e..39c12e13 100644
--- a/config/bind/bind.inc
+++ b/config/bind/bind.inc
@@ -1,10 +1,11 @@
-<?PHP
-/* $Id$ */
+<?php
/*
bind.inc
- part of the Bind package for pfSense
- Copyright (C) 2013 Juliano Oliveira/Adriano Brancher
- Copyright (C) 2013 Marcello Coutinho
+ part of pfSense (https://www.pfSense.org/)
+ Copyright (C) 2013 Juliano Oliveira
+ Copyright (C) 2013 Adriano Brancher
+ Copyright (C) 2013 Marcello Coutinho
+ Copyright (C) 2015 ESF, LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -27,15 +28,14 @@
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
*/
$shortcut_section = "bind";
-require_once('globals.inc');
-require_once('config.inc');
-require_once('util.inc');
-require_once('pfsense-utils.inc');
-require_once('pkg-utils.inc');
-require_once('service-utils.inc');
+require_once("globals.inc");
+require_once("config.inc");
+require_once("util.inc");
+require_once("pfsense-utils.inc");
+require_once("pkg-utils.inc");
+require_once("service-utils.inc");
if (!function_exists("filter_configure")) {
require_once("filter.inc");
}
@@ -49,8 +49,8 @@ if ($pf_version == "2.1" || $pf_version == "2.2") {
define('CHROOT_LOCALBASE', '/cf/named');
-function bind_zone_validate($post, &$input_errors)
-{
+function bind_zone_validate($post, &$input_errors) {
+
if (array_key_exists("mail", $_POST)) {
$_POST['mail'] = preg_replace("/@/", ".", $post['mail']);
}
@@ -112,11 +112,11 @@ function bind_zone_validate($post, &$input_errors)
}
}
-function bind_sync()
-{
+function bind_sync() {
+
global $config;
conf_mount_rw();
- //create rndc
+ // Create rndc
$rndc_confgen = "/usr/local/sbin/rndc-confgen";
if (!file_exists(BIND_LOCALBASE."/etc/rndc-confgen.pfsense") && file_exists($rndc_confgen)) {
exec("$rndc_confgen ", $rndc_conf);
@@ -128,8 +128,8 @@ function bind_sync()
}
$rndc_bindconf = "";
$rndc_file = "";
- if (file_exists(BIND_LOCALBASE."/etc/rndc-confgen.pfsense")) {
- $rndc_conf = file(BIND_LOCALBASE."/etc/rndc-confgen.pfsense");
+ if (file_exists(BIND_LOCALBASE . "/etc/rndc-confgen.pfsense")) {
+ $rndc_conf = file(BIND_LOCALBASE . "/etc/rndc-confgen.pfsense");
$confgen = "rndc.conf";
foreach ($rndc_conf as $line) {
if ($confgen == "rndc.conf") {
@@ -143,7 +143,7 @@ function bind_sync()
}
if (preg_match("/named.conf/", $line)) {
$confgen = "named.conf";
- file_put_contents(BIND_LOCALBASE."/etc/rndc.conf", $rndc_file);
+ file_put_contents(BIND_LOCALBASE . "/etc/rndc.conf", $rndc_file);
}
}
}
@@ -152,7 +152,7 @@ function bind_sync()
$bind_enable = $bind['enable_bind'];
$bind_forwarder = $bind['bind_forwarder'];
$forwarder_ips = $bind['bind_forwarder_ips'];
- $ram_limit = ($bind['bind_ram_limit'] ? $bind['bind_ram_limit'] : "256M");
+ $ram_limit = $bind['bind_ram_limit'] ? $bind['bind_ram_limit'] : "256M";
$hide_version = $bind['bind_hide_version'];
$bind_notify = $bind['bind_notify'];
$custom_options = base64_decode($bind['bind_custom_options']);
@@ -162,7 +162,7 @@ function bind_sync()
$bind_conf .= "#Do not edit this file!!!\n\n";
$bind_conf .= "$rndc_bindconf\n";
$bind_conf .= "$bind_global_settings\n";
- // curly braces in the following <<<EOD are PHP {$variable}, not named.conf text { value; }
+ // Curly braces in the following <<<EOD are PHP {$variable}, not named.conf text { value; }
$bind_conf .= <<<EOD
options {
@@ -172,13 +172,13 @@ options {
max-cache-size {$ram_limit};
EOD;
- // check response rate limit option
+ // Check response rate limit option
//https://kb.isc.org/article/AA-01000/0/A-Quick-Introduction-to-Response-Rate-Limiting.html
//http://ss.vix.su/~vjs/rl-arm.html
if ($bind['rate_enabled'] == "on") {
- $rate_limit = ($bind['rate_limit'] ? $bind['rate_limit'] : "15");
- $log_only = ($bind['log_only'] == "no" ? "no" : "yes");
- // curly braces in the following <<<EOD are PHP {$variable}, not named.conf text { value; }
+ $rate_limit = $bind['rate_limit'] ? $bind['rate_limit'] : "15";
+ $log_only = $bind['log_only'] == "no" ? "no" : "yes";
+ // Curly braces in the following <<<EOD are PHP {$variable}, not named.conf text { value; }
$bind_conf .= <<<EOD
rate-limit {
responses-per-second {$rate_limit};
@@ -187,7 +187,7 @@ EOD;
EOD;
}
- //check ips to listen on
+ // Check IPs to listen on
if (preg_match("/All/", $bind['listenon'])) {
$bind_listenonv6 = "any;";
$bind_listenon = "any;";
@@ -200,7 +200,7 @@ EOD;
} elseif (is_ipaddr($listenon)) {
$bind_listenon .= $listenon."; ";
} else {
- $listenon = (pfSense_get_interface_addresses(convert_friendly_interface_to_real_interface_name($listenon)));
+ $listenon = pfSense_get_interface_addresses(convert_friendly_interface_to_real_interface_name($listenon));
if (is_ipaddr($listenon['ipaddr'])) {
$bind_listenon .= $listenon['ipaddr']."; ";
}
@@ -210,15 +210,15 @@ EOD;
}
}
}
- $bind_listenonv6 = ($bind_listenonv6 == "" ? "none;" : $bind_listenonv6);
- $bind_listenon = ($bind_listenon == "" ? "none;" : $bind_listenon);
- // print "<PRE>$bind_listenonv6 $bind_listenon";
+ $bind_listenonv6 = $bind_listenonv6 == "" ? "none;" : $bind_listenonv6;
+ $bind_listenon = $bind_listenon == "" ? "none;" : $bind_listenon;
+ // Print "<pre>$bind_listenonv6 $bind_listenon";
if (array_key_exists("ipv6allow", $config['system'])) {
$bind_conf .= "\tlisten-on-v6 { $bind_listenonv6 };\n";
}
$bind_conf .= "\tlisten-on { $bind_listenon };\n";
- // forwarder config
+ // Forwarder config
if ($bind_forwarder == 'on') {
$bind_conf .= "\tforwarders { $forwarder_ips };\n";
}
@@ -249,9 +249,9 @@ EOD;
system("/usr/bin/killall -HUP syslogd");
}
$log_categories = explode(",", $bind['log_options']);
- $log_severity = ($bind['log_severity'] ? $bind['log_severity'] : 'default');
+ $log_severity = $bind['log_severity'] ? $bind['log_severity'] : 'default';
if (sizeof($log_categories) > 0 && $log_categories[0] != "") {
- // curly braces in the following <<<EOD are PHP {$variable}, not named.conf text { value; }
+ // Curly braces in the following <<<EOD are PHP {$variable}, not named.conf text { value; }
$bind_conf .= <<<EOD
logging {
@@ -286,7 +286,7 @@ EOD;
array("name" => "localhost", "description" => "BIND Built-in ACL", "row" => array("value" => "", "description" => ""));
$config['installedpackages']['bindacls']['config'][] =
array("name" => "localnets", "description" => "BIND Built-in ACL", "row" => array("value" => "", "description" => ""));
- write_config("Create BIND Built-in ACLs");
+ write_config("Created BIND Built-in ACLs");
}
$bindacls = $config['installedpackages']['bindacls']['config'];
for ($i = 0; $i < sizeof($bindacls); $i++) {
@@ -366,9 +366,7 @@ EOD;
// Ensure zone view folder exists
if ($zonetype != "forward") {
foreach ($zoneviewlist as $zoneview) {
- if (!(is_dir(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview"))) {
- mkdir(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview", 0755, true);
- }
+ safe_mkdir(CHROOT_LOCALBASE . "/etc/namedb/$zonetype/$zoneview", 0755);
}
}
@@ -422,7 +420,7 @@ EOD;
$bind_conf .= "\t\tallow-update { $zoneallowupdate; };\n";
}
if ($zone['dnssec'] == "on") {
- //https://kb.isc.org/article/AA-00626/
+ // https://kb.isc.org/article/AA-00626/
$bind_conf .= "\n\t\t# look for dnssec keys here:\n";
$bind_conf .= "\t\tkey-directory \"/etc/namedb/keys\";\n\n";
$bind_conf .= "\t\t# publish and activate dnssec keys:\n";
@@ -442,7 +440,7 @@ EOD;
$bind_conf .= "\t\tforwarders { $zoneforwarders; };\n";
break;
case 'redirect':
- $bind_conf .= "\t\t# While using redirect zones,NXDOMAIN Redirection will not override DNSSEC\n";
+ $bind_conf .= "\t\t# While using redirect zones, NXDOMAIN Redirection will not override DNSSEC\n";
$bind_conf .= "\t\t# If the client has requested DNSSEC records (DO=1) and the NXDOMAIN response is signed then no substitution will occur\n";
$bind_conf .= "\t\t# https://kb.isc.org/article/AA-00376/192/BIND-9.9-redirect-zones-for-NXDOMAIN-redirection.html\n";
$bind_conf .= "\t\tallow-query { $zoneallowquery; };\n";
@@ -462,17 +460,17 @@ EOD;
switch ($zonetype) {
case 'master':
case 'redirect':
- // check/update slave dir permission
- chown(CHROOT_LOCALBASE."/etc/namedb/$zonetype", "bind");
- chown(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview", "bind");
- $zonetll = ($zone['tll'] ? $zone['tll'] : "43200");
- $zonemail = ($zone['mail'] ? $zone['mail'] : "zonemaster.{$zonename}");
+ // Check/update slave dir permission
+ chown(CHROOT_LOCALBASE . "/etc/namedb/$zonetype", "bind");
+ chown(CHROOT_LOCALBASE . "/etc/namedb/$zonetype/$zoneview", "bind");
+ $zonetll = $zone['tll'] ? $zone['tll'] : "43200";
+ $zonemail = $zone['mail'] ? $zone['mail'] : "zonemaster.{$zonename}";
$zonemail = preg_replace("/@/", ".", $zonemail);
$zoneserial = $zone['serial'];
- $zonerefresh = ($zone['refresh'] ? $zone['refresh'] : "3600");
- $zoneretry = ($zone['retry'] ? $zone['retry'] : "600");
- $zoneexpire = ($zone['expire'] ? $zone['expire'] : "86400");
- $zoneminimum = ($zone['minimum'] ? $zone['minimum'] : "3600");
+ $zonerefresh = $zone['refresh'] ? $zone['refresh'] : "3600";
+ $zoneretry = $zone['retry'] ? $zone['retry'] : "600";
+ $zoneexpire = $zone['expire'] ? $zone['expire'] : "86400";
+ $zoneminimum = $zone['minimum'] ? $zone['minimum'] : "3600";
$zonenameserver = $zone['nameserver'];
$zoneipns = $zone['ipns'];
$zonereverso = $zone['reverso'];
@@ -573,10 +571,10 @@ EOD;
$config['installedpackages']['bindzone']['config'][$x]['resultconfig'] = base64_encode($zone_conf);
$write_config++;
- //check dnssec keys creation for master zones
+ // Check DNSSEC keys creation for master zones
if ($zone['dnssec'] == "on") {
$zone_found = 0;
- foreach (glob(CHROOT_LOCALBASE."/etc/namedb/keys/*{$zonename}*key", GLOB_NOSORT) as $filename) {
+ foreach (glob(CHROOT_LOCALBASE . "/etc/namedb/keys/*{$zonename}*key", GLOB_NOSORT) as $filename) {
$zone_found++;
}
if ($zone_found == 0) {
@@ -596,16 +594,16 @@ EOD;
}
$dnssec_bin = "/usr/local/sbin/dnssec-keygen";
if (file_exists($dnssec_bin) && $key_restored == 0) {
- exec("{$dnssec_bin} -K ".CHROOT_LOCALBASE."/etc/namedb/keys {$zonename}", $kout);
- exec("{$dnssec_bin} -K ".CHROOT_LOCALBASE."/etc/namedb/keys -fk {$zonename}", $kout);
+ exec("{$dnssec_bin} -K " . CHROOT_LOCALBASE . "/etc/namedb/keys {$zonename}", $kout);
+ exec("{$dnssec_bin} -K " . CHROOT_LOCALBASE . "/etc/namedb/keys -fk {$zonename}", $kout);
foreach ($kout as $filename) {
- chown(CHROOT_LOCALBASE."/etc/namedb/keys/{$filename}.key", "bind");
- chown(CHROOT_LOCALBASE."/etc/namedb/keys/{$filename}.private", "bind");
+ chown(CHROOT_LOCALBASE . "/etc/namedb/keys/{$filename}.key", "bind");
+ chown(CHROOT_LOCALBASE . "/etc/namedb/keys/{$filename}.private", "bind");
}
log_error("[bind] DNSSEC keys for {$zonename} created.");
}
}
- // get ds keys
+ // Get DS keys
$dsfromkey = "/usr/local/sbin/dnssec-dsfromkey";
foreach (glob(CHROOT_LOCALBASE."/etc/namedb/keys/*{$zonename}*key", GLOB_NOSORT) as $filename) {
$zone_key = file_get_contents($filename);
@@ -616,10 +614,10 @@ EOD;
}
}
- // save dnssec keys to xml
+ // Save DNSSEC keys to xml
if ($zone['backupkeys'] == "on") {
$dnssec_keys = 0;
- foreach (glob(CHROOT_LOCALBASE."/etc/namedb/keys/*{$zonename}*", GLOB_NOSORT) as $filename) {
+ foreach (glob(CHROOT_LOCALBASE . "/etc/namedb/keys/*{$zonename}*", GLOB_NOSORT) as $filename) {
$file_found = 0;
if (is_array($config['installedpackages']['dnsseckeys']) && is_array($config['installedpackages']['dnsseckeys']['config'])) {
foreach ($config['installedpackages']['dnsseckeys']['config'] as $filer) {
@@ -643,21 +641,21 @@ EOD;
}
break;
case 'slave':
- // check/update slave dir permission
- chown(CHROOT_LOCALBASE."/etc/namedb/$zonetype", "bind");
- chown(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview", "bind");
+ // Check/update slave dir permission
+ chown(CHROOT_LOCALBASE . "/etc/namedb/$zonetype", "bind");
+ chown(CHROOT_LOCALBASE . "/etc/namedb/$zonetype/$zoneview", "bind");
// check if exists slave zone file
$rsconfig = "";
if ($zone['dnssec'] == "on") {
- if (file_exists(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview/$zonename.DB.signed")) {
- exec("/usr/local/sbin/named-checkzone -D -f raw -o - {$zonename} ".CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview/$zonename.DB.signed", $slave_file);
+ if (file_exists(CHROOT_LOCALBASE . "/etc/namedb/$zonetype/$zoneview/$zonename.DB.signed")) {
+ exec("/usr/local/sbin/named-checkzone -D -f raw -o - {$zonename} " . CHROOT_LOCALBASE . "/etc/namedb/$zonetype/$zoneview/$zonename.DB.signed", $slave_file);
}
} else {
- if (file_exists(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview/$zonename.DB")) {
- $slave_file = file(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview/$zonename.DB");
+ if (file_exists(CHROOT_LOCALBASE . "/etc/namedb/$zonetype/$zoneview/$zonename.DB")) {
+ $slave_file = file(CHROOT_LOCALBASE . "/etc/namedb/$zonetype/$zoneview/$zonename.DB");
}
}
- // TODO is is_array() the best test to use? is it only checking for existence?
+ // TODO: is is_array() the best test to use? Is it only checking for existence?
if (is_array($slave_file)) {
foreach ($slave_file as $zfile) {
$rsconfig .= $zfile;
@@ -667,7 +665,7 @@ EOD;
$write_config++;
break;
case 'forward':
- // forwarder zone does not have a DB file
+ // Forwarder zone does not have a DB file
$config['installedpackages']['bindzone']['config'][$x]['resultconfig'] = '';
$write_config++;
break;
@@ -683,18 +681,16 @@ EOD;
$bind_conf .= "\t};\n\n";
}
if ($write_config > 0) {
- write_config("save result config file for zone on xml");
+ write_config("BIND: Saved resulting config file for zone in xml");
}
$bind_conf .= "};\n";
}
$dirs = array("/etc/namedb/keys", "/var/run/named", "/var/dump", "/var/log", "/var/stats", "/dev");
foreach ($dirs as $dir) {
- if (!is_dir(CHROOT_LOCALBASE.$dir)) {
- mkdir(CHROOT_LOCALBASE.$dir, 0755, true);
- }
+ safe_mkdir(CHROOT_LOCALBASE . $dir, 0755);
}
- // dev dirs for chroot
- $bind_dev_dir = CHROOT_LOCALBASE."/dev";
+ // Handle /dev dirs for chroot
+ $bind_dev_dir = CHROOT_LOCALBASE . "/dev";
if (!file_exists("$bind_dev_dir/random")) {
$dev_dirs = array("null", "zero", "random", "urandom");
exec("/sbin/mount -t devfs devfs {$bind_dev_dir}", $dout);
@@ -706,41 +702,40 @@ EOD;
exec("/sbin/devfs -m {$bind_dev_dir} rule applyset", $dout);
}
// http://www.unixwiz.net/techtips/bind9-chroot.html
- file_put_contents(CHROOT_LOCALBASE.'/etc/namedb/named.conf', $bind_conf);
- file_put_contents(CHROOT_LOCALBASE.'/etc/namedb/rndc.conf', $rndc_file);
+ file_put_contents(CHROOT_LOCALBASE . '/etc/namedb/named.conf', $bind_conf);
+ file_put_contents(CHROOT_LOCALBASE . '/etc/namedb/rndc.conf', $rndc_file);
- if (!file_exists(CHROOT_LOCALBASE."/etc/namedb/named.root")) {
+ if (!file_exists(CHROOT_LOCALBASE . "/etc/namedb/named.root")) {
// dig +tcp @a.root-servers.net > CHROOT_LOCALBASE."/etc/namedb/named.root"
$named_root = file_get_contents("http://www.internic.net/domain/named.root");
- file_put_contents(CHROOT_LOCALBASE."/etc/namedb/named.root", $named_root, LOCK_EX);
+ file_put_contents(CHROOT_LOCALBASE . "/etc/namedb/named.root", $named_root, LOCK_EX);
}
if (!file_exists(CHROOT_LOCALBASE."/etc/localtime")) {
- copy("/etc/localtime", CHROOT_LOCALBASE."/etc/localtime");
+ copy("/etc/localtime", CHROOT_LOCALBASE . "/etc/localtime");
}
bind_write_rcfile();
- chown(CHROOT_LOCALBASE."/etc/namedb/keys", "bind");
- chown(CHROOT_LOCALBASE."/etc/namedb", "bind");
- chown(CHROOT_LOCALBASE."/var/log", "bind");
- chown(CHROOT_LOCALBASE."/var/run/named", "bind");
- chgrp(CHROOT_LOCALBASE."/var/log", "bind");
+ chown(CHROOT_LOCALBASE . "/etc/namedb/keys", "bind");
+ chown(CHROOT_LOCALBASE . "/etc/namedb", "bind");
+ chown(CHROOT_LOCALBASE . "/var/log", "bind");
+ chown(CHROOT_LOCALBASE . "/var/run/named", "bind");
+ chgrp(CHROOT_LOCALBASE . "/var/log", "bind");
$bind_sh = "/usr/local/etc/rc.d/named.sh";
if ($bind_enable == "on") {
chmod($bind_sh, 0755);
- mwexec("{$bind_sh} restart");
+ restart_service("named");
} elseif (is_service_running('named')) {
- mwexec("{$bind_sh} stop");
+ stop_service("named");
chmod($bind_sh, 0644);
}
- // sync to backup servers
+ // Sync to backup servers
bind_sync_on_changes();
conf_mount_ro();
}
-function bind_print_javascript_type_zone()
-{
+function bind_print_javascript_type_zone() {
?>
- <script language="JavaScript">
+ <script type="text/javascript">
<!--
function on_type_zone_changed() {
@@ -844,35 +839,33 @@ function bind_print_javascript_type_zone()
<?php
}
-function bind_print_javascript_type_zone2()
-{
- print("<script language=\"JavaScript\">on_type_zone_changed();document.iform.resultconfig.disabled = 1;document.iform.dsset.disabled = 1;</script>\n");
+function bind_print_javascript_type_zone2() {
+ print("<script language=\"text/javascript\">on_type_zone_changed(); document.iform.resultconfig.disabled = 1; document.iform.dsset.disabled = 1;</script>\n");
}
-function bind_write_rcfile()
-{
+function bind_write_rcfile() {
global $config;
$bind = $config['installedpackages']['bind']['config'][0];
$ip_version = ($bind['bind_ip_version'] ? $bind['bind_ip_version'] : "");
$rc = array();
$BIND_LOCALBASE = "/usr/local";
$rc['file'] = 'named.sh';
- // curly braces in the following <<<EOD are PHP {$variable}, not named.conf text { value; }
+ // Curly braces in the following <<<EOD are PHP {$variable}, not named.conf text { value; }
$rc['start'] = <<<EOD
- if [ -z "`ps auxw | grep "[n]amed {$ip_version} -c /etc/namedb/named.conf"|awk '{print $2}'`" ];then
+ if [ -z "`/bin/ps auxw | /usr/bin/grep "[n]amed {$ip_version} -c /etc/namedb/named.conf" | /usr/bin/awk '{print $2}'`" ]; then
{$BIND_LOCALBASE}/sbin/named {$ip_version} -c /etc/namedb/named.conf -u bind -t /cf/named/
fi
EOD;
$rc['stop'] = <<<EOD
- killall -9 named 2>/dev/null
+ /usr/bin/killall -9 named 2>/dev/null
sleep 2
EOD;
// curly braces in the following <<<EOD are PHP {$variable}, not named.conf text { value; }
$rc['restart'] = <<<EOD
- if [ -z "`ps auxw | grep "[n]amed {$ip_version} -c /etc/namedb/named.conf"|awk '{print $2}'`" ];then
+ if [ -z "`/bin/ps auxw | /usr/bin/grep "[n]amed {$ip_version} -c /etc/namedb/named.conf" | /usr/bin/awk '{print $2}'`" ]; then
{$BIND_LOCALBASE}/sbin/named {$ip_version} -c /etc/namedb/named.conf -u bind -t /cf/named/
else
- killall -9 named 2>/dev/null
+ /usr/bin/killall -9 named 2>/dev/null
sleep 3
{$BIND_LOCALBASE}/sbin/named {$ip_version} -c /etc/namedb/named.conf -u bind -t /cf/named/
fi
@@ -896,7 +889,7 @@ function bind_sync_on_changes()
if (is_array($bind_sync['row'])) {
$rs = $bind_sync['row'];
} else {
- log_error("[bind] xmlrpc sync is enabled but there is no hosts to push on bind config.");
+ log_error("[bind] XMLRPC sync is enabled but there are no hosts to push on BIND config.");
return;
}
break;
@@ -907,7 +900,7 @@ function bind_sync_on_changes()
$rs[0]['username'] = $hasync['username'];
$rs[0]['password'] = $hasync['password'];
} else {
- log_error("[bind] xmlrpc sync is enabled but there is no system backup hosts to push bind config.");
+ log_error("[bind] XMLRPC sync is enabled but there are no system backup hosts to push BIND config.");
return;
}
break;
@@ -916,7 +909,7 @@ function bind_sync_on_changes()
break;
}
if (is_array($rs)) {
- log_error("[bind] xmlrpc sync is starting.");
+ log_error("[bind] XMLRPC sync is starting.");
foreach ($rs as $sh) {
$sync_to_ip = $sh['ipaddress'];
$password = $sh['password'];
@@ -929,7 +922,7 @@ function bind_sync_on_changes()
bind_do_xmlrpc_sync($sync_to_ip, $username, $password, $synctimeout, $master_zone_ip);
}
}
- log_error("[bind] xmlrpc sync is ending.");
+ log_error("[bind] XMLRPC sync is ending.");
}
}
}
@@ -955,14 +948,13 @@ function bind_do_xmlrpc_sync($sync_to_ip, $username, $password, $synctimeout, $m
$synctimeout = 25;
}
-
$xmlrpc_sync_neighbor = $sync_to_ip;
if ($config['system']['webgui']['protocol'] != "") {
$synchronizetoip = $config['system']['webgui']['protocol'];
$synchronizetoip .= "://";
}
$port = $config['system']['webgui']['port'];
- /* if port is empty lets rely on the protocol selection */
+ /* If port is empty let's rely on the protocol selection */
if ($port == "") {
if ($config['system']['webgui']['protocol'] == "http") {
$port = "80";
@@ -972,7 +964,7 @@ function bind_do_xmlrpc_sync($sync_to_ip, $username, $password, $synctimeout, $m
}
$synchronizetoip .= $sync_to_ip;
- /* xml will hold the sections to sync */
+ /* XML will hold the sections to sync */
$xml = array();
$xml['bind'] = $config['installedpackages']['bind'];
$xml['bindacls'] = $config['installedpackages']['bindacls'];
@@ -981,7 +973,7 @@ function bind_do_xmlrpc_sync($sync_to_ip, $username, $password, $synctimeout, $m
if (is_array($config['installedpackages']['dnsseckeys'])) {
$xml['dnsseckeys'] = $config['installedpackages']['dnsseckeys'];
}
- //change master zone to slave on backup servers
+ // Change master zone to slave on backup servers
if (is_array($xml['bindzone']["config"])) {
for ($x = 0; $x < sizeof($xml['bindzone']["config"]); $x++) {
if ($xml['bindzone']["config"][$x]['type'] == "master") {
@@ -991,13 +983,13 @@ function bind_do_xmlrpc_sync($sync_to_ip, $username, $password, $synctimeout, $m
}
}
- /* assemble xmlrpc payload */
+ /* Assemble XMLRPC payload */
$params = array(
XML_RPC_encode($password),
XML_RPC_encode($xml)
);
- /* set a few variables needed for sync code borrowed from filter.inc */
+ /* Set a few variables needed for sync code borrowed from filter.inc */
$url = $synchronizetoip;
log_error("[bind] Beginning bind XMLRPC sync to {$url}:{$port}.");
$method = 'pfsense.merge_installedpackages_section_xmlrpc';
@@ -1007,10 +999,10 @@ function bind_do_xmlrpc_sync($sync_to_ip, $username, $password, $synctimeout, $m
if ($g['debug']) {
$cli->setDebug(1);
}
- /* send our XMLRPC message and timeout after defined sync timeout value*/
+ /* Send our XMLRPC message and timeout after defined sync timeout value */
$resp = $cli->send($msg, $synctimeout);
if (!$resp) {
- $error = "A communications error occurred while attempting BIND XMLRPC sync with {$url}:{$port}.";
+ $error = "A communication error occurred while attempting BIND XMLRPC sync with {$url}:{$port}.";
log_error($error);
file_notice("sync_settings", $error, "bind Settings Sync", "");
} elseif ($resp->faultCode()) {
@@ -1023,11 +1015,11 @@ function bind_do_xmlrpc_sync($sync_to_ip, $username, $password, $synctimeout, $m
log_error("[bind] XMLRPC sync successfully completed with {$url}:{$port}.");
}
- /* tell bind to reload our settings on the destination sync host. */
+ /* Tell bind to reload our settings on the destination sync host. */
$method = 'pfsense.exec_php';
$execcmd = "require_once('/usr/local/pkg/bind.inc');\n";
$execcmd .= "bind_sync('yes');";
- /* assemble xmlrpc payload */
+ /* Assemble XMLRPC payload */
$params = array(
XML_RPC_encode($password),
XML_RPC_encode($execcmd)
@@ -1039,13 +1031,13 @@ function bind_do_xmlrpc_sync($sync_to_ip, $username, $password, $synctimeout, $m
$cli->setCredentials($username, $password);
$resp = $cli->send($msg, $synctimeout);
if (!$resp) {
- $error = "A communications error occurred while attempting BIND XMLRPC sync with {$url}:{$port} (pfsense.exec_php).";
+ $error = "A communication error occurred while attempting BIND XMLRPC sync with {$url}:{$port} (pfsense.exec_php).";
log_error($error);
file_notice("sync_settings", $error, "Bind Settings Sync", "");
} elseif ($resp->faultCode()) {
$cli->setDebug(1);
$resp = $cli->send($msg, $synctimeout);
- $error = "[Bind] An error code was received while attempting BIND XMLRPC sync with {$url}:{$port} - Code ".$resp->faultCode().": ".$resp->faultString();
+ $error = "[bind] An error code was received while attempting BIND XMLRPC sync with {$url}:{$port} - Code ".$resp->faultCode().": ".$resp->faultString();
log_error($error);
file_notice("sync_settings", $error, "bind Settings Sync", "");
} else {