Project

General

Profile

Download (19.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	system_advanced_admin.php
5
	part of pfSense
6
	Copyright (C) 2005-2010 Scott Ullrich
7

    
8
	Copyright (C) 2008 Shrew Soft Inc
9

    
10
	originally part of m0n0wall (http://m0n0.ch/wall)
11
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
12
	All rights reserved.
13

    
14
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16

    
17
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19

    
20
	2. Redistributions in binary form must reproduce the above copyright
21
	   notice, this list of conditions and the following disclaimer in the
22
	   documentation and/or other materials provided with the distribution.
23

    
24
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
	POSSIBILITY OF SUCH DAMAGE.
34
*/
35
/*
36
	pfSense_BUILDER_BINARIES:	/usr/bin/killall
37
	pfSense_MODULE:	system
38
*/
39

    
40
##|+PRIV
41
##|*IDENT=page-system-advanced-admin
42
##|*NAME=System: Advanced: Admin Access Page
43
##|*DESCR=Allow access to the 'System: Advanced: Admin Access' page.
44
##|*MATCH=system_advanced_admin.php*
45
##|-PRIV
46

    
47
require("guiconfig.inc");
48
require_once("functions.inc");
49
require_once("filter.inc");
50
require_once("shaper.inc");
51

    
52
$pconfig['webguiproto'] = $config['system']['webgui']['protocol'];
53
$pconfig['webguiport'] = $config['system']['webgui']['port'];
54
$pconfig['ssl-certref'] = $config['system']['webgui']['ssl-certref'];
55
$pconfig['disablehttpredirect'] = isset($config['system']['webgui']['disablehttpredirect']);
56
$pconfig['disableconsolemenu'] = isset($config['system']['disableconsolemenu']);
57
$pconfig['noantilockout'] = isset($config['system']['webgui']['noantilockout']);
58
$pconfig['nodnsrebindcheck'] = isset($config['system']['webgui']['nodnsrebindcheck']);
59
$pconfig['nohttpreferercheck'] = isset($config['system']['webgui']['nohttpreferercheck']);
60
$pconfig['althostnames'] = $config['system']['webgui']['althostnames'];
61
$pconfig['enableserial'] = $config['system']['enableserial'];
62
$pconfig['enablesshd'] = $config['system']['enablesshd'];
63
$pconfig['sshport'] = $config['system']['ssh']['port'];
64
$pconfig['sshdkeyonly'] = isset($config['system']['ssh']['sshdkeyonly']);
65

    
66
$a_cert =& $config['cert'];
67

    
68
$certs_available = false;
69
if (is_array($a_cert) && count($a_cert))
70
	$certs_available = true;
71

    
72
if (!$pconfig['webguiproto'] || !$certs_available)
73
	$pconfig['webguiproto'] = "http";
74

    
75
if ($_POST) {
76

    
77
	unset($input_errors);
78
	$pconfig = $_POST;
79

    
80
	/* input validation */
81
	if ($_POST['webguiport'])
82
		if(!is_port($_POST['webguiport']))
83
			$input_errors[] = gettext("You must specify a valid webConfigurator port number");
84

    
85
	if ($_POST['althostnames']) {
86
		$althosts = explode(" ", $_POST['althostnames']);
87
		foreach ($althosts as $ah)
88
			if (!is_hostname($ah))
89
				$input_errors[] = gettext("Alternate hostname " . htmlspecialchars($ah) . " is not a valid hostname.");
90
	}
91

    
92
	if ($_POST['sshport'])
93
		if(!is_port($_POST['sshport']))
94
			$input_errors[] = gettext("You must specify a valid port number");
95

    
96
	if($_POST['sshdkeyonly'] == "yes")
97
		$config['system']['ssh']['sshdkeyonly'] = "enabled";
98
	else if (isset($config['system']['ssh']['sshdkeyonly']))
99
		unset($config['system']['ssh']['sshdkeyonly']);
100

    
101
	ob_flush();
102
	flush();
103

    
104
	if (!$input_errors) {
105

    
106
		if (update_if_changed("webgui protocol", $config['system']['webgui']['protocol'], $_POST['webguiproto']))
107
			$restart_webgui = true;
108
		if (update_if_changed("webgui port", $config['system']['webgui']['port'], $_POST['webguiport']))
109
			$restart_webgui = true;
110
		if (update_if_changed("webgui certificate", $config['system']['webgui']['ssl-certref'], $_POST['ssl-certref']))
111
			$restart_webgui = true;
112

    
113
		if ($_POST['disablehttpredirect'] == "yes") {
114
			$config['system']['webgui']['disablehttpredirect'] = true;
115
			$restart_webgui = true;
116
		} else {
117
			unset($config['system']['webgui']['disablehttpredirect']);
118
			$restart_webgui = true;
119
		}
120

    
121
		if($_POST['disableconsolemenu'] == "yes") {
122
			$config['system']['disableconsolemenu'] = true;
123
			auto_login();
124
		} else {
125
			unset($config['system']['disableconsolemenu']);
126
			auto_login();
127
		}
128

    
129
		if ($_POST['noantilockout'] == "yes")
130
			$config['system']['webgui']['noantilockout'] = true;
131
		else
132
			unset($config['system']['webgui']['noantilockout']);
133

    
134
		if ($_POST['enableserial'] == "yes")
135
			$config['system']['enableserial'] = true;
136
		else
137
			unset($config['system']['enableserial']);
138

    
139
		if ($_POST['nodnsrebindcheck'] == "yes")
140
			$config['system']['webgui']['nodnsrebindcheck'] = true;
141
		else
142
			unset($config['system']['webgui']['nodnsrebindcheck']);
143

    
144
		if ($_POST['nohttpreferercheck'] == "yes")
145
			$config['system']['webgui']['nohttpreferercheck'] = true;
146
		else
147
			unset($config['system']['webgui']['nohttpreferercheck']);
148

    
149
		if ($_POST['althostnames'])
150
			$config['system']['webgui']['althostnames'] = $_POST['althostnames'];
151
		else
152
			unset($config['system']['webgui']['althostnames']);
153

    
154
		$sshd_enabled = $config['system']['enablesshd'];
155
		if($_POST['enablesshd'])
156
			$config['system']['enablesshd'] = "enabled";
157
		else
158
			unset($config['system']['enablesshd']);
159

    
160
		$sshd_keyonly = isset($config['system']['sshdkeyonly']);
161
		if ($_POST['sshdkeyonly'])
162
			$config['system']['sshdkeyonly'] = true;
163
		else
164
			unset($config['system']['sshdkeyonly']);
165

    
166
		$sshd_port = $config['system']['ssh']['port'];
167
		if ($_POST['sshport'])
168
			$config['system']['ssh']['port'] = $_POST['sshport'];
169
		else if (isset($config['system']['ssh']['port']))
170
			unset($config['system']['ssh']['port']);
171

    
172
		if (($sshd_enabled != $config['system']['enablesshd']) ||
173
			($sshd_keyonly != $config['system']['sshdkeyonly']) ||
174
			($sshd_port != $config['system']['ssh']['port']))
175
			$restart_sshd = true;
176

    
177
		if ($restart_webgui) {
178
			global $_SERVER;
179
			list($host) = explode(":", $_SERVER['HTTP_HOST']);
180
			$prot = $config['system']['webgui']['protocol'];
181
			$port = $config['system']['webgui']['port'];
182
			if ($port)
183
				$url = "{$prot}://{$host}:{$port}/system_advanced_admin.php";
184
			else
185
				$url = "{$prot}://{$host}/system_advanced_admin.php";
186
		}
187

    
188
		write_config();
189

    
190
		$retval = filter_configure();
191
	    $savemsg = get_std_save_message($retval);
192

    
193
		if ($restart_webgui)
194
			$savemsg .= sprintf("<br />" . gettext("One moment...redirecting to %s in 20 seconds."),$url);
195

    
196
		conf_mount_rw();
197
		setup_serial_port();
198
		// Restart dnsmasq in case dns rebinding toggled
199
		services_dnsmasq_configure();
200
		conf_mount_ro();
201
	}
202
}
203

    
204
$pgtitle = array(gettext("System"),gettext("Advanced: Admin Access"));
205
include("head.inc");
206

    
207
?>
208

    
209
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
210
<?php include("fbegin.inc"); ?>
211
<script language="JavaScript">
212
<!--
213

    
214
function prot_change() {
215

    
216
	if (document.iform.https_proto.checked)
217
		document.getElementById("ssl_opts").style.display="";
218
	else
219
		document.getElementById("ssl_opts").style.display="none";
220
}
221

    
222
//-->
223
</script>
224
<?php
225
	if ($input_errors)
226
		print_input_errors($input_errors);
227
	if ($savemsg)
228
		print_info_box($savemsg);
229
?>
230
	<form action="system_advanced_admin.php" method="post" name="iform" id="iform">
231
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
232
			<tr>
233
				<td>
234
					<?php
235
						$tab_array = array();
236
						$tab_array[] = array(gettext("Admin Access"), true, "system_advanced_admin.php");
237
						$tab_array[] = array(gettext("Firewall / NAT"), false, "system_advanced_firewall.php");
238
						$tab_array[] = array(gettext("Networking"), false, "system_advanced_network.php");
239
						$tab_array[] = array(gettext("Miscellaneous"), false, "system_advanced_misc.php");
240
						$tab_array[] = array(gettext("System Tunables"), false, "system_advanced_sysctl.php");
241
						$tab_array[] = array(gettext("Notifications"), false, "system_advanced_notifications.php");
242
						display_top_tabs($tab_array);
243
					?>
244
				</td>
245
			</tr>
246
			<tr>
247
				<td id="mainarea">
248
					<div class="tabcont">
249
						<span class="vexpl">
250
							<span class="red">
251
								<strong><?=gettext("NOTE:"); ?>&nbsp</strong>
252
							</span>
253
							<?=gettext("The options on this page are intended for use by advanced users only."); ?>
254
							<br/>
255
						</span>
256
						<br/>
257
						<table width="100%" border="0" cellpadding="6" cellspacing="0">
258
							<tr>
259
								<td colspan="2" valign="top" class="listtopic"><?=gettext("webConfigurator"); ?></td>
260
							</tr>
261
							<tr>
262
								<td width="22%" valign="top" class="vncell"><?=gettext("Protocol"); ?></td>
263
								<td width="78%" class="vtable">
264
									<?php
265
										if ($pconfig['webguiproto'] == "http")
266
											$http_chk = "checked";
267
										if ($pconfig['webguiproto'] == "https")
268
											$https_chk = "checked";
269
										if (!$certs_available)
270
											$https_disabled = "disabled";
271
									?>
272
									<input name="webguiproto" id="http_proto" type="radio" value="http" <?=$http_chk;?> onClick="prot_change()">
273
									<?=gettext("HTTP"); ?>
274
									&nbsp;&nbsp;&nbsp;
275
									<input name="webguiproto" id="https_proto" type="radio" value="https" <?=$https_chk;?> <?=$https_disabled;?> onClick="prot_change()">
276
									<?=gettext("HTTPS"); ?>
277
									<?php if (!$certs_available): ?>
278
									<br/>
279
									<?=gettext("No Certificates have been defined. You must"); ?>
280
									<a href="system_certmanager.php"><?=gettext("Create or Import"); ?></a>
281
									<?=gettext("a Certificate before SSL can be enabled."); ?>
282
									<?php endif; ?>
283
								</td>
284
							</tr>
285
							<tr id="ssl_opts">
286
								<td width="22%" valign="top" class="vncell"><?=gettext("SSL Certificate"); ?></td>
287
								<td width="78%" class="vtable">
288
									<select name="ssl-certref" id="ssl-certref" class="formselect">
289
										<?php
290
											foreach($a_cert as $cert):
291
												$selected = "";
292
												if ($pconfig['ssl-certref'] == $cert['refid'])
293
													$selected = "selected";
294
										?>
295
										<option value="<?=$cert['refid'];?>"<?=$selected;?>><?=$cert['descr'];?></option>
296
										<?php endforeach; ?>
297
									</select>
298
								</td>
299
							</tr>
300
							<tr>
301
								<td valign="top" class="vncell"><?=gettext("TCP port"); ?></td>
302
								<td class="vtable">
303
									<input name="webguiport" type="text" class="formfld unknown" id="webguiport" "size="5" value="<?=htmlspecialchars($config['system']['webgui']['port']);?>">
304
									<br>
305
									<span class="vexpl">
306
										<?=gettext("Enter a custom port number for the webConfigurator " .
307
										"above if you want to override the default (80 for HTTP, 443 " .
308
										"for HTTPS). Changes will take effect immediately after save."); ?>
309
									</span>
310
								</td>
311
							</tr>
312
							<tr>
313
								<td width="22%" valign="top" class="vncell"><?=gettext("WebGUI redirect"); ?></td>
314
								<td width="78%" class="vtable">
315
									<input name="disablehttpredirect" type="checkbox" id="disablehttpredirect" value="yes" <?php if ($pconfig['disablehttpredirect']) echo "checked"; ?> />
316
									<strong><?=gettext("Disable webConfigurator redirect rule"); ?></strong>
317
									<br/>
318
									<?php gettext("When this is unchecked, access to the webConfigurator " .
319
									"is always permitted even on port 80, regardless of the listening port configured." .
320
									"Check this box to disable this automatically added redirect rule. ");
321
									?>
322
								</td>
323
							</tr>
324
							<tr>
325
								<td width="22%" valign="top" class="vncell"><?=gettext("Anti-lockout"); ?></td>
326
								<td width="78%" class="vtable">
327
									<?php
328
										if($config['interfaces']['lan']) 
329
											$lockout_interface = "LAN";
330
										else 
331
											$lockout_interface = "WAN";
332
									?>
333
									<input name="noantilockout" type="checkbox" id="noantilockout" value="yes" <?php if ($pconfig['noantilockout']) echo "checked"; ?> />
334
									<strong><?=gettext("Disable webConfigurator anti-lockout rule"); ?></strong>
335
									<br/>
336
									<?php printf(gettext("When this is unchecked, access to the webConfigurator " .
337
									"on the %s interface is always permitted, regardless of the user-defined firewall " .
338
									"rule set. Check this box to disable this automatically added rule, so access " .
339
									"to the webConfigurator is controlled by the user-defined firewall rules " .
340
									"(ensure you have a firewall rule in place that allows you in, or you will " .
341
									"lock yourself out!)"), $lockout_interface); ?>
342
									<em> <?=gettext("Hint: the &quot;Set interface(s) IP address&quot; option in the console menu resets this setting as well."); ?> </em>
343
								</td>
344
							</tr>
345
							<tr>
346
								<td width="22%" valign="top" class="vncell"><?=gettext("DNS Rebind Check"); ?></td>
347
								<td width="78%" class="vtable">
348
									<input name="nodnsrebindcheck" type="checkbox" id="nodnsrebindcheck" value="yes" <?php if ($pconfig['nodnsrebindcheck']) echo "checked"; ?> />
349
									<strong><?=gettext("Disable webConfigurator DNS Rebinding Checks"); ?></strong>
350
									<br/>
351
									<?php echo gettext("When this is unchecked, access to the webConfigurator " .
352
									"is protected against <a href=\"http://en.wikipedia.org/wiki/DNS_rebinding\">DNS Rebinding attacks</a>. " .
353
									"Check this box to disable this protection if you find that it interferes with " .
354
									"webConfigurator access in certain corner cases. "); ?>
355
								</td>
356
							</tr>
357
							<tr>
358
								<td width="22%" valign="top" class="vncell"><?=gettext("Alternate Hostnames"); ?></td>
359
								<td width="78%" class="vtable">
360
									<input name="althostnames" type="text" class="formfld unknown" id="althostnames" size="75" value="<?=htmlspecialchars($pconfig['althostnames']);?>"/>
361
									<br/>
362
									<strong><?=gettext("Alternate Hostnames for DNS Rebinding and HTTP_REFERER Checks"); ?></strong>
363
									<br/>
364
									<?php echo gettext("Here you can specify alternate hostnames by which the router may be queried, to " . 
365
									"bypass the DNS Rebinding Attack checks. Separate hostnames with spaces."); ?>
366
								</td>
367
							</tr>
368
							<tr>
369
								<td width="22%" valign="top" class="vncell"><?=gettext("Browser HTTP_REFERER enforcement"); ?></td>
370
								<td width="78%" class="vtable">
371
									<input name="nohttpreferercheck" type="checkbox" id="nohttpreferercheck" value="yes" <?php if ($pconfig['nohttpreferercheck']) echo "checked"; ?> />
372
									<strong><?=gettext("Disable HTTP_REFERER enforcement check"); ?></strong>
373
									<br/>
374
									<?php echo gettext("When this is unchecked, access to the webConfigurator " .
375
									"is protected against HTTP_REFERER redirection attempts. " .
376
									"Check this box to disable this protection if you find that it interferes with " .
377
									"webConfigurator access in certain corner cases such as using external scripts to interact with this system. More information on HTTP_REFERER is available from <a target='_new' href='http://en.wikipedia.org/wiki/HTTP_referrer'>Wikipedia</a>."); ?>
378
								</td>
379
							</tr>
380
							<tr>
381
								<td colspan="2" class="list" height="12">&nbsp;</td>
382
							</tr>
383
							<tr>
384
								<td colspan="2" valign="top" class="listtopic"><?=gettext("Secure Shell"); ?></td>
385
							</tr>
386
							<tr>
387
								<td width="22%" valign="top" class="vncell"><?=gettext("Secure Shell Server"); ?></td>
388
								<td width="78%" class="vtable">
389
									<input name="enablesshd" type="checkbox" id="enablesshd" value="yes" <?php if (isset($pconfig['enablesshd'])) echo "checked"; ?> />
390
									<strong><?=gettext("Enable Secure Shell"); ?></strong>
391
								</td>
392
							</tr>
393
							<tr>
394
								<td width="22%" valign="top" class="vncell"><?=gettext("Authentication Method"); ?></td>
395
								<td width="78%" class="vtable">
396
									<input name="sshdkeyonly" type="checkbox" id="sshdkeyonly" value="yes" <?php if ($pconfig['sshdkeyonly']) echo "checked"; ?> />
397
									<strong><?=gettext("Disable password login for Secure Shell (RSA key only)"); ?></strong>
398
									<br/>
399
									<?=gettext("When enabled, authorized keys need to be configured for each"); ?>
400
									<a href="system_usermanager.php"><?=gettext("user"); ?></a>
401
									<?=gettext("that has been granted secure shell access."); ?>
402
								</td>
403
							</tr>
404
							<tr>
405
								<td width="22%" valign="top" class="vncell"><?=gettext("SSH port"); ?></td>
406
								<td width="78%" class="vtable">
407
									<input name="sshport" type="text" id="sshport" value="<?php echo $pconfig['sshport']; ?>" />
408
									<br/>
409
									<span class="vexpl"><?=gettext("Note: Leave this blank for the default of 22."); ?></span>
410
								</td>
411
							</tr>
412
							<tr>
413
								<td colspan="2" class="list" height="12">&nbsp;</td>
414
							</tr>
415
							<?php if($g['platform'] == "pfSense" || $g['platform'] == "cdrom"): ?>
416
							<tr>
417
								<td colspan="2" valign="top" class="listtopic"><?=gettext("Serial Communcations"); ?></td>
418
							</tr>
419
							<tr>
420
								<td width="22%" valign="top" class="vncell"><?=gettext("Serial Terminal"); ?></td>
421
								<td width="78%" class="vtable">
422
									<input name="enableserial" type="checkbox" id="enableserial" value="yes" <?php if (isset($pconfig['enableserial'])) echo "checked"; ?> />
423
									<strong><?=gettext("This will enable the first serial port with 9600/8/N/1"); ?></strong>
424
									<br>
425
									<span class="vexpl"><?=gettext("Note:  This will redirect the console output and messages to the serial port. You can still access the console menu from the internal video card/keyboard. A <b>null modem</b> serial cable or adapter is required to use the serial console."); ?></span>
426
								</td>
427
							</tr>
428
							<tr>
429
								<td colspan="2" class="list" height="12">&nbsp;</td>
430
							</tr>
431
							<?php endif; ?>
432
							<tr>
433
								<td colspan="2" valign="top" class="listtopic"><?=gettext("Console Options"); ?></td>
434
							</tr>
435
							<tr>
436
								<td width="22%" valign="top" class="vncell"><?=gettext("Console menu"); ?></td>
437
								<td width="78%" class="vtable">
438
									<input name="disableconsolemenu" type="checkbox" id="disableconsolemenu" value="yes" <?php if ($pconfig['disableconsolemenu']) echo "checked"; ?>  />
439
									<strong><?=gettext("Password protect the console menu"); ?></strong>
440
									<br/>
441
									<span class="vexpl"><?=gettext("Changes to this option will take effect after a reboot."); ?></span>
442
								</td>
443
							</tr>
444
							<tr>
445
								<td colspan="2" class="list" height="12">&nbsp;</td>
446
							</tr>							
447
							<tr>
448
								<td width="22%" valign="top">&nbsp;</td>
449
								<td width="78%"><input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /></td>
450
							</tr>
451
							<tr>
452
								<td colspan="2" class="list" height="12">&nbsp;</td>
453
							</tr>
454
						</table>
455
					</div>
456
				</td>
457
			</tr>
458
		</table>
459
	</form>
460
	<script language="JavaScript" type="text/javascript">
461
	<!--
462
		prot_change();
463
	//-->
464
	</script>
465

    
466
<?php include("fend.inc"); ?>
467
<?php
468
	if ($restart_webgui)
469
		echo "<meta http-equiv=\"refresh\" content=\"20;url={$url}\">";
470
?>
471
</body>
472
</html>
473

    
474
<?php
475
if ($restart_sshd) {
476

    
477
	killbyname("sshd");
478
	log_error(gettext("secure shell configuration has changed. Stopping sshd."));
479

    
480
	if ($config['system']['enablesshd']) {
481
		log_error(gettext("secure shell configuration has changed. Restarting sshd."));
482
		send_event("service restart sshd");
483
	}
484
}
485
if ($restart_webgui) {
486
	ob_flush();
487
	flush();
488
	log_error(gettext("webConfigurator configuration has changed. Restarting webConfigurator."));
489
	send_event("service restart webgui");
490
}
491

    
492
?>
(173-173/221)