Project

General

Profile

Download (13.9 KB) Statistics
| Branch: | Tag: | Revision:
1 df81417f Matthew Grooms
<?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
##|+PRIV
37
##|*IDENT=page-system-advanced-admin
38
##|*NAME=System: Advanced: Admin Access Page
39
##|*DESCR=Allow access to the 'System: Advanced: Admin Access' page.
40
##|*MATCH=system_advanced_admin.php*
41
##|-PRIV
42
43
44
require("guiconfig.inc");
45
46 fb1266d3 Matthew Grooms
$pconfig['webguiproto'] = $config['system']['webgui']['protocol'];
47
$pconfig['webguiport'] = $config['system']['webgui']['port'];
48
$pconfig['ssl-certref'] = $config['system']['webgui']['ssl-certref'];
49 df81417f Matthew Grooms
$pconfig['disableconsolemenu'] = isset($config['system']['disableconsolemenu']);
50
$pconfig['noantilockout'] = isset($config['system']['webgui']['noantilockout']);
51
$pconfig['enableserial'] = $config['system']['enableserial'];
52
$pconfig['enablesshd'] = $config['system']['enablesshd'];
53
$pconfig['sshport'] = $config['system']['ssh']['port'];
54 561d5162 Ermal Luçi
$pconfig['sshdkeyonly'] = isset($config['system']['ssh']['sshdkeyonly']);
55 fb1266d3 Matthew Grooms
56
$a_cert =& $config['system']['cert'];
57
58
$certs_available = false;
59
if (is_array($a_cert) && count($a_cert))
60
	$certs_available = true;
61
62
if (!$pconfig['webguiproto'] || !$certs_available)
63
	$pconfig['webguiproto'] = "http";
64 df81417f Matthew Grooms
65
if ($_POST) {
66
67
	unset($input_errors);
68
	$pconfig = $_POST;
69
70
	/* input validation */
71 fb1266d3 Matthew Grooms
	if ($_POST['webguiport'])
72
		if(!is_port($_POST['webguiport']))
73
			$input_errors[] = "You must specify a valid webConfigurator port number";
74 df81417f Matthew Grooms
75
	if ($_POST['sshport'])
76
		if(!is_port($_POST['sshport']))
77
			$input_errors[] = "You must specify a valid port number";
78
79
	if($_POST['sshdkeyonly'] == "yes")
80
		$config['system']['ssh']['sshdkeyonly'] = "enabled";
81 f51f3989 Ermal Luçi
	else if (isset($config['system']['ssh']['sshdkeyonly']))
82 df81417f Matthew Grooms
		unset($config['system']['ssh']['sshdkeyonly']);
83
84
	ob_flush();
85
	flush();
86
87
	if (!$input_errors) {
88
89 fb1266d3 Matthew Grooms
		if (update_if_changed("webgui protocol", $config['system']['webgui']['protocol'], $_POST['webguiproto']))
90
			$restart_webgui = true;
91
		if (update_if_changed("webgui port", $config['system']['webgui']['port'], $_POST['webguiport']))
92
			$restart_webgui = true;
93
		if (update_if_changed("webgui certificate", $config['system']['webgui']['ssl-certref'], $_POST['ssl-certref']))
94
			$restart_webgui = true;
95 df81417f Matthew Grooms
96
		if($_POST['disableconsolemenu'] == "yes") {
97
			$config['system']['disableconsolemenu'] = true;
98
			auto_login(true);
99
		} else {
100
			unset($config['system']['disableconsolemenu']);
101
			auto_login(false);
102
		}
103
104
		if ($_POST['noantilockout'] == "yes")
105
			$config['system']['webgui']['noantilockout'] = true;
106
		else
107
			unset($config['system']['webgui']['noantilockout']);
108
109
		if ($_POST['enableserial'] == "yes")
110
			$config['system']['enableserial'] = true;
111
		else
112
			unset($config['system']['enableserial']);
113
114 fb1266d3 Matthew Grooms
		$sshd_enabled = $config['system']['enablesshd'];
115
		if($_POST['enablesshd'])
116 df81417f Matthew Grooms
			$config['system']['enablesshd'] = "enabled";
117 fb1266d3 Matthew Grooms
		else
118 df81417f Matthew Grooms
			unset($config['system']['enablesshd']);
119
120 fb1266d3 Matthew Grooms
		$sshd_keyonly = $config['system']['sshdkeyonly'];
121
		if ($_POST['sshdkeyonly'])
122 df81417f Matthew Grooms
			$config['system']['sshdkeyonly'] = true;
123 fb1266d3 Matthew Grooms
		else
124 df81417f Matthew Grooms
			unset($config['system']['sshdkeyonly']);
125
126 fb1266d3 Matthew Grooms
		$sshd_port = $config['system']['ssh']['port'];
127
		if ($_POST['sshport'])
128
			$config['system']['ssh']['port'] = $_POST['sshport'];
129 e09a935c Ermal Luçi
		else if (isset($config['system']['ssh']['port']))
130 fb1266d3 Matthew Grooms
			unset($config['system']['ssh']['port']);
131
132
		if (($sshd_enabled != $config['system']['enablesshd']) ||
133
			($sshd_keyonly != $config['system']['sshdkeyonly']) ||
134
			($sshd_port != $config['system']['ssh']['port']))
135
			$restart_sshd = true;
136
137
		if ($restart_webgui) {
138
			global $_SERVER;
139
			list($host) = explode(":", $_SERVER['HTTP_HOST']);
140
			$prot = $config['system']['webgui']['protocol'];
141
			$port = $config['system']['webgui']['port'];
142
			if ($port)
143
				$url = "{$prot}://{$host}:{$port}/system_advanced_admin.php";
144
			else
145
				$url = "{$prot}://{$host}/system.php";
146
		}
147 df81417f Matthew Grooms
148
		write_config();
149
150
		config_lock();
151
		$retval = filter_configure();
152
		config_unlock();
153
154 fb1266d3 Matthew Grooms
	    $savemsg = get_std_save_message($retval);
155
		if ($restart_webgui)
156 e647cc2e Matthew Grooms
			$savemsg .= "<br />One moment...redirecting to {$url} in 20 seconds.";
157 fb1266d3 Matthew Grooms
158 df81417f Matthew Grooms
		conf_mount_rw();
159
		setup_serial_port();
160
		conf_mount_ro();
161
	}
162
}
163
164
$pgtitle = array("System","Advanced: Admin Access");
165
include("head.inc");
166
167
?>
168
169
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
170 fb1266d3 Matthew Grooms
<?php include("fbegin.inc"); ?>
171
<script language="JavaScript">
172
<!--
173
174
function prot_change() {
175
176
	if (document.iform.https_proto.checked)
177
		document.getElementById("ssl_opts").style.display="";
178
	else
179
		document.getElementById("ssl_opts").style.display="none";
180
}
181
182
//-->
183
</script>
184 df81417f Matthew Grooms
<?php
185
	if ($input_errors)
186
		print_input_errors($input_errors);
187
	if ($savemsg)
188
		print_info_box($savemsg);
189
?>
190 ab3c8553 Matthew Grooms
	<form action="system_advanced_admin.php" method="post" name="iform" id="iform">
191
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
192
			<tr>
193
				<td>
194
					<?php
195
						$tab_array = array();
196
						$tab_array[] = array("Admin Access", true, "system_advanced_admin.php");
197
						$tab_array[] = array("Firewall / NAT", false, "system_advanced_firewall.php");
198
						$tab_array[] = array("Networking", false, "system_advanced_network.php");
199
						$tab_array[] = array("Miscellaneous", false, "system_advanced_misc.php");
200
						$tab_array[] = array("System Tunables", false, "system_advanced_sysctl.php");
201
						display_top_tabs($tab_array);
202
					?>
203
				</td>
204
			</tr>
205
			<tr>
206 2ff19bfd Matthew Grooms
				<td id="mainarea">
207
					<div class="tabcont">
208
						<span class="vexpl">
209
							<span class="red">
210
								<strong>NOTE:&nbsp</strong>
211
							</span>
212
							The options on this page are intended for use by advanced users only.
213
							<br/>
214
						</span>
215
						<br/>
216
						<table width="100%" border="0" cellpadding="6" cellspacing="0">
217 ab3c8553 Matthew Grooms
							<tr>
218
								<td colspan="2" valign="top" class="listtopic">webConfigurator</td>
219
							</tr>
220
							<tr>
221
								<td width="22%" valign="top" class="vncell">Protocol</td>
222
								<td width="78%" class="vtable">
223 fb1266d3 Matthew Grooms
									<?php
224 ab3c8553 Matthew Grooms
										if ($pconfig['webguiproto'] == "http")
225
											$http_chk = "checked";
226
										if ($pconfig['webguiproto'] == "https")
227
											$https_chk = "checked";
228
										if (!$certs_available)
229
											$https_disabled = "disabled";
230 fb1266d3 Matthew Grooms
									?>
231 ab3c8553 Matthew Grooms
									<input name="webguiproto" id="http_proto" type="radio" value="http" <?=$http_chk;?> onClick="prot_change()">
232
									HTTP
233
									&nbsp;&nbsp;&nbsp;
234
									<input name="webguiproto" id="https_proto" type="radio" value="https" <?=$https_chk;?> <?=$https_disabled;?> onClick="prot_change()">
235
									HTTPS
236
									<?php if (!$certs_available): ?>
237
									<br/>
238
									No Certificates have been defined. You must
239
									<a href="system_certmanager.php">Create or Import</a>
240
									a Certificate before SSL can be enabled.
241
									<?php endif; ?>
242
								</td>
243
							</tr>
244
							<tr id="ssl_opts">
245
								<td width="22%" valign="top" class="vncell">SSL Certificate</td>
246
								<td width="78%" class="vtable">
247
									<select name="ssl-certref" id="ssl-certref" class="formselect">
248
										<?php
249
											foreach($a_cert as $cert):
250
												$selected = "";
251
												if ($pconfig['ssl-certref'] == $cert['refid'])
252
													$selected = "selected";
253
										?>
254
										<option value="<?=$cert['refid'];?>"<?=$selected;?>><?=$cert['name'];?></option>
255
										<?php endforeach; ?>
256
									</select>
257
								</td>
258
							</tr>
259
							<tr>
260
								<td valign="top" class="vncell">TCP port</td>
261
								<td class="vtable">
262
									<input name="webguiport" type="text" class="formfld unknown" id="webguiport" "size="5" value="<?=htmlspecialchars($config['system']['webgui']['port']);?>">
263
									<br>
264
									<span class="vexpl">
265
										Enter a custom port number for the webConfigurator
266
										above if you want to override the default (80 for HTTP, 443
267
										for HTTPS). Changes will take effect immediately after save.
268
									</span>
269
								</td>
270
							</tr>
271
							<tr>
272
								<td width="22%" valign="top" class="vncell">Anti-lockout</td>
273
								<td width="78%" class="vtable">
274
									<?php
275
										if($config['interfaces']['lan']) 
276
											$lockout_interface = "LAN";
277
										else 
278
											$lockout_interface = "WAN";
279
									?>
280
									<input name="noantilockout" type="checkbox" id="noantilockout" value="yes" <?php if ($pconfig['noantilockout']) echo "checked"; ?> />
281
									<strong>Disable webConfigurator anti-lockout rule</strong>
282
									<br/>
283
									By default, access to the webConfigurator on the <?=$lockout_interface;?>
284
									interface is always permitted, regardless of the user-defined filter
285
									rule set. Enable this feature to control webConfigurator access (make
286
									sure to have a filter rule in place that allows you in, or you will
287
									lock yourself out!). <em> Hint: the &quot;set configure IP address&quot;
288
									option in the console menu resets this setting as well. </em>
289
								</td>
290
							</tr>
291
							<tr>
292
								<td colspan="2" class="list" height="12">&nbsp;</td>
293
							</tr>
294
							<tr>
295
								<td colspan="2" valign="top" class="listtopic">Secure Shell</td>
296
							</tr>
297
							<tr>
298
								<td width="22%" valign="top" class="vncell">Secure Shell Server</td>
299
								<td width="78%" class="vtable">
300
									<input name="enablesshd" type="checkbox" id="enablesshd" value="yes" <?php if (isset($pconfig['enablesshd'])) echo "checked"; ?> />
301
									<strong>Enable Secure Shell</strong>
302
								</td>
303
							</tr>
304
							<tr>
305
								<td width="22%" valign="top" class="vncell">Authentication Method</td>
306
								<td width="78%" class="vtable">
307 4d18eb07 Ermal Luçi
									<input name="sshdkeyonly" type="checkbox" id="sshdkeyonly" value="yes" <?php if ($pconfig['sshdkeyonly']) echo "checked"; ?> />
308 ab3c8553 Matthew Grooms
									<strong>Disable Password login for Secure Shell (rsa key only)</strong>
309
									<br/>
310
									When enabled, authorized keys need to be configured for each
311
									<a href="system_usermanager.php">user</a>
312
									that has been granted secure shell access.
313
								</td>
314
							</tr>
315
							<tr>
316
								<td width="22%" valign="top" class="vncell">SSH port</td>
317
								<td width="78%" class="vtable">
318
									<input name="sshport" type="text" id="sshport" value="<?php echo $pconfig['sshport']; ?>" />
319
									<br/>
320
									<span class="vexpl">Note:  Leave this blank for the default of 22</span>
321
								</td>
322
							</tr>
323
							<tr>
324
								<td colspan="2" class="list" height="12">&nbsp;</td>
325
							</tr>
326
							<?php if($g['platform'] == "pfSense" || $g['platform'] == "cdrom"): ?>
327
							<tr>
328
								<td colspan="2" valign="top" class="listtopic">Serial Communcations</td>
329
							</tr>
330
							<tr>
331
								<td width="22%" valign="top" class="vncell">Serial Terminal</td>
332
								<td width="78%" class="vtable">
333
									<input name="enableserial" type="checkbox" id="enableserial" value="yes" <?php if (isset($pconfig['enableserial'])) echo "checked"; ?> />
334
									<strong>This will enable the first serial port with 9600/8/N/1</strong>
335
									<br>
336
									<span class="vexpl">Note:  This will disable the internal video card/keyboard</span>
337
								</td>
338
							</tr>
339
							<tr>
340
								<td colspan="2" class="list" height="12">&nbsp;</td>
341
							</tr>
342
							<?php endif; ?>
343
							<tr>
344 38332c11 Scott Ullrich
								<td colspan="2" valign="top" class="listtopic">Console Options</td>
345 ab3c8553 Matthew Grooms
							</tr>
346
							<tr>
347
								<td width="22%" valign="top" class="vncell">Console menu</td>
348
								<td width="78%" class="vtable">
349
									<input name="disableconsolemenu" type="checkbox" id="disableconsolemenu" value="yes" <?php if ($pconfig['disableconsolemenu']) echo "checked"; ?>  />
350
									<strong>Password protect the console menu</strong>
351
									<br/>
352
									<span class="vexpl">Changes to this option will take effect after a reboot.</span>
353
								</td>
354
							</tr>
355
							<tr>
356 306f082a Scott Ullrich
								<td colspan="2" class="list" height="12">&nbsp;</td>
357
							</tr>							
358
							<tr>
359 ab3c8553 Matthew Grooms
								<td width="22%" valign="top">&nbsp;</td>
360
								<td width="78%"><input name="Submit" type="submit" class="formbtn" value="Save" /></td>
361
							</tr>
362
							<tr>
363
								<td colspan="2" class="list" height="12">&nbsp;</td>
364
							</tr>
365
						</table>
366
					</div>
367
				</td>
368
			</tr>
369
		</table>
370
	</form>
371 fb1266d3 Matthew Grooms
	<script language="JavaScript" type="text/javascript">
372
	<!--
373
		prot_change();
374
	//-->
375
	</script>
376 df81417f Matthew Grooms
377
<?php include("fend.inc"); ?>
378 fb1266d3 Matthew Grooms
<?php
379
	if ($restart_webgui)
380 e647cc2e Matthew Grooms
		echo "<meta http-equiv=\"refresh\" content=\"20;url={$url}\">";
381 fb1266d3 Matthew Grooms
?>
382 df81417f Matthew Grooms
</body>
383
</html>
384
385
<?php
386 fb1266d3 Matthew Grooms
if ($restart_sshd) {
387 df81417f Matthew Grooms
388 fb1266d3 Matthew Grooms
	mwexec("/usr/bin/killall sshd");
389
	log_error("secure shell configuration has changed. Stopping sshd.");
390
391
	if ($config['system']['enablesshd']) {
392
		log_error("secure shell configuration has changed. Restarting sshd.");
393
		touch("{$g['tmp_path']}/start_sshd");
394 df81417f Matthew Grooms
	}
395
}
396 fb1266d3 Matthew Grooms
if ($restart_webgui) {
397
	ob_flush();
398
	flush();
399
	log_error("webConfigurator configuration has changed. Restarting webConfigurator.");
400
	touch("{$g['tmp_path']}/restart_webgui");
401
}
402 df81417f Matthew Grooms
?>