-#!/usr/bin/perl -w
-# $Id: service.in,v 1.5 1999/09/16 19:42:50 gecko Exp $
+#!/usr/bin/perl
+# $Id: service.in,v 1.33 2001/03/18 05:17:07 doogie Exp $
#
# Usage: service <code>.nn
# Temps: incoming/P<code>.nn
use Mail::Address;
require('/etc/debbugs/config');
require('/usr/lib/debbugs/errorlib');
-$ENV{'PATH'}= '/usr/lib/debbugs'.$ENV{'PATH'};;
+$ENV{'PATH'} = '/usr/lib/debbugs:'.$ENV{'PATH'};
chdir("$gSpoolDir") || die "chdir spool: $!\n";
# open(DEBUG,">&4");
-
-$wwwbase= "$gWebDir";
-
-# defined($intdate= time) || &quit("failed to get time: $!");
+open DEBUG, ">/dev/null";
+$debug = 0;
$_=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;
+if (!rename("incoming/G$nn","incoming/P$nn"))
+{ $_=$!.''; m/no such file or directory/i && exit 0;
&quit("renaming to lock: $!");
}
grep((s/\n$//,s/\s+$//),@msg);
-print DEBUG "###\n",join("##\n",@msg),"\n###\n";
+print "###\n",join("##\n",@msg),"\n###\n" if $debug;
chop($tdate= `date -u '+%a, %d %h %Y %T GMT'`);
$fwd= <<END;
Received: via spool for service; $tdate
END
-for ($i=0; $i<=$#msg; $i++) {
- $_ = $msg[$i];
+for ($i=0; $i<=$#msg; $i++)
+{ $_ = $msg[$i];
last unless length($_);
$fwd .= $_."\n";
- while ($msg[$i+1] =~ m/^\s/) {
- $i++;
+ while ($msg[$i+1] =~ m/^\s/)
+ { $i++;
$fwd .= $msg[$i]."\n" if $ins; # Huh ? Where is ins set ?
$_ .= ' '.$msg[$i];
}
-# print DEBUG ">$_<\n";
- if (s/^(\S+):\s*//) {
- $v= $1; $v =~ y/A-Z/a-z/;
-print DEBUG ">$v=$_<\n";
+ print ">$_<\n" if $debug;
+ if (s/^(\S+):\s*//)
+ { $v= $1; $v =~ y/A-Z/a-z/;
+ print ">$v=$_<\n" if $debug;
$header{$v}= $_;
- } else {
-print DEBUG "!>$_<\n";
- }
+ } else { print "!>$_<\n" if $debug; }
}
+if (defined $header{'resent-from'} && !defined $header{'from'}) {
+ $header{'from'} = $header{'resent-from'};
+}
defined($header{'from'}) || &quit("no From header");
-$replyto= defined($header{'reply-to'}) ? $header{'reply-to'} : $header{'from'};
+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='';
$midix=0;
$extras="";
+#strip blank line(s) after header
while ( $i <= $#msg && !length( $msg[$i] ) ) { $fwd .= "\n"; $i++; }
+#strip, if exists, mime header
+if ( $msg[$i] =~ /^This is a multi-part message in MIME format./ )
+{ while ( $i <= $#msg && length( $msg[$i] ) ) { $fwd .= $msg[$i] . "\n"; $i++; }
+ while ( $i <= $#msg && !length( $msg[$i] ) ) { $fwd .= "\n"; $i++; }
+}
if ( $msg[$i] =~ /^--/ || $msg[$i] =~ /^\s*$/ )
-{
- while ( $i <= $#msg && length( $msg[$i] ) ) { $fwd .= $msg[$i]; $i++; }
+{ while ( $i <= $#msg && length( $msg[$i] ) ) { $fwd .= $msg[$i]; $i++; }
while ( $i <= $#msg && !length( $msg[$i] ) ) { $fwd .= "\n"; $i++; }
}
-for ($procline=$i; $procline<=$#msg; $procline++) {
- $state eq 'idle' || "$state ?";
- $lowstate eq 'idle' || "$lowstate ?";
- $mergelowstate eq 'idle' || "$mergelowstate ?";
+for ($procline=$i; $procline<=$#msg; $procline++)
+{ $state eq 'idle' || print "$state ?\n";
+ $lowstate eq 'idle' || print "$lowstate ?\n";
+ $mergelowstate eq 'idle' || print "$mergelowstate ?\n";
$_= $msg[$procline]; s/\s+$//;
next unless m/\S/; next if m/^\s*\#/;
&transcript("> $_\n");
$action= '';
- if (m/^stop$/ || m/^quit$/ || m/^--/ || m/^thank/) {
- &transcript("Stopping processing here.\n\n");
+ if (m/^stop/i || m/^quit/i || m/^--/ || m/^thank/i)
+ { &transcript("Stopping processing here.\n\n");
last;
- } elsif (m/^debug\s+(\d+)$/ && $1 >= 0 && $1 <= 1000) {
+ } 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{3,})$/) {
- $ref= $2+0; $reffile= $ref; $reffile =~ s,^..,$&/$&,;
- &sendlynxdoc("db/$reffile.html","logs for $gBug#$ref");
- } elsif (m/^send-detail\s+\#?(\d+)$/) {
+ } elsif (m/^(send|get)\s+\#?(\d{2,})$/i) {
+ $ref= $2+0;
+ &sendlynxdoc("$ref","logs for $gBug#$ref");
+ } elsif (m/^send-detail\s+\#?(\d+)$/i) {
$ref= $1+0; $reffile= $ref; $reffile =~ s,^..,$&/$&,;
&sendlynxdoc("db/$reffile-b.html","additional logs for $gBug#$ref");
- } elsif (m/^index(\s+full)?$/) {
+ } elsif (m/^index(\s+full)?$/i) {
&sendlynxdoc("db/ix/full.html",'full index');
- } elsif (m/^index-summary\s+by-package$/) {
+ } elsif (m/^index-summary\s+by-package$/i) {
&sendlynxdoc("db/ix/psummary.html",'summary index sorted by package/title');
- } elsif (m/^index-summary(\s+by-number)?$/) {
+ } elsif (m/^index-summary(\s+by-number)?$/i) {
&sendlynxdoc("db/ix/summary.html",'summary index sorted by number/date');
- } elsif (m/^index(\s+|-)pack(age)?s?$/) {
+ } elsif (m/^index(\s+|-)pack(age)?s?$/i) {
&sendlynxdoc("db/ix/packages.html",'index of packages');
- } elsif (m/^index(\s+|-)maints?$/) {
+ } elsif (m/^index(\s+|-)maints?$/i) {
&sendlynxdoc("db/ix/maintainers.html",'index of maintainers');
- } elsif (m/^index(\s+|-)maint\s+(\S.*\S)$/) {
+ } elsif (m/^index(\s+|-)maint\s+(\S.*\S)$/i) {
$substrg= $2; $matches=0;
opendir(DBD,"$gWebDir/db/ma") || die $!;
while (defined($_=readdir(DBD))) {
"Use \`index-maint' to get list of maintainers.\n\n");
}
$ok++;
- } elsif (m/^index(\s+|-)pack(age)?s?\s+(\S.*\S)$/) {
+ } elsif (m/^index(\s+|-)pack(age)?s?\s+(\S.*\S)$/i) {
$substrg= $+; $matches=0;
opendir(DBD,"$gWebDir/db/pa") || die $!;
while (defined($_=readdir(DBD))) {
"Use \`index-packages' to get list of packages.\n\n");
}
$ok++;
- } elsif (m/^send-unmatched(\s+this|\s+-?0)?$/) {
+ } elsif (m/^send-unmatched(\s+this|\s+-?0)?$/i) {
&sendlynxdoc("db/ju/unmatched-1.html","junk (this week)");
- } elsif (m/^send-unmatched\s+(last|-1)$/) {
+ } elsif (m/^send-unmatched\s+(last|-1)$/i) {
&sendlynxdoc("db/ju/unmatched-2.html","junk (last week)");
- } elsif (m/^send-unmatched\s+(old|-2)$/) {
+ } elsif (m/^send-unmatched\s+(old|-2)$/i) {
&sendlynxdoc("db/ju/unmatched-3.html","junk (two weeks ago)");
- } elsif (m/^getinfo\s+(\S+)$/) {
+ } elsif (m/^getinfo\s+(\S+)$/i) {
$file= $1;
if ($file =~ m/^\./ || $file !~ m/^[-.0-9a-z]+$/ || $file =~ m/\.gz$/) {
&transcript("Filename $file is badly formatted.\n\n");
} else {
&transcript("Info file $file does not exist.\n\n");
}
- } elsif (m/^help$/) {
+ } elsif (m/^help/i) {
&sendhelp;
&transcript("\n");
$ok++;
- } elsif (m/^refcard$/) {
+ } elsif (m/^refcard/i) {
&sendtxthelp("bug-mailserver-refcard.txt","mailservers' reference card");
- } elsif (m/^subscribe/) {
+ } 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://$gWebUrl/ or ask this mailserver
+please do so via http://$gWebDomain/ or ask this mailserver
to send them to you.
soon: MAILINGLISTS_TEXT
END
- } elsif (m/^unsubscribe/) {
+ } elsif (m/^unsubscribe/i) {
&transcript(<<END);
soon: UNSUBSCRIBE_TEXT
soon: MAILINGLISTS_TEXT
&transcript("Too many unknown commands, stopping here.\n\n");
last;
}
- } elsif (m/^close\s+\#?(\d+)$/) {
+ } elsif (m/^close\s+\#?(\d+)$/i) {
$ok++;
$ref= $1;
if (&setbug) {
&transcript("$gBug is already closed, cannot re-close.\n\n");
&nochangebug;
} else {
- $action= "$gBug closed, ack sent to submitter - they'd better know why !";
+ $action= "$gBug closed, send any further explanations to $s_originator";
do {
&addmaintainers($s_package);
if ( length( $gDoneList ) > 0 && length( $gListDomain ) >
0 ) { &addccaddress("$gDoneList\@$gListDomain"); }
$s_done= $replyto;
$message= <<END;
-From: $gMaintainerEmail ($gMaintainer)
+From: $gMaintainerEmail ($gProject $gBug Tracking System)
To: $s_originator
Subject: $gBug#$ref acknowledged by developer
- ($s_subject)
+ ($header{'subject'})
References: $header{'message-id'} $s_msgid
In-Reply-To: $s_msgid
Message-ID: <handler.$ref.$nn.notifdonectrl.$midix\@$gEmailDomain>
-This is an automatic notification regarding your $gBug report.
+This is an automatic notification regarding your $gBug report
+#$ref: $s_subject,
+which was filed against the $s_package package.
It has been marked as closed by one of the developers, namely
$replyto.
$gMaintainer
(administrator, $gProject $gBugs database)
+
END
&sendmailmessage($message,$s_originator);
} while (&getnextbug);
}
}
- } elsif (m/^reassign\s+\#?(\d+)\s+(\S.*\S)$/) {
+ } elsif (m/^reassign\s+\#?(\d+)\s+(\S.*\S)$/i) {
$ok++;
$ref= $1; $newpackage= $2;
+ $newpackage =~ y/A-Z/a-z/;
if (&setbug) {
if (length($s_package)) {
$action= "$gBug reassigned from package \`$s_package'".
$s_package= $newpackage;
} while (&getnextbug);
}
- } elsif (m/^reopen\s+\#?(\d+)$/ ? ($noriginator='', 1) :
- m/^reopen\s+\#?(\d+)\s+\=$/ ? ($noriginator='', 1) :
- m/^reopen\s+\#?(\d+)\s+\!$/ ? ($noriginator=$replyto, 1) :
- m/^reopen\s+\#?(\d+)\s+(\S.*\S)$/ ? ($noriginator=$2, 1) : 0) {
+ } 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($s_done)) {
- &transcript("$gByg is already open, cannot reopen.\n\n");
+ &transcript("$gBug is already open, cannot reopen.\n\n");
&nochangebug;
} else {
$action=
} while (&getnextbug);
}
}
- } elsif (m/^forwarded\s+\#?(\d+)\s+(\S.*\S)$/) {
+ } elsif (m/^forwarded\s+\#?(\d+)\s+(\S.*\S)$/i) {
$ok++;
$ref= $1; $whereto= $2;
if (&setbug) {
$s_forwarded= $whereto;
} while (&getnextbug);
}
- } elsif (m/^notforwarded\s+\#?(\d+)$/) {
+ } elsif (m/^notforwarded\s+\#?(\d+)$/i) {
$ok++;
$ref= $1;
if (&setbug) {
} while (&getnextbug);
}
}
- } elsif (m/^severity\s+\#?(\d+)\s+([-0-9a-z]+)$/) {
+ } 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, @severities, "$gDefaultSeverity")) {
+ if (!grep($_ eq $newseverity, @gSeverityList, "$gDefaultSeverity")) {
&transcript("Severity level \`$newseverity' is not known.\n".
- "Recognised are: ".join(' ',@showseverities).".\n\n");
+ "Recognized are: $gShowSeverities.\n\n");
} elsif (&setbug) {
$printseverity= $s_severity;
$printseverity= "$gDefaultSeverity" if $printseverity eq '';
$action= "Severity set to \`$newseverity'.";
do {
+# if ( &newseverity eq 'fixed' && length( $gDoneList ) > 0 && length( $gListDomain ) > 0 ) {
+# &addccaddress("$gDoneList\@$gListDomain");
+# }
&addmaintainers($s_package);
$s_severity= $newseverity;
} while (&getnextbug);
}
- } elsif (m/^retitle\s+\#?(\d+)\s+(\S.*\S)\s*$/) {
+ } elsif (m/^tags\s+\#?(\d+)\s+(([=+-])\s+)?(\S.*)?$/) {
+ $ok++;
+ $ref= $1; $addsubcode= $3; $tags= $4;
+ $addsub = "add";
+ $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 ($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($s_package);
+ $s_keywords = '' if ($addsub eq "set");
+ if ($addsub eq "sub") {
+ foreach my $t (@badtags) {
+ $s_keywords = join ' ', grep $_ ne $t,
+ split ' ', $s_keywords;
+ }
+ }
+ foreach my $t (@okaytags) {
+ $s_keywords = join ' ', grep $_ ne $t,
+ split ' ', $s_keywords;
+ $s_keywords = "$t $s_keywords" unless($addsub eq "sub");
+ }
+ $s_keywords =~ s/\s*$//;
+ } while (&getnextbug);
+ }
+ } elsif (m/^retitle\s+\#?(\d+)\s+(\S.*\S)\s*$/i) {
$ok++;
$ref= $1; $newtitle= $2;
if (&getbug) {
} else {
¬foundbug;
}
- } elsif (m/^unmerge\s+\#?(\d+)$/) {
+ } elsif (m/^unmerge\s+\#?(\d+)$/i) {
$ok++;
$ref= $1;
if (&setbug) {
} while (&getnextbug);
}
}
- } elsif (m/^merge\s(\d+(\s+\d+)+)\s*$/) {
+ } 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;
next if grep($_ eq $ref,@newmergelist);
if (!&getbug) { ¬foundbug; @newmergelist=(); last }
&foundbug;
- &transcript("D| adding $ref ($s_mergewith)\n") if $dl;
+ &transcript("D| adding $ref ($s_mergedwith)\n") if $dl;
$mismatch= '';
&checkmatch('package','m_package',$s_package);
&checkmatch('forwarded addr','m_forwarded',$s_forwarded);
+ $s_severity = '$gDefaultSeverity' if $s_severity eq '';
&checkmatch('severity','m_severity',$s_severity);
&checkmatch('done mark','m_done',length($s_done) ? 'done' : 'open');
+ foreach my $t (split /\s+/, $s_keywords) { $tags{$t} = 1; }
if (length($mismatch)) {
- &transcript("Mismatch - only $Bugs in same state can be merged:\n".
+ &transcript("Mismatch - only $gBugs in same state can be merged:\n".
$mismatch."\n");
&cancelbug; @newmergelist=(); last;
}
&getbug || die "huh ? $gBug $ref disappeared during merge";
&addmaintainers($s_package);
$s_mergedwith= join(' ',grep($_ ne $ref,@newmergelist));
+ $s_keywords= join(' ', keys %tags);
&savebug;
}
&transcript("$action\n\n");
$reasonstring.= $p.' ' if length($p);
$reasonstring.= join(' ',map("#$_",sort keys %{$$reasonsref{$p}}));
}
+ $reasonstring = "" if (!defined($reasonstring));
push(@maintccs,"$maint ($reasonstring)");
push(@maintccaddrs,"$maint");
}
if (@maintccs) {
&transcript("MC|@maintccs|\n") if $dl>2;
$maintccs= "Cc: ".join(",\n ",@maintccs)."\n";
+} else { $maintccs = ""; }
+
+if (!defined $header{'subject'} || $header{'subject'} eq "") {
+ $header{'subject'} = "your mail";
}
$reply= <<END;
-From: $gMaintainerEmail ($gMaintainer)
+From: $gMaintainerEmail ($gProject $gBug Tracking System)
To: $replyto
${maintccs}Subject: Processed: $header{'subject'}
In-Reply-To: $header{'message-id'}
sub sendmailmessage {
local ($message,@recips) = @_;
- print DEBUG "mailing to >@recips<\n";
+ 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
}
sub transcript {
- print(DEBUG $_[0]);
+ print $_[0] if $debug;
$transcript.= $_[0];
}
close(D);
&transcript("Sending $description in separate message.\n");
&sendmailmessage(<<END.$doc,$replyto);
-From: $gMaintainerEmail ($gMaintainer)
+From: $gMaintainerEmail ($gProject $gBug Tracking System)
To: $replyto
Subject: $gProject $gBug help: $description
References: $header{'message-id'}
sub sendlynxdocraw {
local ($relpath,$description) = @_;
+# check for crap in $relpath
+ if ($relpath =~ m/^\./ || $relpath !~ m/^[\d\w-+.@]+$/) {
+ &transcript("Invalid request $relpath!\n");
+ return;
+ }
$doc='';
- open(L,"lynx -nolist -dump $wwwbase/$relpath 2>&1 |") || &quit("fork for lynx: $!");
+ open(L,"lynx -nolist -dump http://$gWebDomain/$relpath 2>&1 |") || &quit("fork for lynx: $!");
while(<L>) { $doc.=$_; }
$!=0; close(L);
if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
} else {
&transcript("Sending $description.\n");
&sendmailmessage(<<END.$doc,$replyto);
-From: $gMaintainerEmail ($gMaintainer)
+From: $gMaintainerEmail ($gProject $gBug Tracking System)
To: $replyto
Subject: $gProject $gBugs information: $description
References: $header{'message-id'}
$maintccreasons{$cca}{''}{$ref}= 1;
}
-sub addmaintainers {
- # Data structure is:
+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/;
+ for $p (split(m/[ \t?,()]+/,$_[0]))
+ { $p =~ y/A-Z/a-z/;
$pshow= ($p =~ m/[-+.a-z0-9]+/ ? $& : '');
- if (defined($maintainerof{$p})) {
- $addmaint= $maintainerof{$p};
-&transcript("MR|$addmaint|$p|$ref|\n") if $dl>2;
+ if (defined($maintainerof{$p}))
+ { $addmaint= $maintainerof{$p};
+ &transcript("MR|$addmaint|$p|$ref|\n") if $dl>2;
$maintccreasons{$addmaint}{$p}{$ref}= 1;
-print DEBUG "maintainer add >$p|$addmaint<\n";
- } else {
-print DEBUG "maintainer none >$p<\n";
- }
+ print "maintainer add >$p|$addmaint<\n" if $debug;
+ } else { print "maintainer none >$p<\n" if $debug; }
}
}
return if $maintainersloaded++;
open(MAINT,"$gMaintainerFile") || die &quit("maintainers open: $!");
while (<MAINT>) {
+ m/^\n$/ && next;
+ m/^\s*$/ && next;
m/^(\S+)\s+(\S.*\S)\n$/ || &quit("maintainers bogus \`$_'");
$a= $1; $b= $2; $a =~ y/A-Z/a-z/;
$maintainerof{$1}= $2;