Project

General

Profile

Download (20.4 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
$pconfig['quietlogin'] = isset($config['system']['webgui']['quietlogin']);
66

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

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

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

    
76
if ($_POST) {
77

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

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

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

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

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

    
102
	ob_flush();
103
	flush();
104

    
105
	if (!$input_errors) {
106

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

    
114
		if ($_POST['disablehttpredirect'] == "yes") {
115
			$config['system']['webgui']['disablehttpredirect'] = true;
116
			$restart_webgui = true;
117
		} else {
118
			unset($config['system']['webgui']['disablehttpredirect']);
119
			$restart_webgui = true;
120
		}
121
		if ($_POST['quietlogin'] == "yes") {
122
			$config['system']['webgui']['quietlogin'] = true;
123
		} else {
124
			unset($config['system']['webgui']['quietlogin']);
125
		}
126

    
127
		if($_POST['disableconsolemenu'] == "yes") {
128
			$config['system']['disableconsolemenu'] = true;
129
			auto_login();
130
		} else {
131
			unset($config['system']['disableconsolemenu']);
132
			auto_login();
133
		}
134

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

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

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

    
150
		if ($_POST['nohttpreferercheck'] == "yes")
151
			$config['system']['webgui']['nohttpreferercheck'] = true;
152
		else
153
			unset($config['system']['webgui']['nohttpreferercheck']);
154

    
155
		if ($_POST['althostnames'])
156
			$config['system']['webgui']['althostnames'] = $_POST['althostnames'];
157
		else
158
			unset($config['system']['webgui']['althostnames']);
159

    
160
		$sshd_enabled = $config['system']['enablesshd'];
161
		if($_POST['enablesshd'])
162
			$config['system']['enablesshd'] = "enabled";
163
		else
164
			unset($config['system']['enablesshd']);
165

    
166
		$sshd_keyonly = isset($config['system']['sshdkeyonly']);
167
		if ($_POST['sshdkeyonly'])
168
			$config['system']['sshdkeyonly'] = true;
169
		else
170
			unset($config['system']['sshdkeyonly']);
171

    
172
		$sshd_port = $config['system']['ssh']['port'];
173
		if ($_POST['sshport'])
174
			$config['system']['ssh']['port'] = $_POST['sshport'];
175
		else if (isset($config['system']['ssh']['port']))
176
			unset($config['system']['ssh']['port']);
177

    
178
		if (($sshd_enabled != $config['system']['enablesshd']) ||
179
			($sshd_keyonly != $config['system']['sshdkeyonly']) ||
180
			($sshd_port != $config['system']['ssh']['port']))
181
			$restart_sshd = true;
182

    
183
		if ($restart_webgui) {
184
			global $_SERVER;
185
			list($host) = explode(":", $_SERVER['HTTP_HOST']);
186
			$prot = $config['system']['webgui']['protocol'];
187
			$port = $config['system']['webgui']['port'];
188
			if ($port)
189
				$url = "{$prot}://{$host}:{$port}/system_advanced_admin.php";
190
			else
191
				$url = "{$prot}://{$host}/system_advanced_admin.php";
192
		}
193

    
194
		write_config();
195

    
196
		$retval = filter_configure();
197
	    $savemsg = get_std_save_message($retval);
198

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

    
202
		conf_mount_rw();
203
		setup_serial_port();
204
		// Restart dnsmasq in case dns rebinding toggled
205
		services_dnsmasq_configure();
206
		conf_mount_ro();
207
	}
208
}
209

    
210
$pgtitle = array(gettext("System"),gettext("Advanced: Admin Access"));
211
include("head.inc");
212

    
213
?>
214

    
215
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
216
<?php include("fbegin.inc"); ?>
217
<script language="JavaScript">
218
<!--
219

    
220
function prot_change() {
221

    
222
	if (document.iform.https_proto.checked)
223
		document.getElementById("ssl_opts").style.display="";
224
	else
225
		document.getElementById("ssl_opts").style.display="none";
226
}
227

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

    
483
<?php include("fend.inc"); ?>
484
<?php
485
	if ($restart_webgui)
486
		echo "<meta http-equiv=\"refresh\" content=\"20;url={$url}\">";
487
?>
488
</body>
489
</html>
490

    
491
<?php
492
if ($restart_sshd) {
493

    
494
	killbyname("sshd");
495
	log_error(gettext("secure shell configuration has changed. Stopping sshd."));
496

    
497
	if ($config['system']['enablesshd']) {
498
		log_error(gettext("secure shell configuration has changed. Restarting sshd."));
499
		send_event("service restart sshd");
500
	}
501
}
502
if ($restart_webgui) {
503
	ob_flush();
504
	flush();
505
	log_error(gettext("webConfigurator configuration has changed. Restarting webConfigurator."));
506
	send_event("service restart webgui");
507
}
508

    
509
?>
(177-177/225)