Project

General

Profile

Download (14 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

    
49
$pconfig['webguiproto'] = $config['system']['webgui']['protocol'];
50
$pconfig['webguiport'] = $config['system']['webgui']['port'];
51
$pconfig['ssl-certref'] = $config['system']['webgui']['ssl-certref'];
52
$pconfig['disableconsolemenu'] = isset($config['system']['disableconsolemenu']);
53
$pconfig['noantilockout'] = isset($config['system']['webgui']['noantilockout']);
54
$pconfig['enableserial'] = $config['system']['enableserial'];
55
$pconfig['enablesshd'] = $config['system']['enablesshd'];
56
$pconfig['sshport'] = $config['system']['ssh']['port'];
57
$pconfig['sshdkeyonly'] = isset($config['system']['ssh']['sshdkeyonly']);
58

    
59
$a_cert =& $config['system']['cert'];
60

    
61
$certs_available = false;
62
if (is_array($a_cert) && count($a_cert))
63
	$certs_available = true;
64

    
65
if (!$pconfig['webguiproto'] || !$certs_available)
66
	$pconfig['webguiproto'] = "http";
67

    
68
if ($_POST) {
69

    
70
	unset($input_errors);
71
	$pconfig = $_POST;
72

    
73
	/* input validation */
74
	if ($_POST['webguiport'])
75
		if(!is_port($_POST['webguiport']))
76
			$input_errors[] = "You must specify a valid webConfigurator port number";
77

    
78
	if ($_POST['sshport'])
79
		if(!is_port($_POST['sshport']))
80
			$input_errors[] = "You must specify a valid port number";
81

    
82
	if($_POST['sshdkeyonly'] == "yes")
83
		$config['system']['ssh']['sshdkeyonly'] = "enabled";
84
	else if (isset($config['system']['ssh']['sshdkeyonly']))
85
		unset($config['system']['ssh']['sshdkeyonly']);
86

    
87
	ob_flush();
88
	flush();
89

    
90
	if (!$input_errors) {
91

    
92
		if (update_if_changed("webgui protocol", $config['system']['webgui']['protocol'], $_POST['webguiproto']))
93
			$restart_webgui = true;
94
		if (update_if_changed("webgui port", $config['system']['webgui']['port'], $_POST['webguiport']))
95
			$restart_webgui = true;
96
		if (update_if_changed("webgui certificate", $config['system']['webgui']['ssl-certref'], $_POST['ssl-certref']))
97
			$restart_webgui = true;
98

    
99
		if($_POST['disableconsolemenu'] == "yes") {
100
			$config['system']['disableconsolemenu'] = true;
101
			auto_login(true);
102
		} else {
103
			unset($config['system']['disableconsolemenu']);
104
			auto_login(false);
105
		}
106

    
107
		if ($_POST['noantilockout'] == "yes")
108
			$config['system']['webgui']['noantilockout'] = true;
109
		else
110
			unset($config['system']['webgui']['noantilockout']);
111

    
112
		if ($_POST['enableserial'] == "yes")
113
			$config['system']['enableserial'] = true;
114
		else
115
			unset($config['system']['enableserial']);
116

    
117
		$sshd_enabled = $config['system']['enablesshd'];
118
		if($_POST['enablesshd'])
119
			$config['system']['enablesshd'] = "enabled";
120
		else
121
			unset($config['system']['enablesshd']);
122

    
123
		$sshd_keyonly = $config['system']['sshdkeyonly'];
124
		if ($_POST['sshdkeyonly'])
125
			$config['system']['sshdkeyonly'] = true;
126
		else
127
			unset($config['system']['sshdkeyonly']);
128

    
129
		$sshd_port = $config['system']['ssh']['port'];
130
		if ($_POST['sshport'])
131
			$config['system']['ssh']['port'] = $_POST['sshport'];
132
		else if (isset($config['system']['ssh']['port']))
133
			unset($config['system']['ssh']['port']);
134

    
135
		if (($sshd_enabled != $config['system']['enablesshd']) ||
136
			($sshd_keyonly != $config['system']['sshdkeyonly']) ||
137
			($sshd_port != $config['system']['ssh']['port']))
138
			$restart_sshd = true;
139

    
140
		if ($restart_webgui) {
141
			global $_SERVER;
142
			list($host) = explode(":", $_SERVER['HTTP_HOST']);
143
			$prot = $config['system']['webgui']['protocol'];
144
			$port = $config['system']['webgui']['port'];
145
			if ($port)
146
				$url = "{$prot}://{$host}:{$port}/system_advanced_admin.php";
147
			else
148
				$url = "{$prot}://{$host}/system.php";
149
		}
150

    
151
		write_config();
152

    
153
		$retval = filter_configure();
154
	    $savemsg = get_std_save_message($retval);
155

    
156
		if ($restart_webgui)
157
			$savemsg .= "<br />One moment...redirecting to {$url} in 20 seconds.";
158

    
159
		conf_mount_rw();
160
		setup_serial_port();
161
		conf_mount_ro();
162
	}
163
}
164

    
165
$pgtitle = array("System","Advanced: Admin Access");
166
include("head.inc");
167

    
168
?>
169

    
170
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
171
<?php include("fbegin.inc"); ?>
172
<script language="JavaScript">
173
<!--
174

    
175
function prot_change() {
176

    
177
	if (document.iform.https_proto.checked)
178
		document.getElementById("ssl_opts").style.display="";
179
	else
180
		document.getElementById("ssl_opts").style.display="none";
181
}
182

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

    
379
<?php include("fend.inc"); ?>
380
<?php
381
	if ($restart_webgui)
382
		echo "<meta http-equiv=\"refresh\" content=\"20;url={$url}\">";
383
?>
384
</body>
385
</html>
386

    
387
<?php
388
if ($restart_sshd) {
389

    
390
	mwexec("/usr/bin/killall sshd");
391
	log_error("secure shell configuration has changed. Stopping sshd.");
392

    
393
	if ($config['system']['enablesshd']) {
394
		log_error("secure shell configuration has changed. Restarting sshd.");
395
		touch("{$g['tmp_path']}/start_sshd");
396
	}
397
}
398
if ($restart_webgui) {
399
	ob_flush();
400
	flush();
401
	log_error("webConfigurator configuration has changed. Restarting webConfigurator.");
402
	touch("{$g['tmp_path']}/restart_webgui");
403
}
404

    
405
?>
(169-169/217)