Project

General

Profile

Download (13.8 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
##|+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
$pconfig['webguiproto'] = $config['system']['webgui']['protocol'];
47
$pconfig['webguiport'] = $config['system']['webgui']['port'];
48
$pconfig['ssl-certref'] = $config['system']['webgui']['ssl-certref'];
49
$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
$pconfig['sshdkeyonly'] = isset($config['system']['ssh']['sshdkeyonly']);
55

    
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

    
65
if ($_POST) {
66

    
67
	unset($input_errors);
68
	$pconfig = $_POST;
69

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

    
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
	else if (isset($config['system']['ssh']['sshdkeyonly']))
82
		unset($config['system']['ssh']['sshdkeyonly']);
83

    
84
	ob_flush();
85
	flush();
86

    
87
	if (!$input_errors) {
88

    
89
		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

    
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
		$sshd_enabled = $config['system']['enablesshd'];
115
		if($_POST['enablesshd'])
116
			$config['system']['enablesshd'] = "enabled";
117
		else
118
			unset($config['system']['enablesshd']);
119

    
120
		$sshd_keyonly = $config['system']['sshdkeyonly'];
121
		if ($_POST['sshdkeyonly'])
122
			$config['system']['sshdkeyonly'] = true;
123
		else
124
			unset($config['system']['sshdkeyonly']);
125

    
126
		$sshd_port = $config['system']['ssh']['port'];
127
		if ($_POST['sshport'])
128
			$config['system']['ssh']['port'] = $_POST['sshport'];
129
		else if (isset($config['system']['ssh']['port']))
130
			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

    
148
		write_config();
149

    
150
		$retval = filter_configure();
151
	    $savemsg = get_std_save_message($retval);
152

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

    
156
		conf_mount_rw();
157
		setup_serial_port();
158
		conf_mount_ro();
159
	}
160
}
161

    
162
$pgtitle = array("System","Advanced: Admin Access");
163
include("head.inc");
164

    
165
?>
166

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

    
172
function prot_change() {
173

    
174
	if (document.iform.https_proto.checked)
175
		document.getElementById("ssl_opts").style.display="";
176
	else
177
		document.getElementById("ssl_opts").style.display="none";
178
}
179

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

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

    
383
<?php
384
if ($restart_sshd) {
385

    
386
	mwexec("/usr/bin/killall sshd");
387
	log_error("secure shell configuration has changed. Stopping sshd.");
388

    
389
	if ($config['system']['enablesshd']) {
390
		log_error("secure shell configuration has changed. Restarting sshd.");
391
		touch("{$g['tmp_path']}/start_sshd");
392
	}
393
}
394
if ($restart_webgui) {
395
	ob_flush();
396
	flush();
397
	log_error("webConfigurator configuration has changed. Restarting webConfigurator.");
398
	touch("{$g['tmp_path']}/restart_webgui");
399
}
400
?>
(170-170/217)