From 54147cc682c89aaa73fcd41b61fa9464a14cc5fb Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 19 Apr 2016 20:19:11 -0700 Subject: adding privileges and separating DNS Resolver overrides from general settings (cherry picked from commit fc76a1e390c8ce9579df31457c74d1d0e572b78d) --- src/etc/inc/priv.defs.inc | 8 + src/usr/local/www/head.inc | 1 + .../www/services_unbound_domainoverride_edit.php | 21 +- src/usr/local/www/services_unbound_host_edit.php | 19 +- src/usr/local/www/services_unbound_overrides.php | 277 +++++++++++++++++++++ 5 files changed, 323 insertions(+), 3 deletions(-) create mode 100644 src/usr/local/www/services_unbound_overrides.php diff --git a/src/etc/inc/priv.defs.inc b/src/etc/inc/priv.defs.inc index fa3859b..1fb7fb8 100644 --- a/src/etc/inc/priv.defs.inc +++ b/src/etc/inc/priv.defs.inc @@ -814,6 +814,14 @@ $priv_list['page-services-dnsresolver-edithost']['descr'] = gettext("Allow acces $priv_list['page-services-dnsresolver-edithost']['match'] = array(); $priv_list['page-services-dnsresolver-edithost']['match'][] = "services_unbound_host_edit.php*"; +$priv_list['page-services-dnsresolver-overrides'] = array(); +$priv_list['page-services-dnsresolver-overrides']['name'] = gettext("WebCfg - Services: DNS Resolver: Override"); +$priv_list['page-services-dnsresolver-overrides']['descr'] = gettext("Allow access to the 'Services: DNS Resolver: Overrides' page."); +$priv_list['page-services-dnsresolver-overrides']['match'] = array(); +$priv_list['page-services-dnsresolver-overrides']['match'][] = "services_unbound_overrides.php*"; +$priv_list['page-services-dnsresolver-overrides']['match'][] = "services_unbound_host_edit.php*"; +$priv_list['page-services-dnsresolver-overrides']['match'][] = "services_unbound_domainoverride_edit.php*"; + $priv_list['page-services-wakeonlan'] = array(); $priv_list['page-services-wakeonlan']['name'] = gettext("WebCfg - Services: Wake-on-LAN"); $priv_list['page-services-wakeonlan']['descr'] = gettext("Allow access to the 'Services: Wake-on-LAN' page."); diff --git a/src/usr/local/www/head.inc b/src/usr/local/www/head.inc index 788c487..8c3b980 100644 --- a/src/usr/local/www/head.inc +++ b/src/usr/local/www/head.inc @@ -285,6 +285,7 @@ $services_menu = array(); $services_menu[] = array(gettext("Captive Portal"), "/services_captiveportal.php"); $services_menu[] = array(gettext("DNS Forwarder"), "/services_dnsmasq.php"); $services_menu[] = array(gettext("DNS Resolver"), "/services_unbound.php"); +$services_menu[] = array(gettext("DNS Resolver Overrides"), "/services_unbound_overrides.php"); $services_menu[] = array(gettext("DHCP Relay"), "/services_dhcp_relay.php"); $services_menu[] = array(gettext("DHCPv6 Relay"), "/services_dhcpv6_relay.php"); diff --git a/src/usr/local/www/services_unbound_domainoverride_edit.php b/src/usr/local/www/services_unbound_domainoverride_edit.php index ed64580..cb01888 100644 --- a/src/usr/local/www/services_unbound_domainoverride_edit.php +++ b/src/usr/local/www/services_unbound_domainoverride_edit.php @@ -86,6 +86,8 @@ if (isset($id) && $a_domainOverrides[$id]) { $pconfig['descr'] = $a_domainOverrides[$id]['descr']; } +$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/services_unbound.php'); + if ($_POST) { unset($input_errors); @@ -120,6 +122,10 @@ if ($_POST) { $input_errors[] = gettext("A valid IP address must be specified, for example 192.168.100.10."); } } + + if ($_POST['referer']) { + $referer = $_POST['referer']; + } if (!$input_errors) { $doment = array(); @@ -136,8 +142,12 @@ if ($_POST) { mark_subsystem_dirty('unbound'); write_config(); - - header("Location: services_unbound.php"); + + if ($referer == '/services_unbound_overrides.php') { + header("Location: services_unbound_overrides.php"); + } else { + header("Location: services_unbound.php"); + } exit; } } @@ -184,6 +194,13 @@ if (isset($id) && $a_domainOverrides[$id]) { )); } +$section->addInput(new Form_Input( + 'referer', + null, + 'hidden', + $referer +)); + $form->add($section); print $form; diff --git a/src/usr/local/www/services_unbound_host_edit.php b/src/usr/local/www/services_unbound_host_edit.php index fadc451..4fd5c50 100644 --- a/src/usr/local/www/services_unbound_host_edit.php +++ b/src/usr/local/www/services_unbound_host_edit.php @@ -102,6 +102,8 @@ if (isset($id) && $a_hosts[$id]) { $pconfig['aliases'] = $a_hosts[$id]['aliases']; } +$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/services_unbound.php'); + if ($_POST) { unset($input_errors); $pconfig = $_POST; @@ -187,6 +189,10 @@ if ($_POST) { break; } } + + if ($_POST['referer']) { + $referer = $_POST['referer']; + } if (!$input_errors) { $hostent = array(); @@ -207,7 +213,11 @@ if ($_POST) { write_config(); - header("Location: services_unbound.php"); + if ($referer == '/services_unbound_overrides.php') { + header("Location: services_unbound_overrides.php"); + } else { + header("Location: services_unbound.php"); + } exit; } } @@ -337,6 +347,13 @@ $form->addGlobal(new Form_Button( 'fa-plus' ))->removeClass('btn-primary')->addClass('btn-success addbtn'); +$section->addInput(new Form_Input( + 'referer', + null, + 'hidden', + $referer +)); + $form->add($section); print($form); diff --git a/src/usr/local/www/services_unbound_overrides.php b/src/usr/local/www/services_unbound_overrides.php new file mode 100644 index 0000000..d5cb111 --- /dev/null +++ b/src/usr/local/www/services_unbound_overrides.php @@ -0,0 +1,277 @@ +" . gettext("The changes must be applied for them to take effect.")); +} + + +?> + +
+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + +
+
+
+ + + +
+

+
+ + + + + + + + + + + + + + + + + + + + +
+   + +   + +   + + + +
+
+
+ + + +
+ ', ''), 'info', false); ?> +
+ +