Project

General

Profile

Download (18.4 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	diag_logs_settings.php
5
	Copyright (C) 2004-2009 Scott Ullrich
6
	All rights reserved.
7

    
8
	originially part of m0n0wall (http://m0n0.ch/wall)
9
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11

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

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

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

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

    
34
/*
35
	pfSense_MODULE:	system
36
*/
37

    
38
##|+PRIV
39
##|*IDENT=page-diagnostics-logs-settings
40
##|*NAME=Diagnostics: Logs: Settings page
41
##|*DESCR=Allow access to the 'Diagnostics: Logs: Settings' page.
42
##|*MATCH=diag_logs_settings.php*
43
##|-PRIV
44

    
45
require("guiconfig.inc");
46
require_once("functions.inc");
47
require_once("filter.inc");
48
require_once("shaper.inc");
49

    
50
$pconfig['reverse'] = isset($config['syslog']['reverse']);
51
$pconfig['nentries'] = $config['syslog']['nentries'];
52
$pconfig['remoteserver'] = $config['syslog']['remoteserver'];
53
$pconfig['remoteserver2'] = $config['syslog']['remoteserver2'];
54
$pconfig['remoteserver3'] = $config['syslog']['remoteserver3'];
55
$pconfig['filter'] = isset($config['syslog']['filter']);
56
$pconfig['dhcp'] = isset($config['syslog']['dhcp']);
57
$pconfig['portalauth'] = isset($config['syslog']['portalauth']);
58
$pconfig['vpn'] = isset($config['syslog']['vpn']);
59
$pconfig['apinger'] = isset($config['syslog']['apinger']);
60
$pconfig['relayd'] = isset($config['syslog']['relayd']);
61
$pconfig['hostapd'] = isset($config['syslog']['hostapd']);
62
$pconfig['logall'] = isset($config['syslog']['logall']);
63
$pconfig['system'] = isset($config['syslog']['system']);
64
$pconfig['enable'] = isset($config['syslog']['enable']);
65
$pconfig['logdefaultblock'] = !isset($config['syslog']['nologdefaultblock']);
66
$pconfig['logbogons'] = !isset($config['syslog']['nologbogons']);
67
$pconfig['logprivatenets'] = !isset($config['syslog']['nologprivatenets']);
68
$pconfig['loglighttpd'] = !isset($config['syslog']['nologlighttpd']);
69
$pconfig['rawfilter'] = isset($config['syslog']['rawfilter']);
70
$pconfig['filterdescriptions'] = $config['syslog']['filterdescriptions'];
71
$pconfig['disablelocallogging'] = isset($config['syslog']['disablelocallogging']);
72

    
73
if (!$pconfig['nentries'])
74
	$pconfig['nentries'] = 50;
75

    
76
function is_valid_syslog_server($target) {
77
	return (is_ipaddr($target)
78
		|| is_ipaddrwithport($target)
79
		|| is_hostname($target)
80
		|| is_hostnamewithport($target));
81
}
82

    
83
if ($_POST) {
84

    
85
	unset($input_errors);
86
	$pconfig = $_POST;
87

    
88
	/* input validation */
89
	if ($_POST['enable'] && !is_valid_syslog_server($_POST['remoteserver'])) {
90
		$input_errors[] = gettext("A valid IP address/hosname or IP/hostname:port must be specified for remote syslog server #1.");
91
	}
92
	if ($_POST['enable'] && $_POST['remoteserver2'] && !is_valid_syslog_server($_POST['remoteserver2'])) {
93
		$input_errors[] = gettext("A valid IP address/hosname or IP/hostname:port must be specified for remote syslog server #2.");
94
	}
95
	if ($_POST['enable'] && $_POST['remoteserver3'] && !is_valid_syslog_server($_POST['remoteserver3'])) {
96
		$input_errors[] = gettext("A valid IP address/hosname or IP/hostname:port must be specified for remote syslog server #3.");
97
	}
98

    
99
	if (($_POST['nentries'] < 5) || ($_POST['nentries'] > 2000)) {
100
		$input_errors[] = gettext("Number of log entries to show must be between 5 and 2000.");
101
	}
102

    
103
	if (!$input_errors) {
104
		$config['syslog']['reverse'] = $_POST['reverse'] ? true : false;
105
		$config['syslog']['nentries'] = (int)$_POST['nentries'];
106
		$config['syslog']['remoteserver'] = $_POST['remoteserver'];
107
		$config['syslog']['remoteserver2'] = $_POST['remoteserver2'];
108
		$config['syslog']['remoteserver3'] = $_POST['remoteserver3'];
109
		$config['syslog']['filter'] = $_POST['filter'] ? true : false;
110
		$config['syslog']['dhcp'] = $_POST['dhcp'] ? true : false;
111
		$config['syslog']['portalauth'] = $_POST['portalauth'] ? true : false;
112
		$config['syslog']['vpn'] = $_POST['vpn'] ? true : false;
113
		$config['syslog']['apinger'] = $_POST['apinger'] ? true : false;
114
		$config['syslog']['relayd'] = $_POST['relayd'] ? true : false;
115
		$config['syslog']['hostapd'] = $_POST['hostapd'] ? true : false;
116
		$config['syslog']['logall'] = $_POST['logall'] ? true : false;
117
		$config['syslog']['system'] = $_POST['system'] ? true : false;
118
		$config['syslog']['disablelocallogging'] = $_POST['disablelocallogging'] ? true : false;
119
		$config['syslog']['enable'] = $_POST['enable'] ? true : false;
120
		$oldnologdefaultblock = isset($config['syslog']['nologdefaultblock']);
121
		$oldnologbogons = isset($config['syslog']['nologbogons']);
122
		$oldnologprivatenets = isset($config['syslog']['nologprivatenets']);
123
		$oldnologlighttpd = isset($config['syslog']['nologlighttpd']);
124
		$config['syslog']['nologdefaultblock'] = $_POST['logdefaultblock'] ? false : true;
125
		$config['syslog']['nologbogons'] = $_POST['logbogons'] ? false : true;
126
		$config['syslog']['nologprivatenets'] = $_POST['logprivatenets'] ? false : true;
127
		$config['syslog']['nologlighttpd'] = $_POST['loglighttpd'] ? false : true;
128
		$config['syslog']['rawfilter'] = $_POST['rawfilter'] ? true : false;
129
		if (is_numeric($_POST['filterdescriptions']) && $_POST['filterdescriptions'] > 0)
130
			$config['syslog']['filterdescriptions'] = $_POST['filterdescriptions'];
131
		else
132
			unset($config['syslog']['filterdescriptions']);
133
		if($config['syslog']['enable'] == false) {
134
			unset($config['syslog']['remoteserver']);
135
			unset($config['syslog']['remoteserver2']);
136
			unset($config['syslog']['remoteserver3']);
137
		}
138

    
139
		write_config();
140

    
141
		$retval = 0;
142
		$retval = system_syslogd_start();
143
		if (($oldnologdefaultblock !== isset($config['syslog']['nologdefaultblock']))
144
			|| ($oldnologbogons !== isset($config['syslog']['nologbogons']))
145
			|| ($oldnologprivatenets !== isset($config['syslog']['nologprivatenets'])))
146
			$retval |= filter_configure();
147

    
148
		$savemsg = get_std_save_message($retval);
149

    
150
		if ($oldnologlighttpd !== isset($config['syslog']['nologlighttpd'])) {
151
			ob_flush();
152
			flush();
153
			log_error(gettext("webConfigurator configuration has changed. Restarting webConfigurator."));
154
			send_event("service restart webgui");
155
			$savemsg .= "<br />" . gettext("WebGUI process is restarting.");
156
		}
157

    
158
		filter_pflog_start(true);
159
	}
160
}
161

    
162
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("Settings"));
163
include("head.inc");
164

    
165
?>
166

    
167

    
168
<script language="JavaScript">
169
<!--
170
function enable_change(enable_over) {
171
	if (document.iform.enable.checked || enable_over) {
172
		document.iform.remoteserver.disabled = 0;
173
		document.iform.remoteserver2.disabled = 0;
174
		document.iform.remoteserver3.disabled = 0;
175
		document.iform.filter.disabled = 0;
176
		document.iform.dhcp.disabled = 0;
177
		document.iform.portalauth.disabled = 0;
178
		document.iform.vpn.disabled = 0;
179
		document.iform.apinger.disabled = 0;
180
		document.iform.relayd.disabled = 0;
181
		document.iform.hostapd.disabled = 0;
182
		document.iform.system.disabled = 0;
183
		document.iform.logall.disabled = 0;
184
		check_everything();
185
	} else {
186
		document.iform.remoteserver.disabled = 1;
187
		document.iform.remoteserver2.disabled = 1;
188
		document.iform.remoteserver3.disabled = 1;
189
		document.iform.filter.disabled = 1;
190
		document.iform.dhcp.disabled = 1;
191
		document.iform.portalauth.disabled = 1;
192
		document.iform.vpn.disabled = 1;
193
		document.iform.apinger.disabled = 1;
194
		document.iform.relayd.disabled = 1;
195
		document.iform.hostapd.disabled = 1;
196
		document.iform.system.disabled = 1;
197
		document.iform.logall.disabled = 1;
198
	}
199
}
200
function check_everything() {
201
	if (document.iform.logall.checked) {
202
		document.iform.filter.disabled = 1;
203
		document.iform.filter.checked = false;
204
		document.iform.dhcp.disabled = 1;
205
		document.iform.dhcp.checked = false;
206
		document.iform.portalauth.disabled = 1;
207
		document.iform.portalauth.checked = false;
208
		document.iform.vpn.disabled = 1;
209
		document.iform.vpn.checked = false;
210
		document.iform.apinger.disabled = 1;
211
		document.iform.apinger.checked = false;
212
		document.iform.relayd.disabled = 1;
213
		document.iform.relayd.checked = false;
214
		document.iform.hostapd.disabled = 1;
215
		document.iform.hostapd.checked = false;
216
		document.iform.system.disabled = 1;
217
		document.iform.system.checked = false;
218
	} else {
219
		document.iform.filter.disabled = 0;
220
		document.iform.dhcp.disabled = 0;
221
		document.iform.portalauth.disabled = 0;
222
		document.iform.vpn.disabled = 0;
223
		document.iform.apinger.disabled = 0;
224
		document.iform.relayd.disabled = 0;
225
		document.iform.hostapd.disabled = 0;
226
		document.iform.system.disabled = 0;
227
	}
228
}
229
// -->
230
</script>
231

    
232
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
233
<?php include("fbegin.inc"); ?>
234
<form action="diag_logs_settings.php" method="post" name="iform" id="iform">
235
<?php if ($input_errors) print_input_errors($input_errors); ?>
236
<?php if ($savemsg) print_info_box($savemsg); ?>
237
<table width="100%" border="0" cellpadding="0" cellspacing="0">
238
<tr><td>
239
<?php
240
	$tab_array = array();
241
	$tab_array[] = array(gettext("System"), false, "diag_logs.php");
242
	$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php");
243
	$tab_array[] = array(gettext("DHCP"), false, "diag_logs_dhcp.php");
244
	$tab_array[] = array(gettext("Portal Auth"), false, "diag_logs_auth.php");
245
	$tab_array[] = array(gettext("IPsec"), false, "diag_logs_ipsec.php");
246
	$tab_array[] = array(gettext("PPP"), false, "diag_logs_ppp.php");
247
	$tab_array[] = array(gettext("VPN"), false, "diag_logs_vpn.php");
248
	$tab_array[] = array(gettext("Load Balancer"), false, "diag_logs_relayd.php");
249
	$tab_array[] = array(gettext("OpenVPN"), false, "diag_logs_openvpn.php");
250
	$tab_array[] = array(gettext("NTP"), false, "diag_logs_ntpd.php");
251
	$tab_array[] = array(gettext("Settings"), true, "diag_logs_settings.php");
252
	display_top_tabs($tab_array);
253
?>
254
</td></tr>
255
<tr>
256
	<td>
257
	<div id="mainarea">
258
	<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
259
		<tr>
260
			<td colspan="2" valign="top" class="listtopic"><?=gettext("General Logging Options");?></td>
261
		</tr>
262
		<tr>
263
			<td width="22%" valign="top" class="vtable">Forward/Reverse Display</td>
264
			<td width="78%" class="vtable"> <input name="reverse" type="checkbox" id="reverse" value="yes" <?php if ($pconfig['reverse']) echo "checked"; ?>>
265
			<strong><?=gettext("Show log entries in reverse order (newest entries on top)");?></strong></td>
266
		</tr>
267
		<tr>
268
			<td width="22%" valign="top" class="vtable">GUI Log Entries to Display</td>
269
			<td width="78%" class="vtable">
270
			<input name="nentries" id="nentries" type="text" class="formfld unknown" size="4" value="<?=htmlspecialchars($pconfig['nentries']);?>"><br/>
271
			<?=gettext("Hint: This is only the number of log entries displayed in the GUI. It does not affect how many entries are contained in the actual log files.") ?></td>
272
		</tr>
273
		<tr>
274
			<td valign="top" class="vtable">Log Firewall Default Blocks</td>
275
			<td class="vtable">
276
				<input name="logdefaultblock" type="checkbox" id="logdefaultblock" value="yes" <?php if ($pconfig['logdefaultblock']) echo "checked"; ?>>
277
				<strong><?=gettext("Log packets blocked by the default rule");?></strong><br/>
278
				<?=gettext("Hint: packets that are blocked by the implicit default block rule will not be logged if you uncheck this option. Per-rule logging options are still respected.");?>
279
				<br/>
280
				<input name="logbogons" type="checkbox" id="logbogons" value="yes" <?php if ($pconfig['logbogons']) echo "checked"; ?>>
281
				<strong><?=gettext("Log packets blocked by 'Block Bogon Networks' rules");?></strong><br/>
282
				<br/>
283
				<input name="logprivatenets" type="checkbox" id="logprivatenets" value="yes" <?php if ($pconfig['logprivatenets']) echo "checked"; ?>>
284
				<strong><?=gettext("Log packets blocked by 'Block Private Networks' rules");?></strong><br/>
285
			</td>
286
		</tr>
287
		<tr>
288
			<td valign="top" class="vtable">Web Server Log</td>
289
			<td class="vtable"> <input name="loglighttpd" type="checkbox" id="loglighttpd" value="yes" <?php if ($pconfig['loglighttpd']) echo "checked"; ?>>
290
			<strong><?=gettext("Log errors from the web server process.");?></strong><br>
291
			<?=gettext("Hint: If this is checked, errors from the lighttpd web server process for the GUI or Captive Portal will appear in the main system log.");?></td>
292
		</tr>
293
		<tr>
294
			<td valign="top" class="vtable">Raw Logs</td>
295
			<td class="vtable"> <input name="rawfilter" type="checkbox" id="rawfilter" value="yes" <?php if ($pconfig['rawfilter']) echo "checked"; ?>>
296
			<strong><?=gettext("Show raw filter logs");?></strong><br>
297
			<?=gettext("Hint: If this is checked, filter logs are shown as generated by the packet filter, without any formatting. This will reveal more detailed information, but it is more difficult to read.");?></td>
298
		</tr>
299
		<tr>
300
			<td valign="top" class="vtable">Filter descriptions</td>
301
			<td class="vtable">
302
				<select name="filterdescriptions" id="filterdescriptions" >
303
				  <option value="0"<?=!isset($pconfig['filterdescriptions'])?" selected":""?>>Dont load descriptions</option>
304
				  <option value="1"<?=($pconfig['filterdescriptions'])==="1"?" selected":""?>>Display as column</option>
305
				  <option value="2"<?=($pconfig['filterdescriptions'])==="2"?" selected":""?>>Display as second row</option>
306
				</select>
307
				<strong><?=gettext("Show the applied rule description below or in the firewall log rows.");?></strong>
308
				<br/>
309
				<?=gettext("Displaying rule descriptions for all lines in the log might affect performance with large rulessets.");?></td>
310
			</td>
311
		</tr>
312
		<tr>
313
			<td width="22%" valign="top" class="vtable">Local Logging</td>
314
			<td width="78%" class="vtable"> <input name="disablelocallogging" type="checkbox" id="disablelocallogging" value="yes" <?php if ($pconfig['disablelocallogging']) echo "checked"; ?> onClick="enable_change(false)">
315
			<?php if ($g['platform'] == "pfSense"): ?>
316
			<strong><?=gettext("Disable writing log files to the local disk");?></strong></td>
317
			<?php else: ?>
318
			<strong><?=gettext("Disable writing log files to the local RAM disk");?></strong></td>
319
			<?php endif; ?>
320
		</tr>
321
		<tr>
322
			<td colspan="2" valign="top">&nbsp;</td>
323
		</tr>
324
		<tr>
325
			<td colspan="2" valign="top" class="listtopic"><?=gettext("Remote Logging Options");?></td>
326
		</tr>
327
		<tr>
328
			<td width="22%" valign="top" class="vncell"><?=gettext("Enable Remote Logging");?></td>
329
			<td width="78%" class="vtable"> <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
330
				<strong><?=gettext("Send log messages to remote syslog server");?></strong></td>
331
		</tr>
332
		<tr>
333
			<td width="22%" valign="top" class="vncell"><?=gettext("Remote Syslog Servers");?></td>
334
			<td width="78%" class="vtable">
335
				<table>
336
					<tr>
337
						<td><?=gettext("Server") . " 1";?></td>
338
						<td><input name="remoteserver" id="remoteserver" type="text" class="formfld host" size="20" value="<?=htmlspecialchars($pconfig['remoteserver']);?>"></td>
339
					</tr>
340
					<tr>
341
						<td><?=gettext("Server") . " 2";?></td>
342
						<td><input name="remoteserver2" id="remoteserver2" type="text" class="formfld host" size="20" value="<?=htmlspecialchars($pconfig['remoteserver2']);?>"></td>
343
					</tr>
344
					<tr>
345
						<td><?=gettext("Server") . " 3";?></td>
346
						<td><input name="remoteserver3" id="remoteserver3" type="text" class="formfld host" size="20" value="<?=htmlspecialchars($pconfig['remoteserver3']);?>"></td>
347
					</tr>
348
					<tr>
349
						<td>&nbsp;</td>
350
						<td><?=gettext("IP addresses of remote syslog servers, or an IP:port.");?></td>
351
				</table>
352
			</td>
353
		</tr>
354
		<tr>
355
			<td width="22%" valign="top" class="vncell"><?=gettext("Remote Syslog Contents");?></td>
356
			<td width="78%" class="vtable">
357
				<input name="logall" id="logall" type="checkbox" value="yes" <?php if ($pconfig['logall']) echo "checked"; ?> onclick="check_everything();">
358
				<?=gettext("Everything");?><br/><br/>
359
				<input name="system" id="system" type="checkbox" value="yes" onclick="enable_change(false)" <?php if ($pconfig['system']) echo "checked"; ?>>
360
				<?=gettext("System events");?><br/>
361
				<input name="filter" id="filter" type="checkbox" value="yes" <?php if ($pconfig['filter']) echo "checked"; ?>>
362
				<?=gettext("Firewall events");?><br/>
363
				<input name="dhcp" id="dhcp" type="checkbox" value="yes" <?php if ($pconfig['dhcp']) echo "checked"; ?>>
364
				<?=gettext("DHCP service events");?><br/>
365
				<input name="portalauth" id="portalauth" type="checkbox" value="yes" <?php if ($pconfig['portalauth']) echo "checked"; ?>>
366
				<?=gettext("Portal Auth events");?><br/>
367
				<input name="vpn" id="vpn" type="checkbox" value="yes" <?php if ($pconfig['vpn']) echo "checked"; ?>>
368
				<?=gettext("VPN (PPTP, IPsec, OpenVPN) events");?><br/>
369
				<input name="apinger" id="apinger" type="checkbox" value="yes" <?php if ($pconfig['apinger']) echo "checked"; ?>>
370
				<?=gettext("Gateway Monitor events");?><br/>
371
				<input name="relayd" id="relayd" type="checkbox" value="yes" <?php if ($pconfig['relayd']) echo "checked"; ?>>
372
				<?=gettext("Server Load Balancer events");?><br/>
373
				<input name="hostapd" id="hostapd" type="checkbox" value="yes" <?php if ($pconfig['hostapd']) echo "checked"; ?>>
374
				<?=gettext("Wireless events");?><br/>
375
			</td>
376
		</tr>
377
		<tr>
378
			<td width="22%" valign="top">&nbsp;</td>
379
			<td width="78%"> <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="enable_change(true)">
380
			</td>
381
		</tr>
382
		<tr>
383
			<td width="22%" height="53" valign="top">&nbsp;</td>
384
			<td width="78%"><strong><span class="red"><?=gettext("Note:")?></span></strong><br>
385
			<?=gettext("syslog sends UDP datagrams to port 514 on the specified " .
386
			"remote syslog server, unless another port is specified. Be sure to set syslogd on the " .
387
			"remote server to accept syslog messages from");?> <?=$g['product_name']?>.
388
			</td>
389
		</tr>
390
	</table>
391
	</div>
392
</td></tr>
393
</table>
394
</form>
395
<script language="JavaScript">
396
<!--
397
enable_change(false);
398
//-->
399
</script>
400
<?php include("fend.inc"); ?>
401
</body>
402
</html>
(32-32/246)