]> git.donarmstrong.com Git - debbugs.git/blob - scripts/service.in
[project @ 2005-07-18 11:52:33 by cjwatson]
[debbugs.git] / scripts / service.in
1 #!/usr/bin/perl
2 # $Id: service.in,v 1.104 2005/07/18 11:52:33 cjwatson Exp $
3 #
4 # Usage: service <code>.nn
5 # Temps:  incoming/P<code>.nn
6
7 use File::Copy;
8 use MIME::Parser;
9 use Debbugs::MIME qw(decode_rfc1522);
10
11 $config_path = '/etc/debbugs';
12 $lib_path = '/usr/lib/debbugs';
13
14 require "$config_path/config";
15 require "$lib_path/errorlib";
16 $ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};
17
18 chdir("$gSpoolDir") || die "chdir spool: $!\n";
19
20 # open(DEBUG,">&4");
21 open DEBUG, ">/dev/null";
22 $debug = 0;
23 umask(002);
24
25 $_=shift;
26 m/^[RC]\.\d+$/ || &quit("bad argument");
27 $control= m/C/;
28 $nn= $_;
29 if (!rename("incoming/G$nn","incoming/P$nn")) {
30     $_=$!.'';  m/no such file or directory/i && exit 0;
31     &quit("renaming to lock: $!");
32 }    
33
34 open(M,"incoming/P$nn");
35 @log=<M>;
36 @msg=@log;
37 close(M);
38
39 chomp @msg;
40
41 print "###\n",join("##\n",@msg),"\n###\n" if $debug;
42
43 my $parser = new MIME::Parser;
44 mkdir "$gSpoolDir/mime.tmp", 0777;
45 $parser->output_under("$gSpoolDir/mime.tmp");
46 my $entity = eval { $parser->parse_data(join('',@log)) };
47
48 # header and decoded body respectively
49 my (@headerlines, @bodylines);
50
51 if ($entity and $entity->head->tags) {
52     @headerlines = @{$entity->head->header};
53     chomp @headerlines;
54
55     my $entity_body = getmailbody($entity);
56     @bodylines = $entity_body ? $entity_body->as_lines() : ();
57     chomp @bodylines;
58 } else {
59     # Legacy pre-MIME code, kept around in case MIME::Parser fails.
60     my $i;
61     for ($i = 0; $i <= $#msg; $i++) {
62         $_ = $msg[$i];
63         last unless length($_);
64         while ($msg[$i+1] =~ m/^\s/) {
65             $i++;
66             $_ .= "\n".$msg[$i];
67         }
68         push @headerlines, $_;
69     }
70
71     @bodylines = @msg[$i..$#msg];
72 }
73
74 for (@headerlines) {
75     s/\n\s/ /g;
76     print ">$_<\n" if $debug;
77     if (s/^(\S+):\s*//) {
78         my $v = lc $1;
79         print ">$v=$_<\n" if $debug;
80         $header{$v} = decode_rfc1522($_);
81     } else {
82         print "!>$_<\n" if $debug;
83     }
84 }
85
86 # Strip off RFC2440-style PGP clearsigning.
87 if (@bodylines and $bodylines[0] =~ /^-----BEGIN PGP SIGNED/) {
88     shift @bodylines while @bodylines and length $bodylines[0];
89     shift @bodylines while @bodylines and $bodylines[0] !~ /\S/;
90     for my $findsig (0 .. $#bodylines) {
91         if ($bodylines[$findsig] =~ /^-----BEGIN PGP SIGNATURE/) {
92             $#bodylines = $findsig - 1;
93             last;
94         }
95     }
96     map { s/^- // } @bodylines;
97 }
98
99 grep(s/\s+$//,@bodylines);
100
101 print "***\n",join("\n",@bodylines),"\n***\n" if $debug;
102
103 if (defined $header{'resent-from'} && !defined $header{'from'}) {
104     $header{'from'} = $header{'resent-from'};
105 }
106
107 defined($header{'from'}) || &quit("no From header");
108
109 delete $header{'reply-to'} 
110         if ( defined($header{'reply-to'}) && $header{'reply-to'} =~ m/^\s*$/ );
111
112 if ( defined($header{'reply-to'}) && $header{'reply-to'} ne "" ) {
113     $replyto = $header{'reply-to'};
114 } else {
115     $replyto = $header{'from'};
116 }
117
118 $controlrequestaddr= $control ? "control\@$gEmailDomain" : "request\@$gEmailDomain";
119 $transcript='';
120 &transcript("Processing commands for $controlrequestaddr:\n\n");
121
122 $dl= 0;
123 $state= 'idle';
124 $lowstate= 'idle';
125 $mergelowstate= 'idle';
126 $midix=0;    
127 $extras="";
128
129 my $quickabort = 0;
130
131 my $fuckheads = "(" . join("|", @gFuckheads) . ")";
132 if (@gFuckheads and $replyto =~ m/$fuckheads/) {
133         &transcript("This service is unavailable.\n\n");
134         $quickabort = 1;
135 }
136
137 my %limit_pkgs = ();
138 my %clonebugs = ();
139 my @bcc = ();
140
141 sub addbcc {
142     push @bcc, $_[0] unless grep { $_ eq $_[0] } @bcc;
143 }
144
145 for ($procline=0; $procline<=$#bodylines; $procline++) {
146     $state eq 'idle' || print "$state ?\n";
147     $lowstate eq 'idle' || print "$lowstate ?\n";
148     $mergelowstate eq 'idle' || print "$mergelowstate ?\n";
149     if ($quickabort) {
150          &transcript("Stopping processing here.\n\n");
151          last;
152     }
153     $_= $bodylines[$procline]; s/\s+$//;
154     next unless m/\S/;
155     &transcript("> $_\n");
156     next if m/^\s*\#/;
157     $action= '';
158     if (m/^stop/i || m/^quit/i || m/^--/ || m/^thank/i) {
159         &transcript("Stopping processing here.\n\n");
160         last;
161     } elsif (m/^debug\s+(\d+)$/i && $1 >= 0 && $1 <= 1000) {
162         $dl= $1+0;
163         &transcript("Debug level $dl.\n\n");
164     } elsif (m/^(send|get)\s+\#?(\d{2,})$/i) {
165         $ref= $2+0;
166         &sendlynxdoc("bugreport.cgi?bug=$ref","logs for $gBug#$ref");
167     } elsif (m/^send-detail\s+\#?(\d{2,})$/i) {
168         $ref= $1+0;
169         &sendlynxdoc("bugreport.cgi?bug=$ref&boring=yes",
170                      "detailed logs for $gBug#$ref");
171     } elsif (m/^index(\s+full)?$/i) {
172         &transcript("This BTS function is currently disabled, sorry.\n\n");
173         $ok++; # well, it's not really ok, but it fixes #81224 :)
174     } elsif (m/^index-summary\s+by-package$/i) {
175         &transcript("This BTS function is currently disabled, sorry.\n\n");
176         $ok++; # well, it's not really ok, but it fixes #81224 :)
177     } elsif (m/^index-summary(\s+by-number)?$/i) {
178         &transcript("This BTS function is currently disabled, sorry.\n\n");
179         $ok++; # well, it's not really ok, but it fixes #81224 :)
180     } elsif (m/^index(\s+|-)pack(age)?s?$/i) {
181         &sendlynxdoc("pkgindex.cgi?indexon=pkg",'index of packages');
182     } elsif (m/^index(\s+|-)maints?$/i) {
183         &sendlynxdoc("pkgindex.cgi?indexon=maint",'index of maintainers');
184     } elsif (m/^index(\s+|-)maint\s+(\S+)$/i) {
185         $maint = $2;
186         &sendlynxdoc("pkgreport.cgi?maint=" . urlsanit($maint),
187                      "$gBug list for maintainer \`$maint'");
188         $ok++;
189     } elsif (m/^index(\s+|-)pack(age)?s?\s+(\S.*\S)$/i) {
190         $package = $+;
191         &sendlynxdoc("pkgreport.cgi?pkg=" . urlsanit($package),
192                      "$gBug list for package $package");
193         $ok++;
194     } elsif (m/^send-unmatched(\s+this|\s+-?0)?$/i) {
195         &transcript("This BTS function is currently disabled, sorry.\n\n");
196         $ok++; # well, it's not really ok, but it fixes #81224 :)
197     } elsif (m/^send-unmatched\s+(last|-1)$/i) {
198         &transcript("This BTS function is currently disabled, sorry.\n\n");
199         $ok++; # well, it's not really ok, but it fixes #81224 :)
200     } elsif (m/^send-unmatched\s+(old|-2)$/i) {
201         &transcript("This BTS function is currently disabled, sorry.\n\n");
202         $ok++; # well, it's not really ok, but it fixes #81224 :)
203     } elsif (m/^getinfo\s+([\w-.]+)$/i) {
204         # the following is basically a Debian-specific kludge, but who cares
205         $req = $1;
206         if ($req =~ /^maintainers$/i && -f "$gConfigDir/Maintainers") {
207             &sendinfo("local", "$gConfigDir/Maintainers", "Maintainers file");
208         } elsif ($req =~ /^override\.(\w+)\.([\w-.]+)$/i) {
209             $req =~ s/.gz$//;
210             &sendinfo("ftp.d.o", "$req", "override file for $2 part of $1 distribution");
211         } elsif ($req =~ /^pseudo-packages\.(description|maintainers)$/i && -f "$gConfigDir/$req") {
212             &sendinfo("local", "$gConfigDir/$req", "$req file");
213         } else {
214             &transcript("Info file $req does not exist.\n\n");
215         }
216     } elsif (m/^help/i) {
217         &sendhelp;
218         &transcript("\n");
219         $ok++;
220     } elsif (m/^refcard/i) {
221         &sendtxthelp("bug-mailserver-refcard.txt","mail servers' reference card");
222     } elsif (m/^subscribe/i) {
223         &transcript(<<END);
224 There is no $gProject $gBug mailing list.  If you wish to review bug reports
225 please do so via http://$gWebDomain/ or ask this mail server
226 to send them to you.
227 soon: MAILINGLISTS_TEXT
228 END
229     } elsif (m/^unsubscribe/i) {
230         &transcript(<<END);
231 soon: UNSUBSCRIBE_TEXT
232 soon: MAILINGLISTS_TEXT
233 END
234     } elsif (!$control) {
235         &transcript(<<END);
236 Unknown command or malformed arguments to command.
237 (Use control\@$gEmailDomain to manipulate reports.)
238
239 END
240         if (++$unknowns >= 3) {
241             &transcript("Too many unknown commands, stopping here.\n\n");
242             last;
243         }
244 #### interesting ones start here
245     } elsif (m/^close\s+\#?(-?\d+)(?:\s+(\d.*))?$/i) {
246         $ok++;
247         $ref= $1;
248         $version= $2;
249         if (&setbug) {
250             &transcript("'close' is deprecated; see http://$gWebDomain/Developer$gHTMLSuffix#closing.\n");
251             if (length($data->{done}) and not defined($version)) {
252                 &transcript("$gBug is already closed, cannot re-close.\n\n");
253                 &nochangebug;
254             } else {
255                 $action= "$gBug " .
256                     (defined($version) ?
257                         "marked as fixed in version $version" :
258                         "closed") .
259                     ", send any further explanations to $data->{originator}";
260                 do {
261                     &addmaintainers($data);
262                                         if ( length( $gDoneList ) > 0 && length( $gListDomain ) >
263                                         0 ) { &addccaddress("$gDoneList\@$gListDomain"); }
264                     $data->{done}= $replyto;
265                     my @keywords= split ' ', $data->{keywords};
266                     if (grep $_ eq 'pending', @keywords) {
267                         $extramessage= "Removed pending tag.\n";
268                         $data->{keywords}= join ' ', grep $_ ne 'pending',
269                                                 @keywords;
270                     }
271                     addfixedversions($data, undef, $version);
272
273                     $message= <<END;
274 From: $gMaintainerEmail ($gProject $gBug Tracking System)
275 To: $data->{originator}
276 Subject: $gBug#$ref acknowledged by developer
277          ($header{'subject'})
278 References: $header{'message-id'} $data->{msgid}
279 In-Reply-To: $data->{msgid}
280 Message-ID: <handler.$ref.$nn.notifdonectrl.$midix\@$gEmailDomain>
281 Reply-To: $ref\@$gEmailDomain
282 X-$gProject-PR-Message: they-closed-control $ref
283
284 This is an automatic notification regarding your $gBug report
285 #$ref: $data->{subject},
286 which was filed against the $data->{package} package.
287
288 It has been marked as closed by one of the developers, namely
289 $replyto.
290
291 You should be hearing from them with a substantive response shortly,
292 in case you haven't already. If not, please contact them directly.
293
294 $gMaintainer
295 (administrator, $gProject $gBugs database)
296
297 END
298                     &sendmailmessage($message,$data->{originator});
299                 } while (&getnextbug);
300             }
301         }
302     } elsif (m/^reassign\s+\#?(-?\d+)\s+(\S+)(?:\s+(\d.*))?$/i) {
303         $ok++;
304         $ref= $1; $newpackage= $2;
305         $version= $3;
306         $newpackage =~ y/A-Z/a-z/;
307         if (&setbug) {
308             if (length($data->{package})) {
309                 $action= "$gBug reassigned from package \`$data->{package}'".
310                          " to \`$newpackage'.";
311             } else {
312                 $action= "$gBug assigned to package \`$newpackage'.";
313             }
314             do {
315                 &addmaintainers($data);
316                 $data->{package}= $newpackage;
317                 $data->{found_versions}= [];
318                 $data->{fixed_versions}= [];
319                 # TODO: what if $newpackage is a source package?
320                 addfoundversions($data, undef, $version) if defined $version;
321                 &addmaintainers($data);
322             } while (&getnextbug);
323         }
324     } elsif (m/^reopen\s+\#?(-?\d+)$/i ? ($noriginator='', 1) :
325              m/^reopen\s+\#?(-?\d+)\s+\=$/i ? ($noriginator='', 1) :
326              m/^reopen\s+\#?(-?\d+)\s+\!$/i ? ($noriginator=$replyto, 1) :
327              m/^reopen\s+\#?(-?\d+)\s+(\S.*\S)$/i ? ($noriginator=$2, 1) : 0) {
328         $ok++;
329         $ref= $1;
330         if (&setbug) {
331             if (@{$data->{fixed_versions}}) {
332                 &transcript("'reopen' is deprecated when a bug has been closed with a version;\nuse 'found' or 'submitter' as appropriate instead.\n");
333             }
334             if (!length($data->{done})) {
335                 &transcript("$gBug is already open, cannot reopen.\n\n");
336                 &nochangebug;
337             } else {
338                 $action=
339                     $noriginator eq '' ? "$gBug reopened, originator not changed." :
340                         "$gBug reopened, originator set to $noriginator.";
341                 do {
342                     &addmaintainers($data);
343                     $data->{originator}= $noriginator eq '' ?  $data->{originator} : $noriginator;
344                     $data->{fixed_versions}= [];
345                     $data->{done}= '';
346                 } while (&getnextbug);
347             }
348         }
349     } elsif (m/^found\s+\#?(-?\d+)(?:\s+(\d.*))?$/i) {
350         $ok++;
351         $ref= $1;
352         $version= $2;
353         if (&setbug) {
354             if (!length($data->{done}) and not defined($version)) {
355                 &transcript("$gBug is already open, cannot reopen.\n\n");
356                 &nochangebug;
357             } else {
358                 $action=
359                     defined($version) ?
360                         "$gBug marked as found in version $version." :
361                         "$gBug reopened.";
362                 do {
363                     &addmaintainers($data);
364                     # The 'done' field gets a bit weird with version
365                     # tracking, because a bug may be closed by multiple
366                     # people in different branches. Until we have something
367                     # more flexible, we set it every time a bug is fixed,
368                     # and clear it precisely when a found command is
369                     # received for the rightmost fixed-in version, which
370                     # equates to the most recent fixing of the bug, or when
371                     # a versionless found command is received.
372                     if (defined $version) {
373                         my $lastfixed =
374                             (reverse @{$data->{fixed_versions}})[0];
375                         # TODO: what if $data->{package} is a source package?
376                         addfoundversions($data, undef, $version);
377                         if (defined $lastfixed and $version eq $lastfixed) {
378                             $data->{done} = '';
379                         }
380                     } else {
381                         # Versionless found; assume old-style "not fixed at
382                         # all".
383                         $data->{fixed_versions} = [];
384                         $data->{done} = '';
385                     }
386                 } while (&getnextbug);
387             }
388         }
389     } elsif (m/^submitter\s+\#?(-?\d+)\s+\!$/i ? ($newsubmitter=$replyto, 1) :
390              m/^submitter\s+\#?(-?\d+)\s+(\S.*\S)$/i ? ($newsubmitter=$2, 1) : 0) {
391         $ok++;
392         $ref= $1;
393         if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
394             $ref = $clonebugs{$ref};
395         }
396         if (&getbug) {
397             if (&checkpkglimit) {
398                 &foundbug;
399                 &addmaintainers($data);
400                 $oldsubmitter= $data->{originator};
401                 $data->{originator}= $newsubmitter;
402                 $action= "Changed $gBug submitter from $oldsubmitter to $newsubmitter.";
403                 &savebug;
404                 &transcript("$action\n");
405                 if (length($data->{done})) {
406                     &transcript("(By the way, that $gBug is currently marked as done.)\n");
407                 }
408                 &transcript("\n");
409                 $message= <<END;
410 From: $gMaintainerEmail ($gProject $gBug Tracking System)
411 To: $oldsubmitter
412 Subject: $gBug#$ref submitter address changed
413          ($header{'subject'})
414 References: $header{'message-id'} $data->{msgid}
415 In-Reply-To: $data->{msgid}
416 Message-ID: <handler.$ref.$nn.newsubmitter.$midix\@$gEmailDomain>
417 Reply-To: $ref\@$gEmailDomain
418 X-$gProject-PR-Message: submitter-changed $ref
419
420 The submitter address recorded for your $gBug report
421 #$ref: $data->{subject}
422 has been changed.
423
424 The new submitter address for this report is
425 $newsubmitter.
426
427 This change was made by
428 $replyto.
429 If it was incorrect, please contact them directly.
430
431 $gMaintainer
432 (administrator, $gProject $gBugs database)
433
434 END
435                 &sendmailmessage($message,$oldsubmitter);
436             } else {
437                 &cancelbug;
438             }
439         } else {
440             &notfoundbug;
441         }
442     } elsif (m/^forwarded\s+\#?(-?\d+)\s+(\S.*\S)$/i) {
443         $ok++;
444         $ref= $1; $whereto= $2;
445         if (&setbug) {
446             if (length($data->{forwarded})) {
447     $action= "Forwarded-to-address changed from $data->{forwarded} to $whereto.";
448             } else {
449     $action= "Noted your statement that $gBug has been forwarded to $whereto.";
450             }
451             if (length($data->{done})) {
452                 $extramessage= "(By the way, this $gBug is currently marked as done.)\n";
453             }
454             do {
455                 &addmaintainers($data);
456                 if (length($gForwardList)>0 && length($gListDomain)>0 ) {
457                      &addccaddress("$gForwardList\@$gListDomain"); 
458                 }
459                 $data->{forwarded}= $whereto;
460             } while (&getnextbug);
461         }
462     } elsif (m/^notforwarded\s+\#?(-?\d+)$/i) {
463         $ok++;
464         $ref= $1;
465         if (&setbug) {
466             if (!length($data->{forwarded})) {
467                 &transcript("$gBug is not marked as having been forwarded.\n\n");
468                 &nochangebug;
469             } else {
470     $action= "Removed annotation that $gBug had been forwarded to $data->{forwarded}.";
471                 do {
472                     &addmaintainers($data);
473                     $data->{forwarded}= '';
474                 } while (&getnextbug);
475             }
476         }
477     } elsif (m/^severity\s+\#?(-?\d+)\s+([-0-9a-z]+)$/i ||
478         m/^priority\s+\#?(-?\d+)\s+([-0-9a-z]+)$/i) {
479         $ok++;
480         $ref= $1;
481         $newseverity= $2;
482         if (!grep($_ eq $newseverity, @gSeverityList, "$gDefaultSeverity")) {
483             &transcript("Severity level \`$newseverity' is not known.\n".
484                         "Recognized are: $gShowSeverities.\n\n");
485         } elsif (exists $gObsoleteSeverities{$newseverity}) {
486             &transcript("Severity level \`$newseverity' is obsolete. " .
487                         "$gObsoleteSeverities{$newseverity}\n\n");
488         } elsif (&setbug) {
489             $printseverity= $data->{severity};
490             $printseverity= "$gDefaultSeverity" if $printseverity eq '';
491             $action= "Severity set to \`$newseverity'.";
492             do {
493                 &addmaintainers($data);
494                 if (defined $gStrongList and isstrongseverity($newseverity)) {
495                     addbcc("$gStrongList\@$gListDomain");
496                 }
497                 $data->{severity}= $newseverity;
498             } while (&getnextbug);
499         }
500     } elsif (m/^tags?\s+\#?(-?\d+)\s+(([=+-])\s*)?(\S.*)?$/i) {
501         $ok++;
502         $ref = $1; $addsubcode = $3; $tags = $4;
503         $addsub = "add";
504         if (defined $addsubcode) {
505             $addsub = "sub" if ($addsubcode eq "-");
506             $addsub = "add" if ($addsubcode eq "+");
507             $addsub = "set" if ($addsubcode eq "=");
508         }
509         my @okaytags = ();
510         my @badtags = ();
511         foreach my $t (split /[\s,]+/, $tags) {
512             if (!grep($_ eq $t, @gTags)) {
513                 push @badtags, $t;
514             } else {
515                 push @okaytags, $t;
516             }
517         }
518         if (@badtags) {
519             &transcript("Unknown tag/s: ".join(', ', @badtags).".\n".
520                         "Recognized are: ".join(' ', @gTags).".\n\n");
521         }
522         if (&setbug) {
523             if ($data->{keywords} eq '') {
524                 &transcript("There were no tags set.\n");
525             } else {
526                 &transcript("Tags were: $data->{keywords}\n");
527             }
528             if ($addsub eq "set") {
529                 $action= "Tags set to: " . join(", ", @okaytags);
530             } elsif ($addsub eq "add") {
531                 $action= "Tags added: " . join(", ", @okaytags);
532             } elsif ($addsub eq "sub") {
533                 $action= "Tags removed: " . join(", ", @okaytags);
534             }
535             do {
536                 &addmaintainers($data);
537                 $data->{keywords} = '' if ($addsub eq "set");
538                 # Allow removing obsolete tags.
539                 if ($addsub eq "sub") {
540                     foreach my $t (@badtags) {
541                         $data->{keywords} = join ' ', grep $_ ne $t, 
542                             split ' ', $data->{keywords};
543                     }
544                 }
545                 # Now process all other additions and subtractions.
546                 foreach my $t (@okaytags) {
547                     $data->{keywords} = join ' ', grep $_ ne $t, 
548                         split ' ', $data->{keywords};
549                     $data->{keywords} = "$t $data->{keywords}" unless($addsub eq "sub");
550                 }
551                 $data->{keywords} =~ s/\s*$//;
552             } while (&getnextbug);
553         }
554     } elsif (m/^retitle\s+\#?(-?\d+)\s+(\S.*\S)\s*$/i) {
555         $ok++;
556         $ref= $1; $newtitle= $2;
557         if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
558             $ref = $clonebugs{$ref};
559         }
560         if (&getbug) {
561             if (&checkpkglimit) {
562                 &foundbug;
563                 &addmaintainers($data);
564                 $data->{subject}= $newtitle;
565                 $action= "Changed $gBug title.";
566                 &savebug;
567                 &transcript("$action\n");
568                 if (length($data->{done})) {
569                     &transcript("(By the way, that $gBug is currently marked as done.)\n");
570                 }
571                 &transcript("\n");
572             } else {
573                 &cancelbug;
574             }
575         } else {
576             &notfoundbug;
577         }
578     } elsif (m/^unmerge\s+\#?(-?\d+)$/i) {
579         $ok++;
580         $ref= $1;
581         if (&setbug) {
582             if (!length($data->{mergedwith})) {
583                 &transcript("$gBug is not marked as being merged with any others.\n\n");
584                 &nochangebug;
585             } else {
586                 $mergelowstate eq 'locked' || die "$mergelowstate ?";
587                 $action= "Disconnected #$ref from all other report(s).";
588                 @newmergelist= split(/ /,$data->{mergedwith});
589                 $discref= $ref;
590                 do {
591                     &addmaintainers($data);
592                     $data->{mergedwith}= ($ref == $discref) ? ''
593                         : join(' ',grep($_ ne $ref,@newmergelist));
594                 } while (&getnextbug);
595             }
596         }
597     } elsif (m/^merge\s+#?(-?\d+(\s+#?-?\d+)+)\s*$/i) {
598         $ok++;
599         @tomerge= sort { $a <=> $b } split(/\s+#?/,$1);
600         @newmergelist= ();
601         my %tags = ();
602         my %found = ();
603         my %fixed = ();
604         &getmerge;
605         while (defined($ref= shift(@tomerge))) {
606             &transcript("D| checking merge $ref\n") if $dl;
607             $ref+= 0;
608             if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
609                 $ref = $clonebugs{$ref};
610             }
611             next if grep($_ eq $ref,@newmergelist);
612             if (!&getbug) { &notfoundbug; @newmergelist=(); last }
613             if (!&checkpkglimit) { &cancelbug; @newmergelist=(); last; }
614             &foundbug;
615             &transcript("D| adding $ref ($data->{mergedwith})\n") if $dl;
616             $mismatch= '';
617             &checkmatch('package','m_package',$data->{package});
618             &checkmatch('forwarded addr','m_forwarded',$data->{forwarded});
619             $data->{severity} = '$gDefaultSeverity' if $data->{severity} eq '';
620             &checkmatch('severity','m_severity',$data->{severity});
621             &checkmatch('done mark','m_done',length($data->{done}) ? 'done' : 'open');
622             &checkmatch('owner','m_owner',$data->{owner});
623             foreach my $t (split /\s+/, $data->{keywords}) { $tags{$t} = 1; }
624             foreach my $f (@{$data->{found_versions}}) { $found{$f} = 1; }
625             foreach my $f (@{$data->{fixed_versions}}) { $fixed{$f} = 1; }
626             if (length($mismatch)) {
627                 &transcript("Mismatch - only $gBugs in same state can be merged:\n".
628                             $mismatch."\n");
629                 &cancelbug; @newmergelist=(); last;
630             }
631             push(@newmergelist,$ref);
632             push(@tomerge,split(/ /,$data->{mergedwith}));
633             &cancelbug;
634         }
635         if (@newmergelist) {
636             @newmergelist= sort { $a <=> $b } @newmergelist;
637             $action= "Merged @newmergelist.";
638             delete @fixed{keys %found};
639             for $ref (@newmergelist) {
640                 &getbug || die "huh ?  $gBug $ref disappeared during merge";
641                 &addmaintainers($data);
642                 $data->{mergedwith}= join(' ',grep($_ ne $ref,@newmergelist));
643                 $data->{keywords}= join(' ', keys %tags);
644                 $data->{found_versions}= [sort keys %found];
645                 $data->{fixed_versions}= [sort keys %fixed];
646                 &savebug;
647             }
648             &transcript("$action\n\n");
649         }
650         &endmerge;
651     } elsif (m/^clone\s+#?(\d+)\s+((-\d+\s+)*-\d+)\s*$/i) {
652         $ok++;
653
654         $origref = $1;
655         @newclonedids = split /\s+/, $2;
656         $newbugsneeded = scalar(@newclonedids);
657
658         $ref = $origref;
659         if (&setbug) {
660             if (length($data->{mergedwith})) {
661                 &transcript("$gBug is marked as being merged with others.\n\n");
662                 &nochangebug;
663             } else {
664                 &filelock("nextnumber.lock");
665                 open(N,"nextnumber") || &quit("nextnumber: read: $!");
666                 $v=<N>; $v =~ s/\n$// || &quit("nextnumber bad format");
667                 $firstref= $v+0;  $v += $newbugsneeded;
668                 open(NN,">nextnumber"); print NN "$v\n"; close(NN);
669                 &unfilelock;
670
671                 $lastref = $firstref + $newbugsneeded - 1;
672
673                 if ($newbugsneeded == 1) {
674                     $action= "$gBug $origref cloned as bug $firstref.";
675                 } else {
676                     $action= "$gBug $origref cloned as bugs $firstref-$lastref.";
677                 }
678                 &getnextbug;
679                 my $ohash = get_hashname($origref);
680                 $ref = $firstref;
681                 for $newclonedid (@newclonedids) {
682                     $clonebugs{$newclonedid} = $ref;
683             
684                     my $hash = get_hashname($ref);
685                     copy("db-h/$ohash/$origref.log", "db-h/$hash/$ref.log");
686                     copy("db-h/$ohash/$origref.status", "db-h/$hash/$ref.status");
687                     copy("db-h/$ohash/$origref.summary", "db-h/$hash/$ref.summary");
688                     copy("db-h/$ohash/$origref.report", "db-h/$hash/$ref.report");
689                     &bughook('new', $ref, $data);
690
691                     $ref++;
692                 }
693             }
694         }
695     } elsif (m/^package\s+(\S.*\S)?\s*$/i) {
696         $ok++;
697         my @pkgs = split /\s+/, $1;
698         if (scalar(@pkgs) > 0) {
699                 %limit_pkgs = map { ($_, 1) } @pkgs;
700                 &transcript("Ignoring bugs not assigned to: " . 
701                         join(" ", keys(%limit_pkgs)) . "\n\n");
702         } else {
703                 %limit_pkgs = ();
704                 &transcript("Not ignoring any bugs.\n\n");
705         }
706     } elsif (m/^owner\s+\#?(-?\d+)\s+!$/i ? ($newowner = $replyto, 1) :
707              m/^owner\s+\#?(-?\d+)\s+(\S.*\S)$/i ? ($newowner = $2, 1) : 0) {
708         $ok++;
709         $ref = $1;
710         if (&setbug) {
711             if (length $data->{owner}) {
712                 $action = "Owner changed from $data->{owner} to $newowner.";
713             } else {
714                 $action = "Owner recorded as $newowner.";
715             }
716             if (length $data->{done}) {
717                 $extramessage = "(By the way, this $gBug is currently " .
718                                 "marked as done.)\n";
719             }
720             do {
721                 &addmaintainers($data);
722                 $data->{owner} = $newowner;
723             } while (&getnextbug);
724         }
725     } elsif (m/^noowner\s+\#?(-?\d+)$/i) {
726         $ok++;
727         $ref = $1;
728         if (&setbug) {
729             if (length $data->{owner}) {
730                 $action = "Removed annotation that $gBug was owned by " .
731                           "$data->{owner}.";
732                 do {
733                     &addmaintainers($data);
734                     $data->{owner} = '';
735                 } while (&getnextbug);
736             } else {
737                 &transcript("$gBug is not marked as having an owner.\n\n");
738                 &nochangebug;
739             }
740         }
741     } else {
742         &transcript("Unknown command or malformed arguments to command.\n\n");
743         if (++$unknowns >= 5) {
744             &transcript("Too many unknown commands, stopping here.\n\n");
745             last;
746         }
747     }
748 }
749 if ($procline>$#bodylines) {
750     &transcript(">\nEnd of message, stopping processing here.\n\n");
751 }
752 if (!$ok && !quickabort) {
753     &transcript("No commands successfully parsed; sending the help text(s).\n");
754     &sendhelp;
755     &transcript("\n");
756 }
757
758 &transcript("MC\n") if $dl>1;
759 @maintccs= ();
760 for $maint (keys %maintccreasons) {
761 &transcript("MM|$maint|\n") if $dl>1;
762     next if $maint eq $replyto;
763     $reasonstring= '';
764     $reasonsref= $maintccreasons{$maint};
765 &transcript("MY|$maint|\n") if $dl>2;
766     for $p (sort keys %$reasonsref) {
767 &transcript("MP|$p|\n") if $dl>2;
768         $reasonstring.= ', ' if length($reasonstring);
769         $reasonstring.= $p.' ' if length($p);
770         $reasonstring.= join(' ',map("#$_",sort keys %{$$reasonsref{$p}}));
771     }
772     if (length($reasonstring) > 40) {
773         (substr $reasonstring, 37) = "...";
774     }
775     $reasonstring = "" if (!defined($reasonstring));
776     push(@maintccs,"$maint ($reasonstring)");
777     push(@maintccaddrs,"$maint");
778 }
779
780 $maintccs = ""; 
781 if (@maintccs) {
782     &transcript("MC|@maintccs|\n") if $dl>2;
783     $maintccs .= "Cc: " . join(",\n    ",@maintccs) . "\n";
784 }
785
786 if (!defined $header{'subject'} || $header{'subject'} eq "") {
787   $header{'subject'} = "your mail";
788 }
789
790 $reply= <<END;
791 From: $gMaintainerEmail ($gProject $gBug Tracking System)
792 To: $replyto
793 ${maintccs}Subject: Processed: $header{'subject'}
794 In-Reply-To: $header{'message-id'}
795 References: $header{'message-id'}
796 Message-ID: <handler.s.$nn.transcript\@$gEmailDomain>
797 Precedence: bulk
798 X-$gProject-PR-Message: transcript
799
800 ${transcript}Please contact me if you need assistance.
801
802 $gMaintainer
803 (administrator, $gProject $gBugs database)
804 $extras
805 END
806
807 $repliedshow= join(', ',$replyto,@maintccaddrs);
808 &filelock("lock/-1");
809 open(AP,">>db-h/-1.log") || &quit("open db-h/-1.log: $!");
810 print(AP
811       "\2\n$repliedshow\n\5\n$reply\n\3\n".
812       "\6\n".
813       "<strong>Request received</strong> from <code>".
814       &sani($header{'from'})."</code>\n".
815       "to <code>".&sani($controlrequestaddr)."</code>\n".
816       "\3\n".
817       "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/-1.log: $!");
818 close(AP) || &quit("open db-h/-1.log: $!");
819 &unfilelock;
820 utime(time,time,"db-h");
821
822 &sendmailmessage($reply,$replyto,@maintccaddrs,@bcc);
823
824 unlink("incoming/P$nn") || &quit("unlinking incoming/P$nn: $!");
825
826 sub sendmailmessage {
827     local ($message,@recips) = @_;
828     $message = "X-Loop: $gMaintainerEmail\n" . $message;
829     print "mailing to >@recips<\n" if $debug;
830     $c= open(D,"|-");
831     defined($c) || &quit("mailing forking for sendmail: $!");
832     if (!$c) { # ie, we are the child process
833         exec '/usr/lib/sendmail','-f'."$gMaintainerEmail",'-odb','-oem','-oi',get_addresses(@recips);
834         die $!;
835     }
836     print(D $message) || &quit("writing to sendmail process: $!");
837     $!=0; close(D); $? && &quit("sendmail gave exit status $? ($!)");
838     $midix++;
839 }
840
841 sub sendhelp {
842         &sendtxthelpraw("bug-log-mailserver.txt","instructions for request\@$gEmailDomain");
843         &sendtxthelpraw("bug-maint-mailcontrol.txt","instructions for control\@$gEmailDomain")
844             if $control;
845 }
846
847 #sub unimplemented {
848 #    &transcript("Sorry, command $_[0] not yet implemented.\n\n");
849 #}
850
851 sub checkmatch {
852     local ($string,$mvarname,$svarvalue) = @_;
853     local ($mvarvalue);
854     if (@newmergelist) {
855         eval "\$mvarvalue= \$$mvarname";
856         &transcript("D| checkmatch \`$string' /$mvarname/$mvarvalue/$svarvalue/\n")
857             if $dl;
858         $mismatch .=
859             "Values for \`$string' don't match:\n".
860             " #$newmergelist[0] has \`$mvarvalue';\n".
861             " #$ref has \`$svarvalue'\n"
862             if $mvarvalue ne $svarvalue;
863     } else {
864         &transcript("D| setupmatch \`$string' /$mvarname/$svarvalue/\n")
865             if $dl;
866         eval "\$$mvarname= \$svarvalue";
867     }
868 }
869
870 sub checkpkglimit {
871     if (keys %limit_pkgs and not defined $limit_pkgs{$data->{package}}) {
872         &transcript("$gBug number $ref belongs to package $data->{package}, skipping.\n\n");
873         return 0;
874     }
875     return 1;
876 }
877
878 # High-level bug manipulation calls
879 # Do announcements themselves
880 #
881 # Possible calling sequences:
882 #    setbug (returns 0)
883 #    
884 #    setbug (returns 1)
885 #    &transcript(something)
886 #    nochangebug
887 #
888 #    setbug (returns 1)
889 #    $action= (something)
890 #    do {
891 #      (modify s_* variables)
892 #    } while (getnextbug);
893
894 sub nochangebug {
895     &dlen("nochangebug");
896     $state eq 'single' || $state eq 'multiple' || die "$state ?";
897     &cancelbug;
898     &endmerge if $manybugs;
899     $state= 'idle';
900     &dlex("nochangebug");
901 }
902
903 sub setbug {
904     &dlen("setbug $ref");
905     if ($ref =~ m/^-\d+/) {
906         if (!defined $clonebugs{$ref}) {
907             &notfoundbug;
908             &dlex("setbug => noclone");
909             return 0;
910         }
911         $ref = $clonebugs{$ref};
912     }
913     $state eq 'idle' || die "$state ?";
914     if (!&getbug) {
915         &notfoundbug;
916         &dlex("setbug => 0s");
917         return 0;
918     }
919
920     if (!&checkpkglimit) {
921         &cancelbug;
922         return 0;
923     }
924
925     @thisbugmergelist= split(/ /,$data->{mergedwith});
926     if (!@thisbugmergelist) {
927         &foundbug;
928         $manybugs= 0;
929         $state= 'single';
930         $sref=$ref;
931         &dlex("setbug => 1s");
932         return 1;
933     }
934     &cancelbug;
935     &getmerge;
936     $manybugs= 1;
937     if (!&getbug) {
938         &notfoundbug;
939         &endmerge;
940         &dlex("setbug => 0mc");
941         return 0;
942     }
943     &foundbug;
944     $state= 'multiple'; $sref=$ref;
945     &dlex("setbug => 1m");
946     return 1;
947 }
948
949 sub getnextbug {
950     &dlen("getnextbug");
951     $state eq 'single' || $state eq 'multiple' || die "$state ?";
952     &savebug;
953     if (!$manybugs || !@thisbugmergelist) {
954         length($action) || die;
955         &transcript("$action\n$extramessage\n");
956         &endmerge if $manybugs;
957         $state= 'idle';
958         &dlex("getnextbug => 0");
959         return 0;
960     }
961     $ref= shift(@thisbugmergelist);
962     &getbug || die "bug $ref disappeared";
963     &foundbug;
964     &dlex("getnextbug => 1");
965     return 1;
966 }
967
968 # Low-level bug-manipulation calls
969 # Do no announcements
970 #
971 #    getbug (returns 0)
972 #
973 #    getbug (returns 1)
974 #    cancelbug
975 #
976 #    getmerge
977 #    $action= (something)
978 #    getbug (returns 1)
979 #    savebug/cancelbug
980 #    getbug (returns 1)
981 #    savebug/cancelbug
982 #    [getbug (returns 0)]
983 #    &transcript("$action\n\n")
984 #    endmerge
985
986 sub notfoundbug { &transcript("$gBug number $ref not found.\n\n"); }
987 sub foundbug { &transcript("$gBug#$ref: $data->{subject}\n"); }
988
989 sub getmerge {
990     &dlen("getmerge");
991     $mergelowstate eq 'idle' || die "$mergelowstate ?";
992     &filelock('lock/merge');
993     $mergelowstate='locked';
994     &dlex("getmerge");
995 }
996
997 sub endmerge {
998     &dlen("endmerge");
999     $mergelowstate eq 'locked' || die "$mergelowstate ?";
1000     &unfilelock;
1001     $mergelowstate='idle';
1002     &dlex("endmerge");
1003 }
1004
1005 sub getbug {
1006     &dlen("getbug $ref");
1007     $lowstate eq 'idle' || die "$state ?";
1008     if (($data = &lockreadbug($ref))) {
1009         $sref= $ref;
1010         $lowstate= "open";
1011         &dlex("getbug => 1");
1012         $extramessage='';
1013         return 1;
1014     }
1015     $lowstate= 'idle';
1016     &dlex("getbug => 0");
1017     return 0;
1018 }
1019
1020 sub cancelbug {
1021     &dlen("cancelbug");
1022     $lowstate eq 'open' || die "$state ?";
1023     &unfilelock;
1024     $lowstate= 'idle';
1025     &dlex("cancelbug");
1026 }
1027
1028 sub savebug {
1029     &dlen("savebug $ref");
1030     $lowstate eq 'open' || die "$lowstate ?";
1031     length($action) || die;
1032     $ref == $sref || die "read $sref but saving $ref ?";
1033     my $hash = get_hashname($ref);
1034     open(L,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log: $!");
1035     print(L
1036           "\6\n".
1037           "<strong>".&sani($action)."</strong>\n".
1038           "Request was from <code>".&sani($header{'from'})."</code>\n".
1039           "to <code>".&sani($controlrequestaddr)."</code>. \n".
1040           "\3\n".
1041           "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/$hash/$ref.log: $!");
1042     close(L) || &quit("closing db-h/$hash/$ref.log: $!");
1043     unlockwritebug($ref, $data);
1044     $lowstate= "idle";
1045     &dlex("savebug");
1046 }
1047
1048 sub dlen {
1049     return if !$dl;
1050     &transcript("C> @_ ($state $lowstate $mergelowstate)\n");
1051 }
1052
1053 sub dlex {
1054     return if !$dl;
1055     &transcript("R> @_ ($state $lowstate $mergelowstate)\n");
1056 }
1057
1058 sub transcript {
1059     print $_[0] if $debug;
1060     $transcript.= $_[0];
1061 }
1062
1063 sub urlsanit {
1064     my $url = shift;
1065     $url =~ s/%/%25/g;
1066     $url =~ s/\+/%2b/g;
1067     my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
1068     $url =~ s/([<>&"])/\&$saniarray{$1};/g;
1069     return $url;
1070 }
1071
1072 sub sendlynxdoc {
1073     &sendlynxdocraw;
1074     &transcript("\n");
1075     $ok++;
1076 }
1077
1078 sub sendtxthelp {
1079     &sendtxthelpraw;
1080     &transcript("\n");
1081     $ok++;
1082 }
1083
1084 sub sendtxthelpraw {
1085     local ($relpath,$description) = @_;
1086     $doc='';
1087     open(D,"$gDocDir/$relpath") || &quit("open doc file $relpath: $!");
1088     while(<D>) { $doc.=$_; }
1089     close(D);
1090     &transcript("Sending $description in separate message.\n");
1091     &sendmailmessage(<<END.$doc,$replyto);
1092 From: $gMaintainerEmail ($gProject $gBug Tracking System)
1093 To: $replyto
1094 Subject: $gProject $gBug help: $description
1095 References: $header{'message-id'}
1096 In-Reply-To: $header{'message-id'}
1097 Message-ID: <handler.s.$nn.help.$midix\@$gEmailDomain>
1098 Precedence: bulk
1099 X-$gProject-PR-Message: doc-text $relpath
1100
1101 END
1102     $ok++;
1103 }
1104
1105 sub sendlynxdocraw {
1106     local ($relpath,$description) = @_;
1107     $doc='';
1108     open(L,"lynx -nolist -dump http://$gCGIDomain/\Q$relpath\E 2>&1 |") || &quit("fork for lynx: $!");
1109     while(<L>) { $doc.=$_; }
1110     $!=0; close(L);
1111     if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
1112         &transcript("Information ($description) is not available -\n".
1113                     "perhaps the $gBug does not exist or is not on the WWW yet.\n");
1114          $ok++;
1115     } elsif ($?) {
1116         &transcript("Error getting $description (code $? $!):\n$doc\n");
1117     } else {
1118         &transcript("Sending $description.\n");
1119         &sendmailmessage(<<END.$doc,$replyto);
1120 From: $gMaintainerEmail ($gProject $gBug Tracking System)
1121 To: $replyto
1122 Subject: $gProject $gBugs information: $description
1123 References: $header{'message-id'}
1124 In-Reply-To: $header{'message-id'}
1125 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
1126 Precedence: bulk
1127 X-$gProject-PR-Message: doc-html $relpath
1128
1129 END
1130          $ok++;
1131     }
1132 }
1133
1134 sub addccaddress {
1135     my ($cca) = @_;
1136     $maintccreasons{$cca}{''}{$ref}= 1;
1137 }
1138
1139 sub addmaintainers {
1140     # Data structure is:
1141     #   maintainer email address &c -> assoc of packages -> assoc of bug#'s
1142     my $data = shift;
1143     my ($p, $addmaint);
1144     &ensuremaintainersloaded;
1145     $anymaintfound=0; $anymaintnotfound=0;
1146     for $p (split(m/[ \t?,():]+/, $data->{package})) {
1147         $p =~ y/A-Z/a-z/;
1148         $p =~ /([a-z0-9.+-]+)/;
1149         $p = $1;
1150         next unless defined $p;
1151         if (defined $gSubscriptionDomain) {
1152             if (defined($pkgsrc{$p})) {
1153                 addbcc("$pkgsrc{$p}\@$gSubscriptionDomain");
1154             } else {
1155                 addbcc("$p\@$gSubscriptionDomain");
1156             }
1157         }
1158         if (defined $data->{severity} and defined $gStrongList and
1159                 isstrongseverity($data->{severity})) {
1160             addbcc("$gStrongList\@$gListDomain");
1161         }
1162         if (defined($maintainerof{$p})) {
1163             $addmaint= $maintainerof{$p};
1164             &transcript("MR|$addmaint|$p|$ref|\n") if $dl>2;
1165             $maintccreasons{$addmaint}{$p}{$ref}= 1;
1166             print "maintainer add >$p|$addmaint<\n" if $debug;
1167         } else { 
1168             print "maintainer none >$p<\n" if $debug; 
1169             &transcript("Warning: Unknown package '$p'\n");
1170             &transcript("MR|unknown-package|$p|$ref|\n") if $dl>2;
1171             $maintccreasons{$gUnknownMaintainerEmail}{$p}{$ref}= 1;
1172         }
1173     }
1174
1175     if (length $data->{owner}) {
1176         $addmaint = $data->{owner};
1177         &transcript("MO|$addmaint|$data->{package}|$ref|\n") if $dl>2;
1178         $maintccreasons{$addmaint}{$data->{package}}{$ref} = 1;
1179         print "owner add >$data->{package}|$addmaint<\n" if $debug;
1180     }
1181 }
1182
1183 sub ensuremaintainersloaded {
1184     my ($a,$b);
1185     return if $maintainersloaded++;
1186     open(MAINT,"$gMaintainerFile") || die &quit("maintainers open: $!");
1187     while (<MAINT>) {
1188         m/^\n$/ && next;
1189         m/^\s*$/ && next;
1190         m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers bogus \`$_'");
1191         $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
1192         $maintainerof{$1}= $2;
1193     }
1194     close(MAINT);
1195     open(MAINT,"$gMaintainerFileOverride") || die &quit("maintainers.override open: $!");
1196     while (<MAINT>) {
1197         m/^\n$/ && next;
1198         m/^\s*$/ && next;
1199         m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers.override bogus \`$_'");
1200         $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
1201         $maintainerof{$1}= $2;
1202     }
1203
1204     open(SOURCES, "$gPackageSource") || &quit("pkgsrc open: $!");
1205     while (<SOURCES>) {
1206         next unless m/^(\S+)\s+\S+\s+(\S.*\S)\s*$/;
1207         my ($a, $b) = ($1, $2);
1208         $pkgsrc{lc($a)} = $b;
1209     }
1210     close(SOURCES);
1211 }
1212
1213 sub sendinfo {
1214     local ($wherefrom,$path,$description) = @_;
1215     if ($wherefrom eq "ftp.d.o") {
1216       $doc = `lynx -nolist -dump http://ftp.debian.org/debian/indices/$path.gz 2>&1 | gunzip -cf` or &quit("fork for lynx/gunzip: $!");
1217       $! = 0;
1218       if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
1219           &transcript("$description is not available.\n");
1220           $ok++; return;
1221       } elsif ($?) {
1222           &transcript("Error getting $description (code $? $!):\n$doc\n");
1223           return;
1224       }
1225     } elsif ($wherefrom eq "local") {
1226       open P, "$path";
1227       $doc = do { local $/; <P> };
1228       close P;
1229     } else {
1230       &transcript("internal errror: info files location unknown.\n");
1231       $ok++; return;
1232     }
1233     &transcript("Sending $description.\n");
1234     &sendmailmessage(<<END.$doc,$replyto);
1235 From: $gMaintainerEmail ($gProject $gBug Tracking System)
1236 To: $replyto
1237 Subject: $gProject $gBugs information: $description
1238 References: $header{'message-id'}
1239 In-Reply-To: $header{'message-id'}
1240 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
1241 Precedence: bulk
1242 X-$gProject-PR-Message: getinfo
1243
1244 $description follows:
1245
1246 END
1247     $ok++;
1248     &transcript("\n");
1249 }