1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
system_advanced_sysctl.php
|
5
|
part of pfSense
|
6
|
Copyright (C) 2005-2007 Scott Ullrich
|
7
|
Copyright (C) 2008 Shrew Soft Inc
|
8
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
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 notice,
|
21
|
this list of conditions and the following disclaimer in the documentation
|
22
|
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_MODULE: system
|
37
|
*/
|
38
|
|
39
|
##|+PRIV
|
40
|
##|*IDENT=page-system-advanced-sysctl
|
41
|
##|*NAME=System: Advanced: Tunables page
|
42
|
##|*DESCR=Allow access to the 'System: Advanced: Tunables' page.
|
43
|
##|*MATCH=system_advanced_sysctl.php*
|
44
|
##|-PRIV
|
45
|
|
46
|
require("guiconfig.inc");
|
47
|
|
48
|
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/system_advanced_sysctl.php');
|
49
|
|
50
|
if (!is_array($config['sysctl'])) {
|
51
|
$config['sysctl'] = array();
|
52
|
}
|
53
|
if (!is_array($config['sysctl']['item'])) {
|
54
|
$config['sysctl']['item'] = array();
|
55
|
}
|
56
|
|
57
|
$a_tunable = &$config['sysctl']['item'];
|
58
|
$tunables = system_get_sysctls();
|
59
|
|
60
|
if (isset($_GET['id'])) {
|
61
|
$id = htmlspecialchars_decode($_GET['id']);
|
62
|
}
|
63
|
if (isset($_POST['id'])) {
|
64
|
$id = htmlspecialchars_decode($_POST['id']);
|
65
|
}
|
66
|
$act = $_GET['act'];
|
67
|
if (isset($_POST['act'])) {
|
68
|
$act = $_POST['act'];
|
69
|
}
|
70
|
if ($act == "edit") {
|
71
|
if (isset($a_tunable[$id])) {
|
72
|
$pconfig['tunable'] = $a_tunable[$id]['tunable'];
|
73
|
$pconfig['value'] = $a_tunable[$id]['value'];
|
74
|
$pconfig['descr'] = $a_tunable[$id]['descr'];
|
75
|
} else if (isset($tunables[$id])) {
|
76
|
$pconfig['tunable'] = $tunables[$id]['tunable'];
|
77
|
$pconfig['value'] = $tunables[$id]['value'];
|
78
|
$pconfig['descr'] = $tunables[$id]['descr'];
|
79
|
}
|
80
|
}
|
81
|
if ($act == "del") {
|
82
|
if ($a_tunable[$id]) {
|
83
|
/* if this is an AJAX caller then handle via JSON */
|
84
|
if(isAjax() && is_array($input_errors)) {
|
85
|
input_errors2Ajax($input_errors);
|
86
|
exit;
|
87
|
}
|
88
|
if (!$input_errors) {
|
89
|
unset($a_tunable[$id]);
|
90
|
write_config();
|
91
|
mark_subsystem_dirty('sysctl');
|
92
|
pfSenseHeader("system_advanced_sysctl.php");
|
93
|
exit;
|
94
|
}
|
95
|
}
|
96
|
}
|
97
|
|
98
|
if ($_POST) {
|
99
|
unset($input_errors);
|
100
|
$pconfig = $_POST;
|
101
|
|
102
|
/* if this is an AJAX caller then handle via JSON */
|
103
|
if (isAjax() && is_array($input_errors)) {
|
104
|
input_errors2Ajax($input_errors);
|
105
|
exit;
|
106
|
}
|
107
|
|
108
|
if ($_POST['apply']) {
|
109
|
$retval = 0;
|
110
|
system_setup_sysctl();
|
111
|
$savemsg = get_std_save_message($retval);
|
112
|
clear_subsystem_dirty('sysctl');
|
113
|
}
|
114
|
|
115
|
if ($_POST['Submit'] == gettext("Save")) {
|
116
|
$tunableent = array();
|
117
|
|
118
|
$tunableent['tunable'] = $_POST['tunable'];
|
119
|
$tunableent['value'] = $_POST['value'];
|
120
|
$tunableent['descr'] = $_POST['descr'];
|
121
|
|
122
|
if (isset($id) && isset($a_tunable[$id])) {
|
123
|
$a_tunable[$id] = $tunableent;
|
124
|
} else {
|
125
|
$a_tunable[] = $tunableent;
|
126
|
}
|
127
|
|
128
|
mark_subsystem_dirty('sysctl');
|
129
|
write_config();
|
130
|
pfSenseHeader("system_advanced_sysctl.php");
|
131
|
exit;
|
132
|
}
|
133
|
}
|
134
|
|
135
|
$pgtitle = array(gettext("System"),gettext("Advanced: System Tunables"));
|
136
|
include("head.inc");
|
137
|
|
138
|
if ($input_errors)
|
139
|
print_input_errors($input_errors);
|
140
|
if ($savemsg)
|
141
|
print_info_box($savemsg);
|
142
|
if (is_subsystem_dirty('sysctl') && ($act != "edit" ))
|
143
|
print_info_box_np(gettext("The firewall tunables have changed. You must apply the configuration to take affect."));
|
144
|
|
145
|
$tab_array = array();
|
146
|
$tab_array[] = array(gettext("Admin Access"), false, "system_advanced_admin.php");
|
147
|
$tab_array[] = array(gettext("Firewall / NAT"), false, "system_advanced_firewall.php");
|
148
|
$tab_array[] = array(gettext("Networking"), false, "system_advanced_network.php");
|
149
|
$tab_array[] = array(gettext("Miscellaneous"), false, "system_advanced_misc.php");
|
150
|
$tab_array[] = array(gettext("System Tunables"), true, "system_advanced_sysctl.php");
|
151
|
$tab_array[] = array(gettext("Notifications"), false, "system_advanced_notifications.php");
|
152
|
display_top_tabs($tab_array);
|
153
|
|
154
|
if ($act != "edit" ): ?>
|
155
|
<div class="panel panel-default">
|
156
|
<div class="panel-heading">
|
157
|
<h2 class="panel-title"><?=gettext('System Tunables'); ?></h2>
|
158
|
</div>
|
159
|
<div class="panel-body">
|
160
|
<div class="form-group">
|
161
|
<table class="table table-responsive table-hover table-condensed">
|
162
|
<caption><strong><?=gettext('NOTE: '); ?></strong><?=gettext('The options on this page are intended for use by advanced users only.'); ?></caption>
|
163
|
<thead>
|
164
|
<tr>
|
165
|
<th class="col-sm-3"><?=gettext("Tunable Name"); ?></th>
|
166
|
<th><?=gettext("Description"); ?></th>
|
167
|
<th class="col-sm-1"><?=gettext("Value"); ?></th>
|
168
|
<th><a class="btn btn-xs btn-primary" href="system_advanced_sysctl.php?act=edit"><?=gettext('New'); ?></a></th>
|
169
|
</tr>
|
170
|
</thead>
|
171
|
<?php foreach ($tunables as $i => $tunable):
|
172
|
if (!isset($tunable['modified']))
|
173
|
$i = $tunable['tunable']; ?>
|
174
|
<tr>
|
175
|
<td><?=$tunable['tunable']; ?></td>
|
176
|
<td><?=$tunable['descr']; ?></td>
|
177
|
<td><?=$tunable['value']; ?>
|
178
|
<?php if($tunable['value'] == "default")
|
179
|
echo "(" . get_default_sysctl_value($tunable['tunable']) . ")"; ?>
|
180
|
</td>
|
181
|
<td>
|
182
|
<a class="btn btn-xs btn-primary" href="system_advanced_sysctl.php?act=edit&id=<?=$i;?>"><?=gettext('Edit'); ?></a>
|
183
|
<?php if (isset($tunable['modified'])): ?>
|
184
|
<a class="btn btn-xs btn-danger" href="system_advanced_sysctl.php?act=del&id=<?=$i;?>"><?=gettext('Delete/Reset'); ?></a>
|
185
|
<?php endif; ?>
|
186
|
</td>
|
187
|
</tr>
|
188
|
<?php
|
189
|
endforeach;
|
190
|
unset($tunables);
|
191
|
?>
|
192
|
</table>
|
193
|
</div>
|
194
|
</div>
|
195
|
</div>
|
196
|
|
197
|
<?php else:
|
198
|
require('classes/Form.class.php');
|
199
|
$form = new Form;
|
200
|
$section = new Form_Section('Edit Tunable');
|
201
|
|
202
|
$section->addInput(new Form_Input(
|
203
|
'tunable',
|
204
|
'Tunable',
|
205
|
'text',
|
206
|
$pconfig['tunable']
|
207
|
))->setWidth(4);
|
208
|
|
209
|
$section->addInput(new Form_Input(
|
210
|
'descr',
|
211
|
'Description',
|
212
|
'text',
|
213
|
$pconfig['descr']
|
214
|
))->setWidth(4);
|
215
|
|
216
|
$section->addInput(new Form_Input(
|
217
|
'value',
|
218
|
'Value',
|
219
|
'text',
|
220
|
$pconfig['value']
|
221
|
))->setWidth(4);
|
222
|
|
223
|
if (isset($id) && $a_tunable[$id]) {
|
224
|
$form->addGlobal(new Form_Input(
|
225
|
'id',
|
226
|
'id',
|
227
|
'hidden',
|
228
|
$id
|
229
|
));
|
230
|
}
|
231
|
|
232
|
$form->add($section);
|
233
|
|
234
|
$form->addGlobal(new Form_Button(
|
235
|
'cancel',
|
236
|
'Cancel',
|
237
|
$referer
|
238
|
));
|
239
|
print $form;
|
240
|
|
241
|
endif;
|
242
|
|
243
|
include("fend.inc");
|