X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Fprocess.in;h=2f9ccc04c20984f32be7acc5f3b1d0d745aa1631;hb=835538b2cb12eeb8adef40e3eeeb9d7e6ea76829;hp=8cd0c3e71db5f6edce1c3ee95e52669bc52f23d8;hpb=c1a3e8f5dde9537d9e2bc9121dae7da86193ab3b;p=debbugs.git diff --git a/scripts/process.in b/scripts/process.in index 8cd0c3e..2f9ccc0 100755 --- a/scripts/process.in +++ b/scripts/process.in @@ -1,16 +1,24 @@ #!/usr/bin/perl -# $Id: process.in,v 1.69 2003/05/25 13:32:02 joy Exp $ +# $Id: process.in,v 1.109 2006/02/09 22:02:04 don Exp $ # # Usage: process nn # Temps: incoming/Pnn -use POSIX qw(strftime); +use POSIX qw(strftime tzset); +$ENV{"TZ"} = 'UTC'; +tzset(); -use Mail::Address; use MIME::Parser; +use Debbugs::MIME qw(decode_rfc1522 create_mime_message); +use Debbugs::Mail qw(send_mail_message encode_headers); +use Debbugs::Packages qw(getpkgsrc); -$config_path = '/etc/debbugs'; -$lib_path = '/usr/lib/debbugs'; +my $config_path = '/etc/debbugs'; +my $lib_path = '/usr/lib/debbugs'; + +# TODO DLA; needs config reworking and errorlib reworking +# use warnings; +# use strict; require "$config_path/config"; require "$lib_path/errorlib"; @@ -22,13 +30,13 @@ chdir( "$gSpoolDir" ) || die "chdir spool: $!\n"; umask(002); open DEBUG, ">/dev/null"; -defined( $intdate= time ) || &quit( "failed to get time: $!" ); +my $intdate = time or quit("failed to get time: $!"); $_=shift; -m/^([BMQFDU])(\d*)\.\d+$/ || &quit("bad argument"); -$codeletter= $1; -$tryref= length($2) ? $2+0 : -1; -$nn= $_; +m/^([BMQFDUL])(\d*)\.\d+$/ or quit("bad argument: $_"); +my $codeletter= $1; +my $tryref= length($2) ? $2 : -1; +my $nn= $_; if (!rename("incoming/G$nn","incoming/P$nn")) { @@ -36,27 +44,28 @@ if (!rename("incoming/G$nn","incoming/P$nn")) &quit("renaming to lock: $!"); } -$baddress= 'submit' if $codeletter eq 'B'; +my $baddress= 'submit' if $codeletter eq 'B'; $baddress= 'maintonly' if $codeletter eq 'M'; $baddress= 'quiet' if $codeletter eq 'Q'; $baddress= 'forwarded' if $codeletter eq 'F'; $baddress= 'done' if $codeletter eq 'D'; $baddress= 'submitter' if $codeletter eq 'U'; +bug_list_forward($nn) if $codeletter eq 'L'; $baddress || &quit("bad codeletter $codeletter"); -$baddressroot= $baddress; +my $baddressroot= $baddress; $baddress= "$tryref-$baddress" if $tryref>=0; open(M,"incoming/P$nn"); -@log=; +my @log=; close(M); -@msg=@log; +my @msg = @log; chomp @msg; print DEBUG "###\n",join("##\n",@msg),"\n###\n"; -$tdate = strftime "%a, %d %h %Y %T UTC", gmtime; -$fwd= <output_under("$gSpoolDir/mime.tmp"); my $entity = eval { $parser->parse_data(join('',@log)) }; +my $i; if ($entity and $entity->head->tags) { @headerlines = @{$entity->head->header}; chomp @headerlines; @@ -96,12 +106,15 @@ if ($entity and $entity->head->tags) { @bodylines = @msg[$i..$#msg]; } +my %header; + for my $hdr (@headerlines) { + $hdr = decode_rfc1522($hdr); $_ = $hdr; s/\n\s/ /g; &finish if m/^x-loop: (\S+)$/i && $1 eq "$gMaintainerEmail"; my $ins = !m/^subject:/i && !m/^reply-to:/i && !m/^return-path:/i - && !m/^From / && !m/^X-Debbugs-CC:/i; + && !m/^From / && !m/^X-Debbugs-/i; $fwd .= $hdr."\n" if $ins; # print DEBUG ">$_<\n"; if (s/^(\S+):\s*//) { @@ -132,16 +145,21 @@ if (@bodylines and $bodylines[0] =~ /^-----BEGIN PGP SIGNED/) { # extract pseudo-headers for my $phline (@bodylines) { - last if $phline !~ m/^([\w]+):\s*(\S.*)/; + last if $phline !~ m/^([\w-]+):\s*(\S.*)/; my ($fn, $fv) = ($1, $2); $fv =~ s/\s*$//; print DEBUG ">$fn|$fv|\n"; $fn = lc $fn; - $fv = lc $fv; + # Don't lc owner or forwarded + $fv = lc $fv unless $fh =~ /^(?:owner|forwarded)$/; $pheader{$fn} = $fv; print DEBUG ">$fn~$fv<\n"; } +# Allow pseudo headers to set x-debbugs- stuff [#179340] +for my $key (grep /X-Debbugs-.*/i, keys %pheader) { + $header{$key} = $pheader{$key} if not exists $header{$key}; +} $fwd .= join("\n",@msg[$i..$#msg]); @@ -151,13 +169,16 @@ if (defined $header{'resent-from'} && !defined $header{'from'}) { $header{'from'} = $header{'resent-from'}; } defined($header{'from'}) || &quit("no From header"); -$replyto= defined($header{'reply-to'}) ? $header{'reply-to'} : $header{'from'}; -$_= $replyto; -$_= "$2 <$1>" if m/^([^\<\> \t\n\(\)]+) \(([^\(\)\<\>]+)\)$/; -$replytocompare= $_; -print DEBUG "replytocompare >$replytocompare<\n"; - +my $replyto = $header{'reply-to'}; +$replyto = '' unless defined $replyto; +$replyto =~ s/^ +//; +$replyto =~ s/ +$//; +unless (length $replyto) { + $replyto = $header{'from'}; +} + +my $subject = '(no subject)'; if (!defined($header{'subject'})) { $brokenness.= <= 0) $ref= $tryref; } else { &htmllog("Reply","sent", $replyto,"Unknown problem report number $tryref."); + my $archivenote = ''; + if ($gRemoveAge) { + $archivenote = <{package} or defined $pheader{package}) { + my $pkg_src = getpkgsrc(); + $source_package = $pkg_src->{defined $data->{package}?$data->{package}:$pheader{package}}; +} +$source_pr_header = "X-$gProject-PR-Source: $source_package\n" + if defined $source_package and length $source_package; + +# Done and Forwarded Bugs if ($codeletter eq 'D' || $codeletter eq 'F') { if ($replyto =~ m/$gBounceFroms/o || @@ -239,27 +276,39 @@ if ($codeletter eq 'D' || $codeletter eq 'F') } $markedby= $header{'from'} eq $replyto ? $replyto : "$header{'from'} (reply to $replyto)"; - if ($codeletter eq 'F') { + my @generalcc; + if ($codeletter eq 'F') { # Forwarded (&appendlog,&finish) if length($data->{forwarded}); $receivedat= "forwarded\@$gEmailDomain"; $markaswhat= 'forwarded'; $set_forwarded= $header{'to'}; - if ( length( $gListDomain ) > 0 && length( $gFowardList ) > 0 ) { - $generalcc= "$gFowardList\@$gListDomain"; + if ( length( $gListDomain ) > 0 && length( $gForwardList ) > 0 ) { + push @generalcc, "$gForwardList\@$gListDomain"; + $generalcc= "$gForwardList\@$gListDomain"; } else { $generalcc=''; } - } else { - (&appendlog,&finish) if length($data->{done}); + } else { # Done + if (length($data->{done}) and + not defined $pheader{'source-version'} and + not defined $pheader{'version'}) { + &appendlog; + &finish; + } $receivedat= "done\@$gEmailDomain"; $markaswhat= 'done'; $set_done= $header{'from'}; if ( length( $gListDomain ) > 0 && length( $gDoneList ) > 0 ) { $generalcc= "$gDoneList\@$gListDomain"; + push @generalcc, "$gDoneList\@$gListDomain"; } else { $generalcc=''; } } + if (defined $gStrongList and isstrongseverity($data->{severity})) { + $generalcc = join ', ', $generalcc, "$gStrongList\@$gListDomain"; + push @generalcc,"$gStrongList\@$gListDomain"; + } if ($ref<0) { &htmllog("Warning","sent",$replyto,"Message ignored."); &sendmessage(<{mergedwith})); $orgref= $ref; @@ -325,6 +372,24 @@ END } $data->{done}= $set_done if defined($set_done); $data->{forwarded}= $set_forwarded if defined($set_forwarded); + if ($codeletter eq 'D') { + $data->{keywords} = join ' ', grep $_ ne 'pending', + split ' ', $data->{keywords}; + if (defined $pheader{'source-version'}) { + addfixedversions($data, $pheader{source}, $pheader{'source-version'}, ''); + } elsif (defined $pheader{version}) { + addfixedversions($data, $pheader{package}, $pheader{version}, 'binary'); + } + } + + # Add bug mailing list to $generalbcc as appropriate + # This array is used to specify bcc in the cases where we're using create_mime_message. + my @generalbcc = (@generalcc,@addsrcaddrs,"bugs=$ref\@$gListDomain"); + my $generalbcc = join(', ', $generalcc, @addsrcaddrs,"bugs=$ref\@$gListDomain"); + $generalbcc =~ s/\s+\n\s+/ /g; + $generalbcc =~ s/^\s+/ /; $generalbcc =~ s/\s+$//; + if (length $generalbcc) {$generalbcc = "Bcc: $generalbcc\n"}; + writebug($ref, $data); my $hash = get_hashname($ref); @@ -332,18 +397,21 @@ END $x= join('',); close(O); if ($codeletter eq 'F') { &htmllog("Reply","sent",$replyto,"You have marked $gBug as forwarded."); - &sendmessage(<{subject}) -Message-ID: -In-Reply-To: $header{'message-id'} -References: $header{'message-id'} $data->{msgid} -Precedence: bulk -X-$gProject-PR-Message: forwarded $ref -X-$gProject-PR-Package: $data->{package} -X-$gProject-PR-Keywords: $data->{keywords} - + &sendmessage(create_mime_message( + ["X-Loop" => "$gMaintainerEmail", + From => "$gMaintainerEmail ($gProject $gBug Tracking System)", + To => "$replyto", + Subject => "$gBug#$ref: marked as forwarded ($data->{subject})", + "Message-ID" => "", + "In-Reply-To" => $header{'message-id'}, + References => "$header{'message-id'} $data->{msgid}", + Precedence => 'bulk', + "X-$gProject-PR-Message" => "forwarded $ref", + "X-$gProject-PR-Package" => $data->{package}, + "X-$gProject-PR-Keywords" => $data->{keywords}, + # Only have a X-$gProject-PR-Source when we know the source package + length($source_package)?("X-$gProject-PR-Source" => $source_package):(), + ],<{subject}) -Message-ID: -In-Reply-To: $header{'message-id'} -References: $header{'message-id'} $data->{msgid} -Precedence: bulk -X-$gProject-PR-Message: closed $ref -X-$gProject-PR-Package: $data->{package} -X-$gProject-PR-Keywords: $data->{keywords} - + &sendmessage(create_mime_message( + ["X-Loop" => "$gMaintainerEmail", + From => "$gMaintainerEmail ($gProject $gBug Tracking System)", + To => $replyto, + Subject => "$gBug#$ref: marked as done ($data->{subject})", + "Message-ID" => "", + "In-Reply-To" => $header{'message-id'}, + References => "$header{'message-id'} $data->{msgid}", + Precedence => 'bulk', + "X-$gProject-PR-Message" => "closed $ref", + "X-$gProject-PR-Package" => $data->{package}, + "X-$gProject-PR-Keywords" => $data->{keywords}, + # Only have a X-$gProject-PR-Source when we know the source package + length($source_package)?("X-$gProject-PR-Source" => $source_package):(), + ],<{originator}, "$gBug acknowledged by developer."); - &sendmessage(<{originator} -Subject: $gBug#$ref acknowledged by developer - ($header{'subject'}) -Message-ID: -In-Reply-To: $data->{msgid} -References: $header{'message-id'} $data->{msgid} -X-$gProject-PR-Message: they-closed $ref -X-$gProject-PR-Package: $data->{package} -X-$gProject-PR-Keywords: $data->{keywords} -Reply-To: $ref\@$gEmailDomain - + &sendmessage(create_mime_message( + ["X-Loop" => "$gMaintainerEmail", + From => "$gMaintainerEmail ($gProject $gBug Tracking System)", + To => "$data->{originator}", + Subject => "$gBug#$ref closed by $markedby ($header{'subject'})", + "Message-ID" => "", + "In-Reply-To" => "$data->{msgid}", + References => "$header{'message-id'} $data->{msgid}", + "X-$gProject-PR-Message" => "they-closed $ref", + "X-$gProject-PR-Package" => "$data->{package}", + "X-$gProject-PR-Keywords" => "$data->{keywords}", + # Only have a X-$gProject-PR-Source when we know the source package + length($source_package)?("X-$gProject-PR-Source" => $source_package):(), + "Reply-To" => "$ref\@$gEmailDomain", + "Content-Type" => 'text/plain; charset="utf-8"', + ],<{subject}, which was filed against the $data->{package} package. -It has been closed by one of the developers, namely -$markedby. +It has been closed by $markedby. Their explanation is attached below. If this explanation is unsatisfactory and you have not received a better one in a separate -message then please contact the developer, by replying to this email. +message then please contact $markedby by replying +to this email. $gMaintainer (administrator, $gProject $gBugs database) @@ -441,7 +515,7 @@ References: $header{'message-id'} $data->{msgid} Precedence: bulk X-$gProject-PR-Message: error -You sent a message to the $gProject $gBug tracking system send to $gBug +You sent a message to the $gProject $gBug tracking system's $gBug report submitter address $baddress\@$gEmailDomain, without a recognisable $gBug number in the Subject. Your message has been filed under junk but otherwise ignored. @@ -450,7 +524,7 @@ If you don't know what I'm talking about then probably either: (a) you unwittingly sent a message to $baddress\@$gEmailDomain because you replied to all recipients of the message a developer sent -to a $gBug's submitter and you modified the Subject. In this case, +to a $gBug\'s submitter and you modified the Subject. In this case, please do not be alarmed. To avoid confusion do not do it again, but there is no need to apologise or mail anyone asking for an explanation. @@ -473,22 +547,32 @@ END &appendlog; &finish; } - if (!defined($pheader{'package'})) { + + $data->{found_versions} = []; + $data->{fixed_versions} = []; + + if (defined $pheader{source}) { + $data->{package} = $pheader{source}; + } elsif (defined $pheader{package}) { + $data->{package} = $pheader{package}; + } else { &htmllog("Warning","sent",$replyto,"Message not forwarded."); - &sendmessage(< -In-Reply-To: $header{'message-id'} -References: $header{'message-id'} $data->{msgid} -Precedence: bulk -X-$gProject-PR-Message: error + &sendmessage(create_mime_message( + ["X-Loop" => "$gMaintainerEmail", + From => "$gMaintainerEmail ($gProject $gBug Tracking System)", + To => $replyto, + Subject => "Message with no Package: tag cannot be processed! ($subject)", + "Message-ID" => "", + "In-Reply-To" => $header{'message-id'}, + References => "$header{'message-id'} $data->{msgid}", + Precedence => 'bulk', + "X-$gProject-PR-Message" => 'error' + ],<{package}= $pheader{'package'}; - } - - $data->{versions}= ''; - if (defined($pheader{'version'})) { - $data->{versions} = $pheader{'version'}; - $data->{versions} =~ s/\s+/ /; - # BUG: need to bounce unknown versions back to submitter here - } - - $data->{fixed_versions}= ''; - if (defined($pheader{'fixed-in-version'})) { - $data->{fixed_versions} = $pheader{'fixed-in-version'}; - $data->{fixed_versions} =~ s/\s+/ /; } $data->{keywords}= ''; @@ -559,6 +628,12 @@ END $data->{severity}= ''; } } + if (defined($pheader{owner})) { + $data->{owner}= $pheader{owner}; + } + if (defined($pheader{forwarded})) { + $data->{'forwarded-to'} = $pheader{forwarded}; + } &filelock("nextnumber.lock"); open(N,"nextnumber") || &quit("nextnumber: read: $!"); $v=; $v =~ s/\n$// || &quit("nextnumber bad format"); @@ -602,7 +677,29 @@ Your message has been sent to the package maintainer(s): END } -push(@resentccs, @addsrcaddrs); +@bccs = @addsrcaddrs; +if (defined $gStrongList and isstrongseverity($data->{severity})) { + push @bccs, "$gStrongList\@$gListDomain"; +} + +# Send mail to the per bug list subscription too +push @bccs, "bugs=$ref\@$gListDomain"; + +if (defined $pheader{source}) { + # Prefix source versions with the name of the source package. They + # appear that way in version trees so that we can deal with binary + # packages moving from one source package to another. + if (defined $pheader{'source-version'}) { + addfoundversions($data, $pheader{source}, $pheader{'source-version'}, ''); + } elsif (defined $pheader{version}) { + addfoundversions($data, $pheader{source}, $pheader{version}, ''); + } + writebug($ref, $data); +} elsif (defined $pheader{package}) { + # TODO: could handle Source-Version: by looking up the source package? + addfoundversions($data, $pheader{package}, $pheader{version}, 'binary'); + writebug($ref, $data); +} $veryquiet= $codeletter eq 'Q'; if ($codeletter eq 'M' && !@maintaddrs) { @@ -628,7 +725,7 @@ if (length($resentccval)) { if ($codeletter eq 'U') { &htmllog("Message", "sent on", $data->{originator}, "$gBug#$ref."); - &sendmessage(<{originator},@resentccs); + &sendmessage(<{originator},@resentccs],[@bccs]); Subject: $gBug#$ref: $newsubject Reply-To: $replyto, $ref-quiet\@$gEmailDomain ${orgsender}Resent-To: $data->{originator} @@ -638,15 +735,15 @@ Resent-Sender: $gMaintainerEmail X-$gProject-PR-Message: report $ref X-$gProject-PR-Package: $data->{package} X-$gProject-PR-Keywords: $data->{keywords} -$fwd +${source_pr_header}$fwd END -} elsif ($codeletter eq 'B') { +} elsif ($codeletter eq 'B') { # Sent to submit &htmllog($newref ? "Report" : "Information", "forwarded", join(', ',"$gSubmitList\@$gListDomain",@resentccs), "$gBug#$ref". (length($data->{package})? "; Package ".&sani($data->{package})."" : ''). "."); - &sendmessage(<{package} X-$gProject-PR-Keywords: $data->{keywords} -$fwd +${source_pr_header}$fwd END -} elsif (@resentccs) { +} elsif (@resentccs or @bccs) { # Quiet or Maintainer # D and F done far earlier; B just done - so this must be M or Q # We preserve whichever it was in the Reply-To (possibly adding # the $gBug#). - &htmllog($newref ? "Report" : "Information", "forwarded", - $resentccval, - "$gBug#$ref". - (length($data->{package})? "; Package ".&sani($data->{package})."" : ''). - "."); - &sendmessage(<$gBug#$ref". + (length($data->{package}) ? "; Package ".&sani($data->{package})."" : ''). + "."); + } else { + &htmllog($newref ? "Report" : "Information", "stored", + "", + "$gBug#$ref". + (length($data->{package}) ? "; Package ".&sani($data->{package})."" : ''). + "."); + } + &sendmessage(<{package} X-$gProject-PR-Keywords: $data->{keywords} -$fwd +${source_pr_header}$fwd END } @@ -689,122 +794,154 @@ if (length($resentccval)) { $htmlbreak = " Copy sent to ".&sani($resentccval).".". $htmlbreak; } -if ($newref) { - &htmllog("Acknowledgement","sent",$replyto, - ($veryquiet ? - "New $gBug report received and filed, but not forwarded." : - "New $gBug report received and forwarded."). $htmlbreak); - &sendmessage($veryquiet ? < -In-Reply-To: $header{'message-id'} -References: $header{'message-id'} -Precedence: bulk -X-$gProject-PR-Message: ack-quiet $ref -X-$gProject-PR-Package: $data->{package} -X-$gProject-PR-Keywords: $data->{keywords} -Reply-To: $ref-quiet\@$gEmailDomain - +unless (exists $header{'x-debbugs-no-ack'}) { + if ($newref) { + &htmllog("Acknowledgement","sent",$replyto, + ($veryquiet ? + "New $gBug report received and filed, but not forwarded." : + "New $gBug report received and forwarded."). $htmlbreak); + if ($veryquiet) { + &sendmessage(create_mime_message( + ["X-Loop" => "$gMaintainerEmail", + From => "$gMaintainerEmail ($gProject $gBug Tracking System)", + To => $replyto, + Subject => "$gBug#$ref: Acknowledgement of QUIET report ($subject)", + "Message-ID" => "", + "In-Reply-To" => $header{'message-id'}, + References => $header{'message-id'}, + Precedence => 'bulk', + "X-$gProject-PR-Message" => "ack-quiet $ref", + "X-$gProject-PR-Package" => $data->{package}, + "X-$gProject-PR-Keywords" => $data->{keywords}, + # Only have a X-$gProject-PR-Source when we know the source package + length($source_package)?("X-$gProject-PR-Source" => $source_package):(), + "Reply-To" => "$ref-quiet\@$gEmailDomain", + ],< -In-Reply-To: $header{'message-id'} -References: $header{'message-id'} -Precedence: bulk -X-$gProject-PR-Message: ack-maintonly $ref -X-$gProject-PR-Package: $data->{package} -X-$gProject-PR-Keywords: $data->{keywords} -Reply-To: $ref-maintonly\@$gEmailDomain - + } + elsif ($codeletter eq 'M') { # Maintonly + &sendmessage(create_mime_message( + ["X-Loop" => "$gMaintainerEmail", + From => "$gMaintainerEmail ($gProject $gBug Tracking System)", + To => $replyto, + Subject => "$gBug#$ref: Acknowledgement of maintainer-only report ($subject)", + "Message-ID" => "", + "In-Reply-To" => $header{'message-id'}, + References => $header{'message-id'}, + Precedence => 'bulk', + "X-$gProject-PR-Message" => "ack-maintonly $ref", + "X-$gProject-PR-Package" => $data->{package}, + "X-$gProject-PR-Keywords" => $data->{keywords}, + # Only have a X-$gProject-PR-Source when we know the source package + length($source_package)?("X-$gProject-PR-Source" => $source_package):(), + "Reply-To" => "$ref-maintonly\@$gEmailDomain", + ],< -In-Reply-To: $header{'message-id'} -References: $header{'message-id'} -Precedence: bulk -X-$gProject-PR-Message: ack $ref -X-$gProject-PR-Package: $data->{package} -X-$gProject-PR-Keywords: $data->{keywords} -Reply-To: $ref\@$gEmailDomain - + } + else { + &sendmessage(create_mime_message( + ["X-Loop" => "$gMaintainerEmail", + From => "$gMaintainerEmail ($gProject $gBug Tracking System)", + To => $replyto, + Subject => "$gBug#$ref: Acknowledgement ($subject)", + "Message-ID" => "", + "In-Reply-To" => $header{'message-id'}, + References => $header{'message-id'}, + Precedence => 'bulk', + "X-$gProject-PR-Message" => "ack $ref", + "X-$gProject-PR-Package" => $data->{package}, + "X-$gProject-PR-Keywords" => $data->{keywords}, + # Only have a X-$gProject-PR-Source when we know the source package + length($source_package)?("X-$gProject-PR-Source" => $source_package):(), + "Reply-To" => "$ref\@$gEmailDomain", + ],< -In-Reply-To: $header{'message-id'} -References: $header{'message-id'} -Precedence: bulk -X-$gProject-PR-Message: ack-info-quiet $ref -X-$gProject-PR-Package: $data->{package} -X-$gProject-PR-Keywords: $data->{keywords} -Reply-To: $ref-quiet\@$gEmailDomain - + } + } elsif ($codeletter ne 'U' and + $header{'precedence'} !~ /\b(?:bulk|junk|list)\b/) { + &htmllog("Acknowledgement","sent",$replyto, + ($veryquiet ? "Extra info received and filed, but not forwarded." : + $codeletter eq 'M' ? "Extra info received and forwarded to maintainer." : + "Extra info received and forwarded to list."). $htmlbreak); + if ($veryquiet) { + &sendmessage(create_mime_message( + ["X-Loop" => "$gMaintainerEmail", + From => "$gMaintainerEmail ($gProject $gBug Tracking System)", + To => $replyto, + Subject => "$gBug#$ref: Info received and FILED only (was $subject)", + "Message-ID" => "", + "In-Reply-To" => $header{'message-id'}, + References => $header{'message-id'}, + Precedence => 'bulk', + "X-$gProject-PR-Message" => "ack-info-quiet $ref", + "X-$gProject-PR-Package" => $data->{package}, + "X-$gProject-PR-Keywords" => $data->{keywords}, + # Only have a X-$gProject-PR-Source when we know the source package + length($source_package)?("X-$gProject-PR-Source" => $source_package):(), + "Reply-To" => "$ref-maintonly\@$gEmailDomain", + ],< -In-Reply-To: $header{'message-id'} -References: $header{'message-id'} -Precedence: bulk -X-$gProject-PR-Message: ack-info-maintonly $ref -X-$gProject-PR-Package: $data->{package} -X-$gProject-PR-Keywords: $data->{keywords} -Reply-To: $ref-maintonly\@$gEmailDomain - + } + elsif ($codeletter eq 'M') { + &sendmessage(create_mime_message( + ["X-Loop" => "$gMaintainerEmail", + From => "$gMaintainerEmail ($gProject $gBug Tracking System)", + To => $replyto, + Subject => "$gBug#$ref: Info received for maintainer only (was $subject)", + "Message-ID" => "", + "In-Reply-To" => $header{'message-id'}, + References => "$header{'message-id'} $data->{msgid}", + Precedence => 'bulk', + "X-$gProject-PR-Message" => "ack-info-maintonly $ref", + "X-$gProject-PR-Package" => $data->{package}, + "X-$gProject-PR-Keywords" => $data->{keywords}, + "Reply-To" => "$ref-maintonly\@$gEmailDomain", + ],< -In-Reply-To: $header{'message-id'} -References: $header{'message-id'} -Precedence: bulk -X-$gProject-PR-Message: ack-info $ref -X-$gProject-PR-Package: $data->{package} -X-$gProject-PR-Keywords: $data->{keywords} -Disabled-Doogie-Reply-To: $ref\@$gEmailDomain - + } + else { + &sendmessage(create_mime_message( + ["X-Loop" => "$gMaintainerEmail", + From => "$gMaintainerEmail ($gProject $gBug Tracking System)", + To => $replyto, + Subject => "$gBug#$ref: Info received ($subject)", + "Message-ID" => "", + "In-Reply-To" => $header{'message-id'}, + References => "$header{'message-id'} $data->{msgid}", + Precedence => 'bulk', + "X-$gProject-PR-Message" => "ack-info $ref", + "X-$gProject-PR-Package" => $data->{package}, + "X-$gProject-PR-Keywords" => $data->{keywords}, + # Only have a X-$gProject-PR-Source when we know the source package + length($source_package)?("X-$gProject-PR-Source" => $source_package):(), + "Reply-To" => "$ref\@$gEmailDomain", + ],<>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log (lh): $!"); print(AP "\6\n". - "$whatobj $whatverb to ".&sani($where). - ":
\n". $desc. + "$whatobj $whatverb". + ($where eq '' ? "" : " to ".&sani($where).""). + ":
\n". $desc. "\n\3\n") || &quit("writing db-h/$hash/$ref.log (lh): $!"); close(AP) || &quit("closing db-h/$hash/$ref.log (lh): $!"); } -sub get_addresses { - return - map { $_->address() } - map { Mail::Address->parse($_) } @_; +sub stripbccs { + my $msg = shift; + my $ret = ''; + my $bcc = 0; + while ($msg =~ s/(.*\n)//) { + local $_ = $1; + if (/^$/) { + $ret .= $_; + last; + } + if ($bcc) { + # strip continuation lines too + next if /^\s/; + $bcc = 0; + } + if (/^Bcc:/i) { + $bcc = 1; + } else { + $ret .= $_; + } + } + return $ret . $msg; } +=head2 send_message + + send_message($the_message,\@recipients,\@bcc,$do_not_encode) + +The first argument is the scalar message, the second argument is the +arrayref of recipients, the third is the arrayref of Bcc:'ed +recipients. + +The final argument turns off header encoding and the addition of the +X-Loop header if true, defaults to false. + +=cut + + sub sendmessage { - local ($msg,@recips) = @_; - if ($recips[0] eq '' && $#recips == 0) { @recips= ('-t'); } - $msg = "X-Loop: $gMaintainerEmail\n" . $msg; + my ($msg,$recips,$bcc,$no_encode) = @_; + if (not defined $recips or (!ref($recips) && $recips eq '') + or @$recips == 0) { + $recips = ['-t']; + } + # This is suboptimal. The right solution is to send headers + # separately from the rest of the message and encode them rather + # than doing this. + $msg = "X-Loop: $gMaintainerEmail\n" . $msg unless $no_encode; + # The original message received is written out in appendlog, so + # before writing out the other messages we've sent out, we need to + # RFC1522 encode the header. + $msg = encode_headers($msg) unless $no_encode; my $hash = get_hashname($ref); #save email to the log open(AP,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log (lo): $!"); - print(AP "\2\n",join("\4",@recips),"\n\5\n",@{escapelog($msg)},"\n\3\n") || + print(AP "\2\n",join("\4",@$recips),"\n\5\n", + @{escapelog(stripbccs($msg))},"\n\3\n") || &quit("writing db-h/$hash/$ref.log (lo): $!"); close(AP) || &quit("closing db-h/$hash/$ref.log (lo): $!"); - -#if debbuging.. save email to a log -# open AP, ">>debug"; -# print AP join( '|', @recips )."\n>>"; -# print AP get_addresses( @recips ); -# print AP "<<\n".$msg; -# print AP "\n--------------------------------------------------------\n"; -# close AP; - - #start mailing - $_ = ''; - $SIG{'CHLD'}='chldhandle'; - #print DEBUG "mailing sigchild set up<\n"; - $chldexit = 'no'; - $c= open(U,"-|"); - #print DEBUG "mailing opened pipe fork<\n"; - defined($c) || die $!; - #print DEBUG "mailing opened pipe fork ok $c<\n"; - if (!$c) { # ie, we are in the child process - #print DEBUG "mailing child<\n"; - unless (open(STDERR,">&STDOUT")) { - #print DEBUG "mailing child opened stderr<\n"; - print STDOUT "redirect stderr: $!\n"; - #print DEBUG "mailing child opened stderr fail<\n"; - exit 1; - #print DEBUG "mailing child opened stderr fail exit !?<\n"; - } - #print DEBUG "mailing child opened stderr ok<\n"; - $c= open(D,"|-"); - #print DEBUG "mailing child forked again<\n"; - defined($c) || die $!; - #print DEBUG "mailing child forked again ok $c<\n"; - if (!$c) { # ie, we are the child process - #print DEBUG "mailing grandchild<\n"; - exec '/usr/lib/sendmail','-f'."$gMaintainerEmail",'-odq','-oem','-oi',get_addresses(@recips); - #print DEBUG "mailing grandchild exec failed<\n"; - die $!; - #print DEBUG "mailing grandchild died !?<\n"; - } - #print DEBUG "mailing child not grandchild<\n"; - print(D $msg) || die $!; - #print DEBUG "mailing child printed msg<\n"; - close(D); - #print DEBUG "mailing child closed pipe<\n"; - die "\n*** command returned exit status $?\n" if $?; - #print DEBUG "mailing child exit status ok<\n"; - exit 0; - #print DEBUG "mailing child exited ?!<\n"; + + if (ref($bcc)) { + shift @$recips if $recips->[0] eq '-t'; + push @$recips, @$bcc; } - #print DEBUG "mailing parent<\n"; - $results=''; - #print DEBUG "mailing parent results emptied<\n"; - while( $chldexit eq 'no' ) { $results.= $_; } - #print DEBUG "mailing parent results read >$results<\n"; - close(U); - #print DEBUG "mailing parent results closed<\n"; - $results.= "\n*** child returned exit status $?\n" if $?; - #print DEBUG "mailing parent exit status ok<\n"; - $SIG{'CHLD'}='DEFAULT'; - #print DEBUG "mailing parent sigchild default<\n"; - if (length($results)) { &quit("running sendmail: $results"); } - #print DEBUG "mailing parent results ok<\n"; + + send_mail_message(message => $msg, + # Because we encode the headers above, we do not want to encode them here + encode_headers => 0, + recipients => $recips); } +my $maintainerschecked = 0; sub checkmaintainers { return if $maintainerschecked++; return if !length($data->{package}); @@ -1004,7 +1144,8 @@ sub checkmaintainers { m/^\s*$/ && next; m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers bogus \`$_'"); $a= $1; $b= $2; $a =~ y/A-Z/a-z/; - $maintainerof{$1}= $2; + # use the package which is normalized to lower case; we do this because we lc the pseudo headers. + $maintainerof{$a}= $2; } close(MAINT); open(MAINT,"$gMaintainerFileOverride") || die &quit("maintainers.override open: $!"); @@ -1013,7 +1154,8 @@ sub checkmaintainers { m/^\s*$/ && next; m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers.override bogus \`$_'"); $a= $1; $b= $2; $a =~ y/A-Z/a-z/; - $maintainerof{$1}= $2; + # use the package which is normalized to lower case; we do this because we lc the pseudo headers. + $maintainerof{$a}= $2; } close(MAINT); open(SOURCES,"$gPackageSource") || &quit("pkgsrc open: $!"); @@ -1025,8 +1167,11 @@ sub checkmaintainers { } close(SOURCES); $anymaintfound=0; $anymaintnotfound=0; - for $p (split(m/[ \t?,()]+/,$data->{package})) { + for $p (split(m/[ \t?,():]+/,$data->{package})) { $p =~ y/A-Z/a-z/; + $p =~ /([a-z0-9.+-]+)/; + $p = $1; + next unless defined $p; if (defined $gSubscriptionDomain) { if (defined($pkgsrc{$p})) { push @addsrcaddrs, "$pkgsrc{$p}\@$gSubscriptionDomain"; @@ -1047,4 +1192,63 @@ sub checkmaintainers { last; } } + + if (length $data->{owner}) { + print DEBUG "owner add >$data->{package}|$data->{owner}<\n"; + $addmaint = $data->{owner}; + push(@maintaddrs, $addmaint) unless + $addmaint eq $replyto or grep($_ eq $addmaint, @maintaddrs); + } +} + +=head2 bug_list_forward + + bug_list_forward($spool_filename) if $codeletter eq 'L'; + + +Given the spool file, will forward a bug to the per bug mailing list +subscription system. + +=cut + +sub bug_list_forward{ + my ($bug_fn) = @_; + # Read the bug information and package information for passing to + # the mailing list + my ($bug_number) = $bug_fn =~ /^L(\d+)\./; + my ($bfound, $data)= lockreadbugmerge($bug_number); + my $bug_fh = new IO::File "incoming/P$bug_fn" or die "Unable to open incoming/P$bug_fn $!"; + + local $/ = undef; + my $bug_message = <$bug_fh>; + my ($bug_address) = $bug_message =~ /^Received: \(at ([^\)]+)\) by/; + my ($envelope_from) = $bug_message =~ s/\nFrom\s+([^\s]+)[^\n]+\n/\n/; + if (not defined $envelope_from) { + # Try to use the From: header or something to set it + ($envelope_from) = $bug_message =~ /\nFrom:\s+(.+?)\n/; + # Kludgy, and should really be using a full scale header + # parser to do this. + $envelope_from =~ s/^.+?<([^>]+)>.+$/$1/; + } + my ($header,$body) = split /\n\n/, $bug_message, 2; + # Add X-$gProject-PR-Message: list bug_number, package name, and bug title headers + $header .= qq(\nX-$gProject-PR-Message: list $bug_number\n). + qq(X-$gProject-PR-Package: $data->{package}\n). + qq(X-$gProject-PR-Title: $data->{subject}) + if defined $data; + print STDERR "Tried to loop me with $envelope_from\n" + and exit 1 if $envelope_from =~ /\Q$gListDomain\E|\Q$gEmailDomain\E/; + print DEBUG $envelope_from,qq(\n); + # If we don't have a bug address, something has gone horribly wrong. + print STDERR "Doesn't match: $bug_address\n" and exit 1 unless defined $bug_address; + $bug_address =~ s/\@.+//; + print DEBUG "Sending message to bugs=$bug_address\@$gListDomain\n"; + print DEBUG $header.qq(\n\n).$body; + send_mail_message(message => $header.qq(\n\n).$body, + recipients => ["bugs=$bug_address\@$gListDomain"], + envelope_from => $envelope_from, + encode_headers => 0, + ); + unlink("incoming/P$bug_fn") || &quit("unlinking incoming/P$bug_fn: $!"); + exit 0; }