Project

General

Profile

Download (15.9 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
	system_advanced.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31

    
32
require("guiconfig.inc");
33

    
34
$pconfig['disablefilter'] = $config['system']['disablefilter'];
35
$pconfig['filteringbridge_enable'] = isset($config['bridge']['filteringbridge']);
36
$pconfig['ipv6nat_enable'] = isset($config['diag']['ipv6nat']['enable']);
37
$pconfig['ipv6nat_ipaddr'] = $config['diag']['ipv6nat']['ipaddr'];
38
$pconfig['cert'] = base64_decode($config['system']['webgui']['certificate']);
39
$pconfig['key'] = base64_decode($config['system']['webgui']['private-key']);
40
$pconfig['disableconsolemenu'] = isset($config['system']['disableconsolemenu']);
41
$pconfig['disablefirmwarecheck'] = isset($config['system']['disablefirmwarecheck']);
42
$pconfig['expanddiags'] = isset($config['system']['webgui']['expanddiags']);
43
if ($g['platform'] == "generic-pc")
44
	$pconfig['harddiskstandby'] = $config['system']['harddiskstandby'];
45
$pconfig['noantilockout'] = isset($config['system']['webgui']['noantilockout']);
46
$pconfig['tcpidletimeout'] = $config['filter']['tcpidletimeout'];
47

    
48
if ($_POST) {
49

    
50
	unset($input_errors);
51
	$pconfig = $_POST;
52

    
53
	/* input validation */
54
	if ($_POST['ipv6nat_enable'] && !is_ipaddr($_POST['ipv6nat_ipaddr'])) {
55
		$input_errors[] = "You must specify an IP address to NAT IPv6 packets.";
56
	}
57
	if ($_POST['tcpidletimeout'] && !is_numericint($_POST['tcpidletimeout'])) {
58
		$input_errors[] = "The TCP idle timeout must be an integer.";
59
	}
60
	if (($_POST['cert'] && !$_POST['key']) || ($_POST['key'] && !$_POST['cert'])) {
61
		$input_errors[] = "Certificate and key must always be specified together.";
62
	} else if ($_POST['cert'] && $_POST['key']) {
63
		if (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE"))
64
			$input_errors[] = "This certificate does not appear to be valid.";
65
		if (!strstr($_POST['key'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['key'], "END RSA PRIVATE KEY"))
66
			$input_errors[] = "This key does not appear to be valid.";
67
	}
68

    
69
	if (!$input_errors) {
70
		echo $_POST['disablefilter'];
71
		if($_POST['disablefilter'] == "yes") {
72
			$config['system']['disablefilter'] = "enabled";
73
		} else {
74
			unset($config['system']['disablefilter']);
75
		}
76
		$config['bridge']['filteringbridge'] = $_POST['filteringbridge_enable'] ? true : false;
77
		$config['diag']['ipv6nat']['enable'] = $_POST['ipv6nat_enable'] ? true : false;
78
		$config['diag']['ipv6nat']['ipaddr'] = $_POST['ipv6nat_ipaddr'];
79
		$oldcert = $config['system']['webgui']['certificate'];
80
		$oldkey = $config['system']['webgui']['private-key'];
81
		$config['system']['webgui']['certificate'] = base64_encode($_POST['cert']);
82
		$config['system']['webgui']['private-key'] = base64_encode($_POST['key']);
83
		$config['system']['disableconsolemenu'] = $_POST['disableconsolemenu'] ? true : false;
84
		$config['system']['disablefirmwarecheck'] = $_POST['disablefirmwarecheck'] ? true : false;
85
		$config['system']['webgui']['expanddiags'] = $_POST['expanddiags'] ? true : false;
86
		if ($g['platform'] == "generic-pc") {
87
			$oldharddiskstandby = $config['system']['harddiskstandby'];
88
			$config['system']['harddiskstandby'] = $_POST['harddiskstandby'];
89
		}
90
		$config['system']['webgui']['noantilockout'] = $_POST['noantilockout'] ? true : false;
91
		$config['filter']['tcpidletimeout'] = $_POST['tcpidletimeout'];
92

    
93
		write_config();
94

    
95
		if (($config['system']['webgui']['certificate'] != $oldcert)
96
				|| ($config['system']['webgui']['private-key'] != $oldkey)) {
97
			touch($d_sysrebootreqd_path);
98
		} else if (($g['platform'] == "generic-pc") && ($config['system']['harddiskstandby'] != $oldharddiskstandby)) {
99
			if (!$config['system']['harddiskstandby']) {
100
				// Reboot needed to deactivate standby due to a stupid ATA-protocol
101
				touch($d_sysrebootreqd_path);
102
				unset($config['system']['harddiskstandby']);
103
			} else {
104
				// No need to set the standby-time if a reboot is needed anyway
105
				system_set_harddisk_standby();
106
			}
107
		}
108

    
109
		$retval = 0;
110
		if (!file_exists($d_sysrebootreqd_path)) {
111
			config_lock();
112
			$retval = filter_configure();
113
			$retval |= interfaces_optional_configure();
114
			config_unlock();
115
		}
116
		$savemsg = get_std_save_message($retval);
117
	}
118
}
119
?>
120
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
121
<html>
122
<head>
123
<title><?=gentitle("System: Advanced functions");?></title>
124
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
125
<link href="gui.css" rel="stylesheet" type="text/css">
126
<script language="JavaScript">
127
<!--
128
function enable_change(enable_over) {
129
	if (document.iform.ipv6nat_enable.checked || enable_over) {
130
		document.iform.ipv6nat_ipaddr.disabled = 0;
131
	} else {
132
		document.iform.ipv6nat_ipaddr.disabled = 1;
133
	}
134
}
135
// -->
136
</script>
137
</head>
138

    
139
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
140
<form action="system_advanced.php" method="post" name="iform" id="iform">
141
<?php include("fbegin.inc"); ?>
142
      <p class="pgtitle">System: Advanced functions</p>
143
            <?php if ($input_errors) print_input_errors($input_errors); ?>
144
            <?php if ($savemsg) print_info_box($savemsg); ?>
145
            <p><span class="vexpl"><span class="red"><strong>Note: </strong></span>the
146
              options on this page are intended for use by advanced users only,
147
              and there's <strong>NO</strong> support for them.</span></p><br>
148

    
149
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
150

    
151
                <tr>
152
                  <td colspan="2" valign="top" class="listtopic">Disable Firewalling</td>
153
                </tr>
154
                <tr>
155
                  <td width="22%" valign="top" class="vncell">&nbsp;</td>
156
                  <td width="78%" class="vtable">
157
                    <input name="disablefilter" type="checkbox" id="disablefilter" value="yes" <?php if (isset($config['system']['disablefilter'])) echo "checked"; ?> onclick="enable_change(false)">
158
                    <strong>Disable the firewalls filter altogether.</strong><br>
159
                    <span class="vexpl">NOTE!  This basically converts pfSense into a routing only platform!</span></td>
160
                </tr>
161
                <tr>
162
                  <td width="22%" valign="top">&nbsp;</td>
163
                  <td width="78%">
164
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
165
                  </td>
166
                <tr>
167
                  <td colspan="2" class="list" height="12"></td>
168
                </tr>
169

    
170
                <tr>
171
                  <td colspan="2" valign="top" class="listtopic">IPv6 tunneling</td>
172
                </tr>
173
                <tr>
174
                  <td width="22%" valign="top" class="vncell">&nbsp;</td>
175
                  <td width="78%" class="vtable">
176
                    <input name="ipv6nat_enable" type="checkbox" id="ipv6nat_enable" value="yes" <?php if ($pconfig['ipv6nat_enable']) echo "checked"; ?> onclick="enable_change(false)">
177
                    <strong>NAT encapsulated IPv6 packets (IP protocol 41/RFC2893)
178
                    to:</strong><br> <br> <input name="ipv6nat_ipaddr" type="text" class="formfld" id="ipv6nat_ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipv6nat_ipaddr']);?>">
179
                    &nbsp;(IP address)<span class="vexpl"><br>
180
                    Don't forget to add a firewall rule to permit IPv6 packets!</span></td>
181
                </tr>
182
                <tr>
183
                  <td width="22%" valign="top">&nbsp;</td>
184
                  <td width="78%">
185
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
186
                  </td>
187
                </tr>
188
                <tr>
189
                  <td colspan="2" class="list" height="12"></td>
190
                </tr>
191
		<tr>
192
                  <td colspan="2" valign="top" class="listtopic">Filtering bridge</td>
193
                </tr>
194
                <tr>
195
                  <td width="22%" valign="top" class="vncell">&nbsp;</td>
196
                  <td width="78%" class="vtable">
197
                    <input name="filteringbridge_enable" type="checkbox" id="filteringbridge_enable" value="yes" <?php if ($pconfig['filteringbridge_enable']) echo "checked"; ?>>
198
                    <strong>Enable filtering bridge</strong><span class="vexpl"><br>
199
                    This will cause bridged packets to pass through the packet
200
                    filter in the same way as routed packets do (by default bridged
201
                    packets are always passed). If you enable this option, you'll
202
                    have to add filter rules to selectively permit traffic from
203
                    bridged interfaces.</span></td>
204
                </tr>
205
                <tr>
206
                  <td width="22%" valign="top">&nbsp;</td>
207
                  <td width="78%">
208
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
209
                  </td>
210
                </tr>
211
                <tr>
212
                  <td colspan="2" class="list" height="12"></td>
213
                </tr>
214
                <tr>
215
                  <td colspan="2" valign="top" class="listtopic">webGUI SSL certificate/key</td>
216
                </tr>
217
                <tr>
218
                  <td width="22%" valign="top" class="vncell">Certificate</td>
219
                  <td width="78%" class="vtable">
220
                    <textarea name="cert" cols="65" rows="7" id="cert" class="formpre"><?=htmlspecialchars($pconfig['cert']);?></textarea>
221
                    <br>
222
                    Paste a signed certificate in X.509 PEM format here. <A target="_new" HREF='system_advanced_create_certs.php'>Create</a> certificates automatically.</td>
223
                </tr>
224
                <tr>
225
                  <td width="22%" valign="top" class="vncell">Key</td>
226
                  <td width="78%" class="vtable">
227
                    <textarea name="key" cols="65" rows="7" id="key" class="formpre"><?=htmlspecialchars($pconfig['key']);?></textarea>
228
                    <br>
229
                    Paste an RSA private key in PEM format here.</td>
230
                </tr>
231
                <tr>
232
                  <td width="22%" valign="top">&nbsp;</td>
233
                  <td width="78%">
234
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
235
                  </td>
236
                </tr>
237
                <tr>
238
                  <td colspan="2" class="list" height="12"></td>
239
                </tr>
240
                <tr>
241
                  <td colspan="2" valign="top" class="listtopic">Miscellaneous</td>
242
                </tr>
243
				<tr>
244
                  <td width="22%" valign="top" class="vncell">Console menu </td>
245
                  <td width="78%" class="vtable">
246
                    <input name="disableconsolemenu" type="checkbox" id="disableconsolemenu" value="yes" <?php if ($pconfig['disableconsolemenu']) echo "checked"; ?>>
247
                    <strong>Disable console menu</strong><span class="vexpl"><br>
248
                    Changes to this option will take effect after a reboot.</span></td>
249
                </tr>
250
				<tr>
251
                  <td valign="top" class="vncell">Firmware version check </td>
252
                  <td class="vtable">
253
                    <input name="disablefirmwarecheck" type="checkbox" id="disablefirmwarecheck" value="yes" <?php if ($pconfig['disablefirmwarecheck']) echo "checked"; ?>>
254
                    <strong>Disable firmware version check</strong><span class="vexpl"><br>
255
    This will cause m0n0wall not to check for newer firmware versions when the <a href="system_firmware.php">System: Firmware</a> page is viewed.</span></td>
256
			    </tr>
257
				<tr>
258
                  <td valign="top" class="vncell">TCP idle timeout </td>
259
                  <td class="vtable">                    <span class="vexpl">
260
                    <input name="tcpidletimeout" type="text" class="formfld" id="tcpidletimeout" size="8" value="<?=htmlspecialchars($pconfig['tcpidletimeout']);?>">
261
                    seconds<br>
262
    Idle TCP connections will be removed from the state table after no packets have been received for the specified number of seconds. Don't set this too high or your state table could become full of connections that have been improperly shut down. The default is 2.5 hours.</span></td>
263
			    </tr>
264
				<tr>
265
                  <td width="22%" valign="top" class="vncell">Hard disk standby time </td>
266
                  <td width="78%" class="vtable">
267
                    <select name="harddiskstandby" class="formfld">
268
					<?php
269
                        /* Values from ATA-2
270
                           http://www.t13.org/project/d0948r3-ATA-2.pdf
271
                           Page 66 */
272
						$sbvals = explode(" ", "0.5,6 1,12 2,24 3,36 4,48 5,60 7.5,90 10,120 15,180 20,240 30,241 60,242");
273
					?>
274
                      <option value="" <?php if(!$pconfig['harddiskstandby']) echo('selected');?>>Always on</option>
275
					<?php
276
					foreach ($sbvals as $sbval):
277
						list($min,$val) = explode(",", $sbval); ?>
278
                      <option value="<?=$val;?>" <?php if($pconfig['harddiskstandby'] == $val) echo('selected');?>><?=$min;?> minutes</option>
279
					<?php endforeach; ?>
280
                    </select>
281
                    <br>
282
                    Puts the hard disk into standby mode when the selected amount of time after the last
283
                    access has elapsed. <em>Do not set this for CF cards.</em></td>
284
				</tr>
285
				<tr>
286
                  <td width="22%" valign="top" class="vncell">Navigation</td>
287
                  <td width="78%" class="vtable">
288
                    <input name="expanddiags" type="checkbox" id="expanddiags" value="yes" <?php if ($pconfig['expanddiags']) echo "checked"; ?>>
289
                    <strong>Keep diagnostics in navigation expanded </strong></td>
290
                </tr>
291
				<tr>
292
                  <td width="22%" valign="top" class="vncell">webGUI anti-lockout</td>
293
                  <td width="78%" class="vtable">
294
                    <input name="noantilockout" type="checkbox" id="noantilockout" value="yes" <?php if ($pconfig['noantilockout']) echo "checked"; ?>>
295
                    <strong>Disable webGUI anti-lockout rule</strong><br>
296
					By default, access to the webGUI on the LAN interface is always permitted, regardless of the user-defined filter rule set. Enable this feature to control webGUI access (make sure to have a filter rule in place that allows you in, or you will lock yourself out!).<br>
297
					Hint:
298
					the &quot;set LAN IP address&quot; option in the console menu  resets this setting as well.</td>
299
                </tr>
300
                <tr>
301
                  <td width="22%" valign="top">&nbsp;</td>
302
                  <td width="78%">
303
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
304
                  </td>
305
                </tr>
306
              </table>
307
</form>
308
            <script language="JavaScript">
309
<!--
310
enable_change(false);
311
//-->
312
</script>
313
<?php include("fend.inc"); ?>
314
</body>
315
</html>
(81-81/98)