From 28c789fab5114661321f43d163b58f109adde40e Mon Sep 17 00:00:00 2001
From: cjwatson <>
Date: Mon, 9 Jun 2003 23:59:36 -0800
Subject: [PATCH] [project @ 2003-06-10 00:59:36 by cjwatson] Avoid accepting
 mail to archived bugs! The generic getbugcomponent() function can't be quite
 as simple as it seems, because CGI scripts are prepared to accept archived
 bugs while most of the backend scripts aren't. This is a somewhat hacky
 workaround but does the job for now.

---
 cgi/common.pl       |  3 ++-
 scripts/errorlib.in | 11 +++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/cgi/common.pl b/cgi/common.pl
index 543d3ee7..04e77b82 100644
--- a/cgi/common.pl
+++ b/cgi/common.pl
@@ -621,7 +621,8 @@ sub getsrcpkgs {
    
 sub buglog {
     my $bugnum = shift;
-    return getbugcomponent($bugnum, 'log');
+    my $location = getbuglocation($bugnum, 'log');
+    return getbugcomponent($bugnum, 'log', $location);
 }
 
 1;
diff --git a/scripts/errorlib.in b/scripts/errorlib.in
index 062e8640..fe7aceea 100755
--- a/scripts/errorlib.in
+++ b/scripts/errorlib.in
@@ -1,5 +1,5 @@
 # -*- perl -*-
-# $Id: errorlib.in,v 1.29 2003/06/06 17:56:05 cjwatson Exp $
+# $Id: errorlib.in,v 1.30 2003/06/10 00:59:36 cjwatson Exp $
 
 sub F_SETLK { 6; } sub F_WRLCK{ 1; }
 $flockstruct= 'sslll'; # And there ought to be something for this too.
@@ -49,7 +49,14 @@ sub getlocationpath {
 sub getbugcomponent {
     my ($bugnum, $ext, $location) = @_;
 
-    $location = getbuglocation($bugnum, $ext) unless defined $location;
+    unless (defined $location) {
+	$location = getbuglocation($bugnum, $ext);
+	# Default to non-archived bugs only for now; CGI scripts want
+	# archived bugs but most of the backend scripts don't. For now,
+	# anything that is prepared to accept archived bugs should call
+	# getbuglocation() directly first.
+	return undef unless $location eq 'db' or $location eq 'db-h';
+    }
     my $dir = getlocationpath($location);
     return undef unless $dir;
     if ($location eq 'db') {
-- 
2.39.5