2 # $Id: service.in,v 1.67 2003/02/15 00:44:20 cjwatson Exp $
5 # Usage: service <code>.nn
6 # Temps: incoming/P<code>.nn
12 $config_path = '/etc/debbugs';
13 $lib_path = '/usr/lib/debbugs';
15 require "$config_path/config";
16 require "$lib_path/errorlib";
17 $ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};
19 chdir("$gSpoolDir") || die "chdir spool: $!\n";
22 open DEBUG, ">/dev/null";
27 m/^[RC]\.\d+$/ || &quit("bad argument");
30 if (!rename("incoming/G$nn","incoming/P$nn")) {
31 $_=$!.''; m/no such file or directory/i && exit 0;
32 &quit("renaming to lock: $!");
35 open(M,"incoming/P$nn");
42 print "###\n",join("##\n",@msg),"\n###\n" if $debug;
44 my $parser = new MIME::Parser;
45 mkdir "$gSpoolDir/mime.tmp", 0777;
46 $parser->output_under("$gSpoolDir/mime.tmp");
47 my $entity = eval { $parser->parse_data(join('',@log)) };
49 # header and decoded body respectively
50 my (@headerlines, @bodylines);
52 if ($entity and $entity->head->tags) {
53 @headerlines = @{$entity->head->header};
56 my $entity_body = getmailbody($entity);
57 @bodylines = $entity_body ? $entity_body->as_lines() : ();
60 # Legacy pre-MIME code, kept around in case MIME::Parser fails.
62 for ($i = 0; $i <= $#msg; $i++) {
64 last unless length($_);
65 while ($msg[$i+1] =~ m/^\s/) {
69 push @headerlines, $_;
72 @bodylines = @msg[$i..$#msg];
77 print ">$_<\n" if $debug;
80 print ">$v=$_<\n" if $debug;
83 print "!>$_<\n" if $debug;
87 # Strip off RFC2440-style PGP clearsigning.
88 if (@bodylines and $bodylines[0] =~ /^-----BEGIN PGP SIGNED/) {
89 shift @bodylines while @bodylines and length $bodylines[0];
90 shift @bodylines while @bodylines and $bodylines[0] !~ /\S/;
91 for my $findsig (0 .. $#bodylines) {
92 if ($bodylines[$findsig] =~ /^-----BEGIN PGP SIGNATURE/) {
93 $#bodylines = $findsig - 1;
97 map { s/^- // } @bodylines;
100 grep(s/\s+$//,@bodylines);
102 print "***\n",join("\n",@bodylines),"\n***\n" if $debug;
104 if (defined $header{'resent-from'} && !defined $header{'from'}) {
105 $header{'from'} = $header{'resent-from'};
108 defined($header{'from'}) || &quit("no From header");
110 delete $header{'reply-to'}
111 if ( defined($header{'reply-to'}) && $header{'reply-to'} =~ m/^\s*$/ );
113 if ( defined($header{'reply-to'}) && $header{'reply-to'} ne "" ) {
114 $replyto = $header{'reply-to'};
116 $replyto = $header{'from'};
119 $controlrequestaddr= $control ? "control\@$gEmailDomain" : "request\@$gEmailDomain";
121 &transcript("Processing commands for $controlrequestaddr:\n\n");
126 $mergelowstate= 'idle';
132 my $fuckheads = "(" . join("|", @gFuckheads) . ")";
133 if (@gFuckheads and $replyto =~ m/$fuckheads/) {
134 &transcript("This service is unavailable.\n\n");
141 for ($procline=0; $procline<=$#bodylines; $procline++) {
142 $state eq 'idle' || print "$state ?\n";
143 $lowstate eq 'idle' || print "$lowstate ?\n";
144 $mergelowstate eq 'idle' || print "$mergelowstate ?\n";
146 &transcript("Stopping processing here.\n\n");
149 $_= $bodylines[$procline]; s/\s+$//;
150 next unless m/\S/; next if m/^\s*\#/;
151 &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("$ref","logs for $gBug#$ref");
162 } elsif (m/^send-detail\s+\#?(\d+)$/i) {
163 &transcript("This BTS function is currently disabled, sorry.\n\n");
164 $ok++; # well, it's not really ok, but it fixes #81224 :)
165 } elsif (m/^index(\s+full)?$/i) {
166 &transcript("This BTS function is currently disabled, sorry.\n\n");
167 $ok++; # well, it's not really ok, but it fixes #81224 :)
168 } elsif (m/^index-summary\s+by-package$/i) {
169 &transcript("This BTS function is currently disabled, sorry.\n\n");
170 $ok++; # well, it's not really ok, but it fixes #81224 :)
171 } elsif (m/^index-summary(\s+by-number)?$/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(\s+|-)pack(age)?s?$/i) {
175 &sendlynxdoc("cgi-bin/pkgindex.cgi?indexon=pkg",'index of packages');
176 } elsif (m/^index(\s+|-)maints?$/i) {
177 &sendlynxdoc("cgi-bin/pkgindex.cgi?indexon=maint",'index of maintainers');
178 } elsif (m/^index(\s+|-)maint\s+(\S+)$/i) {
180 # check for crap in $maint
181 if ($maint =~ m/^\./ || $maint !~ m/^[\d\w-+.@]+$/) {
182 &transcript("Invalid request $maint!\n");
185 &sendlynxdoc("$maint","$gBug list for maintainer \`$maint'");
187 } elsif (m/^index(\s+|-)pack(age)?s?\s+(\S.*\S)$/i) {
189 # check for crap in $package
190 if ($package =~ m/^\./ || $package !~ m/^[\d\w-+.@]+$/) {
191 &transcript("Invalid request $package!\n");
194 &sendlynxdoc("$package","$gBug list for package $package sent.\n\n");
196 } elsif (m/^send-unmatched(\s+this|\s+-?0)?$/i) {
197 &transcript("This BTS function is currently disabled, sorry.\n\n");
198 $ok++; # well, it's not really ok, but it fixes #81224 :)
199 } elsif (m/^send-unmatched\s+(last|-1)$/i) {
200 &transcript("This BTS function is currently disabled, sorry.\n\n");
201 $ok++; # well, it's not really ok, but it fixes #81224 :)
202 } elsif (m/^send-unmatched\s+(old|-2)$/i) {
203 &transcript("This BTS function is currently disabled, sorry.\n\n");
204 $ok++; # well, it's not really ok, but it fixes #81224 :)
205 } elsif (m/^getinfo\s+([\w-.]+)$/i) {
206 # the following is basically a Debian-specific kludge, but who cares
208 if ($req =~ /^maintainers$/i && -f "$gConfigDir/Maintainers") {
209 &sendinfo("local", "$gConfigDir/Maintainers", "Maintainers file");
210 } elsif ($req =~ /^override\.(\w+)\.([\w-.]+)$/i) {
212 &sendinfo("ftp.d.o", "$req", "override file for $2 part of $1 distribution");
213 } elsif ($req =~ /^pseudo-packages\.(description|maintainers)$/i && -f "$gConfigDir/$req") {
214 &sendinfo("local", "$gConfigDir/$req", "$req file");
216 &transcript("Info file $req does not exist.\n\n");
218 } elsif (m/^help/i) {
222 } elsif (m/^refcard/i) {
223 &sendtxthelp("bug-mailserver-refcard.txt","mail servers' reference card");
224 } elsif (m/^subscribe/i) {
226 There is no $gProject $gBug mailing list. If you wish to review bug reports
227 please do so via http://$gWebDomain/ or ask this mail server
229 soon: MAILINGLISTS_TEXT
231 } elsif (m/^unsubscribe/i) {
233 soon: UNSUBSCRIBE_TEXT
234 soon: MAILINGLISTS_TEXT
236 } elsif (!$control) {
238 Unknown command or malformed arguments to command.
239 (Use control\@$gEmailDomain to manipulate reports.)
242 if (++$unknowns >= 3) {
243 &transcript("Too many unknown commands, stopping here.\n\n");
246 #### interesting ones start here
247 } elsif (m/^close\s+\#?(-?\d+)$/i) {
251 &transcript("'close' is deprecated; see http://$gWebDomain/Developer$gHTMLSuffix#closing.\n");
252 if (length($s_done)) {
253 &transcript("$gBug is already closed, cannot re-close.\n\n");
256 $action= "$gBug closed, send any further explanations to $s_originator";
258 &addmaintainers($s_package);
259 if ( length( $gDoneList ) > 0 && length( $gListDomain ) >
260 0 ) { &addccaddress("$gDoneList\@$gListDomain"); }
263 From: $gMaintainerEmail ($gProject $gBug Tracking System)
265 Subject: $gBug#$ref acknowledged by developer
267 References: $header{'message-id'} $s_msgid
268 In-Reply-To: $s_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
274 which was filed against the $s_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,$s_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($s_package)) {
296 $action= "$gBug reassigned from package \`$s_package'".
297 " to \`$newpackage'.";
299 $action= "$gBug assigned to package \`$newpackage'.";
302 &addmaintainers($s_package);
303 &addmaintainers($newpackage);
304 $s_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($s_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($s_package);
323 $s_originator= $noriginator eq '' ? $s_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($s_package);
338 $oldsubmitter= $s_originator;
339 $s_originator= $newsubmitter;
340 $action= "Changed $gBug submitter from $oldsubmitter to $newsubmitter.";
342 &transcript("$action\n");
343 if (length($s_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'} $s_msgid
353 In-Reply-To: $s_msgid
354 Message-ID: <handler.$ref.$nn.newsubmitter.$midix\@$gEmailDomain>
355 Reply-To: $ref\@$gEmailDomain
357 The submitter address recorded for your $gBug report
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($s_forwarded)) {
381 $action= "Forwarded-to-address changed from $s_forwarded to $whereto.";
383 $action= "Noted your statement that $gBug has been forwarded to $whereto.";
385 if (length($s_done)) {
386 $extramessage= "(By the way, this $gBug is currently marked as done.)\n";
389 &addmaintainers($s_package);
390 if (length($gFowardList)>0 && length($gListDomain)>0 ) {
391 &addccaddress("$gFowardList\@$gListDomain");
393 $s_forwarded= $whereto;
394 } while (&getnextbug);
396 } elsif (m/^notforwarded\s+\#?(-?\d+)$/i) {
400 if (!length($s_forwarded)) {
401 &transcript("$gBug is not marked as having been forwarded.\n\n");
404 $action= "Removed annotation that $gBug had been forwarded to $s_forwarded.";
406 &addmaintainers($s_package);
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");
420 $printseverity= $s_severity;
421 $printseverity= "$gDefaultSeverity" if $printseverity eq '';
422 $action= "Severity set to \`$newseverity'.";
424 &addmaintainers($s_package);
425 $s_severity= $newseverity;
426 } while (&getnextbug);
428 } elsif (m/^tags?\s+\#?(-?\d+)\s+(([=+-])\s*)?(\S.*)?$/i) {
430 $ref = $1; $addsubcode = $3; $tags = $4;
432 if (defined $addsubcode) {
433 $addsub = "sub" if ($addsubcode eq "-");
434 $addsub = "add" if ($addsubcode eq "+");
435 $addsub = "set" if ($addsubcode eq "=");
439 foreach my $t (split /[\s,]+/, $tags) {
440 if (!grep($_ eq $t, @gTags)) {
447 &transcript("Unknown tag/s: ".join(', ', @badtags).".\n".
448 "Recognized are: ".join(' ', @gTags).".\n\n");
451 if ($s_keywords eq '') {
452 &transcript("There were no tags set.\n");
454 &transcript("Tags were: $s_keywords\n");
456 if ($addsub eq "set") {
457 $action= "Tags set to: " . join(", ", @okaytags);
458 } elsif ($addsub eq "add") {
459 $action= "Tags added: " . join(", ", @okaytags);
460 } elsif ($addsub eq "sub") {
461 $action= "Tags removed: " . join(", ", @okaytags);
464 &addmaintainers($s_package);
465 $s_keywords = '' if ($addsub eq "set");
466 if ($addsub eq "sub") {
467 foreach my $t (@badtags) {
468 $s_keywords = join ' ', grep $_ ne $t,
469 split ' ', $s_keywords;
472 foreach my $t (@okaytags) {
473 $s_keywords = join ' ', grep $_ ne $t,
474 split ' ', $s_keywords;
475 $s_keywords = "$t $s_keywords" unless($addsub eq "sub");
477 $s_keywords =~ s/\s*$//;
478 } while (&getnextbug);
480 } elsif (m/^retitle\s+\#?(-?\d+)\s+(\S.*\S)\s*$/i) {
482 $ref= $1; $newtitle= $2;
483 if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
484 $ref = $clonebugs{$ref};
488 &addmaintainers($s_package);
489 $s_subject= $newtitle;
490 $action= "Changed $gBug title.";
492 &transcript("$action\n");
493 if (length($s_done)) {
494 &transcript("(By the way, that $gBug is currently marked as done.)\n");
500 } elsif (m/^unmerge\s+\#?(-?\d+)$/i) {
504 if (!length($s_mergedwith)) {
505 &transcript("$gBug is not marked as being merged with any others.\n\n");
508 $mergelowstate eq 'locked' || die "$mergelowstate ?";
509 $action= "Disconnected #$ref from all other report(s).";
510 @newmergelist= split(/ /,$s_mergedwith);
513 &addmaintainers($s_package);
514 $s_mergedwith= ($ref == $discref) ? ''
515 : join(' ',grep($_ ne $ref,@newmergelist));
516 } while (&getnextbug);
519 } elsif (m/^merge\s+(\d+(\s+\d+)+)\s*$/i) {
521 @tomerge= sort { $a <=> $b } split(/\s+/,$1);
525 while (defined($ref= shift(@tomerge))) {
526 &transcript("D| checking merge $ref\n") if $dl;
528 next if grep($_ eq $ref,@newmergelist);
529 if (!&getbug) { ¬foundbug; @newmergelist=(); last }
531 &transcript("D| adding $ref ($s_mergedwith)\n") if $dl;
533 &checkmatch('package','m_package',$s_package);
534 &checkmatch('forwarded addr','m_forwarded',$s_forwarded);
535 $s_severity = '$gDefaultSeverity' if $s_severity eq '';
536 &checkmatch('severity','m_severity',$s_severity);
537 &checkmatch('done mark','m_done',length($s_done) ? 'done' : 'open');
538 foreach my $t (split /\s+/, $s_keywords) { $tags{$t} = 1; }
539 if (length($mismatch)) {
540 &transcript("Mismatch - only $gBugs in same state can be merged:\n".
542 &cancelbug; @newmergelist=(); last;
544 push(@newmergelist,$ref);
545 push(@tomerge,split(/ /,$s_mergedwith));
549 @newmergelist= sort { $a <=> $b } @newmergelist;
550 $action= "Merged @newmergelist.";
551 for $ref (@newmergelist) {
552 &getbug || die "huh ? $gBug $ref disappeared during merge";
553 &addmaintainers($s_package);
554 $s_mergedwith= join(' ',grep($_ ne $ref,@newmergelist));
555 $s_keywords= join(' ', keys %tags);
558 &transcript("$action\n\n");
561 } elsif (m/^clone\s+#?(\d+)\s+((-\d+\s+)*-\d+)\s*$/i) {
565 @newclonedids = split /\s+/, $2;
566 $newbugsneeded = scalar(@newclonedids);
570 if (length($s_mergedwith)) {
571 &transcript("$gBug is marked as being merged with others.\n\n");
574 &filelock("nextnumber.lock");
575 open(N,"nextnumber") || &quit("nextnumber: read: $!");
576 $v=<N>; $v =~ s/\n$// || &quit("nextnumber bad format");
577 $firstref= $v+0; $v += $newbugsneeded;
578 open(NN,">nextnumber"); print NN "$v\n"; close(NN);
581 $lastref = $firstref + $newbugsneeded - 1;
583 if ($newbugsneeded == 1) {
584 $action= "$gBug $origref cloned as bug $firstref.";
586 $action= "$gBug $origref cloned as bugs $firstref-$lastref.";
589 my $ohash = get_hashname($origref);
591 for $newclonedid (@newclonedids) {
592 $clonebugs{$newclonedid} = $ref;
594 my $hash = get_hashname($ref);
595 copy("db-h/$ohash/$origref.log", "db-h/$hash/$ref.log");
596 copy("db-h/$ohash/$origref.status", "db-h/$hash/$ref.status");
597 copy("db-h/$ohash/$origref.report", "db-h/$hash/$ref.report");
598 &bughook('new', $ref, "$s_originator\n$s_date\n$s_subject\n$s_msgid\n$s_package\n$s_keywords\n$s_done\n$s_forwarded\n$s_mergedwith\n$s_severity\n");
605 &transcript("Unknown command or malformed arguments to command.\n\n");
606 if (++$unknowns >= 5) {
607 &transcript("Too many unknown commands, stopping here.\n\n");
612 if ($procline>$#bodylines) {
613 &transcript(">\nEnd of message, stopping processing here.\n\n");
615 if (!$ok && !quickabort) {
616 &transcript("No commands successfully parsed; sending the help text(s).\n");
621 &transcript("MC\n") if $dl>1;
623 for $maint (keys %maintccreasons) {
624 &transcript("MM|$maint|\n") if $dl>1;
625 next if $maint eq $replyto;
627 $reasonsref= $maintccreasons{$maint};
628 &transcript("MY|$maint|\n") if $dl>2;
629 for $p (sort keys %$reasonsref) {
630 &transcript("MP|$p|\n") if $dl>2;
631 $reasonstring.= ', ' if length($reasonstring);
632 $reasonstring.= $p.' ' if length($p);
633 $reasonstring.= join(' ',map("#$_",sort keys %{$$reasonsref{$p}}));
635 if (length($reasonstring) > 40) {
636 (substr $reasonstring, 37) = "...";
638 $reasonstring = "" if (!defined($reasonstring));
639 push(@maintccs,"$maint ($reasonstring)");
640 push(@maintccaddrs,"$maint");
645 &transcript("MC|@maintccs|\n") if $dl>2;
646 $maintccs .= "Cc: " . join(",\n ",@maintccs) . "\n";
649 if (!defined $header{'subject'} || $header{'subject'} eq "") {
650 $header{'subject'} = "your mail";
654 From: $gMaintainerEmail ($gProject $gBug Tracking System)
656 ${maintccs}Subject: Processed: $header{'subject'}
657 In-Reply-To: $header{'message-id'}
658 References: $header{'message-id'}
659 Message-ID: <handler.s.$nn.transcript\@$gEmailDomain>
661 ${transcript}Please contact me if you need assistance.
664 (administrator, $gProject $gBugs database)
668 $repliedshow= join(', ',$replyto,@maintccaddrs);
669 &filelock("lock/-1");
670 open(AP,">>db-h/-1.log") || &quit("open db-h/-1.log: $!");
672 "\2\n$repliedshow\n\5\n$reply\n\3\n".
674 "<strong>Request received</strong> from <code>".
675 &sani($header{'from'})."</code>\n".
676 "to <code>".&sani($controlrequestaddr)."</code>\n".
678 "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/-1.log: $!");
679 close(AP) || &quit("open db-h/-1.log: $!");
681 utime(time,time,"db-h");
683 &sendmailmessage($reply,$replyto,@maintccaddrs,@bcc);
685 unlink("incoming/P$nn") || &quit("unlinking incoming/P$nn: $!");
689 map { $_->address() }
690 map { Mail::Address->parse($_) } @_;
693 sub sendmailmessage {
694 local ($message,@recips) = @_;
695 $message = "X-Loop: $gMaintainerEmail\n" . $message;
696 print "mailing to >@recips<\n" if $debug;
698 defined($c) || &quit("mailing forking for sendmail: $!");
699 if (!$c) { # ie, we are the child process
700 exec '/usr/lib/sendmail','-f'."$gMaintainerEmail",'-odb','-oem','-oi',get_addresses(@recips);
703 print(D $message) || &quit("writing to sendmail process: $!");
704 $!=0; close(D); $? && &quit("sendmail gave exit status $? ($!)");
709 &sendtxthelpraw("bug-log-mailserver.txt","instructions for request\@$gEmailDomain");
710 &sendtxthelpraw("bug-maint-mailcontrol.txt","instructions for control\@$gEmailDomain")
715 # &transcript("Sorry, command $_[0] not yet implemented.\n\n");
719 local ($string,$mvarname,$svarvalue) = @_;
722 eval "\$mvarvalue= \$$mvarname";
723 &transcript("D| checkmatch \`$string' /$mvarname/$mvarvalue/$svarvalue/\n")
726 "Values for \`$string' don't match:\n".
727 " #$newmergelist[0] has \`$mvarvalue';\n".
728 " #$ref has \`$svarvalue'\n"
729 if $mvarvalue ne $svarvalue;
731 &transcript("D| setupmatch \`$string' /$mvarname/$svarvalue/\n")
733 eval "\$$mvarname= \$svarvalue";
737 # High-level bug manipulation calls
738 # Do announcements themselves
740 # Possible calling sequences:
744 # &transcript(something)
748 # $action= (something)
750 # (modify s_* variables)
751 # } while (getnextbug);
754 &dlen("nochangebug");
755 $state eq 'single' || $state eq 'multiple' || die "$state ?";
757 &endmerge if $manybugs;
759 &dlex("nochangebug");
763 &dlen("setbug $ref");
764 if ($ref =~ m/^-\d+/) {
765 if (!defined $clonebugs{$ref}) {
767 &dlex("setbug => noclone");
770 $ref = $clonebugs{$ref};
772 $state eq 'idle' || die "$state ?";
775 &dlex("setbug => 0s");
778 @thisbugmergelist= split(/ /,$s_mergedwith);
779 if (!@thisbugmergelist) {
784 &dlex("setbug => 1s");
793 &dlex("setbug => 0mc");
797 $state= 'multiple'; $sref=$ref;
798 &dlex("setbug => 1m");
804 $state eq 'single' || $state eq 'multiple' || die "$state ?";
806 if (!$manybugs || !@thisbugmergelist) {
807 length($action) || die;
808 &transcript("$action\n$extramessage\n");
809 &endmerge if $manybugs;
811 &dlex("getnextbug => 0");
814 $ref= shift(@thisbugmergelist);
815 &getbug || die "bug $ref disappeared";
817 &dlex("getnextbug => 1");
821 # Low-level bug-manipulation calls
822 # Do no announcements
830 # $action= (something)
835 # [getbug (returns 0)]
836 # &transcript("$action\n\n")
839 sub notfoundbug { &transcript("$gBug number $ref not found.\n\n"); }
840 sub foundbug { &transcript("$gBug#$ref: $s_subject\n"); }
844 $mergelowstate eq 'idle' || die "$mergelowstate ?";
845 &filelock('lock/merge');
846 $mergelowstate='locked';
852 $mergelowstate eq 'locked' || die "$mergelowstate ?";
854 $mergelowstate='idle';
859 &dlen("getbug $ref");
860 $lowstate eq 'idle' || die "$state ?";
861 if (&lockreadbug($ref)) {
864 &dlex("getbug => 1");
869 &dlex("getbug => 0");
875 $lowstate eq 'open' || die "$state ?";
882 &dlen("savebug $ref");
883 $lowstate eq 'open' || die "$lowstate ?";
884 length($action) || die;
885 $ref == $sref || die "read $sref but saving $ref ?";
886 my $hash = get_hashname($ref);
887 open(L,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log: $!");
890 "<strong>".&sani($action)."</strong>\n".
891 "Request was from <code>".&sani($header{'from'})."</code>\n".
892 "to <code>".&sani($controlrequestaddr)."</code>. \n".
894 "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/$hash/$ref.log: $!");
895 close(L) || &quit("closing db-h/$hash/$ref.log: $!");
896 open(S,">db-h/$hash/$ref.status.new") || &quit("opening db-h/$hash/$ref.status.new: $!");
909 "$s_fixed_versions\n") || &quit("writing db-h/$hash/$ref.status.new: $!");
910 close(S) || &quit("closing db-h/$hash/$ref.status.new: $!");
911 rename("db-h/$hash/$ref.status.new","db-h/$hash/$ref.status") ||
912 &quit("installing new db-h/$hash/$ref.status: $!");
913 &bughook('change',$ref,
925 "$s_fixed_versions\n");
933 &transcript("C> @_ ($state $lowstate $mergelowstate)\n");
938 &transcript("R> @_ ($state $lowstate $mergelowstate)\n");
942 print $_[0] if $debug;
959 local ($relpath,$description) = @_;
961 open(D,"$gDocDir/$relpath") || &quit("open doc file $relpath: $!");
962 while(<D>) { $doc.=$_; }
964 &transcript("Sending $description in separate message.\n");
965 &sendmailmessage(<<END.$doc,$replyto);
966 From: $gMaintainerEmail ($gProject $gBug Tracking System)
968 Subject: $gProject $gBug help: $description
969 References: $header{'message-id'}
970 In-Reply-To: $header{'message-id'}
971 Message-ID: <handler.s.$nn.help.$midix\@$gEmailDomain>
978 local ($relpath,$description) = @_;
980 # the below oughta use $gWebDomain but it can't
981 open(L,"lynx -nolist -dump http://bugs.debian.org/$relpath 2>&1 |") || &quit("fork for lynx: $!");
982 while(<L>) { $doc.=$_; }
984 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
985 &transcript("Information ($description) is not available -\n".
986 "perhaps the $gBug does not exist or is not on the WWW yet.\n");
989 &transcript("Error getting $description (code $? $!):\n$doc\n");
991 &transcript("Sending $description.\n");
992 &sendmailmessage(<<END.$doc,$replyto);
993 From: $gMaintainerEmail ($gProject $gBug Tracking System)
995 Subject: $gProject $gBugs information: $description
996 References: $header{'message-id'}
997 In-Reply-To: $header{'message-id'}
998 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
1007 $maintccreasons{$cca}{''}{$ref}= 1;
1010 sub addmaintainers {
1011 # Data structure is:
1012 # maintainer email address &c -> assoc of packages -> assoc of bug#'s
1013 my ($p, $addmaint, $pshow);
1014 &ensuremaintainersloaded;
1015 $anymaintfound=0; $anymaintnotfound=0;
1016 for $p (split(m/[ \t?,()]+/,$_[0])) {
1018 $pshow= ($p =~ m/[-+.a-z0-9]+/ ? $& : '');
1019 if (defined $gSubscriptionDomain) {
1020 if (defined($pkgsrc{$p})) {
1021 push @bcc, "$pkgsrc{$p}\@$gSubscriptionDomain";
1023 push @bcc, "$p\@$gSubscriptionDomain";
1026 if (defined($maintainerof{$p})) {
1027 $addmaint= $maintainerof{$p};
1028 &transcript("MR|$addmaint|$p|$ref|\n") if $dl>2;
1029 $maintccreasons{$addmaint}{$p}{$ref}= 1;
1030 print "maintainer add >$p|$addmaint<\n" if $debug;
1032 print "maintainer none >$p<\n" if $debug;
1033 &transcript("MR|unknown-package|$p|$ref|\n") if $dl>2;
1034 $maintccreasons{$gUnknownMaintainerEmail}{$p}{$ref}= 1;
1039 sub ensuremaintainersloaded {
1041 return if $maintainersloaded++;
1042 open(MAINT,"$gMaintainerFile") || die &quit("maintainers open: $!");
1046 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers bogus \`$_'");
1047 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
1048 $maintainerof{$1}= $2;
1051 open(MAINT,"$gMaintainerFileOverride") || die &quit("maintainers.override open: $!");
1055 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers.override bogus \`$_'");
1056 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
1057 $maintainerof{$1}= $2;
1060 open(SOURCES, "$gPackageSource") || &quit("pkgsrc open: $!");
1062 next unless m/^(\S+)\s+\S+\s+(\S.*\S)\s*$/;
1063 my ($a, $b) = ($1, $2);
1064 $pkgsrc{lc($a)} = $b;
1070 local ($wherefrom,$path,$description) = @_;
1071 if ($wherefrom eq "ftp.d.o") {
1072 $doc = `lynx -nolist -dump http://ftp.debian.org/debian/indices/$path.gz 2>&1 | gunzip -cf` or &quit("fork for lynx/gunzip: $!");
1074 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
1075 &transcript("$description is not available.\n");
1078 &transcript("Error getting $description (code $? $!):\n$doc\n");
1081 } elsif ($wherefrom eq "local") {
1083 $doc = do { local $/; <P> };
1086 &transcript("internal errror: info files location unknown.\n");
1089 &transcript("Sending $description.\n");
1090 &sendmailmessage(<<END.$doc,$replyto);
1091 From: $gMaintainerEmail ($gProject $gBug Tracking System)
1093 Subject: $gProject $gBugs information: $description
1094 References: $header{'message-id'}
1095 In-Reply-To: $header{'message-id'}
1096 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
1098 $description follows: