From 01038d43b5ecd0a58efd73b9ba3f4cb2feb007de Mon Sep 17 00:00:00 2001 From: Darold Gilles Date: Sun, 17 Feb 2013 10:27:05 +0100 Subject: [PATCH] Fix issue with log file provided at command line (option -l) and non existant LogFile in squidanalyzer.conf. Thanks to Kalin KOZHUHAROV for the report. --- SquidAnalyzer.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SquidAnalyzer.pm b/SquidAnalyzer.pm index e774557..82cdfce 100644 --- a/SquidAnalyzer.pm +++ b/SquidAnalyzer.pm @@ -31,7 +31,7 @@ BEGIN { } -$ZCAT_PROG = "/bin/zcat"; +$ZCAT_PROG = "/bin/zcat"; $BZCAT_PROG = "/bin/bzcat"; $RM_PROG = "/bin/rm"; @@ -396,7 +396,7 @@ sub _init $conf_file = 'squidanalyzer.conf'; } } - my %options = &parse_config($conf_file); + my %options = &parse_config($conf_file, $log_file); # Use squid log file given as command line parameter $options{LogFile} = $log_file if ($log_file); @@ -2820,7 +2820,7 @@ sub _gen_summary sub parse_config { - my ($file) = @_; + my ($file, $log_file) = @_; die "FATAL: no configuration file!\n" if (!-e $file); @@ -2839,7 +2839,7 @@ sub parse_config print STDERR "Error: you must give a valid output directory. See option: Output\n"; exit 0; } - if (!exists $opt{LogFile} || !-f $opt{LogFile}) { + if (!$log_file && (!exists $opt{LogFile} || !-f $opt{LogFile})) { print STDERR "Error: you must give the path to the Squid log file. See option: LogFile\n"; exit 0; }