summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorjim-p <jim@pingle.org>2009-05-06 15:24:22 -0400
committerjim-p <jim@pingle.org>2009-05-06 15:31:07 -0400
commitab046d5a35c1776cb936a9b1cac7f428c7856637 (patch)
treef0b630626af004e4777c947986465a30a528a649 /usr
parent183d99c6eae34e636f846f82ea4c9f5c7b96c63e (diff)
downloadpfsense-ab046d5a35c1776cb936a9b1cac7f428c7856637.zip
pfsense-ab046d5a35c1776cb936a9b1cac7f428c7856637.tar.gz
Unbreak log display on FreeBSD 8 based builds of 2.0.
pflog output in FreeBSD 8 spans two lines, so we need a function to collapse those two lines into one line we can parse. Also deal with some other resulting oddities of parsing the new format.
Diffstat (limited to 'usr')
-rw-r--r--usr/local/www/filter_log.inc33
1 files changed, 28 insertions, 5 deletions
diff --git a/usr/local/www/filter_log.inc b/usr/local/www/filter_log.inc
index aa5957b..f7b6c32 100644
--- a/usr/local/www/filter_log.inc
+++ b/usr/local/www/filter_log.inc
@@ -38,17 +38,23 @@ function conv_log_filter($logfile, $nentries, $tail = 50) {
if (!(is_numeric($tail)))
return;
+ /* FreeBSD 8 splits pf log lines into two lines, so we need to at least
+ * tail twice as many, plus some extra to account for unparseable lines */
+ $tail = $tail * 2 + 50;
+
/* Always do a reverse tail, to be sure we're grabbing the 'end' of the log. */
$logarr = "";
if(isset($config['system']['usefifolog']))
- exec("/usr/sbin/fifolog_reader {$logfile} | /usr/bin/tail -r -n 500", $logarr);
+ exec("/usr/sbin/fifolog_reader {$logfile} | /usr/bin/tail -r -n {$tail}", $logarr);
else
- exec("/usr/sbin/clog {$logfile} | grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail -r -n 500", $logarr);
+ exec("/usr/sbin/clog {$logfile} | grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail -r -n {$tail}", $logarr);
$filterlog = array();
$counter = 0;
+ $logarr = array_reverse(collapse_filter_lines(array_reverse($logarr)));
+
foreach ($logarr as $logent) {
if($counter >= $nentries)
break;
@@ -63,6 +69,25 @@ function conv_log_filter($logfile, $nentries, $tail = 50) {
return isset($config['syslog']['reverse']) ? $filterlog : array_reverse($filterlog);
}
+function collapse_filter_lines($logarr) {
+ $lastline = "";
+ $collapsed = array();
+ foreach ($logarr as $logent) {
+ $line_split = "";
+ preg_match("/.*\spf:\s(.*)/", $logent, $line_split);
+ if (substr($line_split[1], 0, 4) != " ") {
+ if (($lastline != "") && (substr($lastline, 0, 1) != " ")) {
+ $collapsed[] = $lastline;
+ }
+ $lastline = $logent;
+ } else {
+ $lastline .= substr($line_split[1], 3);
+ }
+ }
+ //print_r($collapsed);
+ return $collapsed;
+}
+
function parse_filter_line($line) {
global $config, $g;
$log_split = "";
@@ -97,9 +122,7 @@ function parse_filter_line($line) {
$flent['tcpflags'] = "";
if ($flent['proto'] == "TCP") {
$flags = split('[\, ]', $leftovers);
- $flent['tcpflags'] = $flags[0];
- if ($flent['tcpflags'] == ".")
- $flent['tcpflags'] = "A";
+ $flent['tcpflags'] = str_replace(".", "A", substr($flags[1], 1, -1));
}
/* If there is a src, a dst, and a time, then the line should be usable/good */
OpenPOWER on IntegriCloud