зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
9c4d884e18
Коммит
0ce407c292
|
@ -60,16 +60,16 @@ EXE_FILES = \
|
|||
clean.pl \
|
||||
doadmin.cgi \
|
||||
fixupimages.pl \
|
||||
scrape.pl \
|
||||
showbuilds.cgi \
|
||||
showimages.cgi \
|
||||
showlog.cgi \
|
||||
warnings.pl \
|
||||
$(NULL)
|
||||
|
||||
SETUID_SCRIPTS = \
|
||||
handlemail.pl \
|
||||
processbuild.pl \
|
||||
scrape.pl \
|
||||
warnings.pl \
|
||||
$(NULL)
|
||||
|
||||
FILES = \
|
||||
|
|
|
@ -104,7 +104,8 @@ require "$tinderbox{tree}/treedata.pl" if -r "$tinderbox{tree}/treedata.pl";
|
|||
if (defined $warning_buildnames_pat
|
||||
and $tinderbox{build} =~ /^$warning_buildnames_pat$/
|
||||
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
|
||||
|
@ -112,7 +113,8 @@ if (defined $warning_buildnames_pat
|
|||
require "$tinderbox{tree}/scrapebuilds.pl" if -r "$tinderbox{tree}/scrapebuilds.pl";
|
||||
if ($scrape_builds->{$tinderbox{build}}
|
||||
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
|
||||
|
|
|
@ -30,10 +30,10 @@ sub usage {
|
|||
warn "./scrape.pl <tree> <logfile>";
|
||||
}
|
||||
|
||||
use FileHandle;
|
||||
use Compress::Zlib;
|
||||
use lib "@TINDERBOX_DIR@";
|
||||
require "tbglobals.pl";
|
||||
|
||||
# This is for gunzip (Should add a configure script to handle this).
|
||||
$ENV{PATH} = "@SETUID_PATH@";
|
||||
|
||||
unless ($#ARGV == 1) {
|
||||
|
@ -43,22 +43,27 @@ unless ($#ARGV == 1) {
|
|||
|
||||
($tree, $logfile) = @ARGV;
|
||||
|
||||
$tree = &trick_taint($tree);
|
||||
$logfile = &trick_taint($logfile);
|
||||
|
||||
die "Error: No tree named $tree" unless -r "$tree/treedata.pl";
|
||||
require "$tree/treedata.pl";
|
||||
|
||||
# Seach the build log for the scrape data
|
||||
#
|
||||
$fh = new FileHandle "gunzip -c $tree/$logfile |"
|
||||
or die "Unable to open $tree/$logfile\n";
|
||||
@scrape_data = find_scrape_data($fh);
|
||||
my $gz = gzopen("$tree/$logfile", "rb")
|
||||
or die "gzopen($tree/$logfile): $!\n";
|
||||
@scrape_data = find_scrape_data($gz);
|
||||
$gz->gzclose();
|
||||
|
||||
$fh->close;
|
||||
|
||||
die "No scrape data found in log.\n" unless @scrape_data;
|
||||
if (!defined(@scrape_data)) {
|
||||
print "No scrape data found in log.\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
# 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";
|
||||
close SCRAPE;
|
||||
|
||||
|
@ -74,23 +79,24 @@ close SCRAPE;
|
|||
#============================================================
|
||||
|
||||
sub find_scrape_data {
|
||||
my ($fh) = $_[0];
|
||||
my ($gz) = $_[0];
|
||||
local $_;
|
||||
my @rv;
|
||||
my @line;
|
||||
while (<$fh>) {
|
||||
if (/TinderboxPrint:/) {
|
||||
my ($bytesread, $gzline);
|
||||
while (defined($gz) && (($bytesread = $gz->gzreadline($gzline)) > 0)) {
|
||||
if ($gzline =~ m/TinderboxPrint:/) {
|
||||
# Line format:
|
||||
# TinderboxPrint:<general html>
|
||||
|
||||
# Strip off the TinderboxPrint: part of the line
|
||||
chomp;
|
||||
s/.*TinderboxPrint://;
|
||||
chomp($gzline);
|
||||
$gzline =~ s/.*TinderboxPrint://;
|
||||
|
||||
# No longer use ; to create separate lines.
|
||||
#@line = split(';', $_);
|
||||
|
||||
$line[0] = $_;
|
||||
$line[0] = $gzline;
|
||||
push(@rv, @line);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,11 @@
|
|||
#
|
||||
|
||||
use FileHandle;
|
||||
use Compress::Zlib;
|
||||
use lib "@TINDERBOX_DIR@";
|
||||
|
||||
require 'tbglobals.pl';
|
||||
|
||||
# A few global variables are used in the program.
|
||||
#
|
||||
# %warnings - Main warnings data structure
|
||||
|
@ -95,9 +98,7 @@ $log_file = shift @ARGV;
|
|||
($tree, $log_file) = split '/', $log_file;
|
||||
$form{tree} = $tree;
|
||||
|
||||
&usage, die "Tree does not exist, $tree\n" unless -d $tree;
|
||||
|
||||
require 'tbglobals.pl';
|
||||
&require_only_one_tree();
|
||||
require "$tree/treedata.pl";
|
||||
|
||||
$source_root = 'mozilla';
|
||||
|
@ -145,7 +146,8 @@ $source_root = 'mozilla';
|
|||
# paths to files.
|
||||
#
|
||||
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";
|
||||
|
||||
# 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";
|
||||
|
||||
$fh = new FileHandle "gunzip -c $tree/$log_file |"
|
||||
or die "Unable to open $tree/$log_file\n";
|
||||
my $gz = gzopen("$tree/$log_file", "rb") or
|
||||
die "gzopen($tree/$log_file): $!\n";
|
||||
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') {
|
||||
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
|
||||
# (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
|
||||
#
|
||||
|
@ -184,6 +186,7 @@ $total_ignored_count = 0;
|
|||
|
||||
# Write the warnings indexed by who
|
||||
#
|
||||
$fh = new FileHandle;
|
||||
$fh->open($warn_file, ">") or die "Unable to open $warn_file: $!\n";
|
||||
my $time_str = print_html_by_who($fh, $br);
|
||||
$fh->close;
|
||||
|
@ -322,11 +325,13 @@ sub find_build_record {
|
|||
}
|
||||
|
||||
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 $ignore_pat = "(?:".join('|',@ignore).")";
|
||||
my ($bytesread, $line);
|
||||
|
||||
PARSE_TOP: while (<$fh>) {
|
||||
PARSE_TOP: while (defined($gz) && (($bytesread=$gz->gzreadline($line)) > 0)) {
|
||||
$_ = $line ;
|
||||
# Directory
|
||||
#
|
||||
if (/^gmake\[\d\]: Entering directory \`(.*)\'$/) {
|
||||
|
@ -402,12 +407,13 @@ sub gcc_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 $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:"
|
||||
next unless /^Warning :/;
|
||||
#print STDERR "Found a warning: $_";
|
||||
|
|
Загрузка…
Ссылка в новой задаче