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