Project

General

Profile

Download (18.1 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['system']['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
		conf_mount_ro();
193
	}
194
}
195

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

    
199
?>
200

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

    
206
function prot_change() {
207

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

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

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

    
454
<?php
455
if ($restart_sshd) {
456

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

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

    
472
?>
(173-173/222)