Project

General

Profile

Download (16.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	diag_logs_settings.php
5
	Copyright (C) 2004-2009 Scott Ullrich
6
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
7
	All rights reserved.
8

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

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

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

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

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

    
35
/*
36
	pfSense_MODULE: system
37
*/
38

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

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

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

    
78
if (!$pconfig['nentries'])
79
	$pconfig['nentries'] = 50;
80

    
81
function is_valid_syslog_server($target) {
82
	return (is_ipaddr($target)
83
		|| is_ipaddrwithport($target)
84
		|| is_hostname($target)
85
		|| is_hostnamewithport($target));
86
}
87

    
88
if ($_POST['resetlogs'] == gettext("Reset Log Files")) {
89
	clear_all_log_files();
90
	$savemsg .= gettext("The log files have been reset.");
91
} elseif ($_POST) {
92
	unset($input_errors);
93
	$pconfig = $_POST;
94

    
95
	/* input validation */
96
	if ($_POST['enable'] && !is_valid_syslog_server($_POST['remoteserver'])) {
97
		$input_errors[] = gettext("A valid IP address/hostname or IP/hostname:port must be specified for remote syslog server #1.");
98
	}
99
	if ($_POST['enable'] && $_POST['remoteserver2'] && !is_valid_syslog_server($_POST['remoteserver2'])) {
100
		$input_errors[] = gettext("A valid IP address/hostname or IP/hostname:port must be specified for remote syslog server #2.");
101
	}
102
	if ($_POST['enable'] && $_POST['remoteserver3'] && !is_valid_syslog_server($_POST['remoteserver3'])) {
103
		$input_errors[] = gettext("A valid IP address/hostname or IP/hostname:port must be specified for remote syslog server #3.");
104
	}
105

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

    
110
	if (isset($_POST['logfilesize']) && (strlen($_POST['logfilesize']) > 0)) {
111
		if (!is_numeric($_POST['logfilesize']) || ($_POST['logfilesize'] < 100000)) {
112
			$input_errors[] = gettext("Log file size must be numeric and greater than or equal to 100000.");
113
		}
114
	}
115
	if (!$input_errors) {
116
		$config['syslog']['reverse'] = $_POST['reverse'] ? true : false;
117
		$config['syslog']['nentries'] = (int)$_POST['nentries'];
118
		$pconfig['nentries'] = $config['syslog']['nentries'];
119
		if (isset($_POST['logfilesize']) && (strlen($_POST['logfilesize']) > 0)) {
120
			$config['syslog']['logfilesize'] = (int)$_POST['logfilesize'];
121
			$pconfig['logfilesize'] = $config['syslog']['logfilesize'];
122
		} else {
123
			unset($config['syslog']['logfilesize']);
124
		}
125
		$config['syslog']['remoteserver'] = $_POST['remoteserver'];
126
		$config['syslog']['remoteserver2'] = $_POST['remoteserver2'];
127
		$config['syslog']['remoteserver3'] = $_POST['remoteserver3'];
128
		$config['syslog']['sourceip'] = $_POST['sourceip'];
129
		$config['syslog']['ipproto'] = $_POST['ipproto'];
130
		$config['syslog']['filter'] = $_POST['filter'] ? true : false;
131
		$config['syslog']['dhcp'] = $_POST['dhcp'] ? true : false;
132
		$config['syslog']['portalauth'] = $_POST['portalauth'] ? true : false;
133
		$config['syslog']['vpn'] = $_POST['vpn'] ? true : false;
134
		$config['syslog']['apinger'] = $_POST['apinger'] ? true : false;
135
		$config['syslog']['relayd'] = $_POST['relayd'] ? true : false;
136
		$config['syslog']['hostapd'] = $_POST['hostapd'] ? true : false;
137
		$config['syslog']['logall'] = $_POST['logall'] ? true : false;
138
		$config['syslog']['system'] = $_POST['system'] ? true : false;
139
		$config['syslog']['disablelocallogging'] = $_POST['disablelocallogging'] ? true : false;
140
		$config['syslog']['enable'] = $_POST['enable'] ? true : false;
141
		$oldnologdefaultblock = isset($config['syslog']['nologdefaultblock']);
142
		$oldnologdefaultpass = isset($config['syslog']['nologdefaultpass']);
143
		$oldnologbogons = isset($config['syslog']['nologbogons']);
144
		$oldnologprivatenets = isset($config['syslog']['nologprivatenets']);
145
		$oldnologlighttpd = isset($config['syslog']['nologlighttpd']);
146
		$config['syslog']['nologdefaultblock'] = $_POST['logdefaultblock'] ? false : true;
147
		$config['syslog']['nologdefaultpass'] = $_POST['logdefaultpass'] ? true : false;
148
		$config['syslog']['nologbogons'] = $_POST['logbogons'] ? false : true;
149
		$config['syslog']['nologprivatenets'] = $_POST['logprivatenets'] ? false : true;
150
		$config['syslog']['nologlighttpd'] = $_POST['loglighttpd'] ? false : true;
151
		$config['syslog']['rawfilter'] = $_POST['rawfilter'] ? true : false;
152
		if (is_numeric($_POST['filterdescriptions']) && $_POST['filterdescriptions'] > 0)
153
			$config['syslog']['filterdescriptions'] = $_POST['filterdescriptions'];
154
		else
155
			unset($config['syslog']['filterdescriptions']);
156
		if($config['syslog']['enable'] == false) {
157
			unset($config['syslog']['remoteserver']);
158
			unset($config['syslog']['remoteserver2']);
159
			unset($config['syslog']['remoteserver3']);
160
		}
161

    
162
		write_config();
163

    
164
		$retval = 0;
165
		$retval = system_syslogd_start();
166
		if (($oldnologdefaultblock !== isset($config['syslog']['nologdefaultblock']))
167
			|| ($oldnologdefaultpass !== isset($config['syslog']['nologdefaultpass']))
168
			|| ($oldnologbogons !== isset($config['syslog']['nologbogons']))
169
			|| ($oldnologprivatenets !== isset($config['syslog']['nologprivatenets'])))
170
			$retval |= filter_configure();
171

    
172
		$savemsg = get_std_save_message($retval);
173

    
174
		if ($oldnologlighttpd !== isset($config['syslog']['nologlighttpd'])) {
175
			ob_flush();
176
			flush();
177
			log_error(gettext("webConfigurator configuration has changed. Restarting webConfigurator."));
178
			send_event("service restart webgui");
179
			$savemsg .= "<br />" . gettext("WebGUI process is restarting.");
180
		}
181

    
182
		filter_pflog_start(true);
183
	}
184
}
185

    
186
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("Settings"));
187
include("head.inc");
188

    
189
$logfilesizeHelp =	gettext("Logs are held in constant-size circular log files. This field controls how large each log file is, and thus how many entries may exist inside the log. By default this is approximately 500KB per log file, and there are nearly 20 such log files.") .
190
					'<br /><br />' .
191
					gettext("NOTE: Log sizes are changed the next time a log file is cleared or deleted. To immediately increase the size of the log files, you must first save the options to set the size, then clear all logs using the \"Reset Log Files\" option farther down this page. ") .
192
					gettext("Be aware that increasing this value increases every log file size, so disk usage will increase significantly.") . '<br /><br />' .
193
					gettext("Disk space currently used by log files is: ") . exec("/usr/bin/du -sh /var/log | /usr/bin/awk '{print $1;}'") .
194
					gettext(" Remaining disk space for log files: ") . exec("/bin/df -h /var/log | /usr/bin/awk '{print $4;}'");
195

    
196
$remoteloghelp =	gettext("This option will allow the logging daemon to bind to a single IP address, rather than all IP addresses.") .
197
					gettext("If you pick a single IP, remote syslog severs must all be of that IP type. If you wish to mix IPv4 and IPv6 remote syslog servers, you must bind to all interfaces.") .
198
					"<br /><br />" .
199
					gettext("NOTE: If an IP address cannot be located on the chosen interface, the daemon will bind to all addresses.");
200
if ($input_errors)
201
	print_input_errors($input_errors);
202
else if ($savemsg)
203
	print_info_box($savemsg);
204

    
205
$tab_array = array();
206
$tab_array[] = array(gettext("System"), false, "diag_logs.php");
207
$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php");
208
$tab_array[] = array(gettext("DHCP"), false, "diag_logs.php?logfile=dhcpd");
209
$tab_array[] = array(gettext("Portal Auth"), false, "diag_logs.php?logfile=portalauth");
210
$tab_array[] = array(gettext("IPsec"), false, "diag_logs.php?logfile=ipsec");
211
$tab_array[] = array(gettext("PPP"), false, "diag_logs.php?logfile=ppp");
212
$tab_array[] = array(gettext("VPN"), false, "diag_logs_vpn.php");
213
$tab_array[] = array(gettext("Load Balancer"), false, "diag_logs.php?logfile=relayd");
214
$tab_array[] = array(gettext("OpenVPN"), false, "diag_logs.php?logfile=openvpn");
215
$tab_array[] = array(gettext("NTP"), false, "diag_logs.php?logfile=ntpd");
216
$tab_array[] = array(gettext("Settings"), true, "diag_logs_settings.php");
217
display_top_tabs($tab_array);
218

    
219
require('classes/Form.class.php');
220

    
221
$form = new Form(new Form_Button(
222
	'Submit',
223
	gettext("Save")
224
));
225

    
226
$section = new Form_Section('General Logging Options');
227

    
228
$section->addInput(new Form_Checkbox(
229
	'reverse',
230
	'Forward/Reverse Display',
231
	'Show log entries in reverse order (newest entries on top)',
232
	$pconfig['reverse']
233
));
234

    
235
$section->addInput(new Form_Input(
236
	'nentries',
237
	'GUI Log Entries',
238
	'text',
239
	$pconfig['nentries'],
240
	['placeholder' => '']
241
))->setHelp('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.');
242

    
243
$section->addInput(new Form_Input(
244
	'logfilesize',
245
	'Log file size (Bytes)',
246
	'text',
247
	$pconfig['logfilesize'],
248
	['placeholder' => 'Bytes']
249
))->setHelp($logfilesizeHelp);
250

    
251
$section->addInput(new Form_Checkbox(
252
	'logdefaultblock',
253
	'Log firewall default blocks',
254
	'Log packets matched from the default block rules in the ruleset',
255
	$pconfig['logdefaultblock']
256
))->setHelp('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.');
257

    
258
$section->addInput(new Form_Checkbox(
259
	'logdefaultpass',
260
	null,
261
	'Log packets matched from the default pass rules put in the ruleset',
262
	$pconfig['logdefaultpass']
263
))->setHelp('Packets that are allowed by the implicit default pass rule will be logged if you check this option. Per-rule logging options are still respected. ');
264

    
265
$section->addInput(new Form_Checkbox(
266
	'logbogons',
267
	null,
268
	'Log packets blocked by \'Block Bogon Networks\' rules',
269
	$pconfig['logbogons']
270
));
271

    
272
$section->addInput(new Form_Checkbox(
273
	'logprivatenets',
274
	null,
275
	'Log packets blocked by \'Block Private Networks\' rules',
276
	$pconfig['logprivatenets']
277
));
278

    
279
$section->addInput(new Form_Checkbox(
280
	'loglighttpd',
281
	'Web Server Log',
282
	'Log errors from the web server process',
283
	$pconfig['loglighttpd']
284
))->setHelp('If this is checked, errors from the lighttpd web server process for the GUI or Captive Portal will appear in the main system log');
285

    
286
$section->addInput(new Form_Checkbox(
287
	'rawfilter',
288
	'Raw Logs',
289
	'Show raw filter logs)',
290
	$pconfig['rawfilter']
291
))->setHelp(gettext('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'));
292

    
293
$section->addInput(new Form_Select(
294
	'filterdescriptions',
295
	'Where to show rule descriptions',
296
	!isset($pconfig['filterdescriptions']) ? '0':$pconfig['filterdescriptions'],
297
	array(
298
		'0' => 'Dont load descriptions',
299
		'1' => 'Display as column',
300
		'2' => 'Display as second row'
301
	)
302
))->setHelp('Show the applied rule description below or in the firewall log rows' . '<br />' .
303
			'Displaying rule descriptions for all lines in the log might affect performance with large rule sets');
304

    
305
$section->addInput(new Form_Checkbox(
306
	'disablelocallogging',
307
	'Local Logging',
308
	$g['platform'] == 'pfSense' ? "Disable writing log files to the local disk" : "Disable writing log files to the local RAM disk",
309
	$pconfig['disablelocallogging']
310
));
311

    
312
$section->addInput(new Form_Button(
313
	'resetlogs',
314
	'Reset Log Files'
315
))->addClass('btn-danger btn-xs')->setHelp('Clears all local log files and reinitializes them as empty logs. This also restarts the DHCP daemon. Use the Save button first if you have made any setting changes.');
316

    
317
$form->add($section);
318
$section = new Form_Section('Remote Logging Options');
319
$section->addClass('toggle-remote');
320

    
321
$section->addInput(new Form_Checkbox(
322
	'enable',
323
	'Enable Remote Logging',
324
	'Send log messages to remote syslog server',
325
	$pconfig['enable']
326
))->toggles('.toggle-remote .panel-body .form-group:not(:first-child)');
327

    
328
$section->addInput(new Form_Select(
329
	'sourceip',
330
	'Source Address',
331
	link_interface_to_bridge($pconfig['sourceip']) ? null : $pconfig['sourceip'],
332
	get_possible_traffic_source_addresses(false)
333
))->setHelp($remoteloghelp);
334

    
335
$section->addInput(new Form_Select(
336
	'ipproto',
337
	'IP Protocol',
338
	$ipproto,
339
	array('ipv4' => 'IPv4', 'ipv6' => 'IPv6')
340
))->setHelp('This option is only used when a non-default address is chosen as the source above. This option only expresses a preference; If an IP address of the selected type is not found on the chosen interface, the other type will be tried.');
341

    
342
// Group colapses/appears based on 'enable' checkbox above
343
$group = new Form_Group('Remote log servers');
344

    
345
$group->add(new Form_Input(
346
	'remoteserver',
347
	'Server 1',
348
	'text',
349
	$pconfig['remoteserver'],
350
	['placeholder' => 'IP[:port]']
351
));
352

    
353
$group->add(new Form_Input(
354
	'remoteserver2',
355
	'Server 2',
356
	'text',
357
	$pconfig['remoteserver2'],
358
	['placeholder' => 'IP[:port]']
359
));
360

    
361
$group->add(new Form_Input(
362
	'remoteserver3',
363
	'Server 3',
364
	'text',
365
	$pconfig['remoteserver3'],
366
	['placeholder' => 'IP[:port]']
367
));
368

    
369
$section->add($group);
370

    
371
$group = new Form_Group('Remote Syslog Contents');
372
$group->add(new Form_Checkbox(
373
	'system',
374
	null,
375
	'System Events',
376
	$pconfig['system']
377
));
378

    
379
$group->add(new Form_Checkbox(
380
	'filter',
381
	null,
382
	'Firewall Events',
383
	$pconfig['filter']
384
));
385

    
386
$group->add(new Form_Checkbox(
387
	'dhcp',
388
	null,
389
	'DHCP service events',
390
	$pconfig['dhcp']
391
));
392

    
393
$group->add(new Form_Checkbox(
394
	'portalauth',
395
	null,
396
	'Portal Auth events',
397
	$pconfig['portalauth']
398
));
399

    
400
$group->add(new Form_Checkbox(
401
	'vpn',
402
	null,
403
	'VPN (PPTP, IPsec, OpenVPN) events',
404
	$pconfig['vpn']
405
));
406

    
407
$group->add(new Form_Checkbox(
408
	'apinger',
409
	null,
410
	'Gateway Monitor events',
411
	$pconfig['apinger']
412
));
413

    
414
$group->add(new Form_Checkbox(
415
	'relayd',
416
	null,
417
	'Server Load Balancer events',
418
	$pconfig['relayd']
419
));
420

    
421
$group->add(new Form_Checkbox(
422
	'hostapd',
423
	null,
424
	'Wireless events',
425
	$pconfig['hostapd']
426
));
427

    
428
$group->setHelp('syslog sends UDP datagrams to port 514 on the specified remote '.
429
	'syslog server, unless another port is specified. Be sure to set syslogd on '.
430
	'the remote server to accept syslog messages from pfSense.');
431

    
432
$section->add($group);
433

    
434
$form->add($section);
435
print $form;
436

    
437
include("foot.inc");
(24-24/241)