]> git.donarmstrong.com Git - debbugs.git/blob - scripts/process.in
[project @ 1999-09-16 07:16:47 by gecko]
[debbugs.git] / scripts / process.in
1 #!/usr/bin/perl
2 # $Id: process.in,v 1.3 1999/09/16 07:16:47 gecko Exp $
3 #
4 # Usage: process nn
5 # Temps:  incoming/Pnn
6
7 use Mail::Address;
8 require( '/etc/debbugs/config' );
9 require( '/usr/lib/debbugs/errorlib' );
10 chdir( "$gSpoolDir" ) || die 'chdir spool: $!\n';
11 @showseverities=();
12
13 #open(DEBUG,"> /tmp/debbugs.debug");
14
15 defined( $intdate= time ) || &quit( "failed to get time: $!" );
16
17 $_=shift;
18 m/^([BMQFDU])(\d*)\.\d+$/ || &quit("bad argument");
19 $codeletter= $1;
20 $tryref= length($2) ? $2+0 : -1;
21 $nn= $_;
22
23 if (!rename("incoming/G$nn","incoming/P$nn")) 
24 {       $_=$!.'';  m/no such file or directory/i && exit 0;
25     &quit("renaming to lock: $!");
26 }    
27
28 $baddress= 'bugs' if $codeletter eq 'B';
29 $baddress= 'maintonly' if $codeletter eq 'M';
30 $baddress= 'quiet' if $codeletter eq 'Q';
31 $baddress= 'forwarded' if $codeletter eq 'F';
32 $baddress= 'done' if $codeletter eq 'D';
33 $baddress= 'submitter' if $codeletter eq 'U';
34 $baddress || &quit("bad codeletter $codeletter");
35 $baddressroot= $baddress;
36 $baddress= "$tryref-$baddress" if $tryref>=0;
37
38 open(M,"incoming/P$nn");
39 @log=<M>;
40 close(M);
41
42 @msg=@log;
43 grep(s/\n+$//,@msg);
44
45 print DEBUG "###\n",join("##\n",@msg),"\n###\n";
46
47 chop($tdate= `date -u '+%a, %d %h %Y %T GMT'`);
48 $fwd= <<END;
49 X-Loop: $gMaintainerEmail
50 Received: via spool by $baddress\@$gEmailDomain id=$nn
51           (code $codeletter ref $tryref); $tdate
52 END
53
54 for ($i=0; $i<=$#msg; $i++) {
55     $_ = $msg[$i];
56     last unless length($_);
57     &quit("looping detected") if m/^x-loop: (\S+)$/i && $1 eq "$gMaintainerEmail";
58     $ins= !m/^subject:/i && !m/^reply-to:/i && !m/^return-path:/i
59        && !m/^From / && !m/^X-Debbugs-CC:/i && !m/^received:/i;
60     $fwd .= $_."\n" if $ins;
61     while ($msg[$i+1] =~ m/^\s/) {
62         $i++;
63         $fwd .= $msg[$i]."\n" if $ins;
64         $_ .= ' '.$msg[$i];
65     }
66 # print DEBUG ">$_<\n";
67     if (s/^(\S+):\s*//) {
68         $v= $1; $v =~ y/A-Z/a-z/;
69                 print DEBUG ">$v=$_<\n";
70         $header{$v}= $_;
71     } else {
72         print DEBUG "!>$_<\n";
73     }
74 }
75
76 #remove blank lines
77 while ($i <= $#msg && !length($msg[$i])) { $fwd .= "\n"; $i++; }
78 if ( $msg[$i] =~ /^--/ || $msg[$i] =~ /^\s*$/ )
79 {
80         while ( $i <= $#msg && length( $msg[$i] ) ) { $fwd .= $msg[$i]; $i++; }
81         while ( $i <= $#msg && !length( $msg[$i] ) ) { $fwd .= "\n"; $i++; }
82 }               
83
84 while (defined ($msg[$i] ) )
85 {
86         last if ( $msg[$i] !~ m/^([\w]+):\s*(\S+)/ );
87         $i++;
88         $fn = $1; $fv = $2;
89         print DEBUG ">$fn|$'|\n";
90     $fwd .= $fn.': '.$fv."\n";
91     $fn =~ y/A-Z/a-z/;
92     $pheader{$fn}= $fv;
93         print DEBUG ">$fn~$fv<\n";
94 }
95
96
97 $fwd .= join("\n",@msg[$i..$#msg]);
98
99 print DEBUG "***\n$fwd\n***\n";
100
101 defined($header{'from'}) || &quit("no From header");
102 $replyto= defined($header{'reply-to'}) ? $header{'reply-to'} : $header{'from'};
103
104 $_= $replyto;
105 $_= "$2 <$1>" if m/^([^\<\> \t\n\(\)]+) \(([^\(\)\<\>]+)\)$/;
106 $replytocompare= $_;
107 print DEBUG "replytocompare >$replytocompare<\n";
108     
109 if (!defined($header{'subject'})) 
110 {       $brokenness.= <<END;
111
112 Your message did not contain a Subject field.  This is broken, I am
113 afraid - the Subject: line is a Required Header according to RFC822.
114 Please remember to include a Subject field in your messages in future.
115 If you did so the fact that it got lost probably indicates a poorly
116 configured mail system at your site or an intervening one.
117 END
118     $subject= '(no subject)';
119 } else { $subject= $header{'subject'}; }
120
121 $ref=-1;
122 $subject =~ s/^Re:\s*//i; $_= $subject."\n";
123 if ($tryref < 0 && m/^Bug ?\#(\d+)\D/i) { $tryref= $1+0; }
124
125 if ($tryref >= 0) 
126 {       $bfound= &lockreadbugmerge($tryref);
127     if ($bfound) { $ref= $tryref; } 
128         else 
129         {       &htmllog("Reply","sent", $replyto,"Unknown problem report number <code>$tryref</code>.");
130         &sendmessage(<<END, '');
131 From: $gMaintainerEmail ($gProject $gBug Tracking System)
132 To: $replyto
133 Subject: Unknown problem report $gBug#$tryref ($subject)
134 Message-ID: <handler.x.$nn.unknown\@$gEmailDomain>
135 In-Reply-To: $header{'message-id'}
136 References: $header{'message-id'} $s_msgid
137 X-$gProject-PR-Message: error
138
139 You sent a message to the $gBug tracking system which gave (in the
140 Subject line or encoded into the recipient at $gEmailDomain),
141 the number of a nonexistent $gBug report (#$tryref).
142
143 This may be because that $gBug report has been resolved for more than $gRemoveAge
144 days, and the record of it has been expunged, or because you mistyped
145 the $gBug report number.
146
147 Your message was dated $header{'date'} and was sent to
148 $baddress\@$gEmailDomain.  It had
149 Message-ID $header{'message-id'}
150 and Subject $subject.
151
152 It has been filed (under junk) but otherwise ignored.
153
154 Please consult your records to find the correct $gBug report number, or
155 contact me, the system administrator, for assistance.
156
157 $gMaintainer
158 (administrator, $gProject $gBugs database)
159
160 (NB: If you are a system administrator and have no idea what I am
161 talking about this indicates a serious mail system misconfiguration
162 somewhere.  Please contact me immediately.)
163
164 END
165                 &appendlog;
166         &finish;
167     }
168 } else { &filelock('lock/-1'); }
169
170 if ($codeletter eq 'D' || $codeletter eq 'F') 
171 {       if ($replyto =~ m/$gBounceFroms/o ||
172                 $header{'from'} =~ m/$gBounceFroms/o) 
173                 { &quit("bounce detected !  Mwaap! Mwaap!"); }
174     $markedby= $header{'from'} eq $replyto ? $replyto :
175                "$header{'from'} (reply to $replyto)";
176     if ($codeletter eq 'F') 
177         {       (&appendlog,&finish) if length($s_forwarded);
178         $receivedat= "forwarded\@$gEmailDomain";
179         $markaswhat= 'forwarded';
180         $set_forwarded= $header{'to'};
181                 if ( length( $gListDomain ) > 0 && length( $gFowardList ) > 0 ) 
182                         { $generalcc= "$gFowardList\@$gListDomain"; } 
183                 else { $generalcc=''; }
184     } else 
185         {       (&appendlog,&finish) if length($s_done);
186         $receivedat= "done\@$gEmailDomain";
187         $markaswhat= 'done';
188         $set_done= $header{'from'};
189                 if ( length( $gListDomain ) > 0 && length( $gDoneList ) > 0 ) 
190                         { $generalcc= "$gDoneList\@$gListDomain"; } 
191                 else { $generalcc=''; }
192     }
193     if ($ref<0) 
194         {       &htmllog("Warning","sent",$replyto,"Message ignored.");
195         &sendmessage(<<END, '');
196 From: $gMaintainerEmail ($gProject $gBug Tracking System)
197 To: $replyto
198 Subject: Message with no $gBug number ignored by $receivedat
199          ($subject)
200 Message-ID: <header.x.$nn.warnignore\@$gEmailDomain>
201 In-Reply-To: $header{'message-id'}
202 References: $header{'message-id'} $s_msgid
203 X-$gProject-PR-Message: error
204
205 You sent a message to the $gProject $gBug tracking system old-style
206 unified mark as $markaswhat address ($receivedat),
207 without a recognisable $gBug number in the Subject.
208 Your message has been filed under junk but otherwise ignored.
209
210 If you don't know what I'm talking about then probably either:
211
212 (a) you unwittingly sent a message to done\@$gEmailDomain
213 because you replied to all recipients of the message a developer used
214 to mark a $gBug as done and you modified the Subject.  In this case,
215 please do not be alarmed.  To avoid confusion do not do it again, but
216 there is no need to apologise or mail anyone asking for an explanation.
217
218 (b) you are a system administrator, reading this because the $gBug 
219 tracking system is responding to a misdirected bounce message.  In this
220 case there is a serious mail system misconfiguration somewhere - please
221 contact me immediately.
222
223 Your message was dated $header{'date'} and had
224 message-id $header{'message-id'}
225 and subject $subject.
226
227 If you need any assistance or explanation please contact me.
228
229 $gMaintainer
230 (administrator, $gProject $gBugs database)
231
232 END
233                 &appendlog;
234                 &finish;
235     }
236     &checkmaintainers;
237     $noticeccval.= join(', ', grep($_ ne $replyto,@maintaddrs));
238     $noticeccval =~ s/\s+\n\s+/ /g; $noticeccval =~ s/^\s+/ /; $noticeccval =~ s/\s+$//;
239     if (length($noticeccval)) { $noticecc= "Cc: $noticeccval\n"; }
240         if (length($generalcc)) { $noticecc.= "Bcc: $generalcc\n"; }
241     @process= ($ref,split(/ /,$s_mergedwith));
242     $orgref= $ref;
243     for $ref (@process) 
244         {       if ($ref != $orgref) 
245                 {       &unfilelock;
246                 &lockreadbug($ref) || die "huh ? $ref from $orgref out of @process";
247                 }
248         $s_done= $set_done if defined($set_done);
249         $s_forwarded= $set_forwarded if defined($set_forwarded);
250                 &overwrite("db/$ref.status",
251                    "$s_originator\n$s_date\n$s_subject\n$s_msgid\n".
252                    "$s_package\n$s_keywords\n$s_done\n$s_forwarded\n$s_mergedwith\n$s_severity\n");
253         open(O,"db/$ref.report") || &quit("read original report: $!");
254         $x= join('',<O>); close(O);
255         if ($codeletter eq 'F') 
256                 {       &htmllog("Reply","sent",$replyto,"You have marked $gBug as forwarded.");
257             &sendmessage(<<END.$x, '');
258 From: $gMaintainerEmail ($gProject $gBug Tracking System)
259 To: $replyto
260 ${noticecc}Subject: $gBug#$ref: marked as forwarded ($s_subject)
261 Message-ID: <header.$ref.$nn.ackfwdd\@$gEmailDomain>
262 In-Reply-To: $header{'message-id'}
263 References: $header{'message-id'} $s_msgid
264 X-$gProject-PR-Message: forwarded $ref
265
266 Your message dated $header{'date'}
267 with message-id $header{'message-id'}
268 and subject line $subject
269 has caused the $gProject $gBug report #$ref,
270 regarding $s_subject
271 to be marked as having been forwarded to the upstream software
272 author(s) $s_forwarded.
273
274 (NB: If you are a system administrator and have no idea what I am
275 talking about this indicates a serious mail system misconfiguration
276 somewhere.  Please contact me immediately.)
277
278 $gMaintainer
279 (administrator, $gProject $gBugs database)
280
281 END
282         } else 
283                 {   &htmllog("Reply","sent",$replyto,"You have taken responsibility.");
284             &sendmessage(<<END.$x, '');
285 From: $gMaintainerEmail ($gProject $gBug Tracking System)
286 To: $replyto
287 ${noticecc}Subject: $gBug#$ref: marked as done ($s_subject)
288 Message-ID: <handler.$ref.$nn.ackdone\@$gEmailDomain>
289 In-Reply-To: $header{'message-id'}
290 References: $header{'message-id'} $s_msgid
291 X-$gProject-PR-Message: closed $ref
292
293 Your message dated $header{'date'}
294 with message-id $header{'message-id'}
295 and subject line $subject
296 has caused the attached $gBug report to be marked as done.
297
298 This means that you claim that the problem has been dealt with.
299 If this is not the case it is now your responsibility to reopen the
300 $gBug report if necessary, and/or fix the problem forthwith.
301
302 (NB: If you are a system administrator and have no idea what I am
303 talking about this indicates a serious mail system misconfiguration
304 somewhere.  Please contact me immediately.)
305
306 $gMaintainer
307 (administrator, $gProject $gBugs database)
308
309 END
310             &htmllog("Notification","sent",$s_originator, 
311                                 "$gBug acknowledged by developer.");
312             &sendmessage(<<END.join("\n",@msg),'');
313 From: $gMaintainerEmail ($gProject $gBug Tracking System)
314 To: $s_originator
315 Subject: $gBug#$ref acknowledged by developer ($s_subject)
316 Message-ID: <handler.$ref.$nn.notifdone\@$gEmailDomain>
317 In-Reply-To: $s_msgid
318 References: $header{'message-id'} $s_msgid
319 X-$gProject-PR-Message: they-closed $ref
320
321 This is an automatic notification regarding your $gBug report.
322
323 It has been closed by one of the developers, namely
324 $markedby.
325
326 Their explanation is attached below.  If this explanation is
327 unsatisfactory and you have not received a better one in a separate
328 message then please contact the developer directly, or email
329 submit\@$gEmailDomain or me.
330
331 $gMaintainer
332 (administrator, $gProject $gBugs database)
333
334 END
335         }
336                 &appendlog;
337     }
338     &finish;
339 }
340
341 if ($ref<0) 
342 {       if ($codeletter eq 'U') 
343         {       &htmllog("Warning","sent",$replyto,"Message not forwarded.");
344         &sendmessage(<<END, '');
345 From: $gMaintainerEmail ($gProject $gBug Tracking System)
346 To: $replyto
347 Subject: Message with no $gBug number cannot be sent to submitter !
348          ($subject)
349 Message-ID: <handler.x.$nn.nonumnosub\@$gEmailDomain>
350 In-Reply-To: $header{'message-id'}
351 References: $header{'message-id'} $s_msgid
352 X-$gProject-PR-Message: error
353
354 You sent a message to the $gProject $gBug tracking system send to $gBug 
355 report submitter address $baddress\@$gEmailDomain, without a
356 recognisable $gBug number in the Subject.  Your message has been filed
357 under junk but otherwise ignored.
358
359 If you don't know what I'm talking about then probably either:
360
361 (a) you unwittingly sent a message to $baddress\@$gEmailDomain
362 because you replied to all recipients of the message a developer sent
363 to a $gBug's submitter and you modified the Subject.  In this case,
364 please do not be alarmed.  To avoid confusion do not do it again, but
365 there is no need to apologise or mail anyone asking for an
366 explanation.
367
368 (b) you are a system administrator, reading this because the $gBug 
369 tracking system is responding to a misdirected bounce message.  In this
370 case there is a serious mail system misconfiguration somewhere - please
371 contact me immediately.
372
373 Your message was dated $header{'date'} and had
374 message-id $header{'message-id'}
375 and subject $subject.
376
377 If you need any assistance or explanation please contact me.
378
379 $gMaintainer
380 (administrator, $gProject $gBugs database)
381
382 END
383         &appendlog;
384         &finish;
385     }
386     if (!defined($pheader{'package'}))
387         {       &htmllog("Warning","sent",$replyto,"Message not forwarded.");
388         &sendmessage(<<END, '');
389 From: $gMaintainerEmail ($gProject $gBug Tracking System)
390 To: $replyto
391 Subject: Message with no Package: tag cannot be processed!
392          ($subject)
393 Message-ID: <handler.x.$nn.nonumnosub\@$gEmailDomain>
394 In-Reply-To: $header{'message-id'}
395 References: $header{'message-id'} $s_msgid
396 X-$gProject-PR-Message: error
397
398 Your message didn't have a Package: line at the start (in the
399 pseudo-header following the real mail header), or didn't have a
400 psuedo-header at all.
401
402 This makes it much harder for us to categorise and deal with your
403 problem report. Please resubmit your report and tell us which package the
404 report is on.  For help, check out http://$gWebDomain/Reporting.html.
405
406 Your message was dated $header{'date'} and had
407 message-id $header{'message-id'}
408 and subject $subject.
409
410 If you need any assistance or explanation please contact me.
411
412 $gMaintainer
413 (administrator, $gProject $gBugs database)
414
415 END
416         &appendlog;
417         &finish;
418     } else {
419         $s_package= $pheader{'package'};
420                 print "Package: $s_package\n";
421     }
422     if (defined($pheader{'keywords'})) {
423         $s_keywords= $pheader{'keywords'};
424     }
425     $s_severity= '';
426     if (defined($pheader{'severity'})) {
427         $s_severity= $pheader{'severity'};
428         if (!grep($_ eq $s_severity, @severities, "$gDefaultSeverity")) {
429             $brokenness.= <<END;
430
431 Your message specified a Severity: in the psuedo-header, but
432 the severity value $s_severity was not recognised.
433 The default severity $gDefaultSeverity is being used instead.
434 The recognised values are: @showseverities.
435 END
436             $s_severity= '';
437         }
438     }
439     &filelock("nextnumber.lock");
440     open(N,"nextnumber") || &quit("nextnumber: read: $!");
441     $v=<N>; $v =~ s/\n$// || &quit("nextnumber bad format");
442     $ref= $v+0;  $v += 1;  $newref=1;
443     &overwrite('nextnumber', "$v\n");
444     &unfilelock;
445     &overwrite("db/$ref.log",'');
446     &overwrite("db/$ref.status",
447                "$replyto\n$intdate\n$subject\n$header{'message-id'}\n".
448                "$s_package\n$s_keywords\n\n\n\n$s_severity\n");
449     &overwrite("db/$ref.report",
450                join("\n",@msg)."\n");
451 }
452
453 &checkmaintainers;
454
455 print DEBUG "maintainers >@maintaddrs<\n";
456
457 $orgsender= defined($header{'sender'}) ? "Orignal-Sender: $header{'sender'}\n" : '';
458 $newsubject= $subject;  $newsubject =~ s/^$gBug#$ref\W*\s*//;
459
460 $xcchdr= $header{X-Debbugs-CC};
461 if ($xcchdr =~ m/\S/) {
462     push(@resentccs,$xcchdr);
463     $resentccexplain.= <<END;
464
465 As you requested using X-Debbugs-CC, your message was also forwarded to
466    $xcchdr
467 (after having been given a $gBug report number, if it did not have one).
468 END
469 }
470
471 if (@maintaddrs && ($codeletter eq 'B' || $codeletter eq 'M')) {
472     push(@resentccs,@maintaddrs);
473     $resentccexplain.= <<END." ".join("\n ",@maintaddrs)."\n";
474
475 Your message has been sent to the package maintainer(s):
476 END
477 }
478
479 $veryquiet= $codeletter eq 'Q';
480 if ($codeletter eq 'M' && !@maintaddrs) {
481     $veryquiet= 1;
482     $brokenness.= <<END;
483
484 You requested that the message be sent to the package maintainer(s)
485 but either the $gBug report is not associated with any package (probably
486 because of a missing Package psuedo-header field in the original $gBug
487 report), or the package(s) specified do not have any maintainer(s).
488
489 Your message has *not* been sent to any package maintainers; it has
490 merely been filed in the $gBug tracking system.  If you require assistance
491 please contact $gMaintainerEmail quoting the $gBug number $ref.
492 END
493 }
494
495 $resentccval.= join(', ',@resentccs);
496 $resentccval =~ s/\s+\n\s+/ /g; $resentccval =~ s/^\s+/ /; $resentccval =~ s/\s+$//;
497 if (length($resentccval)) { $resentcc= "Resent-CC: $resentccval\n"; }
498
499 if ($codeletter eq 'U') {
500     &htmllog("Message", "sent on", $s_originator, "$gBug#$ref.");
501     &sendmessage(<<END,$s_originator,@resentccs);
502 Subject: $gBug#$ref: $newsubject
503 Reply-To: $replyto, $ref-quiet\@$gEmailDomain
504 ${orgsender}Resent-To: $s_originator
505 ${resentcc}Resent-Date: $tdate
506 Resent-Message-ID: <handler.$ref.$nn\@$gEmailDomain>
507 Resent-Sender: $gMaintainerEmail
508 X-$gProject-PR-Message: report $ref
509 X-$gProject-PR-Package: $s_package
510 X-$gProject-PR-Keywords: $s_keywords
511 $fwd
512 END
513 } elsif ($codeletter eq 'B') {
514     &htmllog($newref ? "Report" : "Information", "forwarded",
515              join(', ',"$gSubmitList\@$gListDomain",@resentccs),
516              "<code>$gBug#$ref</code>".
517              (length($s_package)? "; Package <code>".&sani($s_package)."</code>" : '').
518              (length($s_keywords)? "; Keywords <code>".&sani($s_keywords)."</code>":'').
519              ".");
520     &sendmessage(<<END,"$gSubmitList\@$gListDomain",@resentccs);
521 Subject: $gBug#$ref: $newsubject
522 Reply-To: $replyto, $ref\@$gEmailDomain
523 Resent-From: $header{'from'}
524 ${orgsender}Resent-To: $gSubmitList\@$gListDomain
525 ${resentcc}Resent-Date: $tdate
526 Resent-Message-ID: <handler.$ref.$nn\@$gEmailDomain>
527 Resent-Sender: $gMaintainerEmail
528 X-$gProject-PR-Message: report $ref
529 X-$gProject-PR-Package: $s_package
530 X-$gProject-PR-Keywords: $s_keywords
531 $fwd
532 END
533 } elsif (@resentccs) {
534     # D and F done far earlier; B just done - so this must be M or Q
535     # We preserve whichever it was in the Reply-To (possibly adding
536     # the $gBug#).
537     &htmllog($newref ? "Report" : "Information", "forwarded",
538              $resentccval,
539              "<code>$gBug#$ref</code>".
540              (length($s_package)? "; Package <code>".&sani($s_package)."</code>" : '').
541              (length($s_keywords)? "; Keywords <code>".&sani($s_keywords)."</code>":'').
542              ".");
543     &sendmessage(<<END,@resentccs);
544 Subject: $gBug#$ref: $newsubject
545 Reply-To: $replyto, $ref-$baddressroot\@$gEmailDomain
546 Resent-From: $header{'from'}
547 ${orgsender}Resent-To: $resentccval
548 Resent-Date: $tdate
549 Resent-Message-ID: <handler.$ref.$nn\@$gEmailDomain>
550 Resent-Sender: $gMaintainerEmail
551 X-$gProject-PR-Message: report $ref
552 X-$gProject-PR-Package: $s_package
553 X-$gProject-PR-Keywords: $s_keywords
554 $fwd
555 END
556 }
557
558 $htmlbreak= length($brokenness) ? "<p>\n".&sani($brokenness)."\n<p>\n" : '';
559 $htmlbreak =~ s/\n\n/\n<P>\n\n/g;
560 if (length($resentccval)) {
561     $htmlbreak =
562         "  Copy sent to <code>".&sani($resentccval)."</code>.".
563         $htmlbreak;
564 }
565 if ($newref) {
566     &htmllog("Acknowledgement","sent",$replyto,
567              ($veryquiet ?
568               "New $gBug report received and filed, but not forwarded." :
569               "New $gBug report received and forwarded."). $htmlbreak);
570     &sendmessage($veryquiet ? <<END : $codeletter eq 'M' ? <<END : <<END,'');
571 From: $gMaintainerEmail ($gProject $gBug Tracking System)
572 To: $replyto
573 Subject: $gBug#$ref: Acknowledgement of QUIET report
574          ($subject)
575 Message-ID: <handler.$ref.$nn.ackquiet\@$gEmailDomain>
576 In-Reply-To: $header{'message-id'}
577 References: $header{'message-id'}
578 X-$gProject-PR-Message: ack-quiet $ref
579
580 Thank you for the problem report you have sent regarding $gProject.
581 This is an automatically generated reply, to let you know your message
582 has been received.  It has not been forwarded to the developers or
583 their mailing list; you should ensure that the developers are aware of
584 the problem you have entered into the system - preferably quoting the
585 $gBug reference number, #$ref.
586 $resentccexplain
587 If you wish to submit further information on your problem, please send it
588 to $ref-$baddressroot\@$gEmailDomain (and *not*
589 to $baddress\@$gEmailDomain).
590
591 Please do not reply to the address at the top of this message,
592 unless you wish to report a problem with the $gBug-tracking system.
593 $brokenness
594 $gMaintainer
595 (administrator, $gProject $gBugs database)
596 END
597 From: $gMaintainerEmail ($gProject $gBug Tracking System)
598 To: $replyto
599 Subject: $gBug#$ref: Acknowledgement of maintainer-only report
600          ($subject)
601 Message-ID: <handler.$ref.$nn.ackmaint\@$gEmailDomain>
602 In-Reply-To: $header{'message-id'}
603 References: $header{'message-id'}
604 X-$gProject-PR-Message: ack-maintonly $ref
605
606 Thank you for the problem report you have sent regarding $gProject.
607 This is an automatically generated reply, to let you know your message has
608 been received.  It is being forwarded to the developers (but not the mailing
609 list, as you requested) for their attention; they will reply in due course.
610 $resentccexplain
611 If you wish to submit further information on your problem, please send
612 it to $ref-$baddressroot\@$gEmailDomain (and *not*
613 to $baddress\@$gEmailDomain).
614
615 Please do not reply to the address at the top of this message,
616 unless you wish to report a problem with the $gBug-tracking system.
617 $brokenness
618 $gMaintainer
619 (administrator, $gProject $gBugs database)
620 END
621 From: $gMaintainerEmail ($gProject $gBug Tracking System)
622 To: $replyto
623 Subject: $gBug#$ref: Acknowledgement ($subject)
624 Message-ID: <handler.$ref.$nn.ack\@$gEmailDomain>
625 In-Reply-To: $header{'message-id'}
626 References: $header{'message-id'}
627 X-$gProject-PR-Message: ack $ref
628
629 Thank you for the problem report you have sent regarding $gProject.
630 This is an automatically generated reply, to let you know your message has
631 been received.  It is being forwarded to the developers mailing list for
632 their attention; they will reply in due course.
633 $resentccexplain
634 If you wish to submit further information on your problem, please send
635 it to $ref\@$gEmailDomain (and *not* to
636 $baddress\@$gEmailDomain).
637
638 Please do not reply to the address at the top of this message,
639 unless you wish to report a problem with the $gBug-tracking system.
640 $brokenness
641 $gMaintainer
642 (administrator, $gProject $gBugs database)
643 END
644 } elsif ($codeletter ne 'U') {
645     &htmllog("Acknowledgement","sent",$replyto,
646              ($veryquiet ? "Extra info received and filed, but not forwarded." :
647               $codeletter eq 'M' ? "Extra info received and forwarded to maintainer." :
648               "Extra info received and forwarded to list."). $htmlbreak);
649     &sendmessage($veryquiet ? <<END : $codeletter eq 'M' ? <<END : <<END,'');
650 From: $gMaintainerEmail ($gProject $gBug Tracking System)
651 To: $replyto
652 Subject: $gBug#$ref: Info received and FILED only
653          (was $subject)
654 Message-ID: <handler.$ref.$nn.ackinfoquiet\@$gEmailDomain>
655 In-Reply-To: $header{'message-id'}
656 References: $header{'message-id'}
657 X-$gProject-PR-Message: ack-info-quiet $ref
658
659 Thank you for the additional information you have supplied regarding
660 this problem report.  It has NOT been forwarded to the developers, but
661 will accompany the original report in the $gBug tracking system.  Please
662 ensure that you yourself have sent a copy of the additional
663 information to any relevant developers or mailing lists.
664 $resentccexplain
665 If you wish to continue to submit further information on your problem,
666 please send it to $ref-$baddressroot\@$gEmailDomain, as before.
667
668 Please do not reply to the address at the top of this message,
669 unless you wish to report a problem with the $gBug-tracking system.
670 $brokenness
671 $gMaintainer
672 (administrator, $gProject $gBugs database)
673 END
674 From: $gMaintainerEmail ($gProject $gBug Tracking System)
675 To: $replyto
676 Subject: $gBug#$ref: Info received for maintainer only
677          (was $subject)
678 Message-ID: <handler.$ref.$nn.ackinfomaint\@$gEmailDomain>
679 In-Reply-To: $header{'message-id'}
680 References: $header{'message-id'}
681 X-$gProject-PR-Message: ack-info $ref
682
683 Thank you for the additional information you have supplied regarding
684 this problem report.  It has been forwarded to the developer(s) (but
685 not to the mailing list) to accompany the original report.
686 $resentccexplain
687 If you wish to continue to submit further information on your problem,
688 please send it to $ref-$baddressroot\@$gEmailDomain, as before.
689
690 Please do not reply to the address at the top of this message,
691 unless you wish to report a problem with the $gBug-tracking system.
692 $brokenness
693 $gMaintainer
694 (administrator, $gProject $gBugs database)
695 END
696 From: $gMaintainerEmail ($gProject $gBug Tracking System)
697 To: $replyto
698 Subject: $gBug#$ref: Info received (was $subject)
699 Message-ID: <handler.$ref.$nn.ackinfo\@$gEmailDomain>
700 In-Reply-To: $header{'message-id'}
701 References: $header{'message-id'}
702 X-$gProject-PR-Message: ack-info-maintonly $ref
703
704 Thank you for the additional information you have supplied regarding
705 this problem report.  It has been forwarded to the developer(s) and
706 to the developers mailing list to accompany the original report.
707 $resentccexplain
708 If you wish to continue to submit further information on your problem,
709 please send it to $ref\@$gEmailDomain, as before.
710
711 Please do not reply to the address at the top of this message,
712 unless you wish to report a problem with the $gBug-tracking system.
713 $brokenness
714 $gMaintainer
715 (administrator, $gProject $gBugs database)
716 END
717 }
718
719 &appendlog;
720 &finish;
721
722 sub overwrite {
723     local ($f,$v) = @_;
724     open(NEW,">$f.new") || &quit("$f.new: create: $!");
725     print(NEW "$v") || &quit("$f.new: write: $!");
726     close(NEW) || &quit("$f.new: close: $!");
727     rename("$f.new","$f") || &quit("rename $f.new to $f: $!");
728 }
729
730 sub appendlog {
731     if (!open(AP,">>db/$ref.log")) {
732         print DEBUG "failed open log<\n";
733         print DEBUG "failed open log err $!<\n";
734         &quit("opening db/$ref.log (li): $!");
735     }
736     print(AP "\7\n",@log,"\n\3\n") || &quit("writing db/$ref.log (li): $!");
737     close(AP) || &quit("closing db/$ref.log (li): $!");
738 }
739
740 sub finish {
741     utime(time,time,"db");
742     local ($u);
743     while ($u= $cleanups[$#cleanups]) { &$u; }
744     unlink("incoming/P$nn") || &quit("unlinking incoming/P$nn: $!");
745     exit $_[0];
746 }
747
748 &quit("wot no exit");
749
750 sub chldhandle { $chldexit = 'yes'; }
751
752 sub htmllog {
753     local ($whatobj,$whatverb,$where,$desc) = @_;
754     open(AP,">>db/$ref.log") || &quit("opening db/$ref.log (lh): $!");
755     print(AP
756           "\6\n".
757           "<strong>$whatobj $whatverb</strong> to <code>".&sani($where).
758           "</code>:<br>\n". $desc.
759           "\n\3\n") || &quit("writing db/$ref.log (lh): $!");
760     close(AP) || &quit("closing db/$ref.log (lh): $!");
761 }    
762
763 sub get_addresses {
764         return
765                 map { $_->address() }
766                 map { Mail::Address->parse($_) } @_;
767 }
768
769
770 sub sendmessage {
771     local ($msg,@recips) = @_;
772     if ($recips[0] eq '' && $#recips == 0) { @recips= ('-t'); }
773     open(AP,">>db/$ref.log") || &quit("opening db/$ref.log (lo): $!");
774     print(AP "\2\n",join("\4",@recips),"\n\5\n$msg\n\3\n") ||
775         &quit("writing db/$ref.log (lo): $!");
776     close(AP) || &quit("closing db/$ref.log (lo): $!");
777     
778     print DEBUG "mailing to >",join('|',@recips),"<\n";
779     $SIG{'CHLD'}='chldhandle';
780         #print DEBUG "mailing sigchild set up<\n";
781         $chldexit = 'no';
782     $c= open(U,"-|");
783         #print DEBUG "mailing opened pipe fork<\n";
784     defined($c) || die $!;
785         #print DEBUG "mailing opened pipe fork ok $c<\n";
786     if (!$c) { # ie, we are in the child process
787                 #print DEBUG "mailing child<\n";
788         unless (open(STDERR,">&STDOUT")) {
789                         #print DEBUG "mailing child opened stderr<\n";
790             print STDOUT "redirect stderr: $!\n";
791                         #print DEBUG "mailing child opened stderr fail<\n";
792             exit 1;
793                         #print DEBUG "mailing child opened stderr fail exit !?<\n";
794         }
795                 #print DEBUG "mailing child opened stderr ok<\n";
796         $c= open(D,"|-");
797                 #print DEBUG "mailing child forked again<\n";
798         defined($c) || die $!;
799                 #print DEBUG "mailing child forked again ok $c<\n";
800         if (!$c) { # ie, we are the child process
801                         #print DEBUG "mailing grandchild<\n";
802             exec '/usr/lib/sendmail','-f'."$gMaintainerEmail",'-odi','-oem','-oi',get_addresses(@recips);
803                         #print DEBUG "mailing grandchild exec failed<\n";
804             die $!;
805                         #print DEBUG "mailing grandchild died !?<\n";
806         }
807                 #print DEBUG "mailing child not grandchild<\n";
808         print(D $msg) || die $!;
809                 #print DEBUG "mailing child printed msg<\n";
810         close(D);
811                 #print DEBUG "mailing child closed pipe<\n";
812         die "\n*** command returned exit status $?\n" if $?;
813                 #print DEBUG "mailing child exit status ok<\n";
814         exit 0;
815                 #print DEBUG "mailing child exited ?!<\n";
816     }
817         #print DEBUG "mailing parent<\n";
818     $results='';
819         #print DEBUG "mailing parent results emptied<\n";
820     while( $chldexit eq 'no' ) { $results.= $_; }
821         #print DEBUG "mailing parent results read >$results<\n";
822     close(U);
823         #print DEBUG "mailing parent results closed<\n";
824     $results.= "\n*** child returned exit status $?\n" if $?;
825         #print DEBUG "mailing parent exit status ok<\n";
826     $SIG{'CHLD'}='DEFAULT';
827         #print DEBUG "mailing parent sigchild default<\n";
828     if (length($results)) { &quit("running sendmail: $results"); }
829         #print DEBUG "mailing parent results ok<\n";
830 }
831
832 sub checkmaintainers {
833     return if $maintainerschecked++;
834     return if !length($s_package);
835     open(MAINT,"$gMaintainerFile") || die &quit("maintainers open: $!");
836     while (<MAINT>) {
837         m/^(\S+)\s+(\S.*\S)\n$/ || &quit("maintainers bogus \`$_'");
838         $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
839         $maintainerof{$1}= $2;
840     }
841     close(MAINT);
842     $anymaintfound=0; $anymaintnotfound=0;
843     for $p (split(m/[ \t?,()]+/,$s_package)) {
844         $p =~ y/A-Z/a-z/;
845         if (defined($maintainerof{$p})) {
846 print DEBUG "maintainer add >$p|$maintainerof{$p}<\n";
847             $addmaint= $maintainerof{$p};
848             push(@maintaddrs,$addmaint) unless
849                 $addmaint eq $replyto || grep($_ eq $addmaint, @maintaddrs);
850             $anymaintfound++;
851         } else {
852 print DEBUG "maintainer none >$p<\n";
853             $anymaintnotfound++;
854             last;
855         }
856     }
857 }