From 0727dc4d2ef097efecc7440c382abb844f886af0 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Tue, 6 Mar 2007 20:09:01 -0800 Subject: [PATCH] * Remove getmaintainers from Debbugs::CGI * Add post_process_all and text_instructions to Debbugs::Config * Make receive.in use Debbugs::Config and warnings/strict * Output more debbuging information in the tests that are run --- Debbugs/CGI.pm | 31 +------------------------------ Debbugs/Config.pm | 12 ++++++++++++ cgi/bugreport.cgi | 2 +- scripts/processall.in | 24 +++++++++++++----------- scripts/receive.in | 3 +-- t/06_mail_handling.t | 6 ++++-- t/lib/DebbugsTest.pm | 13 ++++++++++--- 7 files changed, 42 insertions(+), 49 deletions(-) diff --git a/Debbugs/CGI.pm b/Debbugs/CGI.pm index e8321299..0fd19af9 100644 --- a/Debbugs/CGI.pm +++ b/Debbugs/CGI.pm @@ -53,7 +53,7 @@ BEGIN{ qw(maybelink htmlize_addresslinks htmlize_maintlinks), ], util => [qw(cgi_parameters quitcgi), - qw(getmaintainers getpseudodesc) + qw(getpseudodesc) ], #status => [qw(getbugstatus)], ); @@ -460,35 +460,6 @@ sub htmlize_maintlinks { my $_maintainer; my $_maintainer_rev; -sub getmaintainers { - return $_maintainer if $_maintainer; - my %maintainer; - my %maintainer_rev; - for my $file (@config{qw(maintainer_file maintainer_file_override)}) { - next unless defined $file; - my $maintfile = new IO::File $file,'r' or - &quitcgi("Unable to open $file: $!"); - while(<$maintfile>) { - next unless m/^(\S+)\s+(\S.*\S)\s*$/; - ($a,$b)=($1,$2); - $a =~ y/A-Z/a-z/; - $maintainer{$a}= $b; - for my $maint (map {lc($_->address)} getparsedaddrs($b)) { - push @{$maintainer_rev{$maint}},$a; - } - } - close($maintfile); - } - $_maintainer = \%maintainer; - $_maintainer_rev = \%maintainer_rev; - return $_maintainer; -} -sub getmaintainers_reverse{ - return $_maintainer_rev if $_maintainer_rev; - getmaintainers(); - return $_maintainer_rev; -} - my $_pseudodesc; sub getpseudodesc { diff --git a/Debbugs/Config.pm b/Debbugs/Config.pm index 6f869e8e..e8231f11 100644 --- a/Debbugs/Config.pm +++ b/Debbugs/Config.pm @@ -52,6 +52,7 @@ BEGIN { qw($gSendmail $gLibPath), qw(%gSeverityDisplay @gTags @gSeverityList @gStrongSeverities), qw(%gSearchEstraier), + qw(@gPostProcessall), ], text => [qw($gBadEmailPrefix $gHTMLTail $gHTMLExpireNote), ], @@ -377,6 +378,8 @@ set_default(\%config,'package_source',$config{config_dir}.'/indices/sources'); set_default(\%config,'version_packages_dir',$config{spool_dir}.'/../versions/pkg'); +set_default(\%config,'post_processall',[]); + =item sendmail Sets the sendmail binary to execute; defaults to /usr/lib/sendmail @@ -410,6 +413,15 @@ This prefixes the text of all lines in a bad e-mail message ack. set_default(\%config,'bad_email_prefix',''); + +=item text_instructions + +This gives more information about bad e-mails to receive.in + +=cut + +set_default(\%config,'text_instructions',$config{bad_email_prefix}); + =item html_tail This shows up at the end of (most) html pages diff --git a/cgi/bugreport.cgi b/cgi/bugreport.cgi index bdca6122..01f69340 100755 --- a/cgi/bugreport.cgi +++ b/cgi/bugreport.cgi @@ -14,7 +14,7 @@ use Debbugs::Config qw(:globals :text); use Debbugs::Log; use Debbugs::MIME qw(convert_to_utf8 decode_rfc1522 create_mime_message); use Debbugs::CGI qw(:url :html :util); -use Debbugs::Common qw(buglog); +use Debbugs::Common qw(buglog getmaintainers); use Debbugs::Packages qw(getpkgsrc); use Debbugs::Status qw(splitpackages get_bug_status isstrongseverity); diff --git a/scripts/processall.in b/scripts/processall.in index 326bc665..2606b26e 100755 --- a/scripts/processall.in +++ b/scripts/processall.in @@ -8,27 +8,28 @@ # Creates: incoming/E.nn # Stop: stop +use warnings; +use strict; + use Debbugs::Config qw(:globals); +use Debbugs::Common qw(:lock); my $lib_path = $gLibPath; - -require "$lib_path/errorlib"; -$ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'}; - use File::Path; chdir( $gSpoolDir ) || die "chdir spool: $!\n"; -push( @INC, $lib_path ); #open(DEBUG,">&4"); umask(002); $|=1; -undef %fudged; +my %fudged; +my @ids; +my $ndone = 0; &filelock('incoming-cleaner'); for (;;) { if (-f 'stop') { @@ -42,8 +43,8 @@ for (;;) { @ids= sort(@ids); } stat("$gMaintainerFile") || die "stat $gMaintainerFile: $!\n"; - $nf= @ids; - $id= shift(@ids); + my $nf= @ids; + my $id= shift(@ids); unless (rename("incoming/I$id","incoming/G$id")) { if ($fudged{$id}) { die "$id already fudged once! $!\n"; @@ -51,8 +52,9 @@ for (;;) { $fudged{$id}= 1; next; } + my $c; if ($id =~ m/^[RC]/) { - print(STDOUT "[$nf] $id service ...") || die $!; + print(STDOUT "[$nf] $id service ...") || die $!; defined($c=fork) || die $!; if (!$c) { exec("$lib_path/service",$id); die "unable to execute $lib_path/service: $!"; } } elsif ($id =~ m/^[BMQFDUL]/) { @@ -62,8 +64,8 @@ for (;;) { } else { die "bad name $id"; } - $cc=waitpid($c,0); $cc == $c || die "$cc $c $!"; - $status=$?; + my $cc=waitpid($c,0); $cc == $c || die "$cc $c $!"; + my $status=$?; if ($status) { print(STDERR "$id: process failed ($status $!) - now in [PG]$id\n") || die $!; } diff --git a/scripts/receive.in b/scripts/receive.in index df602bbf..eb101a40 100755 --- a/scripts/receive.in +++ b/scripts/receive.in @@ -5,7 +5,7 @@ #set umask in order to have group-writable incoming/* #umask(002); -use Debbugs::Config qw(:globals); +use Debbugs::Config qw(:globals :text); my $lib_path = $gLibPath; $ENV{'PATH'} = '/usr/lib/debbugs:'.$ENV{'PATH'}; @@ -26,7 +26,6 @@ if ( $gMailer eq 'exim' ) s/\>//; s/\ exists $ENV{DEBUG}?$ENV{DEBUG}:0); @@ -107,7 +109,7 @@ $SD_SIZE_NOW = dirsize($sendmail_dir); ok($SD_SIZE_NOW-$SD_SIZE_PREV >= 1,'control@bugs.something messages appear to have been sent out properly'); $SD_SIZE_PREV=$SD_SIZE_NOW; # now we need to check to make sure the control message was processed without errors -ok(system("sh -c 'find ".$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug"')) == 0, +ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug")) == 0, 'control@bugs.something message was parsed without errors'); # now we need to check to make sure that the control message actually did anything # This is an eval because $ENV{DEBBUGS_CONFIG_FILE} isn't set at BEGIN{} time @@ -175,7 +177,7 @@ EOF ok($SD_SIZE_NOW-$SD_SIZE_PREV >= 1,'control@bugs.something messages appear to have been sent out properly'); $SD_SIZE_PREV=$SD_SIZE_NOW; # now we need to check to make sure the control message was processed without errors - ok(system("sh -c 'find ".$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug with $command"')) == 0, + ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug with $command")) == 0, 'control@bugs.something'. "$command message was parsed without errors"); # now we need to check to make sure that the control message actually did anything my $status = read_bug(bug=>1); diff --git a/t/lib/DebbugsTest.pm b/t/lib/DebbugsTest.pm index f7dbe6d8..a2e0537d 100644 --- a/t/lib/DebbugsTest.pm +++ b/t/lib/DebbugsTest.pm @@ -30,6 +30,7 @@ use Cwd qw(getcwd); use Debbugs::MIME qw(create_mime_message); use File::Basename qw(dirname basename); use IPC::Open3; +use IO::Handle; use Params::Validate qw(validate_with :types); @@ -146,13 +147,19 @@ sub send_message{ $ENV{LOCAL_PART} = $param{to}; my ($rfd,$wfd); my $output=''; + local $SIG{PIPE} = 'IGNORE'; + local $SIG{CHLD} = sub {}; my $pid = open3($wfd,$rfd,$rfd,'scripts/receive.in') or die "Unable to start receive.in: $!"; print {$wfd} create_mime_message($param{headers}, $param{body}) or die "Unable to to print to receive.in"; close($wfd) or die "Unable to close receive.in"; - waitpid($pid,0); - my $err = $?>>8; + my $err = $? >> 8; + my $childpid = waitpid($pid,0); + if ($childpid != -1) { + $err = $? >> 8; + print STDERR "receive.in pid: $pid doesn't match childpid: $childpid\n" if $childpid != $pid; + } if ($err != 0 ) { my $rfh = IO::Handle->new_from_fd($rfd,'r') or die "Unable to create filehandle: $!"; $rfh->blocking(0); @@ -161,7 +168,7 @@ sub send_message{ if (not defined $rv) { print STDERR "Reading from STDOUT/STDERR would have blocked."; } - print STDERR $output; + print STDERR $output,qq(\n); die "receive.in failed with exit status $err"; } # now we should run processall to see if the message gets processed -- 2.39.5