Project

General

Profile

« Previous | Next » 

Revision 54147cc6

Added by Joe Palmer about 9 years ago

adding privileges and separating DNS Resolver overrides from general settings

(cherry picked from commit fc76a1e390c8ce9579df31457c74d1d0e572b78d)

View differences:

src/etc/inc/priv.defs.inc
814 814
$priv_list['page-services-dnsresolver-edithost']['match'] = array();
815 815
$priv_list['page-services-dnsresolver-edithost']['match'][] = "services_unbound_host_edit.php*";
816 816

  
817
$priv_list['page-services-dnsresolver-overrides'] = array();
818
$priv_list['page-services-dnsresolver-overrides']['name'] = gettext("WebCfg - Services: DNS Resolver: Override");
819
$priv_list['page-services-dnsresolver-overrides']['descr'] = gettext("Allow access to the 'Services: DNS Resolver: Overrides' page.");
820
$priv_list['page-services-dnsresolver-overrides']['match'] = array();
821
$priv_list['page-services-dnsresolver-overrides']['match'][] = "services_unbound_overrides.php*";
822
$priv_list['page-services-dnsresolver-overrides']['match'][] = "services_unbound_host_edit.php*";
823
$priv_list['page-services-dnsresolver-overrides']['match'][] = "services_unbound_domainoverride_edit.php*";
824

  
817 825
$priv_list['page-services-wakeonlan'] = array();
818 826
$priv_list['page-services-wakeonlan']['name'] = gettext("WebCfg - Services: Wake-on-LAN");
819 827
$priv_list['page-services-wakeonlan']['descr'] = gettext("Allow access to the 'Services: Wake-on-LAN' page.");
src/usr/local/www/head.inc
285 285
$services_menu[] = array(gettext("Captive Portal"), "/services_captiveportal.php");
286 286
$services_menu[] = array(gettext("DNS Forwarder"), "/services_dnsmasq.php");
287 287
$services_menu[] = array(gettext("DNS Resolver"), "/services_unbound.php");
288
$services_menu[] = array(gettext("DNS Resolver Overrides"), "/services_unbound_overrides.php");
288 289
$services_menu[] = array(gettext("DHCP Relay"), "/services_dhcp_relay.php");
289 290
$services_menu[] = array(gettext("DHCPv6 Relay"), "/services_dhcpv6_relay.php");
290 291

  
src/usr/local/www/services_unbound_domainoverride_edit.php
86 86
	$pconfig['descr'] = $a_domainOverrides[$id]['descr'];
87 87
}
88 88

  
89
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/services_unbound.php');
90

  
89 91
if ($_POST) {
90 92

  
91 93
	unset($input_errors);
......
120 122
			$input_errors[] = gettext("A valid IP address must be specified, for example 192.168.100.10.");
121 123
		}
122 124
	}
125
	
126
	if ($_POST['referer']) {
127
		$referer = $_POST['referer'];
128
	}
123 129

  
124 130
	if (!$input_errors) {
125 131
		$doment = array();
......
136 142
		mark_subsystem_dirty('unbound');
137 143

  
138 144
		write_config();
139

  
140
		header("Location: services_unbound.php");
145
		
146
		if ($referer == '/services_unbound_overrides.php') {
147
			header("Location: services_unbound_overrides.php");	
148
		} else {
149
			header("Location: services_unbound.php");
150
		}
141 151
		exit;
142 152
	}
143 153
}
......
184 194
	));
185 195
}
186 196

  
197
$section->addInput(new Form_Input(
198
	'referer',
199
	null,
200
	'hidden',
201
	$referer
202
));
203

  
187 204
$form->add($section);
188 205

  
189 206
print $form;
src/usr/local/www/services_unbound_host_edit.php
102 102
	$pconfig['aliases'] = $a_hosts[$id]['aliases'];
103 103
}
104 104

  
105
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/services_unbound.php');
106

  
105 107
if ($_POST) {
106 108
	unset($input_errors);
107 109
	$pconfig = $_POST;
......
187 189
			break;
188 190
		}
189 191
	}
192
	
193
	if ($_POST['referer']) {
194
		$referer = $_POST['referer'];
195
	}	
190 196

  
191 197
	if (!$input_errors) {
192 198
		$hostent = array();
......
207 213

  
208 214
		write_config();
209 215

  
210
		header("Location: services_unbound.php");
216
		if ($referer == '/services_unbound_overrides.php') {
217
			header("Location: services_unbound_overrides.php");	
218
		} else {
219
			header("Location: services_unbound.php");
220
		}
211 221
		exit;
212 222
	}
213 223
}
......
337 347
	'fa-plus'
338 348
))->removeClass('btn-primary')->addClass('btn-success addbtn');
339 349

  
350
$section->addInput(new Form_Input(
351
	'referer',
352
	null,
353
	'hidden',
354
	$referer
355
));
356

  
340 357
$form->add($section);
341 358
print($form);
342 359

  
src/usr/local/www/services_unbound_overrides.php
1
<?php
2
/*
3
	services_unbound.php
4
*/
5
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *	Copyright (c)  2014 Warren Baker (warren@pfsense.org)
8
 *
9
 *	Redistribution and use in source and binary forms, with or without modification,
10
 *	are permitted provided that the following conditions are met:
11
 *
12
 *	1. Redistributions of source code must retain the above copyright notice,
13
 *		this list of conditions and the following disclaimer.
14
 *
15
 *	2. Redistributions in binary form must reproduce the above copyright
16
 *		notice, this list of conditions and the following disclaimer in
17
 *		the documentation and/or other materials provided with the
18
 *		distribution.
19
 *
20
 *	3. All advertising materials mentioning features or use of this software
21
 *		must display the following acknowledgment:
22
 *		"This product includes software developed by the pfSense Project
23
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
24
 *
25
 *	4. The names "pfSense" and "pfSense Project" must not be used to
26
 *		 endorse or promote products derived from this software without
27
 *		 prior written permission. For written permission, please contact
28
 *		 coreteam@pfsense.org.
29
 *
30
 *	5. Products derived from this software may not be called "pfSense"
31
 *		nor may "pfSense" appear in their names without prior written
32
 *		permission of the Electric Sheep Fencing, LLC.
33
 *
34
 *	6. Redistributions of any form whatsoever must retain the following
35
 *		acknowledgment:
36
 *
37
 *	"This product includes software developed by the pfSense Project
38
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
39
 *
40
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
41
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
44
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
52
 *
53
 *	====================================================================
54
 *
55
 */
56

  
57
##|+PRIV
58
##|*IDENT=page-services-dnsresolver-overrides
59
##|*NAME=Services: DNS Resolver Overrides
60
##|*DESCR=Allow access to the 'Services: DNS Resolver' Overrides page.
61
##|*MATCH=services_unbound_overrides.php*
62
##|-PRIV
63

  
64
require_once("guiconfig.inc");
65
require_once("unbound.inc");
66
require_once("system.inc");
67

  
68
if (!is_array($config['unbound'])) {
69
	$config['unbound'] = array();
70
}
71

  
72
$a_unboundcfg =& $config['unbound'];
73

  
74
if (!is_array($a_unboundcfg['hosts'])) {
75
	$a_unboundcfg['hosts'] = array();
76
}
77

  
78
$a_hosts =& $a_unboundcfg['hosts'];
79

  
80
if (!is_array($a_unboundcfg['domainoverrides'])) {
81
	$a_unboundcfg['domainoverrides'] = array();
82
}
83

  
84
$a_domainOverrides = &$a_unboundcfg['domainoverrides'];
85

  
86
if ($_POST) {
87
	if ($_POST['apply']) {
88
		$retval = services_unbound_configure();
89
		$savemsg = get_std_save_message($retval);
90
		if ($retval == 0) {
91
			clear_subsystem_dirty('unbound');
92
		}
93
		/* Update resolv.conf in case the interface bindings exclude localhost. */
94
		system_resolvconf_generate();
95
		/* Start or restart dhcpleases when it's necessary */
96
		system_dhcpleases_configure();
97
	}
98
}
99

  
100
if ($_GET['act'] == "del") {
101
	if ($_GET['type'] == 'host') {
102
		if ($a_hosts[$_GET['id']]) {
103
			unset($a_hosts[$_GET['id']]);
104
			write_config();
105
			mark_subsystem_dirty('unbound');
106
			header("Location: services_unbound_overrides.php");
107
			exit;
108
		}
109
	} elseif ($_GET['type'] == 'doverride') {
110
		if ($a_domainOverrides[$_GET['id']]) {
111
			unset($a_domainOverrides[$_GET['id']]);
112
			write_config();
113
			mark_subsystem_dirty('unbound');
114
			header("Location: services_unbound_overrides.php");
115
			exit;
116
		}
117
	}
118
}
119

  
120
$pgtitle = array(gettext("Services"), gettext("DNS Resolver"), gettext("Overrides"));
121
$shortcut_section = "resolver";
122

  
123
include_once("head.inc");
124

  
125
if ($input_errors) {
126
	print_input_errors($input_errors);
127
}
128

  
129
if ($savemsg) {
130
	print_info_box($savemsg, 'success');
131
}
132

  
133
if (is_subsystem_dirty('unbound')) {
134
	print_apply_box(gettext("The DNS resolver configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
135
}
136

  
137

  
138
?>
139

  
140
<div class="panel panel-default">
141
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Host Overrides")?></h2></div>
142
	<div class="panel-body table-responsive">
143
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
144
			<thead>
145
				<tr>
146
					<th><?=gettext("Host")?></th>
147
					<th><?=gettext("Domain")?></th>
148
					<th><?=gettext("IP")?></th>
149
					<th><?=gettext("Description")?></th>
150
					<th><?=gettext("Actions")?></th>
151
				</tr>
152
			</thead>
153
			<tbody>
154
<?php
155
$i = 0;
156
foreach ($a_hosts as $hostent):
157
?>
158
				<tr>
159
					<td>
160
						<?=$hostent['host']?>
161
					</td>
162
					<td>
163
						<?=$hostent['domain']?>
164
					</td>
165
					<td>
166
						<?=$hostent['ip']?>
167
					</td>
168
					<td>
169
						<?=htmlspecialchars($hostent['descr'])?>
170
					</td>
171
					<td>
172
						<a class="fa fa-pencil"	title="<?=gettext('Edit host override')?>" href="services_unbound_host_edit.php?id=<?=$i?>"></a>
173
						<a class="fa fa-trash"	title="<?=gettext('Delete host override')?>" href="services_unbound_overrides.php?type=host&amp;act=del&amp;id=<?=$i?>"></a>
174
					</td>
175
				</tr>
176

  
177
<?php
178
	if ($hostent['aliases']['item'] && is_array($hostent['aliases']['item'])):
179
		foreach ($hostent['aliases']['item'] as $alias):
180
?>
181
				<tr>
182
					<td>
183
						<?=$alias['host']?>
184
					</td>
185
					<td>
186
						<?=$alias['domain']?>
187
					</td>
188
					<td>
189
						<?=gettext("Alias for ");?><?=$hostent['host'] ? $hostent['host'] . '.' . $hostent['domain'] : $hostent['domain']?>
190
					</td>
191
					<td>
192
						<i class="fa fa-angle-double-right text-info"></i>
193
						<?=htmlspecialchars($alias['description'])?>
194
					</td>
195
					<td>
196
						<a a class="fa fa-pencil"	title="<?=gettext('Edit host override')?>" 	href="services_unbound_host_edit.php?id=<?=$i?>"></a>
197
					</td>
198
				</tr>
199
<?php
200
		endforeach;
201
	endif;
202
	$i++;
203
endforeach;
204
?>
205
			</tbody>
206
		</table>
207
	</div>
208
</div>
209

  
210
<nav class="action-buttons">
211
	<a href="services_unbound_host_edit.php" class="btn btn-sm btn-success">
212
		<i class="fa fa-plus icon-embed-btn"></i>
213
		<?=gettext('Add')?>
214
	</a>
215
</nav>
216

  
217
<div class="panel panel-default">
218
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Domain Overrides")?></h2></div>
219
	<div class="panel-body table-responsive">
220
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
221
			<thead>
222
				<tr>
223
					<th><?=gettext("Domain")?></th>
224
					<th><?=gettext("IP")?></th>
225
					<th><?=gettext("Description")?></th>
226
					<th><?=gettext("Actions")?></th>
227
				</tr>
228
			</thead>
229

  
230
			<tbody>
231
<?php
232
$i = 0;
233
foreach ($a_domainOverrides as $doment):
234
?>
235
				<tr>
236
					<td>
237
						<?=$doment['domain']?>&nbsp;
238
					</td>
239
					<td>
240
						<?=$doment['ip']?>&nbsp;
241
					</td>
242
					<td>
243
						<?=htmlspecialchars($doment['descr'])?>&nbsp;
244
					</td>
245
					<td>
246
						<a class="fa fa-pencil"	title="<?=gettext('Edit domain override')?>" href="services_unbound_domainoverride_edit.php?id=<?=$i?>"></a>
247
						<a class="fa fa-trash"	title="<?=gettext('Delete domain override')?>" href="services_unbound_overrides.php?act=del&amp;type=doverride&amp;id=<?=$i?>"></a>
248
					</td>
249
				</tr>
250
<?php
251
	$i++;
252
endforeach;
253
?>
254
			</tbody>
255
		</table>
256
	</div>
257
</div>
258

  
259
<nav class="action-buttons">
260
	<a href="services_unbound_domainoverride_edit.php" class="btn btn-sm btn-success">
261
		<i class="fa fa-plus icon-embed-btn"></i>
262
		<?=gettext('Add')?>
263
	</a>
264
</nav>
265

  
266
<div class="infoblock">
267
	<?php print_info_box(sprintf(gettext("If the DNS Resolver is enabled, the DHCP".
268
		" service (if enabled) will automatically serve the LAN IP".
269
		" address as a DNS server to DHCP clients so they will use".
270
		" the DNS Resolver. If Forwarding is enabled, the DNS Resolver will use the DNS servers".
271
		" entered in %sSystem: General setup%s".
272
		" or those obtained via DHCP or PPP on WAN if &quot;Allow".
273
		" DNS server list to be overridden by DHCP/PPP on WAN&quot;".
274
		" is checked."), '<a href="system.php">', '</a>'), 'info', false); ?>
275
</div>
276

  
277
<?php include("foot.inc");

Also available in: Unified diff