More fixes for setuid tinderbox mail:

* Use Compress::Zlib instead of gunzip in warning & scrape scripts
* Exit with error if warning or scrape scripts fail.
* Do not make warning.pl or scrape.pl setuid
Bug #344695 r=bear
This commit is contained in:
cls%seawood.org 2006-08-16 22:07:17 +00:00
Родитель 9c4d884e18
Коммит 0ce407c292
4 изменённых файлов: 57 добавлений и 43 удалений

Просмотреть файл

@ -60,16 +60,16 @@ EXE_FILES = \
clean.pl \ clean.pl \
doadmin.cgi \ doadmin.cgi \
fixupimages.pl \ fixupimages.pl \
scrape.pl \
showbuilds.cgi \ showbuilds.cgi \
showimages.cgi \ showimages.cgi \
showlog.cgi \ showlog.cgi \
warnings.pl \
$(NULL) $(NULL)
SETUID_SCRIPTS = \ SETUID_SCRIPTS = \
handlemail.pl \ handlemail.pl \
processbuild.pl \ processbuild.pl \
scrape.pl \
warnings.pl \
$(NULL) $(NULL)
FILES = \ FILES = \

Просмотреть файл

@ -104,7 +104,8 @@ require "$tinderbox{tree}/treedata.pl" if -r "$tinderbox{tree}/treedata.pl";
if (defined $warning_buildnames_pat if (defined $warning_buildnames_pat
and $tinderbox{build} =~ /^$warning_buildnames_pat$/ and $tinderbox{build} =~ /^$warning_buildnames_pat$/
and $tinderbox{status} ne 'failed') { and $tinderbox{status} ne 'failed') {
system("./warnings.pl", "$tinderbox{tree}/$tinderbox{logfile}"); $err = system("./warnings.pl", "$tinderbox{tree}/$tinderbox{logfile}");
die "warnings.pl returned an error\n" if ($err);
} }
# Scrape data # Scrape data
@ -112,7 +113,8 @@ if (defined $warning_buildnames_pat
require "$tinderbox{tree}/scrapebuilds.pl" if -r "$tinderbox{tree}/scrapebuilds.pl"; require "$tinderbox{tree}/scrapebuilds.pl" if -r "$tinderbox{tree}/scrapebuilds.pl";
if ($scrape_builds->{$tinderbox{build}} if ($scrape_builds->{$tinderbox{build}}
and $tinderbox{status} ne 'building') { and $tinderbox{status} ne 'building') {
system("./scrape.pl", "$tinderbox{tree}", "$tinderbox{logfile}"); $err = system("./scrape.pl", "$tinderbox{tree}", "$tinderbox{logfile}");
die "scrape.pl returned an error\n" if ($err);
} }
# Static pages # Static pages

Просмотреть файл

@ -30,10 +30,10 @@ sub usage {
warn "./scrape.pl <tree> <logfile>"; warn "./scrape.pl <tree> <logfile>";
} }
use FileHandle; use Compress::Zlib;
use lib "@TINDERBOX_DIR@"; use lib "@TINDERBOX_DIR@";
require "tbglobals.pl";
# This is for gunzip (Should add a configure script to handle this).
$ENV{PATH} = "@SETUID_PATH@"; $ENV{PATH} = "@SETUID_PATH@";
unless ($#ARGV == 1) { unless ($#ARGV == 1) {
@ -43,22 +43,27 @@ unless ($#ARGV == 1) {
($tree, $logfile) = @ARGV; ($tree, $logfile) = @ARGV;
$tree = &trick_taint($tree);
$logfile = &trick_taint($logfile);
die "Error: No tree named $tree" unless -r "$tree/treedata.pl"; die "Error: No tree named $tree" unless -r "$tree/treedata.pl";
require "$tree/treedata.pl"; require "$tree/treedata.pl";
# Seach the build log for the scrape data # Seach the build log for the scrape data
# #
$fh = new FileHandle "gunzip -c $tree/$logfile |" my $gz = gzopen("$tree/$logfile", "rb")
or die "Unable to open $tree/$logfile\n"; or die "gzopen($tree/$logfile): $!\n";
@scrape_data = find_scrape_data($fh); @scrape_data = find_scrape_data($gz);
$gz->gzclose();
$fh->close; if (!defined(@scrape_data)) {
print "No scrape data found in log.\n";
die "No scrape data found in log.\n" unless @scrape_data; exit(0);
}
# Save the scrape data to 'scrape.dat' # Save the scrape data to 'scrape.dat'
# #
open(SCRAPE, ">>", $tree/scrape.dat") or die "Unable to open $tree/scrape.dat"; open(SCRAPE, ">>", "$tree/scrape.dat") or die "Unable to open $tree/scrape.dat";
print SCRAPE "$logfile|".join('|', @scrape_data)."\n"; print SCRAPE "$logfile|".join('|', @scrape_data)."\n";
close SCRAPE; close SCRAPE;
@ -74,25 +79,26 @@ close SCRAPE;
#============================================================ #============================================================
sub find_scrape_data { sub find_scrape_data {
my ($fh) = $_[0]; my ($gz) = $_[0];
local $_; local $_;
my @rv; my @rv;
my @line; my @line;
while (<$fh>) { my ($bytesread, $gzline);
if (/TinderboxPrint:/) { while (defined($gz) && (($bytesread = $gz->gzreadline($gzline)) > 0)) {
# Line format: if ($gzline =~ m/TinderboxPrint:/) {
# TinderboxPrint:<general html> # Line format:
# TinderboxPrint:<general html>
# Strip off the TinderboxPrint: part of the line
chomp; # Strip off the TinderboxPrint: part of the line
s/.*TinderboxPrint://; chomp($gzline);
$gzline =~ s/.*TinderboxPrint://;
# No longer use ; to create separate lines.
#@line = split(';', $_); # No longer use ; to create separate lines.
#@line = split(';', $_);
$line[0] = $_;
push(@rv, @line); $line[0] = $gzline;
} push(@rv, @line);
}
} }
return @rv; return @rv;
} }

Просмотреть файл

@ -30,8 +30,11 @@
# #
use FileHandle; use FileHandle;
use Compress::Zlib;
use lib "@TINDERBOX_DIR@"; use lib "@TINDERBOX_DIR@";
require 'tbglobals.pl';
# A few global variables are used in the program. # A few global variables are used in the program.
# #
# %warnings - Main warnings data structure # %warnings - Main warnings data structure
@ -95,9 +98,7 @@ $log_file = shift @ARGV;
($tree, $log_file) = split '/', $log_file; ($tree, $log_file) = split '/', $log_file;
$form{tree} = $tree; $form{tree} = $tree;
&usage, die "Tree does not exist, $tree\n" unless -d $tree; &require_only_one_tree();
require 'tbglobals.pl';
require "$tree/treedata.pl"; require "$tree/treedata.pl";
$source_root = 'mozilla'; $source_root = 'mozilla';
@ -145,7 +146,8 @@ $source_root = 'mozilla';
# paths to files. # paths to files.
# #
print STDERR "Building hash of file names..."; print STDERR "Building hash of file names...";
($file_bases, $file_fullpaths) = build_file_hash($cvs_root, @cvs_modules); ($file_bases, $file_fullpaths) = build_file_hash($cvs_root, @cvs_modules)
if ($cvs_module ne '');
print STDERR "done.\n"; print STDERR "done.\n";
# Find the build we want and generate warnings for it # Find the build we want and generate warnings for it
@ -162,18 +164,18 @@ $total_ignored_count = 0;
# #
warn "Parsing $br->{buildname}, $log_file\n"; warn "Parsing $br->{buildname}, $log_file\n";
$fh = new FileHandle "gunzip -c $tree/$log_file |" my $gz = gzopen("$tree/$log_file", "rb") or
or die "Unable to open $tree/$log_file\n"; die "gzopen($tree/$log_file): $!\n";
if ($br->{errorparser} eq 'unix') { if ($br->{errorparser} eq 'unix') {
gcc_parser($fh, $cvs_root, $tree, $log_file, $file_bases, $file_fullpaths); gcc_parser($gz, $cvs_root, $tree, $log_file, $file_bases, $file_fullpaths);
} elsif ($br->{errorparser} eq 'mac') { } elsif ($br->{errorparser} eq 'mac') {
mac_parser($fh, $cvs_root, $tree, $log_file, $file_bases, $file_fullpaths); mac_parser($gz, $cvs_root, $tree, $log_file, $file_bases, $file_fullpaths);
} }
$fh->close; $gz->gzclose();
# Attach blame to all the warnings # Attach blame to all the warnings
# (Yes, global variables are flying around.) # (Yes, global variables are flying around.)
&build_blame($cvs_root, $file_fullpaths); &build_blame($cvs_root, $file_fullpaths) if ($cvs_module ne '');
# Come up with the temporary filenames for the output # Come up with the temporary filenames for the output
# #
@ -184,6 +186,7 @@ $total_ignored_count = 0;
# Write the warnings indexed by who # Write the warnings indexed by who
# #
$fh = new FileHandle;
$fh->open($warn_file, ">") or die "Unable to open $warn_file: $!\n"; $fh->open($warn_file, ">") or die "Unable to open $warn_file: $!\n";
my $time_str = print_html_by_who($fh, $br); my $time_str = print_html_by_who($fh, $br);
$fh->close; $fh->close;
@ -322,11 +325,13 @@ sub find_build_record {
} }
sub gcc_parser { sub gcc_parser {
my ($fh, $cvs_root, $tree, $log_file, $file_bases, $file_fullnames) = @_; my ($gz, $cvs_root, $tree, $log_file, $file_bases, $file_fullnames) = @_;
my $build_dir = ''; my $build_dir = '';
my $ignore_pat = "(?:".join('|',@ignore).")"; my $ignore_pat = "(?:".join('|',@ignore).")";
my ($bytesread, $line);
PARSE_TOP: while (<$fh>) { PARSE_TOP: while (defined($gz) && (($bytesread=$gz->gzreadline($line)) > 0)) {
$_ = $line ;
# Directory # Directory
# #
if (/^gmake\[\d\]: Entering directory \`(.*)\'$/) { if (/^gmake\[\d\]: Entering directory \`(.*)\'$/) {
@ -402,12 +407,13 @@ sub gcc_parser {
} }
sub mac_parser { sub mac_parser {
my ($fh, $cvs_root, $tree, $log_file, $file_bases, $file_fullnames) = @_; my ($gz, $cvs_root, $tree, $log_file, $file_bases, $file_fullnames) = @_;
my $build_dir = ''; my $build_dir = '';
my $ignore_pat = "(?:".join('|',@mac_ignore).")"; my $ignore_pat = "(?:".join('|',@mac_ignore).")";
PARSE_TOP: while (<$fh>) { PARSE_TOP: while (defined($gz) && (($bytesred=$gz->gzreadline($line)) > 0)) {
$_ = $line ;
# Now only match lines with "warning:" # Now only match lines with "warning:"
next unless /^Warning :/; next unless /^Warning :/;
#print STDERR "Found a warning: $_"; #print STDERR "Found a warning: $_";