Project

General

Profile

Download (18.2 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	system_advanced_admin.php
5
	part of pfSense
6
	Copyright (C) 2005-2007 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['althostnames'] = $config['system']['webgui']['althostnames'];
60
$pconfig['enableserial'] = $config['system']['enableserial'];
61
$pconfig['enablesshd'] = $config['system']['enablesshd'];
62
$pconfig['sshport'] = $config['system']['ssh']['port'];
63
$pconfig['sshdkeyonly'] = isset($config['system']['ssh']['sshdkeyonly']);
64

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

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

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

    
74
if ($_POST) {
75

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

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

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

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

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

    
100
	ob_flush();
101
	flush();
102

    
103
	if (!$input_errors) {
104

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

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

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

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

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

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

    
143
		if ($_POST['althostnames'])
144
			$config['system']['webgui']['althostnames'] = $_POST['althostnames'];
145
		else
146
			unset($config['system']['webgui']['althostnames']);
147

    
148
		$sshd_enabled = $config['system']['enablesshd'];
149
		if($_POST['enablesshd'])
150
			$config['system']['enablesshd'] = "enabled";
151
		else
152
			unset($config['system']['enablesshd']);
153

    
154
		$sshd_keyonly = isset($config['system']['sshdkeyonly']);
155
		if ($_POST['sshdkeyonly'])
156
			$config['system']['sshdkeyonly'] = true;
157
		else
158
			unset($config['system']['sshdkeyonly']);
159

    
160
		$sshd_port = $config['system']['ssh']['port'];
161
		if ($_POST['sshport'])
162
			$config['system']['ssh']['port'] = $_POST['sshport'];
163
		else if (isset($config['system']['ssh']['port']))
164
			unset($config['system']['ssh']['port']);
165

    
166
		if (($sshd_enabled != $config['system']['enablesshd']) ||
167
			($sshd_keyonly != $config['system']['sshdkeyonly']) ||
168
			($sshd_port != $config['system']['ssh']['port']))
169
			$restart_sshd = true;
170

    
171
		if ($restart_webgui) {
172
			global $_SERVER;
173
			list($host) = explode(":", $_SERVER['HTTP_HOST']);
174
			$prot = $config['system']['webgui']['protocol'];
175
			$port = $config['system']['webgui']['port'];
176
			if ($port)
177
				$url = "{$prot}://{$host}:{$port}/system_advanced_admin.php";
178
			else
179
				$url = "{$prot}://{$host}/system_advanced_admin.php";
180
		}
181

    
182
		write_config();
183

    
184
		$retval = filter_configure();
185
	    $savemsg = get_std_save_message($retval);
186

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

    
190
		conf_mount_rw();
191
		setup_serial_port();
192
		// Restart dnsmasq in case dns rebinding toggled
193
		services_dnsmasq_configure();
194
		conf_mount_ro();
195
	}
196
}
197

    
198
$pgtitle = array(gettext("System"),gettext("Advanced: Admin Access"));
199
include("head.inc");
200

    
201
?>
202

    
203
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
204
<?php include("fbegin.inc"); ?>
205
<script language="JavaScript">
206
<!--
207

    
208
function prot_change() {
209

    
210
	if (document.iform.https_proto.checked)
211
		document.getElementById("ssl_opts").style.display="";
212
	else
213
		document.getElementById("ssl_opts").style.display="none";
214
}
215

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

    
448
<?php include("fend.inc"); ?>
449
<?php
450
	if ($restart_webgui)
451
		echo "<meta http-equiv=\"refresh\" content=\"20;url={$url}\">";
452
?>
453
</body>
454
</html>
455

    
456
<?php
457
if ($restart_sshd) {
458

    
459
	killbyname("sshd");
460
	log_error(gettext("secure shell configuration has changed. Stopping sshd."));
461

    
462
	if ($config['system']['enablesshd']) {
463
		log_error(gettext("secure shell configuration has changed. Restarting sshd."));
464
		touch("{$g['tmp_path']}/start_sshd");
465
	}
466
}
467
if ($restart_webgui) {
468
	ob_flush();
469
	flush();
470
	log_error(gettext("webConfigurator configuration has changed. Restarting webConfigurator."));
471
	touch("{$g['tmp_path']}/restart_webgui");
472
}
473

    
474
?>
(172-172/220)