Add an embryonic Gnats.pm that will collect variables and subroutines

related to querying GNATS together, in order to aid with the upgrade to
GNATS 4.

Switch over dosendpr.cgi and query-pr.cgi to use it.
query-pr-summary.cgi to follow.
This commit is contained in:
Ceri Davies 2004-02-16 16:57:10 +00:00
parent 84cbdf31c8
commit f08bb99ab7
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/www/; revision=20046
4 changed files with 52 additions and 28 deletions

41
en/cgi/Gnats.pm Normal file
View file

@ -0,0 +1,41 @@
# $Id: Gnats.pm,v 1.1 2004-02-16 16:57:10 ceri Exp $
package Gnats;
# We probably don't have "our" in this Perl
use vars qw/
$gnats_root
$query_pr
$submission_address
$submission_program
$use_mail
/;
$gnats_root="/usr/local/libexec/gnats";
$query_pr="/usr/local/bin/query-pr.web";
$submission_address="freebsd-gnats-submit\@FreeBSD.org";
$use_mail=1;
if ($use_mail) {
if (-e "/usr/lib/sendmail") { $submission_program = "/usr/lib/sendmail -t" };
if (-e "/usr/sbin/sendmail") { $submission_program = "/usr/sbin/sendmail -t" };
} else {
if (-e "$gnats_root/queue-pr") { $submission_program = "$gnats_root/queue-pr -q" };
}
##### End site specific stuff
BEGIN {
use Exporter();
use vars qw/$VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS/;
$VERSION = 0.01; # Has to have two decimal places
@ISA = qw/Exporter/;
# Names for sets of symbols
%EXPORT_TAGS = (
'standard'=>[qw/$gnats_root $query_pr $submission_address
$submission_program/],
);
Exporter::export_tags('standard');
Exporter::export_ok_tags('standard');
}
1;

View file

@ -1,4 +1,4 @@
# $FreeBSD: www/en/cgi/Makefile,v 1.20 2003/12/14 17:28:13 ceri Exp $
# $FreeBSD: www/en/cgi/Makefile,v 1.21 2004/02/16 15:18:02 ceri Exp $
.if exists(../Makefile.conf)
.include "../Makefile.conf"
@ -7,7 +7,7 @@
.include "../Makefile.inc"
.endif
DATA= ftp.mirrors freebsd.def html.pl cgi-lib.pl cgi-style.pl
DATA= ftp.mirrors freebsd.def html.pl cgi-lib.pl cgi-style.pl Gnats.pm
DATA+= cvsweb.conf cvsweb.conf-freebsd cvsweb.conf-netbsd cvsweb.conf-openbsd
CGI= ftp.cgi gallery.cgi mirror.cgi
CGI+= search.cgi cvsweb.cgi query-pr.cgi query-pr-summary.cgi

View file

@ -8,13 +8,14 @@
# GNU General Public License Version 2.
# (http://www.gnu.ai.mit.edu/copyleft/gpl.html)
#
# $FreeBSD: www/en/cgi/dosendpr.cgi,v 1.19 2004/02/16 16:49:25 ceri Exp $
# $FreeBSD: www/en/cgi/dosendpr.cgi,v 1.20 2004/02/16 16:54:06 ceri Exp $
require "html.pl";
use Socket;
use DB_File;
use Fcntl qw(:DEFAULT :flock);
require "./Gnats.pm"; import Gnats;
my $blackhole = "dnsbl.njabl.org";
my $openproxyip = "127.0.0.9";
@ -80,28 +81,9 @@ sub prerror {
&www_content ("text","html");
&cgi_form_in();
$gndb = $cgi_data{'gndb'};
if ($gndb =~ /^[a-z]+$/ && -e "$gndb.def")
{ require "$gndb.def"; }
else
{ &prerror("gndb problem"); }
&prerror("request method problem") if $ENV{'REQUEST_METHOD'} eq 'GET';
# Configuration
if ($gnhow eq "mail")
{
if (-e "/usr/lib/sendmail")
{ $submitprog = "/usr/lib/sendmail -t" };
if (-e "/usr/sbin/sendmail")
{ $submitprog = "/usr/sbin/sendmail -t" };
}
else
{ if (-e "$gnroot/queue-pr")
{ $submitprog = "$gnroot/queue-pr -q" };
}
if (!$submitprog) { &prerror("submit program problem"); }
if (!$submission_program) { &prerror("submit program problem"); }
&html_title ("Thank you for the problem report");
&html_body ();
@ -164,14 +146,14 @@ if (defined $openproxy) {
}
# Build the PR.
$pr = "To: $gnemail\n" .
$pr = "To: $submission_address\n" .
"From: $cgi_data{'originator'} <$cgi_data{'email'}>\n" .
"Subject: $cgi_data{'synopsis'}\n" .
env2hdr(@ENV_captures);
if ($blackhole_err) {
$pr .= "X-REMOTE_ADDR-Is-Open-Proxy: Maybe\n";
}
$pr .= "X-Send-Pr-Version: www-2.2\n\n" .
$pr .= "X-Send-Pr-Version: www-2.3\n\n" .
">Submitter-Id:\t$cgi_data{'submitterid'}\n" .
">Originator:\t$cgi_data{'originator'}\n" .
">Organization:\t$cgi_data{'organization'}\n" .
@ -190,7 +172,7 @@ $pr .= "X-Send-Pr-Version: www-2.2\n\n" .
# remove any carrage returns that appear in the report.
$pr =~ s/\r//g;
if (open (SUBMIT, "|$submitprog")){
if (open (SUBMIT, "|$submission_program")){
print SUBMIT $pr;
close (SUBMIT);

View file

@ -1,5 +1,5 @@
#!/usr/bin/perl -T
# $FreeBSD: www/en/cgi/query-pr.cgi,v 1.35 2003/06/09 14:58:00 ceri Exp $
# $FreeBSD: www/en/cgi/query-pr.cgi,v 1.36 2003/11/12 20:58:13 ceri Exp $
$ENV{'PATH'} = "/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin";
@ -11,6 +11,7 @@ $ENV{'PATH'} = "/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin";
require "./cgi-lib.pl";
require "./cgi-style.pl";
require "getopts.pl";
require "./Gnats.pm"; import Gnats;
&Getopts('p:');
@ -56,7 +57,7 @@ if ($pr < 1 || $pr > 499999) {
exit 0;
}
unless (open(Q, "query-pr.web -F $pr 2>&1 |")) {
unless (open(Q, "$query_pr -F $pr 2>&1 |")) {
print &html_header("Server error");
print "<p>Unable to open PR database.</p>\n";
print &html_footer;