2 # $Id: service.in,v 1.63 2002/11/25 12:44:19 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 if (length($s_done)) {
252 &transcript("$gBug is already closed, cannot re-close.\n\n");
255 $action= "$gBug closed, send any further explanations to $s_originator";
257 &addmaintainers($s_package);
258 if ( length( $gDoneList ) > 0 && length( $gListDomain ) >
259 0 ) { &addccaddress("$gDoneList\@$gListDomain"); }
262 From: $gMaintainerEmail ($gProject $gBug Tracking System)
264 Subject: $gBug#$ref acknowledged by developer
266 References: $header{'message-id'} $s_msgid
267 In-Reply-To: $s_msgid
268 Message-ID: <handler.$ref.$nn.notifdonectrl.$midix\@$gEmailDomain>
269 Reply-To: $ref\@$gEmailDomain
271 This is an automatic notification regarding your $gBug report
273 which was filed against the $s_package package.
275 It has been marked as closed by one of the developers, namely
278 You should be hearing from them with a substantive response shortly,
279 in case you haven't already. If not, please contact them directly.
282 (administrator, $gProject $gBugs database)
285 &sendmailmessage($message,$s_originator);
286 } while (&getnextbug);
289 } elsif (m/^reassign\s+\#?(-?\d+)\s+(\S.*\S)$/i) {
291 $ref= $1; $newpackage= $2;
292 $newpackage =~ y/A-Z/a-z/;
294 if (length($s_package)) {
295 $action= "$gBug reassigned from package \`$s_package'".
296 " to \`$newpackage'.";
298 $action= "$gBug assigned to package \`$newpackage'.";
301 &addmaintainers($s_package);
302 &addmaintainers($newpackage);
303 $s_package= $newpackage;
304 } while (&getnextbug);
306 } elsif (m/^reopen\s+\#?(-?\d+)$/i ? ($noriginator='', 1) :
307 m/^reopen\s+\#?(-?\d+)\s+\=$/i ? ($noriginator='', 1) :
308 m/^reopen\s+\#?(-?\d+)\s+\!$/i ? ($noriginator=$replyto, 1) :
309 m/^reopen\s+\#?(-?\d+)\s+(\S.*\S)$/i ? ($noriginator=$2, 1) : 0) {
313 if (!length($s_done)) {
314 &transcript("$gBug is already open, cannot reopen.\n\n");
318 $noriginator eq '' ? "$gBug reopened, originator not changed." :
319 "$gBug reopened, originator set to $noriginator.";
321 &addmaintainers($s_package);
322 $s_originator= $noriginator eq '' ? $s_originator : $noriginator;
324 } while (&getnextbug);
327 } elsif (m/^forwarded\s+\#?(-?\d+)\s+(\S.*\S)$/i) {
329 $ref= $1; $whereto= $2;
331 if (length($s_forwarded)) {
332 $action= "Forwarded-to-address changed from $s_forwarded to $whereto.";
334 $action= "Noted your statement that $gBug has been forwarded to $whereto.";
336 if (length($s_done)) {
337 $extramessage= "(By the way, this $gBug is currently marked as done.)\n";
340 &addmaintainers($s_package);
341 if (length($gFowardList)>0 && length($gListDomain)>0 ) {
342 &addccaddress("$gFowardList\@$gListDomain");
344 $s_forwarded= $whereto;
345 } while (&getnextbug);
347 } elsif (m/^notforwarded\s+\#?(-?\d+)$/i) {
351 if (!length($s_forwarded)) {
352 &transcript("$gBug is not marked as having been forwarded.\n\n");
355 $action= "Removed annotation that $gBug had been forwarded to $s_forwarded.";
357 &addmaintainers($s_package);
359 } while (&getnextbug);
362 } elsif (m/^severity\s+\#?(-?\d+)\s+([-0-9a-z]+)$/i ||
363 m/^priority\s+\#?(-?\d+)\s+([-0-9a-z]+)$/i) {
367 if (!grep($_ eq $newseverity, @gSeverityList, "$gDefaultSeverity")) {
368 &transcript("Severity level \`$newseverity' is not known.\n".
369 "Recognized are: $gShowSeverities.\n\n");
371 $printseverity= $s_severity;
372 $printseverity= "$gDefaultSeverity" if $printseverity eq '';
373 $action= "Severity set to \`$newseverity'.";
375 &addmaintainers($s_package);
376 $s_severity= $newseverity;
377 } while (&getnextbug);
379 } elsif (m/^tags?\s+\#?(-?\d+)\s+(([=+-])\s*)?(\S.*)?$/i) {
381 $ref = $1; $addsubcode = $3; $tags = $4;
383 if (defined $addsubcode) {
384 $addsub = "sub" if ($addsubcode eq "-");
385 $addsub = "add" if ($addsubcode eq "+");
386 $addsub = "set" if ($addsubcode eq "=");
390 foreach my $t (split /[\s,]+/, $tags) {
391 if (!grep($_ eq $t, @gTags)) {
398 &transcript("Unknown tag/s: ".join(', ', @badtags).".\n".
399 "Recognized are: ".join(' ', @gTags).".\n\n");
402 if ($s_keywords eq '') {
403 &transcript("There were no tags set.\n");
405 &transcript("Tags were: $s_keywords\n");
407 if ($addsub eq "set") {
408 $action= "Tags set to: " . join(", ", @okaytags);
409 } elsif ($addsub eq "add") {
410 $action= "Tags added: " . join(", ", @okaytags);
411 } elsif ($addsub eq "sub") {
412 $action= "Tags removed: " . join(", ", @okaytags);
415 &addmaintainers($s_package);
416 $s_keywords = '' if ($addsub eq "set");
417 if ($addsub eq "sub") {
418 foreach my $t (@badtags) {
419 $s_keywords = join ' ', grep $_ ne $t,
420 split ' ', $s_keywords;
423 foreach my $t (@okaytags) {
424 $s_keywords = join ' ', grep $_ ne $t,
425 split ' ', $s_keywords;
426 $s_keywords = "$t $s_keywords" unless($addsub eq "sub");
428 $s_keywords =~ s/\s*$//;
429 } while (&getnextbug);
431 } elsif (m/^retitle\s+\#?(-?\d+)\s+(\S.*\S)\s*$/i) {
433 $ref= $1; $newtitle= $2;
434 if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
435 $ref = $clonebugs{$ref};
439 &addmaintainers($s_package);
440 $s_subject= $newtitle;
441 $action= "Changed $gBug title.";
443 &transcript("$action\n");
444 if (length($s_done)) {
445 &transcript("(By the way, that $gBug is currently marked as done.)\n");
451 } elsif (m/^unmerge\s+\#?(-?\d+)$/i) {
455 if (!length($s_mergedwith)) {
456 &transcript("$gBug is not marked as being merged with any others.\n\n");
459 $mergelowstate eq 'locked' || die "$mergelowstate ?";
460 $action= "Disconnected #$ref from all other report(s).";
461 @newmergelist= split(/ /,$s_mergedwith);
464 &addmaintainers($s_package);
465 $s_mergedwith= ($ref == $discref) ? ''
466 : join(' ',grep($_ ne $ref,@newmergelist));
467 } while (&getnextbug);
470 } elsif (m/^merge\s+(\d+(\s+\d+)+)\s*$/i) {
472 @tomerge= sort { $a <=> $b } split(/\s+/,$1);
476 while (defined($ref= shift(@tomerge))) {
477 &transcript("D| checking merge $ref\n") if $dl;
479 next if grep($_ eq $ref,@newmergelist);
480 if (!&getbug) { ¬foundbug; @newmergelist=(); last }
482 &transcript("D| adding $ref ($s_mergedwith)\n") if $dl;
484 &checkmatch('package','m_package',$s_package);
485 &checkmatch('forwarded addr','m_forwarded',$s_forwarded);
486 $s_severity = '$gDefaultSeverity' if $s_severity eq '';
487 &checkmatch('severity','m_severity',$s_severity);
488 &checkmatch('done mark','m_done',length($s_done) ? 'done' : 'open');
489 foreach my $t (split /\s+/, $s_keywords) { $tags{$t} = 1; }
490 if (length($mismatch)) {
491 &transcript("Mismatch - only $gBugs in same state can be merged:\n".
493 &cancelbug; @newmergelist=(); last;
495 push(@newmergelist,$ref);
496 push(@tomerge,split(/ /,$s_mergedwith));
500 @newmergelist= sort { $a <=> $b } @newmergelist;
501 $action= "Merged @newmergelist.";
502 for $ref (@newmergelist) {
503 &getbug || die "huh ? $gBug $ref disappeared during merge";
504 &addmaintainers($s_package);
505 $s_mergedwith= join(' ',grep($_ ne $ref,@newmergelist));
506 $s_keywords= join(' ', keys %tags);
509 &transcript("$action\n\n");
512 } elsif (m/^clone\s+#?(\d+)\s+((-\d+\s+)*-\d+)\s*$/i) {
516 @newclonedids = split /\s+/, $2;
517 $newbugsneeded = scalar(@newclonedids);
521 if (length($s_mergedwith)) {
522 &transcript("$gBug is marked as being merged with others.\n\n");
525 &filelock("nextnumber.lock");
526 open(N,"nextnumber") || &quit("nextnumber: read: $!");
527 $v=<N>; $v =~ s/\n$// || &quit("nextnumber bad format");
528 $firstref= $v+0; $v += $newbugsneeded;
529 open(NN,">nextnumber"); print NN "$v\n"; close(NN);
532 $lastref = $firstref + $newbugsneeded - 1;
534 if ($newbugsneeded == 1) {
535 $action= "$gBug $origref cloned as bug $firstref.";
537 $action= "$gBug $origref cloned as bugs $firstref-$lastref.";
540 my $ohash = get_hashname($origref);
542 for $newclonedid (@newclonedids) {
543 $clonebugs{$newclonedid} = $ref;
545 my $hash = get_hashname($ref);
546 copy("db-h/$ohash/$origref.log", "db-h/$hash/$ref.log");
547 copy("db-h/$ohash/$origref.status", "db-h/$hash/$ref.status");
548 copy("db-h/$ohash/$origref.report", "db-h/$hash/$ref.report");
549 &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");
556 &transcript("Unknown command or malformed arguments to command.\n\n");
557 if (++$unknowns >= 5) {
558 &transcript("Too many unknown commands, stopping here.\n\n");
563 if ($procline>$#bodylines) {
564 &transcript(">\nEnd of message, stopping processing here.\n\n");
566 if (!$ok && !quickabort) {
567 &transcript("No commands successfully parsed; sending the help text(s).\n");
572 &transcript("MC\n") if $dl>1;
574 for $maint (keys %maintccreasons) {
575 &transcript("MM|$maint|\n") if $dl>1;
576 next if $maint eq $replyto;
578 $reasonsref= $maintccreasons{$maint};
579 &transcript("MY|$maint|\n") if $dl>2;
580 for $p (sort keys %$reasonsref) {
581 &transcript("MP|$p|\n") if $dl>2;
582 $reasonstring.= ', ' if length($reasonstring);
583 $reasonstring.= $p.' ' if length($p);
584 $reasonstring.= join(' ',map("#$_",sort keys %{$$reasonsref{$p}}));
586 if (length($reasonstring) > 40) {
587 (substr $reasonstring, 37) = "...";
589 $reasonstring = "" if (!defined($reasonstring));
590 push(@maintccs,"$maint ($reasonstring)");
591 push(@maintccaddrs,"$maint");
596 &transcript("MC|@maintccs|\n") if $dl>2;
597 $maintccs .= "Cc: " . join(",\n ",@maintccs) . "\n";
600 if (!defined $header{'subject'} || $header{'subject'} eq "") {
601 $header{'subject'} = "your mail";
605 From: $gMaintainerEmail ($gProject $gBug Tracking System)
607 ${maintccs}Subject: Processed: $header{'subject'}
608 In-Reply-To: $header{'message-id'}
609 References: $header{'message-id'}
610 Message-ID: <handler.s.$nn.transcript\@$gEmailDomain>
612 ${transcript}Please contact me if you need assistance.
615 (administrator, $gProject $gBugs database)
619 $repliedshow= join(', ',$replyto,@maintccaddrs);
620 &filelock("lock/-1");
621 open(AP,">>db-h/-1.log") || &quit("open db-h/-1.log: $!");
623 "\2\n$repliedshow\n\5\n$reply\n\3\n".
625 "<strong>Request received</strong> from <code>".
626 &sani($header{'from'})."</code>\n".
627 "to <code>".&sani($controlrequestaddr)."</code>\n".
629 "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/-1.log: $!");
630 close(AP) || &quit("open db-h/-1.log: $!");
632 utime(time,time,"db-h");
634 &sendmailmessage($reply,$replyto,@maintccaddrs,@bcc);
636 unlink("incoming/P$nn") || &quit("unlinking incoming/P$nn: $!");
640 map { $_->address() }
641 map { Mail::Address->parse($_) } @_;
644 sub sendmailmessage {
645 local ($message,@recips) = @_;
646 $message = "X-Loop: $gMaintainerEmail\n" . $message;
647 print "mailing to >@recips<\n" if $debug;
649 defined($c) || &quit("mailing forking for sendmail: $!");
650 if (!$c) { # ie, we are the child process
651 exec '/usr/lib/sendmail','-f'."$gMaintainerEmail",'-odb','-oem','-oi',get_addresses(@recips);
654 print(D $message) || &quit("writing to sendmail process: $!");
655 $!=0; close(D); $? && &quit("sendmail gave exit status $? ($!)");
660 &sendtxthelpraw("bug-log-mailserver.txt","instructions for request\@$gEmailDomain");
661 &sendtxthelpraw("bug-maint-mailcontrol.txt","instructions for control\@$gEmailDomain")
666 # &transcript("Sorry, command $_[0] not yet implemented.\n\n");
670 local ($string,$mvarname,$svarvalue) = @_;
673 eval "\$mvarvalue= \$$mvarname";
674 &transcript("D| checkmatch \`$string' /$mvarname/$mvarvalue/$svarvalue/\n")
677 "Values for \`$string' don't match:\n".
678 " #$newmergelist[0] has \`$mvarvalue';\n".
679 " #$ref has \`$svarvalue'\n"
680 if $mvarvalue ne $svarvalue;
682 &transcript("D| setupmatch \`$string' /$mvarname/$svarvalue/\n")
684 eval "\$$mvarname= \$svarvalue";
688 # High-level bug manipulation calls
689 # Do announcements themselves
691 # Possible calling sequences:
695 # &transcript(something)
699 # $action= (something)
701 # (modify s_* variables)
702 # } while (getnextbug);
705 &dlen("nochangebug");
706 $state eq 'single' || $state eq 'multiple' || die "$state ?";
708 &endmerge if $manybugs;
710 &dlex("nochangebug");
714 &dlen("setbug $ref");
715 if ($ref =~ m/^-\d+/) {
716 if (!defined $clonebugs{$ref}) {
718 &dlex("setbug => noclone");
721 $ref = $clonebugs{$ref};
723 $state eq 'idle' || die "$state ?";
726 &dlex("setbug => 0s");
729 @thisbugmergelist= split(/ /,$s_mergedwith);
730 if (!@thisbugmergelist) {
735 &dlex("setbug => 1s");
744 &dlex("setbug => 0mc");
748 $state= 'multiple'; $sref=$ref;
749 &dlex("setbug => 1m");
755 $state eq 'single' || $state eq 'multiple' || die "$state ?";
757 if (!$manybugs || !@thisbugmergelist) {
758 length($action) || die;
759 &transcript("$action\n$extramessage\n");
760 &endmerge if $manybugs;
762 &dlex("getnextbug => 0");
765 $ref= shift(@thisbugmergelist);
766 &getbug || die "bug $ref disappeared";
768 &dlex("getnextbug => 1");
772 # Low-level bug-manipulation calls
773 # Do no announcements
781 # $action= (something)
786 # [getbug (returns 0)]
787 # &transcript("$action\n\n")
790 sub notfoundbug { &transcript("$gBug number $ref not found.\n\n"); }
791 sub foundbug { &transcript("$gBug#$ref: $s_subject\n"); }
795 $mergelowstate eq 'idle' || die "$mergelowstate ?";
796 &filelock('lock/merge');
797 $mergelowstate='locked';
803 $mergelowstate eq 'locked' || die "$mergelowstate ?";
805 $mergelowstate='idle';
810 &dlen("getbug $ref");
811 $lowstate eq 'idle' || die "$state ?";
812 if (&lockreadbug($ref)) {
815 &dlex("getbug => 1");
820 &dlex("getbug => 0");
826 $lowstate eq 'open' || die "$state ?";
833 &dlen("savebug $ref");
834 $lowstate eq 'open' || die "$lowstate ?";
835 length($action) || die;
836 $ref == $sref || die "read $sref but saving $ref ?";
837 my $hash = get_hashname($ref);
838 open(L,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log: $!");
841 "<strong>".&sani($action)."</strong>\n".
842 "Request was from <code>".&sani($header{'from'})."</code>\n".
843 "to <code>".&sani($controlrequestaddr)."</code>. \n".
845 "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/$hash/$ref.log: $!");
846 close(L) || &quit("closing db-h/$hash/$ref.log: $!");
847 open(S,">db-h/$hash/$ref.status.new") || &quit("opening db-h/$hash/$ref.status.new: $!");
860 "$s_fixed_versions\n") || &quit("writing db-h/$hash/$ref.status.new: $!");
861 close(S) || &quit("closing db-h/$hash/$ref.status.new: $!");
862 rename("db-h/$hash/$ref.status.new","db-h/$hash/$ref.status") ||
863 &quit("installing new db-h/$hash/$ref.status: $!");
864 &bughook('change',$ref,
876 "$s_fixed_versions\n");
884 &transcript("C> @_ ($state $lowstate $mergelowstate)\n");
889 &transcript("R> @_ ($state $lowstate $mergelowstate)\n");
893 print $_[0] if $debug;
910 local ($relpath,$description) = @_;
912 open(D,"$gDocDir/$relpath") || &quit("open doc file $relpath: $!");
913 while(<D>) { $doc.=$_; }
915 &transcript("Sending $description in separate message.\n");
916 &sendmailmessage(<<END.$doc,$replyto);
917 From: $gMaintainerEmail ($gProject $gBug Tracking System)
919 Subject: $gProject $gBug help: $description
920 References: $header{'message-id'}
921 In-Reply-To: $header{'message-id'}
922 Message-ID: <handler.s.$nn.help.$midix\@$gEmailDomain>
929 local ($relpath,$description) = @_;
931 # the below oughta use $gWebDomain but it can't
932 open(L,"lynx -nolist -dump http://bugs.debian.org/$relpath 2>&1 |") || &quit("fork for lynx: $!");
933 while(<L>) { $doc.=$_; }
935 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
936 &transcript("Information ($description) is not available -\n".
937 "perhaps the $gBug does not exist or is not on the WWW yet.\n");
940 &transcript("Error getting $description (code $? $!):\n$doc\n");
942 &transcript("Sending $description.\n");
943 &sendmailmessage(<<END.$doc,$replyto);
944 From: $gMaintainerEmail ($gProject $gBug Tracking System)
946 Subject: $gProject $gBugs information: $description
947 References: $header{'message-id'}
948 In-Reply-To: $header{'message-id'}
949 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
958 $maintccreasons{$cca}{''}{$ref}= 1;
963 # maintainer email address &c -> assoc of packages -> assoc of bug#'s
964 my ($p, $addmaint, $pshow);
965 &ensuremaintainersloaded;
966 $anymaintfound=0; $anymaintnotfound=0;
967 for $p (split(m/[ \t?,()]+/,$_[0])) {
969 $pshow= ($p =~ m/[-+.a-z0-9]+/ ? $& : '');
970 if (defined $gSubscriptionDomain) {
971 if (defined($pkgsrc{$p})) {
972 push @bcc, "$pkgsrc{$p}\@$gSubscriptionDomain";
974 push @bcc, "$p\@$gSubscriptionDomain";
977 if (defined($maintainerof{$p})) {
978 $addmaint= $maintainerof{$p};
979 &transcript("MR|$addmaint|$p|$ref|\n") if $dl>2;
980 $maintccreasons{$addmaint}{$p}{$ref}= 1;
981 print "maintainer add >$p|$addmaint<\n" if $debug;
983 print "maintainer none >$p<\n" if $debug;
984 &transcript("MR|unknown-package|$p|$ref|\n") if $dl>2;
985 $maintccreasons{$gUnknownMaintainerEmail}{$p}{$ref}= 1;
990 sub ensuremaintainersloaded {
992 return if $maintainersloaded++;
993 open(MAINT,"$gMaintainerFile") || die &quit("maintainers open: $!");
997 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers bogus \`$_'");
998 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
999 $maintainerof{$1}= $2;
1002 open(MAINT,"$gMaintainerFileOverride") || die &quit("maintainers.override open: $!");
1006 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers.override bogus \`$_'");
1007 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
1008 $maintainerof{$1}= $2;
1011 open(SOURCES, "$gPackageSource") || &quit("pkgsrc open: $!");
1013 next unless m/^(\S+)\s+\S+\s+(\S.*\S)\s*$/;
1014 my ($a, $b) = ($1, $2);
1015 $pkgsrc{lc($a)} = $b;
1021 local ($wherefrom,$path,$description) = @_;
1022 if ($wherefrom eq "ftp.d.o") {
1023 $doc = `lynx -nolist -dump http://ftp.debian.org/debian/indices/$path.gz 2>&1 | gunzip -cf` or &quit("fork for lynx/gunzip: $!");
1025 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
1026 &transcript("$description is not available.\n");
1029 &transcript("Error getting $description (code $? $!):\n$doc\n");
1032 } elsif ($wherefrom eq "local") {
1034 $doc = do { local $/; <P> };
1037 &transcript("internal errror: info files location unknown.\n");
1040 &transcript("Sending $description.\n");
1041 &sendmailmessage(<<END.$doc,$replyto);
1042 From: $gMaintainerEmail ($gProject $gBug Tracking System)
1044 Subject: $gProject $gBugs information: $description
1045 References: $header{'message-id'}
1046 In-Reply-To: $header{'message-id'}
1047 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
1049 $description follows: