Project

General

Profile

Download (15.9 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']['disablehttpredirect']);
56
$pconfig['disableconsolemenu'] = isset($config['system']['disableconsolemenu']);
57
$pconfig['noantilockout'] = isset($config['system']['webgui']['noantilockout']);
58
$pconfig['enableserial'] = $config['system']['enableserial'];
59
$pconfig['enablesshd'] = $config['system']['enablesshd'];
60
$pconfig['sshport'] = $config['system']['ssh']['port'];
61
$pconfig['sshdkeyonly'] = isset($config['system']['ssh']['sshdkeyonly']);
62

    
63
$a_cert =& $config['system']['cert'];
64

    
65
$certs_available = false;
66
if (is_array($a_cert) && count($a_cert))
67
	$certs_available = true;
68

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

    
72
if ($_POST) {
73

    
74
	unset($input_errors);
75
	$pconfig = $_POST;
76

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

    
82
	if ($_POST['sshport'])
83
		if(!is_port($_POST['sshport']))
84
			$input_errors[] = gettext("You must specify a valid port number");
85

    
86
	if($_POST['sshdkeyonly'] == "yes")
87
		$config['system']['ssh']['sshdkeyonly'] = "enabled";
88
	else if (isset($config['system']['ssh']['sshdkeyonly']))
89
		unset($config['system']['ssh']['sshdkeyonly']);
90

    
91
	ob_flush();
92
	flush();
93

    
94
	if (!$input_errors) {
95

    
96
		if (update_if_changed("webgui protocol", $config['system']['webgui']['protocol'], $_POST['webguiproto']))
97
			$restart_webgui = true;
98
		if (update_if_changed("webgui port", $config['system']['webgui']['port'], $_POST['webguiport']))
99
			$restart_webgui = true;
100
		if (update_if_changed("webgui certificate", $config['system']['webgui']['ssl-certref'], $_POST['ssl-certref']))
101
			$restart_webgui = true;
102

    
103
		if ($_POST['disablehttpredirect'] == "yes") {
104
			$config['system']['disablehttpredirect'] = true;
105
			$restart_webgui = true;
106
		} else {
107
			unset($config['system']['disablehttpredirect']);
108
			$restart_webgui = true;
109
		}
110

    
111
		if($_POST['disableconsolemenu'] == "yes") {
112
			$config['system']['disableconsolemenu'] = true;
113
			auto_login();
114
		} else {
115
			unset($config['system']['disableconsolemenu']);
116
			auto_login();
117
		}
118

    
119
		if ($_POST['noantilockout'] == "yes")
120
			$config['system']['webgui']['noantilockout'] = true;
121
		else
122
			unset($config['system']['webgui']['noantilockout']);
123

    
124
		if ($_POST['enableserial'] == "yes")
125
			$config['system']['enableserial'] = true;
126
		else
127
			unset($config['system']['enableserial']);
128

    
129
		$sshd_enabled = $config['system']['enablesshd'];
130
		if($_POST['enablesshd'])
131
			$config['system']['enablesshd'] = "enabled";
132
		else
133
			unset($config['system']['enablesshd']);
134

    
135
		$sshd_keyonly = $config['system']['sshdkeyonly'];
136
		if ($_POST['sshdkeyonly'])
137
			$config['system']['sshdkeyonly'] = true;
138
		else
139
			unset($config['system']['sshdkeyonly']);
140

    
141
		$sshd_port = $config['system']['ssh']['port'];
142
		if ($_POST['sshport'])
143
			$config['system']['ssh']['port'] = $_POST['sshport'];
144
		else if (isset($config['system']['ssh']['port']))
145
			unset($config['system']['ssh']['port']);
146

    
147
		if (($sshd_enabled != $config['system']['enablesshd']) ||
148
			($sshd_keyonly != $config['system']['sshdkeyonly']) ||
149
			($sshd_port != $config['system']['ssh']['port']))
150
			$restart_sshd = true;
151

    
152
		if ($restart_webgui) {
153
			global $_SERVER;
154
			list($host) = explode(":", $_SERVER['HTTP_HOST']);
155
			$prot = $config['system']['webgui']['protocol'];
156
			$port = $config['system']['webgui']['port'];
157
			if ($port)
158
				$url = "{$prot}://{$host}:{$port}/system_advanced_admin.php";
159
			else
160
				$url = "{$prot}://{$host}/system.php";
161
		}
162

    
163
		write_config();
164

    
165
		$retval = filter_configure();
166
	    $savemsg = get_std_save_message($retval);
167

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

    
171
		conf_mount_rw();
172
		setup_serial_port();
173
		conf_mount_ro();
174
	}
175
}
176

    
177
$pgtitle = array(gettext("System"),gettext("Advanced: Admin Access"));
178
include("head.inc");
179

    
180
?>
181

    
182
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
183
<?php include("fbegin.inc"); ?>
184
<script language="JavaScript">
185
<!--
186

    
187
function prot_change() {
188

    
189
	if (document.iform.https_proto.checked)
190
		document.getElementById("ssl_opts").style.display="";
191
	else
192
		document.getElementById("ssl_opts").style.display="none";
193
}
194

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

    
404
<?php include("fend.inc"); ?>
405
<?php
406
	if ($restart_webgui)
407
		echo "<meta http-equiv=\"refresh\" content=\"20;url={$url}\">";
408
?>
409
</body>
410
</html>
411

    
412
<?php
413
if ($restart_sshd) {
414

    
415
	killbyname(sshd);
416
	log_error(gettext("secure shell configuration has changed. Stopping sshd."));
417

    
418
	if ($config['system']['enablesshd']) {
419
		log_error(gettext("secure shell configuration has changed. Restarting sshd."));
420
		touch("{$g['tmp_path']}/start_sshd");
421
	}
422
}
423
if ($restart_webgui) {
424
	ob_flush();
425
	flush();
426
	log_error(gettext("webConfigurator configuration has changed. Restarting webConfigurator."));
427
	touch("{$g['tmp_path']}/restart_webgui");
428
}
429

    
430
?>
(172-172/221)