X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Famoverview.pl.in;h=07fdb975d3a4b0a251711596e02f18aad1f2e57b;hb=310f09c0f55a2fb6f3f3746d6ded20099792b773;hp=25f1e07c888d89da0a77957c88c59d12114daf5e;hpb=bde83ad58d800ae004caccab6531234272181da2;p=debian%2Famanda diff --git a/server-src/amoverview.pl.in b/server-src/amoverview.pl.in index 25f1e07..07fdb97 100644 --- a/server-src/amoverview.pl.in +++ b/server-src/amoverview.pl.in @@ -9,9 +9,13 @@ require 5.001; use FileHandle; use Getopt::Long; +use Text::ParseWords; use Carp; use POSIX; +delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV', 'PATH'}; +$ENV{'PATH'} = "/usr/bin:/usr/sbin:/sbin:/bin"; + sub Usage { print STDERR < 0) { Usage(); } +#untaint user input $ARGV[0] + +if ($opt_config =~ /^([\w.-]+)$/) { # $1 is untainted + $opt_config = $1; +} else { + die "filename '$opt_config' has invalid characters.\n"; +} + + -d "$confdir/$opt_config" or die "$0: directory `$confdir/$opt_config' does not exist.\n"; @@ -115,16 +128,31 @@ while (<$fh>) { next if /found Amanda directory/; next if /skipping cruft directory/; next if /skip-incr/; - ($date, $host, $disk, $level, $tape, $file, $status) = split ' ', $_; + + ($date, $time, $host, $disk, $level, $tape, $file, $part, $status) = shellwords($_); + next if $date eq 'date'; next if $date eq 'Warning:'; next if $date eq 'Scanning'; next if $date eq ""; + + if($time !~/^\d\d:\d\d:\d\d$/) { + $status = $part; + $part = $file; + $file = $tape; + $tape = $level; + $level = $disk; + $disk = $host; + $host = $time; + } + if ($date =~ /^\d\d\d\d-\d\d-\d\d$/) { - defined($level{$host}{$disk}{$date}) or - $level{$host}{$disk}{$date} = ''; - $level{$host}{$disk}{$date} .= ($status eq 'OK') ? $level : 'E'; - $dates{$date}++; + if(defined $disks{$host}{$disk}) { + defined($level{$host}{$disk}{$date}) or + $level{$host}{$disk}{$date} = ''; + $level{$host}{$disk}{$date} .= ($status eq 'OK') ? $level : 'E'; + $dates{$date}++; + } } else { print "bad date $date in $_\n";