2 # $Id: process.in,v 1.95 2005/07/19 11:00:28 cjwatson Exp $
7 use POSIX qw(strftime tzset);
12 use Debbugs::MIME qw(decode_rfc1522);
14 $config_path = '/etc/debbugs';
15 $lib_path = '/usr/lib/debbugs';
17 require "$config_path/config";
18 require "$lib_path/errorlib";
19 $ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};
21 chdir( "$gSpoolDir" ) || die "chdir spool: $!\n";
23 #open(DEBUG,"> /tmp/debbugs.debug");
25 open DEBUG, ">/dev/null";
27 defined( $intdate= time ) || &quit( "failed to get time: $!" );
30 m/^([BMQFDU])(\d*)\.\d+$/ || &quit("bad argument");
32 $tryref= length($2) ? $2+0 : -1;
35 if (!rename("incoming/G$nn","incoming/P$nn"))
37 $_=$!.''; m/no such file or directory/i && exit 0;
38 &quit("renaming to lock: $!");
41 $baddress= 'submit' if $codeletter eq 'B';
42 $baddress= 'maintonly' if $codeletter eq 'M';
43 $baddress= 'quiet' if $codeletter eq 'Q';
44 $baddress= 'forwarded' if $codeletter eq 'F';
45 $baddress= 'done' if $codeletter eq 'D';
46 $baddress= 'submitter' if $codeletter eq 'U';
47 $baddress || &quit("bad codeletter $codeletter");
48 $baddressroot= $baddress;
49 $baddress= "$tryref-$baddress" if $tryref>=0;
51 open(M,"incoming/P$nn");
58 print DEBUG "###\n",join("##\n",@msg),"\n###\n";
60 $tdate = strftime "%a, %d %h %Y %T UTC", localtime;
62 Received: via spool by $baddress\@$gEmailDomain id=$nn
63 (code $codeletter ref $tryref); $tdate
66 # header and decoded body respectively
67 my (@headerlines, @bodylines);
69 my $parser = new MIME::Parser;
70 mkdir "$gSpoolDir/mime.tmp", 0777;
71 $parser->output_under("$gSpoolDir/mime.tmp");
72 my $entity = eval { $parser->parse_data(join('',@log)) };
74 if ($entity and $entity->head->tags) {
75 @headerlines = @{$entity->head->header};
78 my $entity_body = getmailbody($entity);
79 @bodylines = $entity_body ? $entity_body->as_lines() : ();
82 # set $i to beginning of encoded body data, so we can dump it out
85 ++$i while $msg[$i] =~ /./;
87 # Legacy pre-MIME code, kept around in case MIME::Parser fails.
88 for ($i = 0; $i <= $#msg; $i++) {
90 last unless length($_);
91 while ($msg[$i+1] =~ m/^\s/) {
95 push @headerlines, $_;
98 @bodylines = @msg[$i..$#msg];
101 for my $hdr (@headerlines) {
104 &finish if m/^x-loop: (\S+)$/i && $1 eq "$gMaintainerEmail";
105 my $ins = !m/^subject:/i && !m/^reply-to:/i && !m/^return-path:/i
106 && !m/^From / && !m/^X-Debbugs-/i;
107 $fwd .= $hdr."\n" if $ins;
108 # print DEBUG ">$_<\n";
109 if (s/^(\S+):\s*//) {
111 print DEBUG ">$v=$_<\n";
112 $header{$v} = decode_rfc1522($_);
114 print DEBUG "!>$_<\n";
119 shift @bodylines while @bodylines and $bodylines[0] !~ /\S/;
121 # Strip off RFC2440-style PGP clearsigning.
122 if (@bodylines and $bodylines[0] =~ /^-----BEGIN PGP SIGNED/) {
123 shift @bodylines while @bodylines and length $bodylines[0];
124 shift @bodylines while @bodylines and $bodylines[0] !~ /\S/;
125 for my $findsig (0 .. $#bodylines) {
126 if ($bodylines[$findsig] =~ /^-----BEGIN PGP SIGNATURE/) {
127 $#bodylines = $findsig - 1;
131 map { s/^- // } @bodylines;
134 # extract pseudo-headers
135 for my $phline (@bodylines)
137 last if $phline !~ m/^([\w-]+):\s*(\S.*)/;
138 my ($fn, $fv) = ($1, $2);
140 print DEBUG ">$fn|$fv|\n";
144 print DEBUG ">$fn~$fv<\n";
148 $fwd .= join("\n",@msg[$i..$#msg]);
150 print DEBUG "***\n$fwd\n***\n";
152 if (defined $header{'resent-from'} && !defined $header{'from'}) {
153 $header{'from'} = $header{'resent-from'};
155 defined($header{'from'}) || &quit("no From header");
157 $replyto = $header{'reply-to'};
158 $replyto = '' unless defined $replyto;
161 unless (length $replyto) {
162 $replyto = $header{'from'};
166 $_= "$2 <$1>" if m/^([^\<\> \t\n\(\)]+) \(([^\(\)\<\>]+)\)$/;
168 print DEBUG "replytocompare >$replytocompare<\n";
170 if (!defined($header{'subject'}))
174 Your message did not contain a Subject field. They are recommended and
175 useful because the title of a $gBug is determined using this field.
176 Please remember to include a Subject field in your messages in future.
179 # RFC822 actually lists it as an `optional-field'.
181 $subject= '(no subject)';
183 $subject= $header{'subject'};
187 $subject =~ s/^Re:\s*//i; $_= $subject."\n";
188 if ($tryref < 0 && m/^Bug ?\#(\d+)\D/i) {
194 ($bfound, $data)= &lockreadbugmerge($tryref);
198 &htmllog("Reply","sent", $replyto,"Unknown problem report number <code>$tryref</code>.");
199 my $archivenote = '';
201 $archivenote = <<END;
202 This may be because that $gBug report has been resolved for more than $gRemoveAge
203 days, and the record of it has been archived and made read-only, or
204 because you mistyped the $gBug report number.
208 &sendmessage(<<END, '');
209 From: $gMaintainerEmail ($gProject $gBug Tracking System)
211 Subject: Unknown problem report $gBug#$tryref ($subject)
212 Message-ID: <handler.x.$nn.unknown\@$gEmailDomain>
213 In-Reply-To: $header{'message-id'}
214 References: $header{'message-id'} $data->{msgid}
216 X-$gProject-PR-Message: error
218 You sent a message to the $gBug tracking system which gave (in the
219 Subject line or encoded into the recipient at $gEmailDomain),
220 the number of a nonexistent $gBug report (#$tryref).
222 ${archivenote}Your message was dated $header{'date'} and was sent to
223 $baddress\@$gEmailDomain. It had
224 Message-ID $header{'message-id'}
225 and Subject $subject.
227 It has been filed (under junk) but otherwise ignored.
229 Please consult your records to find the correct $gBug report number, or
230 contact me, the system administrator, for assistance.
233 (administrator, $gProject $gBugs database)
235 (NB: If you are a system administrator and have no idea what I am
236 talking about this indicates a serious mail system misconfiguration
237 somewhere. Please contact me immediately.)
244 &filelock('lock/-1');
247 if ($codeletter eq 'D' || $codeletter eq 'F')
249 if ($replyto =~ m/$gBounceFroms/o ||
250 $header{'from'} =~ m/$gBounceFroms/o)
252 &quit("bounce detected ! Mwaap! Mwaap!");
254 $markedby= $header{'from'} eq $replyto ? $replyto :
255 "$header{'from'} (reply to $replyto)";
256 if ($codeletter eq 'F') {
257 (&appendlog,&finish) if length($data->{forwarded});
258 $receivedat= "forwarded\@$gEmailDomain";
259 $markaswhat= 'forwarded';
260 $set_forwarded= $header{'to'};
261 if ( length( $gListDomain ) > 0 && length( $gForwardList ) > 0 ) {
262 $generalcc= "$gForwardList\@$gListDomain";
267 if (length($data->{done}) and
268 not defined $pheader{'source-version'} and
269 not defined $pheader{'version'}) {
273 $receivedat= "done\@$gEmailDomain";
275 $set_done= $header{'from'};
276 if ( length( $gListDomain ) > 0 && length( $gDoneList ) > 0 ) {
277 $generalcc= "$gDoneList\@$gListDomain";
282 if (defined $gStrongList and isstrongseverity($data->{severity})) {
283 $generalcc = join ', ', $generalcc, "$gStrongList\@$gListDomain";
286 &htmllog("Warning","sent",$replyto,"Message ignored.");
287 &sendmessage(<<END, '');
288 From: $gMaintainerEmail ($gProject $gBug Tracking System)
290 Subject: Message with no $gBug number ignored by $receivedat
292 Message-ID: <header.x.$nn.warnignore\@$gEmailDomain>
293 In-Reply-To: $header{'message-id'}
294 References: $header{'message-id'} $data->{msgid}
296 X-$gProject-PR-Message: error
298 You sent a message to the $gProject $gBug tracking system old-style
299 unified mark as $markaswhat address ($receivedat),
300 without a recognisable $gBug number in the Subject.
301 Your message has been filed under junk but otherwise ignored.
303 If you don't know what I'm talking about then probably either:
305 (a) you unwittingly sent a message to done\@$gEmailDomain
306 because you replied to all recipients of the message a developer used
307 to mark a $gBug as done and you modified the Subject. In this case,
308 please do not be alarmed. To avoid confusion do not do it again, but
309 there is no need to apologise or mail anyone asking for an explanation.
311 (b) you are a system administrator, reading this because the $gBug
312 tracking system is responding to a misdirected bounce message. In this
313 case there is a serious mail system misconfiguration somewhere - please
314 contact me immediately.
316 Your message was dated $header{'date'} and had
317 message-id $header{'message-id'}
318 and subject $subject.
320 If you need any assistance or explanation please contact me.
323 (administrator, $gProject $gBugs database)
332 $noticeccval.= join(', ', grep($_ ne $replyto,@maintaddrs));
333 $noticeccval =~ s/\s+\n\s+/ /g;
334 $noticeccval =~ s/^\s+/ /; $noticeccval =~ s/\s+$//;
336 $generalcc = join(', ', $generalcc, @addsrcaddrs);
337 $generalcc =~ s/\s+\n\s+/ /g;
338 $generalcc =~ s/^\s+/ /; $generalcc =~ s/\s+$//;
340 if (length($noticeccval)) { $noticecc= "Cc: $noticeccval\n"; }
341 if (length($generalcc)) { $noticecc.= "Bcc: $generalcc\n"; }
343 @process= ($ref,split(/ /,$data->{mergedwith}));
346 for $ref (@process) {
347 if ($ref != $orgref) {
349 $data = &lockreadbug($ref)
350 || die "huh ? $ref from $orgref out of @process";
352 $data->{done}= $set_done if defined($set_done);
353 $data->{forwarded}= $set_forwarded if defined($set_forwarded);
354 if ($codeletter eq 'D') {
355 $data->{keywords} = join ' ', grep $_ ne 'pending',
356 split ' ', $data->{keywords};
357 if (defined $pheader{'source-version'}) {
358 addfixedversions($data, $pheader{source}, $pheader{'source-version'});
359 } elsif (defined $pheader{version}) {
360 addfixedversions($data, undef, $pheader{version});
364 writebug($ref, $data);
366 my $hash = get_hashname($ref);
367 open(O,"db-h/$hash/$ref.report") || &quit("read original report: $!");
368 $x= join('',<O>); close(O);
369 if ($codeletter eq 'F') {
370 &htmllog("Reply","sent",$replyto,"You have marked $gBug as forwarded.");
371 &sendmessage(<<END."---------------------------------------\n".join( "\n", @msg ), '');
372 From: $gMaintainerEmail ($gProject $gBug Tracking System)
374 ${noticecc}Subject: $gBug#$ref: marked as forwarded ($data->{subject})
375 Message-ID: <header.$ref.$nn.ackfwdd\@$gEmailDomain>
376 In-Reply-To: $header{'message-id'}
377 References: $header{'message-id'} $data->{msgid}
379 X-$gProject-PR-Message: forwarded $ref
380 X-$gProject-PR-Package: $data->{package}
381 X-$gProject-PR-Keywords: $data->{keywords}
383 Your message dated $header{'date'}
384 with message-id $header{'message-id'}
385 has caused the $gProject $gBug report #$ref,
386 regarding $data->{subject}
387 to be marked as having been forwarded to the upstream software
388 author(s) $data->{forwarded}.
390 (NB: If you are a system administrator and have no idea what I am
391 talking about this indicates a serious mail system misconfiguration
392 somewhere. Please contact me immediately.)
395 (administrator, $gProject $gBugs database)
400 &htmllog("Reply","sent",$replyto,"You have taken responsibility.");
401 &sendmessage(<<END."--------------------------------------\n".$x."---------------------------------------\n".join( "\n", @msg ), '');
402 From: $gMaintainerEmail ($gProject $gBug Tracking System)
404 ${noticecc}Subject: $gBug#$ref: marked as done ($data->{subject})
405 Message-ID: <handler.$ref.$nn.ackdone\@$gEmailDomain>
406 In-Reply-To: $header{'message-id'}
407 References: $header{'message-id'} $data->{msgid}
409 X-$gProject-PR-Message: closed $ref
410 X-$gProject-PR-Package: $data->{package}
411 X-$gProject-PR-Keywords: $data->{keywords}
413 Your message dated $header{'date'}
414 with message-id $header{'message-id'}
415 and subject line $subject
416 has caused the attached $gBug report to be marked as done.
418 This means that you claim that the problem has been dealt with.
419 If this is not the case it is now your responsibility to reopen the
420 $gBug report if necessary, and/or fix the problem forthwith.
422 (NB: If you are a system administrator and have no idea what I am
423 talking about this indicates a serious mail system misconfiguration
424 somewhere. Please contact me immediately.)
427 (administrator, $gProject $gBugs database)
430 &htmllog("Notification","sent",$data->{originator},
431 "$gBug acknowledged by developer.");
432 &sendmessage(<<END.join("\n",@msg),'');
433 From: $gMaintainerEmail ($gProject $gBug Tracking System)
434 To: $data->{originator}
435 Subject: $gBug#$ref acknowledged by developer
437 Message-ID: <handler.$ref.$nn.notifdone\@$gEmailDomain>
438 In-Reply-To: $data->{msgid}
439 References: $header{'message-id'} $data->{msgid}
440 X-$gProject-PR-Message: they-closed $ref
441 X-$gProject-PR-Package: $data->{package}
442 X-$gProject-PR-Keywords: $data->{keywords}
443 Reply-To: $ref\@$gEmailDomain
445 This is an automatic notification regarding your $gBug report
446 #$ref: $data->{subject},
447 which was filed against the $data->{package} package.
449 It has been closed by one of the developers, namely
452 Their explanation is attached below. If this explanation is
453 unsatisfactory and you have not received a better one in a separate
454 message then please contact the developer, by replying to this email.
457 (administrator, $gProject $gBugs database)
467 if ($codeletter eq 'U') {
468 &htmllog("Warning","sent",$replyto,"Message not forwarded.");
469 &sendmessage(<<END, '');
470 From: $gMaintainerEmail ($gProject $gBug Tracking System)
472 Subject: Message with no $gBug number cannot be sent to submitter !
474 Message-ID: <handler.x.$nn.nonumnosub\@$gEmailDomain>
475 In-Reply-To: $header{'message-id'}
476 References: $header{'message-id'} $data->{msgid}
478 X-$gProject-PR-Message: error
480 You sent a message to the $gProject $gBug tracking system's $gBug
481 report submitter address $baddress\@$gEmailDomain, without a
482 recognisable $gBug number in the Subject. Your message has been filed
483 under junk but otherwise ignored.
485 If you don't know what I'm talking about then probably either:
487 (a) you unwittingly sent a message to $baddress\@$gEmailDomain
488 because you replied to all recipients of the message a developer sent
489 to a $gBug\'s submitter and you modified the Subject. In this case,
490 please do not be alarmed. To avoid confusion do not do it again, but
491 there is no need to apologise or mail anyone asking for an
494 (b) you are a system administrator, reading this because the $gBug
495 tracking system is responding to a misdirected bounce message. In this
496 case there is a serious mail system misconfiguration somewhere - please
497 contact me immediately.
499 Your message was dated $header{'date'} and had
500 message-id $header{'message-id'}
501 and subject $subject.
503 If you need any assistance or explanation please contact me.
506 (administrator, $gProject $gBugs database)
513 $data->{found_versions} = [];
514 $data->{fixed_versions} = [];
516 if (defined $pheader{source}) {
517 $data->{package} = $pheader{source};
518 } elsif (defined $pheader{package}) {
519 $data->{package} = $pheader{package};
521 &htmllog("Warning","sent",$replyto,"Message not forwarded.");
522 &sendmessage(<<END."---------------------------------------------------------------------------\n".join("\n", @msg), '');
523 From: $gMaintainerEmail ($gProject $gBug Tracking System)
525 Subject: Message with no Package: tag cannot be processed!
527 Message-ID: <handler.x.$nn.nonumnosub\@$gEmailDomain>
528 In-Reply-To: $header{'message-id'}
529 References: $header{'message-id'} $data->{msgid}
531 X-$gProject-PR-Message: error
533 Your message didn't have a Package: line at the start (in the
534 pseudo-header following the real mail header), or didn't have a
535 pseudo-header at all. Your message has been filed under junk but
538 This makes it much harder for us to categorise and deal with your
539 problem report. Please _resubmit_ your report to $baddress\@$gEmailDomain
540 and tell us which package the report is on. For help, check out
541 http://$gWebDomain/Reporting$gHTMLSuffix.
543 Your message was dated $header{'date'} and had
544 message-id $header{'message-id'}
545 and subject $subject.
546 The complete text of it is attached to this message.
548 If you need any assistance or explanation please contact me.
551 (administrator, $gProject $gBugs database)
558 $data->{keywords}= '';
559 if (defined($pheader{'keywords'})) {
560 $data->{keywords}= $pheader{'keywords'};
561 } elsif (defined($pheader{'tags'})) {
562 $data->{keywords}= $pheader{'tags'};
564 if (length($data->{keywords})) {
566 my %gkws = map { ($_, 1) } @gTags;
567 foreach my $kw (sort split(/[,\s]+/, lc($data->{keywords}))) {
568 push @kws, $kw if (defined $gkws{$kw});
570 $data->{keywords} = join(" ", @kws);
572 $data->{severity}= '';
573 if (defined($pheader{'severity'}) || defined($pheader{'priority'})) {
574 $data->{severity}= $pheader{'severity'};
575 $data->{severity}= $pheader{'priority'} unless ($data->{severity});
576 $data->{severity} =~ s/^\s*(.+)\s*$/$1/;
578 if (!grep($_ eq $data->{severity}, @severities, "$gDefaultSeverity")) {
581 Your message specified a Severity: in the pseudo-header, but
582 the severity value $data->{severity} was not recognised.
583 The default severity $gDefaultSeverity is being used instead.
584 The recognised values are: $gShowSeverities.
586 # if we use @gSeverityList array in the above line, perl -c gives:
587 # In string, @gSeverityList now must be written as \@gSeverityList at
588 # process line 452, near "$gDefaultSeverity is being used instead.
589 $data->{severity}= '';
592 if (defined($pheader{owner})) {
593 $data->{owner}= $pheader{owner};
595 &filelock("nextnumber.lock");
596 open(N,"nextnumber") || &quit("nextnumber: read: $!");
597 $v=<N>; $v =~ s/\n$// || &quit("nextnumber bad format");
598 $ref= $v+0; $v += 1; $newref=1;
599 &overwrite('nextnumber', "$v\n");
601 my $hash = get_hashname($ref);
602 &overwrite("db-h/$hash/$ref.log",'');
603 $data->{originator} = $replyto;
604 $data->{date} = $intdate;
605 $data->{subject} = $subject;
606 $data->{msgid} = $header{'message-id'};
607 writebug($ref, $data);
608 &overwrite("db-h/$hash/$ref.report",
609 join("\n",@msg)."\n");
614 print DEBUG "maintainers >@maintaddrs<\n";
616 $orgsender= defined($header{'sender'}) ? "Original-Sender: $header{'sender'}\n" : '';
617 $newsubject= $subject; $newsubject =~ s/^$gBug#$ref:*\s*//;
619 $xcchdr= $header{ 'x-debbugs-cc' };
620 if ($xcchdr =~ m/\S/) {
621 push(@resentccs,$xcchdr);
622 $resentccexplain.= <<END;
624 As you requested using X-Debbugs-CC, your message was also forwarded to
626 (after having been given a $gBug report number, if it did not have one).
630 if (@maintaddrs && ($codeletter eq 'B' || $codeletter eq 'M')) {
631 push(@resentccs,@maintaddrs);
632 $resentccexplain.= <<END." ".join("\n ",@maintaddrs)."\n";
634 Your message has been sent to the package maintainer(s):
638 @bccs = @addsrcaddrs;
639 if (defined $gStrongList and isstrongseverity($data->{severity})) {
640 push @bccs, "$gStrongList\@$gListDomain";
643 if (defined $pheader{source}) {
644 # Prefix source versions with the name of the source package. They
645 # appear that way in version trees so that we can deal with binary
646 # packages moving from one source package to another.
647 if (defined $pheader{'source-version'}) {
648 addfoundversions($data, $pheader{source}, $pheader{'source-version'});
649 } elsif (defined $pheader{version}) {
650 addfoundversions($data, $pheader{source}, $pheader{version});
652 writebug($ref, $data);
653 } elsif (defined $pheader{package}) {
654 # TODO: could handle Source-Version: by looking up the source package?
655 addfoundversions($data, undef, $pheader{version}) if defined($pheader{version});
656 writebug($ref, $data);
659 $veryquiet= $codeletter eq 'Q';
660 if ($codeletter eq 'M' && !@maintaddrs) {
664 You requested that the message be sent to the package maintainer(s)
665 but either the $gBug report is not associated with any package (probably
666 because of a missing Package pseudo-header field in the original $gBug
667 report), or the package(s) specified do not have any maintainer(s).
669 Your message has *not* been sent to any package maintainers; it has
670 merely been filed in the $gBug tracking system. If you require assistance
671 please contact $gMaintainerEmail quoting the $gBug number $ref.
675 $resentccval.= join(', ',@resentccs);
676 $resentccval =~ s/\s+\n\s+/ /g; $resentccval =~ s/^\s+/ /; $resentccval =~ s/\s+$//;
677 if (length($resentccval)) {
678 $resentcc= "Resent-CC: $resentccval\n";
681 if ($codeletter eq 'U') {
682 &htmllog("Message", "sent on", $data->{originator}, "$gBug#$ref.");
683 &sendmessage(<<END,[$data->{originator},@resentccs],[@bccs]);
684 Subject: $gBug#$ref: $newsubject
685 Reply-To: $replyto, $ref-quiet\@$gEmailDomain
686 ${orgsender}Resent-To: $data->{originator}
687 ${resentcc}Resent-Date: $tdate
688 Resent-Message-ID: <handler.$ref.$nn\@$gEmailDomain>
689 Resent-Sender: $gMaintainerEmail
690 X-$gProject-PR-Message: report $ref
691 X-$gProject-PR-Package: $data->{package}
692 X-$gProject-PR-Keywords: $data->{keywords}
695 } elsif ($codeletter eq 'B') {
696 &htmllog($newref ? "Report" : "Information", "forwarded",
697 join(', ',"$gSubmitList\@$gListDomain",@resentccs),
698 "<code>$gBug#$ref</code>".
699 (length($data->{package})? "; Package <code>".&sani($data->{package})."</code>" : '').
701 &sendmessage(<<END,["$gSubmitList\@$gListDomain",@resentccs],[@bccs]);
702 Subject: $gBug#$ref: $newsubject
703 Reply-To: $replyto, $ref\@$gEmailDomain
704 Resent-From: $header{'from'}
705 ${orgsender}Resent-To: $gSubmitList\@$gListDomain
706 ${resentcc}Resent-Date: $tdate
707 Resent-Message-ID: <handler.$ref.$nn\@$gEmailDomain>
708 Resent-Sender: $gMaintainerEmail
709 X-$gProject-PR-Message: report $ref
710 X-$gProject-PR-Package: $data->{package}
711 X-$gProject-PR-Keywords: $data->{keywords}
714 } elsif (@resentccs or @bccs) {
715 # D and F done far earlier; B just done - so this must be M or Q
716 # We preserve whichever it was in the Reply-To (possibly adding
719 &htmllog($newref ? "Report" : "Information", "forwarded",
721 "<code>$gBug#$ref</code>".
722 (length($data->{package}) ? "; Package <code>".&sani($data->{package})."</code>" : '').
725 &htmllog($newref ? "Report" : "Information", "stored",
727 "<code>$gBug#$ref</code>".
728 (length($data->{package}) ? "; Package <code>".&sani($data->{package})."</code>" : '').
731 &sendmessage(<<END,[@resentccs],[@bccs]);
732 Subject: $gBug#$ref: $newsubject
733 Reply-To: $replyto, $ref-$baddressroot\@$gEmailDomain
734 Resent-From: $header{'from'}
735 ${orgsender}Resent-To: $resentccval
737 Resent-Message-ID: <handler.$ref.$nn\@$gEmailDomain>
738 Resent-Sender: $gMaintainerEmail
739 X-$gProject-PR-Message: report $ref
740 X-$gProject-PR-Package: $data->{package}
741 X-$gProject-PR-Keywords: $data->{keywords}
746 $htmlbreak= length($brokenness) ? "<p>\n".&sani($brokenness)."\n<p>\n" : '';
747 $htmlbreak =~ s/\n\n/\n<P>\n\n/g;
748 if (length($resentccval)) {
749 $htmlbreak = " Copy sent to <code>".&sani($resentccval)."</code>.".
752 unless (exists $header{'x-debbugs-no-ack'}) {
754 &htmllog("Acknowledgement","sent",$replyto,
756 "New $gBug report received and filed, but not forwarded." :
757 "New $gBug report received and forwarded."). $htmlbreak);
758 &sendmessage($veryquiet ? <<END : $codeletter eq 'M' ? <<END : <<END,'');
759 From: $gMaintainerEmail ($gProject $gBug Tracking System)
761 Subject: $gBug#$ref: Acknowledgement of QUIET report
763 Message-ID: <handler.$ref.$nn.ackquiet\@$gEmailDomain>
764 In-Reply-To: $header{'message-id'}
765 References: $header{'message-id'}
767 X-$gProject-PR-Message: ack-quiet $ref
768 X-$gProject-PR-Package: $data->{package}
769 X-$gProject-PR-Keywords: $data->{keywords}
770 Reply-To: $ref-quiet\@$gEmailDomain
772 Thank you for the problem report you have sent regarding $gProject.
773 This is an automatically generated reply, to let you know your message
774 has been received. It has not been forwarded to the package maintainers
775 or other interested parties; you should ensure that the developers are
776 aware of the problem you have entered into the system - preferably
777 quoting the $gBug reference number, #$ref.
779 If you wish to submit further information on your problem, please send it
780 to $ref-$baddressroot\@$gEmailDomain (and *not*
781 to $baddress\@$gEmailDomain).
783 Please do not reply to the address at the top of this message,
784 unless you wish to report a problem with the $gBug-tracking system.
787 (administrator, $gProject $gBugs database)
789 From: $gMaintainerEmail ($gProject $gBug Tracking System)
791 Subject: $gBug#$ref: Acknowledgement of maintainer-only report
793 Message-ID: <handler.$ref.$nn.ackmaint\@$gEmailDomain>
794 In-Reply-To: $header{'message-id'}
795 References: $header{'message-id'}
797 X-$gProject-PR-Message: ack-maintonly $ref
798 X-$gProject-PR-Package: $data->{package}
799 X-$gProject-PR-Keywords: $data->{keywords}
800 Reply-To: $ref-maintonly\@$gEmailDomain
802 Thank you for the problem report you have sent regarding $gProject.
803 This is an automatically generated reply, to let you know your message has
804 been received. It is being forwarded to the package maintainers (but not
805 other interested parties, as you requested) for their attention; they will
808 If you wish to submit further information on your problem, please send
809 it to $ref-$baddressroot\@$gEmailDomain (and *not*
810 to $baddress\@$gEmailDomain).
812 Please do not reply to the address at the top of this message,
813 unless you wish to report a problem with the $gBug-tracking system.
816 (administrator, $gProject $gBugs database)
818 From: $gMaintainerEmail ($gProject $gBug Tracking System)
820 Subject: $gBug#$ref: Acknowledgement ($subject)
821 Message-ID: <handler.$ref.$nn.ack\@$gEmailDomain>
822 In-Reply-To: $header{'message-id'}
823 References: $header{'message-id'}
825 X-$gProject-PR-Message: ack $ref
826 X-$gProject-PR-Package: $data->{package}
827 X-$gProject-PR-Keywords: $data->{keywords}
828 Reply-To: $ref\@$gEmailDomain
830 Thank you for the problem report you have sent regarding $gProject.
831 This is an automatically generated reply, to let you know your message has
832 been received. It is being forwarded to the package maintainers and other
833 interested parties for their attention; they will reply in due course.
835 If you wish to submit further information on your problem, please send
836 it to $ref\@$gEmailDomain (and *not* to
837 $baddress\@$gEmailDomain).
839 Please do not reply to the address at the top of this message,
840 unless you wish to report a problem with the $gBug-tracking system.
843 (administrator, $gProject $gBugs database)
845 } elsif ($codeletter ne 'U' and
846 $header{'precedence'} !~ /\b(?:bulk|junk|list)\b/) {
847 &htmllog("Acknowledgement","sent",$replyto,
848 ($veryquiet ? "Extra info received and filed, but not forwarded." :
849 $codeletter eq 'M' ? "Extra info received and forwarded to maintainer." :
850 "Extra info received and forwarded to list."). $htmlbreak);
851 &sendmessage($veryquiet ? <<END : $codeletter eq 'M' ? <<END : <<END,'');
852 From: $gMaintainerEmail ($gProject $gBug Tracking System)
854 Subject: $gBug#$ref: Info received and FILED only
856 Message-ID: <handler.$ref.$nn.ackinfoquiet\@$gEmailDomain>
857 In-Reply-To: $header{'message-id'}
858 References: $header{'message-id'}
860 X-$gProject-PR-Message: ack-info-quiet $ref
861 X-$gProject-PR-Package: $data->{package}
862 X-$gProject-PR-Keywords: $data->{keywords}
863 Reply-To: $ref-quiet\@$gEmailDomain
865 Thank you for the additional information you have supplied regarding
866 this problem report. It has NOT been forwarded to the package
867 maintainers, but will accompany the original report in the $gBug
868 tracking system. Please ensure that you yourself have sent a copy of
869 the additional information to any relevant developers or mailing lists.
871 If you wish to continue to submit further information on your problem,
872 please send it to $ref-$baddressroot\@$gEmailDomain, as before.
874 Please do not reply to the address at the top of this message,
875 unless you wish to report a problem with the $gBug-tracking system.
878 (administrator, $gProject $gBugs database)
880 From: $gMaintainerEmail ($gProject $gBug Tracking System)
882 Subject: $gBug#$ref: Info received for maintainer only
884 Message-ID: <handler.$ref.$nn.ackinfomaint\@$gEmailDomain>
885 In-Reply-To: $header{'message-id'}
886 References: $header{'message-id'}
888 X-$gProject-PR-Message: ack-info-maintonly $ref
889 X-$gProject-PR-Package: $data->{package}
890 X-$gProject-PR-Keywords: $data->{keywords}
891 Reply-To: $ref-maintonly\@$gEmailDomain
893 Thank you for the additional information you have supplied regarding
894 this problem report. It has been forwarded to the package maintainer(s)
895 (but not to other interested parties) to accompany the original report.
897 If you wish to continue to submit further information on your problem,
898 please send it to $ref-$baddressroot\@$gEmailDomain, as before.
900 Please do not reply to the address at the top of this message,
901 unless you wish to report a problem with the $gBug-tracking system.
904 (administrator, $gProject $gBugs database)
906 From: $gMaintainerEmail ($gProject $gBug Tracking System)
908 Subject: $gBug#$ref: Info received (was $subject)
909 Message-ID: <handler.$ref.$nn.ackinfo\@$gEmailDomain>
910 In-Reply-To: $header{'message-id'}
911 References: $header{'message-id'}
913 X-$gProject-PR-Message: ack-info $ref
914 X-$gProject-PR-Package: $data->{package}
915 X-$gProject-PR-Keywords: $data->{keywords}
917 Thank you for the additional information you have supplied regarding
918 this problem report. It has been forwarded to the package maintainer(s)
919 and to other interested parties to accompany the original report.
921 If you wish to continue to submit further information on your problem,
922 please send it to $ref\@$gEmailDomain, as before.
924 Please do not reply to the address at the top of this message,
925 unless you wish to report a problem with the $gBug-tracking system.
928 (administrator, $gProject $gBugs database)
930 # Reply-To: in previous ack disabled by doogie due to mail loops.
931 # Are these still a concern?
932 # Reply-To: $ref\@$gEmailDomain
941 open(NEW,">$f.new") || &quit("$f.new: create: $!");
942 print(NEW "$v") || &quit("$f.new: write: $!");
943 close(NEW) || &quit("$f.new: close: $!");
944 rename("$f.new","$f") || &quit("rename $f.new to $f: $!");
948 my $hash = get_hashname($ref);
949 if (!open(AP,">>db-h/$hash/$ref.log")) {
950 print DEBUG "failed open log<\n";
951 print DEBUG "failed open log err $!<\n";
952 &quit("opening db-h/$hash/$ref.log (li): $!");
954 print(AP "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/$hash/$ref.log (li): $!");
955 close(AP) || &quit("closing db-h/$hash/$ref.log (li): $!");
959 utime(time,time,"db");
961 while ($u= $cleanups[$#cleanups]) { &$u; }
962 unlink("incoming/P$nn") || &quit("unlinking incoming/P$nn: $!");
966 &quit("wot no exit");
968 sub chldhandle { $chldexit = 'yes'; }
971 local ($whatobj,$whatverb,$where,$desc) = @_;
972 my $hash = get_hashname($ref);
973 open(AP,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log (lh): $!");
976 "<strong>$whatobj $whatverb</strong>".
977 ($where eq '' ? "" : " to <code>".&sani($where)."</code>").
979 "\n\3\n") || &quit("writing db-h/$hash/$ref.log (lh): $!");
980 close(AP) || &quit("closing db-h/$hash/$ref.log (lh): $!");
987 while ($msg =~ s/(.*\n)//) {
994 # strip continuation lines too
1008 local ($msg,$recips,$bcc) = @_;
1009 if ((!ref($recips) && $recips eq '') || @$recips == 0) {
1012 $msg = "X-Loop: $gMaintainerEmail\n" . $msg;
1014 my $hash = get_hashname($ref);
1015 #save email to the log
1016 open(AP,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log (lo): $!");
1017 print(AP "\2\n",join("\4",@$recips),"\n\5\n",
1018 @{escapelog(stripbccs($msg))},"\n\3\n") ||
1019 &quit("writing db-h/$hash/$ref.log (lo): $!");
1020 close(AP) || &quit("closing db-h/$hash/$ref.log (lo): $!");
1023 shift @$recips if $recips->[0] eq '-t';
1024 push @$recips, @$bcc;
1027 #if debugging.. save email to a log
1028 # open AP, ">>debug";
1029 # print AP join( '|', @$recips )."\n>>";
1030 # print AP get_addresses( @$recips );
1031 # print AP "<<\n".$msg;
1032 # print AP "\n--------------------------------------------------------\n";
1037 $SIG{'CHLD'}='chldhandle';
1038 #print DEBUG "mailing sigchild set up<\n";
1041 #print DEBUG "mailing opened pipe fork<\n";
1042 defined($c) || die $!;
1043 #print DEBUG "mailing opened pipe fork ok $c<\n";
1044 if (!$c) { # ie, we are in the child process
1045 #print DEBUG "mailing child<\n";
1046 unless (open(STDERR,">&STDOUT")) {
1047 #print DEBUG "mailing child opened stderr<\n";
1048 print STDOUT "redirect stderr: $!\n";
1049 #print DEBUG "mailing child opened stderr fail<\n";
1051 #print DEBUG "mailing child opened stderr fail exit !?<\n";
1053 #print DEBUG "mailing child opened stderr ok<\n";
1055 #print DEBUG "mailing child forked again<\n";
1056 defined($c) || die $!;
1057 #print DEBUG "mailing child forked again ok $c<\n";
1058 if (!$c) { # ie, we are the child process
1059 #print DEBUG "mailing grandchild<\n";
1060 exec '/usr/lib/sendmail','-f'."$gMaintainerEmail",'-odq','-oem','-oi',get_addresses(@$recips);
1061 #print DEBUG "mailing grandchild exec failed<\n";
1063 #print DEBUG "mailing grandchild died !?<\n";
1065 #print DEBUG "mailing child not grandchild<\n";
1066 print(D $msg) || die $!;
1067 #print DEBUG "mailing child printed msg<\n";
1069 #print DEBUG "mailing child closed pipe<\n";
1070 die "\n*** command returned exit status $?\n" if $?;
1071 #print DEBUG "mailing child exit status ok<\n";
1073 #print DEBUG "mailing child exited ?!<\n";
1075 #print DEBUG "mailing parent<\n";
1077 #print DEBUG "mailing parent results emptied<\n";
1078 while( $chldexit eq 'no' ) { $results.= $_; }
1079 #print DEBUG "mailing parent results read >$results<\n";
1081 #print DEBUG "mailing parent results closed<\n";
1082 $results.= "\n*** child returned exit status $?\n" if $?;
1083 #print DEBUG "mailing parent exit status ok<\n";
1084 $SIG{'CHLD'}='DEFAULT';
1085 #print DEBUG "mailing parent sigchild default<\n";
1086 if (length($results)) { &quit("running sendmail: $results"); }
1087 #print DEBUG "mailing parent results ok<\n";
1090 sub checkmaintainers {
1091 return if $maintainerschecked++;
1092 return if !length($data->{package});
1093 open(MAINT,"$gMaintainerFile") || die &quit("maintainers open: $!");
1097 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers bogus \`$_'");
1098 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
1099 $maintainerof{$1}= $2;
1102 open(MAINT,"$gMaintainerFileOverride") || die &quit("maintainers.override open: $!");
1106 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers.override bogus \`$_'");
1107 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
1108 $maintainerof{$1}= $2;
1111 open(SOURCES,"$gPackageSource") || &quit("pkgsrc open: $!");
1113 next unless m/^(\S+)\s+\S+\s+(\S.*\S)\s*$/;
1119 $anymaintfound=0; $anymaintnotfound=0;
1120 for $p (split(m/[ \t?,():]+/,$data->{package})) {
1122 $p =~ /([a-z0-9.+-]+)/;
1124 next unless defined $p;
1125 if (defined $gSubscriptionDomain) {
1126 if (defined($pkgsrc{$p})) {
1127 push @addsrcaddrs, "$pkgsrc{$p}\@$gSubscriptionDomain";
1129 push @addsrcaddrs, "$p\@$gSubscriptionDomain";
1132 if (defined($maintainerof{$p})) {
1133 print DEBUG "maintainer add >$p|$maintainerof{$p}<\n";
1134 $addmaint= $maintainerof{$p};
1135 push(@maintaddrs,$addmaint) unless
1136 ($addmaint eq $replyto and $codeletter ne 'M') ||
1137 grep($_ eq $addmaint, @maintaddrs);
1140 print DEBUG "maintainer none >$p<\n";
1141 push(@maintaddrs,$gUnknownMaintainerEmail) unless $anymaintnotfound;
1142 $anymaintnotfound++;
1147 if (length $data->{owner}) {
1148 print DEBUG "owner add >$data->{package}|$data->{owner}<\n";
1149 $addmaint = $data->{owner};
1150 push(@maintaddrs, $addmaint) unless
1151 $addmaint eq $replyto or grep($_ eq $addmaint, @maintaddrs);