From 7b03ef633aeadd8b128c69fbd1c89990004810e7 Mon Sep 17 00:00:00 2001 From: Chris Buechler Date: Sat, 6 Feb 2016 01:32:13 -0600 Subject: Verify a DNS server exists before allowing enabling of forwarding mode. Ticket #4747 --- src/usr/local/www/services_unbound.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/usr/local/www/services_unbound.php') diff --git a/src/usr/local/www/services_unbound.php b/src/usr/local/www/services_unbound.php index 48f017a..5a35ddb 100644 --- a/src/usr/local/www/services_unbound.php +++ b/src/usr/local/www/services_unbound.php @@ -141,6 +141,32 @@ if ($_POST) { } } + // forwarding mode requires having valid DNS servers + if (isset($pconfig['forwarding'])) { + $founddns = false; + if (isset($config['system']['dnsallowoverride'])) { + $a_gateways = return_gateways_array(); + if (is_array($a_gateways)) { + foreach ($a_gateways as $gateway) { + if ($gateway['dynamic'] == true) { + // assume DNS is being obtained dynamically + $founddns = true; + } + } + } + } + if (is_array($config['system']['dnsserver'])) { + foreach ($config['system']['dnsserver'] as $dnsserver) { + if (is_ipaddr($dnsserver)) { + $founddns = true; + } + } + } + if ($founddns == false) { + $input_errors[] = gettext("At least one DNS server must be specified under System>General Setup to enable Forwarding mode."); + } + } + if (empty($pconfig['active_interface'])) { $input_errors[] = gettext("One or more Network Interfaces must be selected for binding."); } else if (!isset($config['system']['dnslocalhost']) && (!in_array("lo0", $pconfig['active_interface']) && !in_array("all", $pconfig['active_interface']))) { -- cgit v1.1