2 # $Id: service.in,v 1.88 2003/08/23 13:50:45 cjwatson Exp $
4 # Usage: service <code>.nn
5 # Temps: incoming/P<code>.nn
10 $config_path = '/etc/debbugs';
11 $lib_path = '/usr/lib/debbugs';
13 require "$config_path/config";
14 require "$lib_path/errorlib";
15 $ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};
17 chdir("$gSpoolDir") || die "chdir spool: $!\n";
20 open DEBUG, ">/dev/null";
25 m/^[RC]\.\d+$/ || &quit("bad argument");
28 if (!rename("incoming/G$nn","incoming/P$nn")) {
29 $_=$!.''; m/no such file or directory/i && exit 0;
30 &quit("renaming to lock: $!");
33 open(M,"incoming/P$nn");
40 print "###\n",join("##\n",@msg),"\n###\n" if $debug;
42 my $parser = new MIME::Parser;
43 mkdir "$gSpoolDir/mime.tmp", 0777;
44 $parser->output_under("$gSpoolDir/mime.tmp");
45 my $entity = eval { $parser->parse_data(join('',@log)) };
47 # header and decoded body respectively
48 my (@headerlines, @bodylines);
50 if ($entity and $entity->head->tags) {
51 @headerlines = @{$entity->head->header};
54 my $entity_body = getmailbody($entity);
55 @bodylines = $entity_body ? $entity_body->as_lines() : ();
58 # Legacy pre-MIME code, kept around in case MIME::Parser fails.
60 for ($i = 0; $i <= $#msg; $i++) {
62 last unless length($_);
63 while ($msg[$i+1] =~ m/^\s/) {
67 push @headerlines, $_;
70 @bodylines = @msg[$i..$#msg];
75 print ">$_<\n" if $debug;
78 print ">$v=$_<\n" if $debug;
81 print "!>$_<\n" if $debug;
85 # Strip off RFC2440-style PGP clearsigning.
86 if (@bodylines and $bodylines[0] =~ /^-----BEGIN PGP SIGNED/) {
87 shift @bodylines while @bodylines and length $bodylines[0];
88 shift @bodylines while @bodylines and $bodylines[0] !~ /\S/;
89 for my $findsig (0 .. $#bodylines) {
90 if ($bodylines[$findsig] =~ /^-----BEGIN PGP SIGNATURE/) {
91 $#bodylines = $findsig - 1;
95 map { s/^- // } @bodylines;
98 grep(s/\s+$//,@bodylines);
100 print "***\n",join("\n",@bodylines),"\n***\n" if $debug;
102 if (defined $header{'resent-from'} && !defined $header{'from'}) {
103 $header{'from'} = $header{'resent-from'};
106 defined($header{'from'}) || &quit("no From header");
108 delete $header{'reply-to'}
109 if ( defined($header{'reply-to'}) && $header{'reply-to'} =~ m/^\s*$/ );
111 if ( defined($header{'reply-to'}) && $header{'reply-to'} ne "" ) {
112 $replyto = $header{'reply-to'};
114 $replyto = $header{'from'};
117 $controlrequestaddr= $control ? "control\@$gEmailDomain" : "request\@$gEmailDomain";
119 &transcript("Processing commands for $controlrequestaddr:\n\n");
124 $mergelowstate= 'idle';
130 my $fuckheads = "(" . join("|", @gFuckheads) . ")";
131 if (@gFuckheads and $replyto =~ m/$fuckheads/) {
132 &transcript("This service is unavailable.\n\n");
140 for ($procline=0; $procline<=$#bodylines; $procline++) {
141 $state eq 'idle' || print "$state ?\n";
142 $lowstate eq 'idle' || print "$lowstate ?\n";
143 $mergelowstate eq 'idle' || print "$mergelowstate ?\n";
145 &transcript("Stopping processing here.\n\n");
148 $_= $bodylines[$procline]; s/\s+$//;
150 &transcript("> $_\n");
153 if (m/^stop/i || m/^quit/i || m/^--/ || m/^thank/i) {
154 &transcript("Stopping processing here.\n\n");
156 } elsif (m/^debug\s+(\d+)$/i && $1 >= 0 && $1 <= 1000) {
158 &transcript("Debug level $dl.\n\n");
159 } elsif (m/^(send|get)\s+\#?(\d{2,})$/i) {
161 &sendlynxdoc("bugreport.cgi?bug=$ref","logs for $gBug#$ref");
162 } elsif (m/^send-detail\s+\#?(\d{2,})$/i) {
164 &sendlynxdoc("bugreport.cgi?bug=$ref&boring=yes",
165 "detailed logs for $gBug#$ref");
166 } elsif (m/^index(\s+full)?$/i) {
167 &transcript("This BTS function is currently disabled, sorry.\n\n");
168 $ok++; # well, it's not really ok, but it fixes #81224 :)
169 } elsif (m/^index-summary\s+by-package$/i) {
170 &transcript("This BTS function is currently disabled, sorry.\n\n");
171 $ok++; # well, it's not really ok, but it fixes #81224 :)
172 } elsif (m/^index-summary(\s+by-number)?$/i) {
173 &transcript("This BTS function is currently disabled, sorry.\n\n");
174 $ok++; # well, it's not really ok, but it fixes #81224 :)
175 } elsif (m/^index(\s+|-)pack(age)?s?$/i) {
176 &sendlynxdoc("pkgindex.cgi?indexon=pkg",'index of packages');
177 } elsif (m/^index(\s+|-)maints?$/i) {
178 &sendlynxdoc("pkgindex.cgi?indexon=maint",'index of maintainers');
179 } elsif (m/^index(\s+|-)maint\s+(\S+)$/i) {
181 &sendlynxdoc("pkgreport.cgi?maint=" . urlsanit($maint),
182 "$gBug list for maintainer \`$maint'");
184 } elsif (m/^index(\s+|-)pack(age)?s?\s+(\S.*\S)$/i) {
186 &sendlynxdoc("pkgreport.cgi?pkg=" . urlsanit($package),
187 "$gBug list for package $package");
189 } elsif (m/^send-unmatched(\s+this|\s+-?0)?$/i) {
190 &transcript("This BTS function is currently disabled, sorry.\n\n");
191 $ok++; # well, it's not really ok, but it fixes #81224 :)
192 } elsif (m/^send-unmatched\s+(last|-1)$/i) {
193 &transcript("This BTS function is currently disabled, sorry.\n\n");
194 $ok++; # well, it's not really ok, but it fixes #81224 :)
195 } elsif (m/^send-unmatched\s+(old|-2)$/i) {
196 &transcript("This BTS function is currently disabled, sorry.\n\n");
197 $ok++; # well, it's not really ok, but it fixes #81224 :)
198 } elsif (m/^getinfo\s+([\w-.]+)$/i) {
199 # the following is basically a Debian-specific kludge, but who cares
201 if ($req =~ /^maintainers$/i && -f "$gConfigDir/Maintainers") {
202 &sendinfo("local", "$gConfigDir/Maintainers", "Maintainers file");
203 } elsif ($req =~ /^override\.(\w+)\.([\w-.]+)$/i) {
205 &sendinfo("ftp.d.o", "$req", "override file for $2 part of $1 distribution");
206 } elsif ($req =~ /^pseudo-packages\.(description|maintainers)$/i && -f "$gConfigDir/$req") {
207 &sendinfo("local", "$gConfigDir/$req", "$req file");
209 &transcript("Info file $req does not exist.\n\n");
211 } elsif (m/^help/i) {
215 } elsif (m/^refcard/i) {
216 &sendtxthelp("bug-mailserver-refcard.txt","mail servers' reference card");
217 } elsif (m/^subscribe/i) {
219 There is no $gProject $gBug mailing list. If you wish to review bug reports
220 please do so via http://$gWebDomain/ or ask this mail server
222 soon: MAILINGLISTS_TEXT
224 } elsif (m/^unsubscribe/i) {
226 soon: UNSUBSCRIBE_TEXT
227 soon: MAILINGLISTS_TEXT
229 } elsif (!$control) {
231 Unknown command or malformed arguments to command.
232 (Use control\@$gEmailDomain to manipulate reports.)
235 if (++$unknowns >= 3) {
236 &transcript("Too many unknown commands, stopping here.\n\n");
239 #### interesting ones start here
240 } elsif (m/^close\s+\#?(-?\d+)$/i) {
244 &transcript("'close' is deprecated; see http://$gWebDomain/Developer$gHTMLSuffix#closing.\n");
245 if (length($data->{done})) {
246 &transcript("$gBug is already closed, cannot re-close.\n\n");
249 $action= "$gBug closed, send any further explanations to $data->{originator}";
251 &addmaintainers($data->{package}, $data->{severity});
252 if ( length( $gDoneList ) > 0 && length( $gListDomain ) >
253 0 ) { &addccaddress("$gDoneList\@$gListDomain"); }
254 $data->{done}= $replyto;
255 my @keywords= split ' ', $data->{keywords};
256 if (grep $_ eq 'pending', @keywords) {
257 $extramessage= "Removed pending tag.\n";
258 $data->{keywords}= join ' ', grep $_ ne 'pending',
263 From: $gMaintainerEmail ($gProject $gBug Tracking System)
264 To: $data->{originator}
265 Subject: $gBug#$ref acknowledged by developer
267 References: $header{'message-id'} $data->{msgid}
268 In-Reply-To: $data->{msgid}
269 Message-ID: <handler.$ref.$nn.notifdonectrl.$midix\@$gEmailDomain>
270 Reply-To: $ref\@$gEmailDomain
272 This is an automatic notification regarding your $gBug report
273 #$ref: $data->{subject},
274 which was filed against the $data->{package} package.
276 It has been marked as closed by one of the developers, namely
279 You should be hearing from them with a substantive response shortly,
280 in case you haven't already. If not, please contact them directly.
283 (administrator, $gProject $gBugs database)
286 &sendmailmessage($message,$data->{originator});
287 } while (&getnextbug);
290 } elsif (m/^reassign\s+\#?(-?\d+)\s+(\S.*\S)$/i) {
292 $ref= $1; $newpackage= $2;
293 $newpackage =~ y/A-Z/a-z/;
295 if (length($data->{package})) {
296 $action= "$gBug reassigned from package \`$data->{package}'".
297 " to \`$newpackage'.";
299 $action= "$gBug assigned to package \`$newpackage'.";
302 &addmaintainers($data->{package}, $data->{severity});
303 &addmaintainers($newpackage);
304 $data->{package}= $newpackage;
305 } while (&getnextbug);
307 } elsif (m/^reopen\s+\#?(-?\d+)$/i ? ($noriginator='', 1) :
308 m/^reopen\s+\#?(-?\d+)\s+\=$/i ? ($noriginator='', 1) :
309 m/^reopen\s+\#?(-?\d+)\s+\!$/i ? ($noriginator=$replyto, 1) :
310 m/^reopen\s+\#?(-?\d+)\s+(\S.*\S)$/i ? ($noriginator=$2, 1) : 0) {
314 if (!length($data->{done})) {
315 &transcript("$gBug is already open, cannot reopen.\n\n");
319 $noriginator eq '' ? "$gBug reopened, originator not changed." :
320 "$gBug reopened, originator set to $noriginator.";
322 &addmaintainers($data->{package}, $data->{severity});
323 $data->{originator}= $noriginator eq '' ? $data->{originator} : $noriginator;
325 } while (&getnextbug);
328 } elsif (m/^submitter\s+\#?(-?\d+)\s+\!$/i ? ($newsubmitter=$replyto, 1) :
329 m/^submitter\s+\#?(-?\d+)\s+(\S.*\S)$/i ? ($newsubmitter=$2, 1) : 0) {
332 if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
333 $ref = $clonebugs{$ref};
337 &addmaintainers($data->{package}, $data->{severity});
338 $oldsubmitter= $data->{originator};
339 $data->{originator}= $newsubmitter;
340 $action= "Changed $gBug submitter from $oldsubmitter to $newsubmitter.";
342 &transcript("$action\n");
343 if (length($data->{done})) {
344 &transcript("(By the way, that $gBug is currently marked as done.)\n");
348 From: $gMaintainerEmail ($gProject $gBug Tracking System)
350 Subject: $gBug#$ref submitter address changed
352 References: $header{'message-id'} $data->{msgid}
353 In-Reply-To: $data->{msgid}
354 Message-ID: <handler.$ref.$nn.newsubmitter.$midix\@$gEmailDomain>
355 Reply-To: $ref\@$gEmailDomain
357 The submitter address recorded for your $gBug report
358 #$ref: $data->{subject}
361 The new submitter address for this report is
364 This change was made by
366 If it was incorrect, please contact them directly.
369 (administrator, $gProject $gBugs database)
372 &sendmailmessage($message,$oldsubmitter);
376 } elsif (m/^forwarded\s+\#?(-?\d+)\s+(\S.*\S)$/i) {
378 $ref= $1; $whereto= $2;
380 if (length($data->{forwarded})) {
381 $action= "Forwarded-to-address changed from $data->{forwarded} to $whereto.";
383 $action= "Noted your statement that $gBug has been forwarded to $whereto.";
385 if (length($data->{done})) {
386 $extramessage= "(By the way, this $gBug is currently marked as done.)\n";
389 &addmaintainers($data->{package}, $data->{severity});
390 if (length($gForwardList)>0 && length($gListDomain)>0 ) {
391 &addccaddress("$gForwardList\@$gListDomain");
393 $data->{forwarded}= $whereto;
394 } while (&getnextbug);
396 } elsif (m/^notforwarded\s+\#?(-?\d+)$/i) {
400 if (!length($data->{forwarded})) {
401 &transcript("$gBug is not marked as having been forwarded.\n\n");
404 $action= "Removed annotation that $gBug had been forwarded to $data->{forwarded}.";
406 &addmaintainers($data->{package}, $data->{severity});
407 $data->{forwarded}= '';
408 } while (&getnextbug);
411 } elsif (m/^severity\s+\#?(-?\d+)\s+([-0-9a-z]+)$/i ||
412 m/^priority\s+\#?(-?\d+)\s+([-0-9a-z]+)$/i) {
416 if (!grep($_ eq $newseverity, @gSeverityList, "$gDefaultSeverity")) {
417 &transcript("Severity level \`$newseverity' is not known.\n".
418 "Recognized are: $gShowSeverities.\n\n");
419 } elsif (exists $gObsoleteSeverities{$newseverity}) {
420 &transcript("Severity level \`$newseverity' is obsolete. " .
421 "$gObsoleteSeverities{$newseverity}\n\n");
423 $printseverity= $data->{severity};
424 $printseverity= "$gDefaultSeverity" if $printseverity eq '';
425 $action= "Severity set to \`$newseverity'.";
427 &addmaintainers($data->{package}, $data->{severity});
428 if (defined $gStrongList and isstrongseverity($newseverity)) {
429 my $addbcc = "$gStrongList\@$gListDomain";
430 push @bcc, $addbcc unless grep { $_ eq $addbcc } @bccs;
432 $data->{severity}= $newseverity;
433 } while (&getnextbug);
435 } elsif (m/^tags?\s+\#?(-?\d+)\s+(([=+-])\s*)?(\S.*)?$/i) {
437 $ref = $1; $addsubcode = $3; $tags = $4;
439 if (defined $addsubcode) {
440 $addsub = "sub" if ($addsubcode eq "-");
441 $addsub = "add" if ($addsubcode eq "+");
442 $addsub = "set" if ($addsubcode eq "=");
446 foreach my $t (split /[\s,]+/, $tags) {
447 if (!grep($_ eq $t, @gTags)) {
454 &transcript("Unknown tag/s: ".join(', ', @badtags).".\n".
455 "Recognized are: ".join(' ', @gTags).".\n\n");
458 if ($data->{keywords} eq '') {
459 &transcript("There were no tags set.\n");
461 &transcript("Tags were: $data->{keywords}\n");
463 if ($addsub eq "set") {
464 $action= "Tags set to: " . join(", ", @okaytags);
465 } elsif ($addsub eq "add") {
466 $action= "Tags added: " . join(", ", @okaytags);
467 } elsif ($addsub eq "sub") {
468 $action= "Tags removed: " . join(", ", @okaytags);
471 &addmaintainers($data->{package}, $data->{severity});
472 $data->{keywords} = '' if ($addsub eq "set");
473 if ($addsub eq "sub") {
474 foreach my $t (@badtags) {
475 $data->{keywords} = join ' ', grep $_ ne $t,
476 split ' ', $data->{keywords};
479 foreach my $t (@okaytags) {
480 $data->{keywords} = join ' ', grep $_ ne $t,
481 split ' ', $data->{keywords};
482 $data->{keywords} = "$t $data->{keywords}" unless($addsub eq "sub");
484 $data->{keywords} =~ s/\s*$//;
485 } while (&getnextbug);
487 } elsif (m/^retitle\s+\#?(-?\d+)\s+(\S.*\S)\s*$/i) {
489 $ref= $1; $newtitle= $2;
490 if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
491 $ref = $clonebugs{$ref};
495 &addmaintainers($data->{package}, $data->{severity});
496 $data->{subject}= $newtitle;
497 $action= "Changed $gBug title.";
499 &transcript("$action\n");
500 if (length($data->{done})) {
501 &transcript("(By the way, that $gBug is currently marked as done.)\n");
507 } elsif (m/^unmerge\s+\#?(-?\d+)$/i) {
511 if (!length($data->{mergedwith})) {
512 &transcript("$gBug is not marked as being merged with any others.\n\n");
515 $mergelowstate eq 'locked' || die "$mergelowstate ?";
516 $action= "Disconnected #$ref from all other report(s).";
517 @newmergelist= split(/ /,$data->{mergedwith});
520 &addmaintainers($data->{package}, $data->{severity});
521 $data->{mergedwith}= ($ref == $discref) ? ''
522 : join(' ',grep($_ ne $ref,@newmergelist));
523 } while (&getnextbug);
526 } elsif (m/^merge\s+(-?\d+(\s+-?\d+)+)\s*$/i) {
528 @tomerge= sort { $a <=> $b } split(/\s+/,$1);
532 while (defined($ref= shift(@tomerge))) {
533 &transcript("D| checking merge $ref\n") if $dl;
535 if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
536 $ref = $clonebugs{$ref};
538 next if grep($_ eq $ref,@newmergelist);
539 if (!&getbug) { ¬foundbug; @newmergelist=(); last }
541 &transcript("D| adding $ref ($data->{mergedwith})\n") if $dl;
543 &checkmatch('package','m_package',$data->{package});
544 &checkmatch('forwarded addr','m_forwarded',$data->{forwarded});
545 $data->{severity} = '$gDefaultSeverity' if $data->{severity} eq '';
546 &checkmatch('severity','m_severity',$data->{severity});
547 &checkmatch('done mark','m_done',length($data->{done}) ? 'done' : 'open');
548 foreach my $t (split /\s+/, $data->{keywords}) { $tags{$t} = 1; }
549 if (length($mismatch)) {
550 &transcript("Mismatch - only $gBugs in same state can be merged:\n".
552 &cancelbug; @newmergelist=(); last;
554 push(@newmergelist,$ref);
555 push(@tomerge,split(/ /,$data->{mergedwith}));
559 @newmergelist= sort { $a <=> $b } @newmergelist;
560 $action= "Merged @newmergelist.";
561 for $ref (@newmergelist) {
562 &getbug || die "huh ? $gBug $ref disappeared during merge";
563 &addmaintainers($data->{package}, $data->{severity});
564 $data->{mergedwith}= join(' ',grep($_ ne $ref,@newmergelist));
565 $data->{keywords}= join(' ', keys %tags);
568 &transcript("$action\n\n");
571 } elsif (m/^clone\s+#?(\d+)\s+((-\d+\s+)*-\d+)\s*$/i) {
575 @newclonedids = split /\s+/, $2;
576 $newbugsneeded = scalar(@newclonedids);
580 if (length($data->{mergedwith})) {
581 &transcript("$gBug is marked as being merged with others.\n\n");
584 &filelock("nextnumber.lock");
585 open(N,"nextnumber") || &quit("nextnumber: read: $!");
586 $v=<N>; $v =~ s/\n$// || &quit("nextnumber bad format");
587 $firstref= $v+0; $v += $newbugsneeded;
588 open(NN,">nextnumber"); print NN "$v\n"; close(NN);
591 $lastref = $firstref + $newbugsneeded - 1;
593 if ($newbugsneeded == 1) {
594 $action= "$gBug $origref cloned as bug $firstref.";
596 $action= "$gBug $origref cloned as bugs $firstref-$lastref.";
599 my $ohash = get_hashname($origref);
601 for $newclonedid (@newclonedids) {
602 $clonebugs{$newclonedid} = $ref;
604 my $hash = get_hashname($ref);
605 copy("db-h/$ohash/$origref.log", "db-h/$hash/$ref.log");
606 copy("db-h/$ohash/$origref.status", "db-h/$hash/$ref.status");
607 copy("db-h/$ohash/$origref.db", "db-h/$hash/$ref.db");
608 copy("db-h/$ohash/$origref.report", "db-h/$hash/$ref.report");
609 &bughook('new', $ref, $data);
615 } elsif (m/^package\s*(\S.*\S)?\s*$/i) {
617 my @pkgs = split /\s+/, $1;
618 if (scalar(@pkgs) > 0) {
619 %limit_pkgs = map { ($_, 1) } @pkgs;
620 &transcript("Ignoring bugs not assigned to: " .
621 join(" ", keys(%limit_pkgs)) . "\n\n");
624 &transcript("Not ignoring any bugs.\n\n");
627 &transcript("Unknown command or malformed arguments to command.\n\n");
628 if (++$unknowns >= 5) {
629 &transcript("Too many unknown commands, stopping here.\n\n");
634 if ($procline>$#bodylines) {
635 &transcript(">\nEnd of message, stopping processing here.\n\n");
637 if (!$ok && !quickabort) {
638 &transcript("No commands successfully parsed; sending the help text(s).\n");
643 &transcript("MC\n") if $dl>1;
645 for $maint (keys %maintccreasons) {
646 &transcript("MM|$maint|\n") if $dl>1;
647 next if $maint eq $replyto;
649 $reasonsref= $maintccreasons{$maint};
650 &transcript("MY|$maint|\n") if $dl>2;
651 for $p (sort keys %$reasonsref) {
652 &transcript("MP|$p|\n") if $dl>2;
653 $reasonstring.= ', ' if length($reasonstring);
654 $reasonstring.= $p.' ' if length($p);
655 $reasonstring.= join(' ',map("#$_",sort keys %{$$reasonsref{$p}}));
657 if (length($reasonstring) > 40) {
658 (substr $reasonstring, 37) = "...";
660 $reasonstring = "" if (!defined($reasonstring));
661 push(@maintccs,"$maint ($reasonstring)");
662 push(@maintccaddrs,"$maint");
667 &transcript("MC|@maintccs|\n") if $dl>2;
668 $maintccs .= "Cc: " . join(",\n ",@maintccs) . "\n";
671 if (!defined $header{'subject'} || $header{'subject'} eq "") {
672 $header{'subject'} = "your mail";
676 From: $gMaintainerEmail ($gProject $gBug Tracking System)
678 ${maintccs}Subject: Processed: $header{'subject'}
679 In-Reply-To: $header{'message-id'}
680 References: $header{'message-id'}
681 Message-ID: <handler.s.$nn.transcript\@$gEmailDomain>
684 ${transcript}Please contact me if you need assistance.
687 (administrator, $gProject $gBugs database)
691 $repliedshow= join(', ',$replyto,@maintccaddrs);
692 &filelock("lock/-1");
693 open(AP,">>db-h/-1.log") || &quit("open db-h/-1.log: $!");
695 "\2\n$repliedshow\n\5\n$reply\n\3\n".
697 "<strong>Request received</strong> from <code>".
698 &sani($header{'from'})."</code>\n".
699 "to <code>".&sani($controlrequestaddr)."</code>\n".
701 "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/-1.log: $!");
702 close(AP) || &quit("open db-h/-1.log: $!");
704 utime(time,time,"db-h");
706 &sendmailmessage($reply,$replyto,@maintccaddrs,@bcc);
708 unlink("incoming/P$nn") || &quit("unlinking incoming/P$nn: $!");
710 sub sendmailmessage {
711 local ($message,@recips) = @_;
712 $message = "X-Loop: $gMaintainerEmail\n" . $message;
713 print "mailing to >@recips<\n" if $debug;
715 defined($c) || &quit("mailing forking for sendmail: $!");
716 if (!$c) { # ie, we are the child process
717 exec '/usr/lib/sendmail','-f'."$gMaintainerEmail",'-odb','-oem','-oi',get_addresses(@recips);
720 print(D $message) || &quit("writing to sendmail process: $!");
721 $!=0; close(D); $? && &quit("sendmail gave exit status $? ($!)");
726 &sendtxthelpraw("bug-log-mailserver.txt","instructions for request\@$gEmailDomain");
727 &sendtxthelpraw("bug-maint-mailcontrol.txt","instructions for control\@$gEmailDomain")
732 # &transcript("Sorry, command $_[0] not yet implemented.\n\n");
736 local ($string,$mvarname,$svarvalue) = @_;
739 eval "\$mvarvalue= \$$mvarname";
740 &transcript("D| checkmatch \`$string' /$mvarname/$mvarvalue/$svarvalue/\n")
743 "Values for \`$string' don't match:\n".
744 " #$newmergelist[0] has \`$mvarvalue';\n".
745 " #$ref has \`$svarvalue'\n"
746 if $mvarvalue ne $svarvalue;
748 &transcript("D| setupmatch \`$string' /$mvarname/$svarvalue/\n")
750 eval "\$$mvarname= \$svarvalue";
754 # High-level bug manipulation calls
755 # Do announcements themselves
757 # Possible calling sequences:
761 # &transcript(something)
765 # $action= (something)
767 # (modify s_* variables)
768 # } while (getnextbug);
771 &dlen("nochangebug");
772 $state eq 'single' || $state eq 'multiple' || die "$state ?";
774 &endmerge if $manybugs;
776 &dlex("nochangebug");
780 &dlen("setbug $ref");
781 if ($ref =~ m/^-\d+/) {
782 if (!defined $clonebugs{$ref}) {
784 &dlex("setbug => noclone");
787 $ref = $clonebugs{$ref};
789 $state eq 'idle' || die "$state ?";
792 &dlex("setbug => 0s");
796 if (keys(%limit_pkgs) && not defined $limit_pkgs{$data->{package}}) {
797 &transcript("$gBug number $ref belongs to package $data->{package}, skipping.\n\n");
802 @thisbugmergelist= split(/ /,$data->{mergedwith});
803 if (!@thisbugmergelist) {
808 &dlex("setbug => 1s");
817 &dlex("setbug => 0mc");
821 $state= 'multiple'; $sref=$ref;
822 &dlex("setbug => 1m");
828 $state eq 'single' || $state eq 'multiple' || die "$state ?";
830 if (!$manybugs || !@thisbugmergelist) {
831 length($action) || die;
832 &transcript("$action\n$extramessage\n");
833 &endmerge if $manybugs;
835 &dlex("getnextbug => 0");
838 $ref= shift(@thisbugmergelist);
839 &getbug || die "bug $ref disappeared";
841 &dlex("getnextbug => 1");
845 # Low-level bug-manipulation calls
846 # Do no announcements
854 # $action= (something)
859 # [getbug (returns 0)]
860 # &transcript("$action\n\n")
863 sub notfoundbug { &transcript("$gBug number $ref not found.\n\n"); }
864 sub foundbug { &transcript("$gBug#$ref: $data->{subject}\n"); }
868 $mergelowstate eq 'idle' || die "$mergelowstate ?";
869 &filelock('lock/merge');
870 $mergelowstate='locked';
876 $mergelowstate eq 'locked' || die "$mergelowstate ?";
878 $mergelowstate='idle';
883 &dlen("getbug $ref");
884 $lowstate eq 'idle' || die "$state ?";
885 if (($data = &lockreadbug($ref))) {
888 &dlex("getbug => 1");
893 &dlex("getbug => 0");
899 $lowstate eq 'open' || die "$state ?";
906 &dlen("savebug $ref");
907 $lowstate eq 'open' || die "$lowstate ?";
908 length($action) || die;
909 $ref == $sref || die "read $sref but saving $ref ?";
910 my $hash = get_hashname($ref);
911 open(L,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log: $!");
914 "<strong>".&sani($action)."</strong>\n".
915 "Request was from <code>".&sani($header{'from'})."</code>\n".
916 "to <code>".&sani($controlrequestaddr)."</code>. \n".
918 "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/$hash/$ref.log: $!");
919 close(L) || &quit("closing db-h/$hash/$ref.log: $!");
920 unlockwritebug($ref, $data);
927 &transcript("C> @_ ($state $lowstate $mergelowstate)\n");
932 &transcript("R> @_ ($state $lowstate $mergelowstate)\n");
936 print $_[0] if $debug;
944 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
945 $url =~ s/([<>&"])/\&$saniarray{$1};/g;
962 local ($relpath,$description) = @_;
964 open(D,"$gDocDir/$relpath") || &quit("open doc file $relpath: $!");
965 while(<D>) { $doc.=$_; }
967 &transcript("Sending $description in separate message.\n");
968 &sendmailmessage(<<END.$doc,$replyto);
969 From: $gMaintainerEmail ($gProject $gBug Tracking System)
971 Subject: $gProject $gBug help: $description
972 References: $header{'message-id'}
973 In-Reply-To: $header{'message-id'}
974 Message-ID: <handler.s.$nn.help.$midix\@$gEmailDomain>
982 local ($relpath,$description) = @_;
984 open(L,"lynx -nolist -dump http://$gCGIDomain/\Q$relpath\E 2>&1 |") || &quit("fork for lynx: $!");
985 while(<L>) { $doc.=$_; }
987 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
988 &transcript("Information ($description) is not available -\n".
989 "perhaps the $gBug does not exist or is not on the WWW yet.\n");
992 &transcript("Error getting $description (code $? $!):\n$doc\n");
994 &transcript("Sending $description.\n");
995 &sendmailmessage(<<END.$doc,$replyto);
996 From: $gMaintainerEmail ($gProject $gBug Tracking System)
998 Subject: $gProject $gBugs information: $description
999 References: $header{'message-id'}
1000 In-Reply-To: $header{'message-id'}
1001 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
1011 $maintccreasons{$cca}{''}{$ref}= 1;
1014 sub addmaintainers {
1015 # Data structure is:
1016 # maintainer email address &c -> assoc of packages -> assoc of bug#'s
1017 my ($p, $addmaint, $pshow);
1018 &ensuremaintainersloaded;
1019 $anymaintfound=0; $anymaintnotfound=0;
1020 for $p (split(m/[ \t?,()]+/,$_[0])) {
1022 $pshow= ($p =~ m/[-+.a-z0-9]+/ ? $& : '');
1023 if (defined $gSubscriptionDomain) {
1024 if (defined($pkgsrc{$p})) {
1025 push @bcc, "$pkgsrc{$p}\@$gSubscriptionDomain";
1027 push @bcc, "$p\@$gSubscriptionDomain";
1030 if (defined $_[1] and defined $gStrongList and
1031 isstrongseverity($_[1])) {
1032 push @bcc, "$gStrongList\@$gListDomain";
1034 if (defined($maintainerof{$p})) {
1035 $addmaint= $maintainerof{$p};
1036 &transcript("MR|$addmaint|$p|$ref|\n") if $dl>2;
1037 $maintccreasons{$addmaint}{$p}{$ref}= 1;
1038 print "maintainer add >$p|$addmaint<\n" if $debug;
1040 print "maintainer none >$p<\n" if $debug;
1041 &transcript("Warning: Unknown package '$p'\n");
1042 &transcript("MR|unknown-package|$p|$ref|\n") if $dl>2;
1043 $maintccreasons{$gUnknownMaintainerEmail}{$p}{$ref}= 1;
1048 sub ensuremaintainersloaded {
1050 return if $maintainersloaded++;
1051 open(MAINT,"$gMaintainerFile") || die &quit("maintainers open: $!");
1055 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers bogus \`$_'");
1056 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
1057 $maintainerof{$1}= $2;
1060 open(MAINT,"$gMaintainerFileOverride") || die &quit("maintainers.override open: $!");
1064 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers.override bogus \`$_'");
1065 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
1066 $maintainerof{$1}= $2;
1069 open(SOURCES, "$gPackageSource") || &quit("pkgsrc open: $!");
1071 next unless m/^(\S+)\s+\S+\s+(\S.*\S)\s*$/;
1072 my ($a, $b) = ($1, $2);
1073 $pkgsrc{lc($a)} = $b;
1079 local ($wherefrom,$path,$description) = @_;
1080 if ($wherefrom eq "ftp.d.o") {
1081 $doc = `lynx -nolist -dump http://ftp.debian.org/debian/indices/$path.gz 2>&1 | gunzip -cf` or &quit("fork for lynx/gunzip: $!");
1083 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
1084 &transcript("$description is not available.\n");
1087 &transcript("Error getting $description (code $? $!):\n$doc\n");
1090 } elsif ($wherefrom eq "local") {
1092 $doc = do { local $/; <P> };
1095 &transcript("internal errror: info files location unknown.\n");
1098 &transcript("Sending $description.\n");
1099 &sendmailmessage(<<END.$doc,$replyto);
1100 From: $gMaintainerEmail ($gProject $gBug Tracking System)
1102 Subject: $gProject $gBugs information: $description
1103 References: $header{'message-id'}
1104 In-Reply-To: $header{'message-id'}
1105 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
1108 $description follows: