Project

General

Profile

Download (11.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['cert'] = base64_decode($config['system']['webgui']['certificate']);
47
$pconfig['key'] = base64_decode($config['system']['webgui']['private-key']);
48
$pconfig['disableconsolemenu'] = isset($config['system']['disableconsolemenu']);
49
$pconfig['noantilockout'] = isset($config['system']['webgui']['noantilockout']);
50
$pconfig['enableserial'] = $config['system']['enableserial'];
51
$pconfig['enablesshd'] = $config['system']['enablesshd'];
52
$pconfig['sshport'] = $config['system']['ssh']['port'];
53
$pconfig['sshdkeyonly'] = $config['system']['ssh']['sshdkeyonly'];
54
$pconfig['authorizedkeys'] = base64_decode($config['system']['ssh']['authorizedkeys']);
55

    
56
if ($_POST) {
57

    
58
	unset($input_errors);
59
	$pconfig = $_POST;
60

    
61
	/* input validation */
62
	if (($_POST['cert'] && !$_POST['key']) || ($_POST['key'] && !$_POST['cert']))
63
		$input_errors[] = "Certificate and key must always be specified together.";
64

    
65
	if ($_POST['cert'] && $_POST['key']) {
66
		if (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE"))
67
			$input_errors[] = "This certificate does not appear to be valid.";
68
		if (!strstr($_POST['key'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['key'], "END RSA PRIVATE KEY"))
69
			$input_errors[] = "This key does not appear to be valid.";
70
	}
71

    
72
	if ($_POST['sshport'])
73
		if(!is_port($_POST['sshport']))
74
			$input_errors[] = "You must specify a valid port number";
75

    
76
	if($_POST['sshdkeyonly'] == "yes")
77
		$config['system']['ssh']['sshdkeyonly'] = "enabled";
78
	else
79
		unset($config['system']['ssh']['sshdkeyonly']);
80

    
81
	ob_flush();
82
	flush();
83

    
84
	if (!$input_errors) {
85

    
86
		$oldcert = $config['system']['webgui']['certificate'];
87
		$oldkey = $config['system']['webgui']['private-key'];
88
		$config['system']['webgui']['certificate'] = base64_encode($_POST['cert']);
89
		$config['system']['webgui']['private-key'] = base64_encode($_POST['key']);
90

    
91
		if($_POST['disableconsolemenu'] == "yes") {
92
			$config['system']['disableconsolemenu'] = true;
93
			auto_login(true);
94
		} else {
95
			unset($config['system']['disableconsolemenu']);
96
			auto_login(false);
97
		}
98

    
99
		if ($_POST['noantilockout'] == "yes")
100
			$config['system']['webgui']['noantilockout'] = true;
101
		else
102
			unset($config['system']['webgui']['noantilockout']);
103

    
104
		if ($_POST['enableserial'] == "yes")
105
			$config['system']['enableserial'] = true;
106
		else
107
			unset($config['system']['enableserial']);
108

    
109
		if($_POST['enablesshd'] == "yes") {
110
			$config['system']['enablesshd'] = "enabled";
111
//			touch("{$g['tmp_path']}/start_sshd");
112
		} else {
113
			unset($config['system']['enablesshd']);
114
//			mwexec("/usr/bin/killall sshd");
115
		}
116

    
117
		$oldsshport = $config['system']['ssh']['port'];
118

    
119
		if ($_POST['sshdkeyonly'] == "yes") {
120
			$config['system']['sshdkeyonly'] = true;
121
			touch("{$g['tmp_path']}/start_sshd");
122
		} else {
123
			unset($config['system']['sshdkeyonly']);
124
			mwexec("/usr/bin/killall sshd");
125
		}
126

    
127
		$config['system']['ssh']['port'] = $_POST['sshport'];
128
		$config['system']['ssh']['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
129

    
130
		write_config();
131

    
132
		config_lock();
133
		$retval = filter_configure();
134
		if(stristr($retval, "error") <> true)
135
		    $savemsg = get_std_save_message($retval);
136
		else
137
		    $savemsg = $retval;
138
		config_unlock();
139

    
140
		conf_mount_rw();
141
		setup_serial_port();
142
		conf_mount_ro();
143
	}
144
}
145

    
146
$pgtitle = array("System","Advanced: Admin Access");
147
include("head.inc");
148

    
149
?>
150

    
151
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
152
<?php
153
	include("fbegin.inc");
154
	if ($input_errors)
155
		print_input_errors($input_errors);
156
	if ($savemsg)
157
		print_info_box($savemsg);
158
?>
159
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
160
		<tr>
161
			<td>
162
				<span class="vexpl">
163
					<span class="red">
164
						<strong>Note:</strong>
165
					</span>
166
					the options on this page are intended for use by advanced users only.
167
					<br/>
168
				</span>
169
				<br/>
170
			</td>
171
		</tr>
172
		<tr>
173
			<td class="tabnavtbl">
174
				<ul id="tabnav">
175
				<?php
176
					$tab_array = array();
177
					$tab_array[] = array("Admin Access", true, "system_advanced_admin.php");
178
					$tab_array[] = array("Firewall / NAT", false, "system_advanced_firewall.php");
179
					$tab_array[] = array("Networking", false, "system_advanced_network.php");
180
					$tab_array[] = array("Miscellaneous", false, "system_advanced_misc.php");
181
					$tab_array[] = array("System Tunables", false, "system_advanced_sysctl.php");
182
					display_top_tabs($tab_array);
183
				?>
184
				</ul>
185
			</td>
186
		</tr>
187
		<tr>
188
			<td class="tabcont">
189
				<form action="system_advanced_admin.php" method="post" name="iform" id="iform">
190
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
191
						<tr>
192
							<td colspan="2" valign="top" class="listtopic">webConfigurator</td>
193
						</tr>
194
						<tr>
195
							<td width="22%" valign="top" class="vncell">Certificate</td>
196
							<td width="78%" class="vtable">
197
								<textarea name="cert" cols="65" rows="7" id="cert" class="formpre"><?=htmlspecialchars($pconfig['cert']);?></textarea>
198
								<br/>
199
								Paste a signed certificate in X.509 PEM format here. <a href="javascript:if(openwindow('system_advanced_create_certs.php') == false) alert('Popup blocker detected.  Action aborted.');" >Create</a> certificates automatically.
200
							</td>
201
						</tr>
202
						<tr>
203
							<td width="22%" valign="top" class="vncell">Key</td>
204
							<td width="78%" class="vtable">
205
								<textarea name="key" cols="65" rows="7" id="key" class="formpre"><?=htmlspecialchars($pconfig['key']);?></textarea>
206
								<br/>
207
								Paste an RSA private key in PEM format here.
208
							</td>
209
						</tr>
210
						<tr>
211
							<td width="22%" valign="top" class="vncell">Anti-lockout</td>
212
							<td width="78%" class="vtable">
213
								<?php
214
									if($config['interfaces']['lan']) 
215
										$lockout_interface = "LAN";
216
									else 
217
										$lockout_interface = "WAN";
218
								?>
219
								<input name="noantilockout" type="checkbox" id="noantilockout" value="yes" <?php if ($pconfig['noantilockout']) echo "checked"; ?> />
220
								<strong>Disable webConfigurator anti-lockout rule</strong>
221
								<br/>
222
								By default, access to the webConfigurator on the <?=$lockout_interface;?>
223
								interface is always permitted, regardless of the user-defined filter
224
								rule set. Enable this feature to control webConfigurator access (make
225
								sure to have a filter rule in place that allows you in, or you will
226
								lock yourself out!). <em> Hint: the &quot;set configure IP address&quot;
227
								option in the console menu resets this setting as well. </em>
228
							</td>
229
						</tr>
230
						<tr>
231
							<td colspan="2" class="list" height="12">&nbsp;</td>
232
						</tr>
233
						<tr>
234
							<td colspan="2" valign="top" class="listtopic">Secure Shell</td>
235
						</tr>
236
						<tr>
237
							<td width="22%" valign="top" class="vncell">Secure Shell Server</td>
238
							<td width="78%" class="vtable">
239
								<input name="enablesshd" type="checkbox" id="enablesshd" value="yes" <?php if (isset($pconfig['enablesshd'])) echo "checked"; ?> />
240
								<strong>Enable Secure Shell</strong>
241
							</td>
242
						</tr>
243
						<tr>
244
							<td width="22%" valign="top" class="vncell">Authentication Method</td>
245
							<td width="78%" class="vtable">
246
								<input name="sshdkeyonly" type="checkbox" id="sshdkeyonly" value="yes" <?php if (isset($pconfig['sshdkeyonly'])) echo "checked"; ?> />
247
								<strong>Disable Password login for Secure Shell (rsa key only)</strong>
248
								<br/>
249
								When this option is enabled, you will need to configure
250
								allowed keys for each user that has secure shell
251
								access.
252
							</td>
253
						</tr>
254
						<tr>
255
							<td width="22%" valign="top" class="vncell">SSH port</td>
256
							<td width="78%" class="vtable">
257
								<input name="sshport" type="text" id="sshport" value="<?php echo $pconfig['sshport']; ?>" />
258
								<br/>
259
								<span class="vexpl">Note:  Leave this blank for the default of 22</span>
260
							</td>
261
						</tr>
262
						<tr>
263
							<td width="22%" valign="top" class="vncell"><?=gettext("Authorizedkeys");?></td>
264
							<td width="78%" class="vtable">
265
								<textarea name="authorizedkeys" cols="65" rows="7" id="authorizedkeys" class="formfld_cert"><?=htmlspecialchars($pconfig['authorizedkeys']);?></textarea>
266
								<br/>
267
								Paste an authorized keys file here.
268
							</td>
269
						</tr>
270
						<tr>
271
							<td colspan="2" class="list" height="12">&nbsp;</td>
272
						</tr>
273
						<?php if($g['platform'] == "pfSense" || $g['platform'] == "cdrom"): ?>
274
						<tr>
275
							<td colspan="2" valign="top" class="listtopic">Serial Communcations</td>
276
						</tr>
277
						<tr>
278
							<td width="22%" valign="top" class="vncell">Serial Terminal</td>
279
							<td width="78%" class="vtable">
280
								<input name="enableserial" type="checkbox" id="enableserial" value="yes" <?php if (isset($pconfig['enableserial'])) echo "checked"; ?> />
281
								<strong>This will enable the first serial port with 9600/8/N/1</strong>
282
								<br>
283
								<span class="vexpl">Note:  This will disable the internal video card/keyboard</span>
284
							</td>
285
						</tr>
286
						<tr>
287
							<td colspan="2" class="list" height="12">&nbsp;</td>
288
						</tr>
289
						<?php endif; ?>
290
						<tr>
291
							<td colspan="2" valign="top" class="listtopic">Shell Options</td>
292
						</tr>
293
						<tr>
294
							<td width="22%" valign="top" class="vncell">Console menu</td>
295
							<td width="78%" class="vtable">
296
								<input name="disableconsolemenu" type="checkbox" id="disableconsolemenu" value="yes" <?php if ($pconfig['disableconsolemenu']) echo "checked"; ?>  />
297
								<strong>Password protect the console menu</strong>
298
								<br/>
299
								<span class="vexpl">Changes to this option will take effect after a reboot.</span>
300
							</td>
301
						</tr>
302
						<tr>
303
							<td width="22%" valign="top">&nbsp;</td>
304
							<td width="78%"><input name="Submit" type="submit" class="formbtn" value="Save" /></td>
305
						</tr>
306
						<tr>
307
							<td colspan="2" class="list" height="12">&nbsp;</td>
308
						</tr>
309
					</table>
310
				</form>
311
			</td>
312
		</tr>
313
	</table>
314

    
315
<?php include("fend.inc"); ?>
316
</body>
317
</html>
318

    
319
<?php
320

    
321
if($_POST['cert'] || $_POST['key']) {
322
	if (($config['system']['webgui']['certificate'] != $oldcert)
323
			|| ($config['system']['webgui']['private-key'] != $oldkey)) {
324
		ob_flush();
325
		flush();
326
		log_error("webConfigurator certificates have changed.  Restarting webConfigurator.");
327
		sleep(1);
328
		touch("/tmp/restart_webgui");
329
	}
330
}
331

    
332
?>
(165-165/211)