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