From 9464d7496e9f62abf65da7345a3de1de41914451 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Tue, 16 Jun 2009 21:06:12 +0000 Subject: [PATCH] Handle rsyslog format tags --- syslog/CHANGELOG | 2 ++ syslog/save_log.cgi | 1 + syslog/syslog-lib.pl | 12 ++++++++++++ 3 files changed, 15 insertions(+) diff --git a/syslog/CHANGELOG b/syslog/CHANGELOG index bbaac8e05..d6baccdac 100644 --- a/syslog/CHANGELOG +++ b/syslog/CHANGELOG @@ -12,3 +12,5 @@ On Debian systems, use a syslog restart to tell it to re-open log files, as a HU On Fedora 8, use rsyslog by default instead of syslog. ---- Changes since 1.430 ---- Added support for rsyslogd, as seen by default on Debian 5.0. +---- Changes since 1.480 ---- +Rsyslog format tags in the config file are now recogized and preserved, rather than being included in the log filename. diff --git a/syslog/save_log.cgi b/syslog/save_log.cgi index bf1d097b4..5d78e7d0c 100755 --- a/syslog/save_log.cgi +++ b/syslog/save_log.cgi @@ -209,6 +209,7 @@ else { else { &can_edit_log($log) || &error($text{'save_ecannot4'}); $old = $conf->[$in{'idx'}]; + $log->{'format'} = $old->{'format'}; # Copy for now &can_edit_log($old) || &error($text{'save_ecannot5'}); &update_log($old, $log); } diff --git a/syslog/syslog-lib.pl b/syslog/syslog-lib.pl index 4a7bb8311..020840c36 100644 --- a/syslog/syslog-lib.pl +++ b/syslog/syslog-lib.pl @@ -35,6 +35,9 @@ while($line = ) { if ($line =~ /^\$(\S+)\s*(\S*)/) { # rsyslog special directive - ignored for now } + elsif ($line =~ /^if\s+/) { + # rsyslog if statement .. ignored too + } elsif ($line =~ /^(#*)\s*([^#\s]+\.\S+)\s+(\S+)$/ || $line =~ /^(#*)\s*([^#\s]+\.\S+)\s+(\|.*)$/) { # Regular log destination @@ -69,6 +72,11 @@ while($line = ) { $log->{'index'} = scalar(@rv); $log->{'section'} = $tag; $tag->{'eline'} = $lnum; + if ($log->{'file'} =~ s/^(\/\S+);(\S+)$/$1/ || + $log->{'pipe'} =~ s/^(\/\S+);(\S+)$/$1/) { + # rsyslog file format + $log->{'format'} = $2; + } push(@rv, $log); } elsif ($line =~ /^(#?)!(\S+)$/) { @@ -152,6 +160,10 @@ elsif ($_[0]->{'socket'}) { else { $d = '*'; } +if ($_[0]->{'format'}) { + # Add rsyslog format + $d .= ";".$_[0]->{'format'}; + } return ($_[0]->{'active'} ? "" : "#").join(";", @{$_[0]->{'sel'}})."\t".$d; }