summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbbaetz%acm.org <>2003-11-22 12:50:36 +0100
committerbbaetz%acm.org <>2003-11-22 12:50:36 +0100
commitda857afa089e79ad16fb833dd1ffe397055fd892 (patch)
tree4582f630aa59c35fdb25aa30fd71c617977e0a86
parent63790559f094b702688365ed12242526ce3ff969 (diff)
downloadbugzilla-da857afa089e79ad16fb833dd1ffe397055fd892.tar.gz
bugzilla-da857afa089e79ad16fb833dd1ffe397055fd892.tar.xz
Bug 208604 - Make data/template dir locations configurable
-rw-r--r--Bugzilla/BugMail.pm4
-rw-r--r--Bugzilla/Config.pm54
-rw-r--r--Bugzilla/DB.pm4
-rw-r--r--Bugzilla/Template.pm15
-rw-r--r--Bugzilla/Util.pm2
-rwxr-xr-xchecksetup.pl201
-rwxr-xr-xcollectstats.pl17
-rwxr-xr-xcontrib/bug_email.pl25
-rwxr-xr-xcontrib/bugzilla_email_append.pl18
-rw-r--r--defparams.pl16
-rwxr-xr-xdoeditparams.cgi4
-rwxr-xr-xduplicates.cgi7
-rwxr-xr-xeditcomponents.cgi7
-rwxr-xr-xeditkeywords.cgi8
-rwxr-xr-xeditmilestones.cgi11
-rwxr-xr-xeditproducts.cgi8
-rwxr-xr-xeditversions.cgi9
-rw-r--r--globals.pl20
-rwxr-xr-ximportxml.pl7
-rwxr-xr-xmove.pl7
-rwxr-xr-xpage.cgi2
-rwxr-xr-xreports.cgi4
-rwxr-xr-xshowdependencygraph.cgi16
23 files changed, 264 insertions, 202 deletions
diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm
index 7937fe176..7fdf44980 100644
--- a/Bugzilla/BugMail.pm
+++ b/Bugzilla/BugMail.pm
@@ -32,6 +32,8 @@ package Bugzilla::BugMail;
use RelationSet;
+use Bugzilla::Config qw(:DEFAULT $datadir);
+
# This code is really ugly. It was a commandline interface, then it was moved
# There are package-global variables which we rely on ProcessOneBug to clean
# up each time, and other sorts of fun.
@@ -66,7 +68,7 @@ sub AUTOLOAD {
}
# This is run when we load the package
-if (open(NOMAIL, "<data/nomail")) {
+if (open(NOMAIL, '<', "$datadir/nomail")) {
while (<NOMAIL>) {
$nomail{trim($_)} = 1;
}
diff --git a/Bugzilla/Config.pm b/Bugzilla/Config.pm
index f0d64e5ac..f639b4a44 100644
--- a/Bugzilla/Config.pm
+++ b/Bugzilla/Config.pm
@@ -34,6 +34,29 @@ use base qw(Exporter);
use Bugzilla::Util;
+# Under mod_perl, get this from a .htaccess config variable,
+# and/or default from the current 'real' dir
+# At some stage after this, it may be possible for these dir locations
+# to go into localconfig. localconfig can't be specified in a config file,
+# except possibly with mod_perl. If you move localconfig, you need to change
+# the define here.
+# $libpath is really only for mod_perl; its not yet possible to move the
+# .pms elsewhere.
+# $webdotdir must be in the webtree somewhere. Even if you use a local dot,
+# we output images to there. Also, if $webdot dir is not relative to the
+# bugzilla root directory, you'll need to change showdependancygraph.cgi to
+# set image_url to the correct location.
+# The script should really generate these graphs directly...
+# Note that if $libpath is changed, some stuff will break, notably dependancy
+# graphs (since the path will be wrong in the HTML). This will be fixed at
+# some point.
+
+our $libpath = '.';
+our $localconfig = "$libpath/localconfig";
+our $datadir = "$libpath/data";
+our $templatedir = "$libpath/template";
+our $webdotdir = "$datadir/webdot";
+
# Module stuff
@Bugzilla::Config::EXPORT = qw(Param);
@@ -42,13 +65,15 @@ use Bugzilla::Util;
# when it shouldn't
# ChmodDataFile is here until that stuff all moves out of globals.pl
# into this file
-@Bugzilla::Config::EXPORT_OK = qw($contenttypes ChmodDataFile);
+@Bugzilla::Config::EXPORT_OK = qw(ChmodDataFile);
+
%Bugzilla::Config::EXPORT_TAGS =
(
admin => [qw(GetParamList UpdateParams SetParam WriteParams)],
db => [qw($db_host $db_port $db_name $db_user $db_pass $db_sock)],
+ locations => [qw($libpath $localconfig $datadir $templatedir $webdotdir)],
);
-Exporter::export_ok_tags('admin', 'db');
+Exporter::export_ok_tags('admin', 'db', 'locations');
# Bugzilla version
$Bugzilla::Config::VERSION = "2.17.6";
@@ -74,23 +99,24 @@ my %param;
# XXX - mod_perl - need to register Apache init handler for params
sub _load_datafiles {
# read in localconfig variables
- do 'localconfig';
+ do $localconfig;
- if (-e 'data/params') {
+ if (-e "$datadir/params") {
# Handle reading old param files by munging the symbol table
# Don't have to do this if we use safe mode, since its evaled
# in a sandbox where $foo is in the same module as $::foo
#local *::param = \%param;
- # Note that checksetup.pl sets file permissions on 'data/params'
+ # Note that checksetup.pl sets file permissions on '$datadir/params'
# Using Safe mode is _not_ a guarantee of safety if someone does
# manage to write to the file. However, it won't hurt...
# See bug 165144 for not needing to eval this at all
my $s = new Safe;
- $s->rdo('data/params');
- die "Error evaluating data/params: $@" if $@;
+ $s->rdo("$datadir/params");
+ die "Error reading $datadir/params: $!" if $!;
+ die "Error evaluating $datadir/params: $@" if $@;
# Now read the param back out from the sandbox
%param = %{$s->varglob('param')};
@@ -226,17 +252,17 @@ sub WriteParams {
require File::Temp;
my ($fh, $tmpname) = File::Temp::tempfile('params.XXXXX',
- DIR => 'data' );
+ DIR => $datadir );
print $fh (Data::Dumper->Dump([ \%param ], [ '*param' ]))
|| die "Can't write param file: $!";
close $fh;
- rename $tmpname, "data/params"
- || die "Can't rename $tmpname to data/params: $!";
+ rename $tmpname, "$datadir/params"
+ || die "Can't rename $tmpname to $datadir/params: $!";
- ChmodDataFile('data/params', 0666);
+ ChmodDataFile("$datadir/params", 0666);
}
# Some files in the data directory must be world readable iff we don't have
@@ -248,7 +274,7 @@ sub WriteParams {
sub ChmodDataFile {
my ($file, $mask) = @_;
my $perm = 0770;
- if ((stat('data'))[2] & 0002) {
+ if ((stat($datadir))[2] & 0002) {
$perm = 0777;
}
$perm = $perm & $mask;
@@ -321,10 +347,6 @@ Bugzilla::Config - Configuration parameters for Bugzilla
use Bugzilla::Config qw(:db);
print "Connecting to $db_name as $db_user with $db_pass\n";
- # This variable does not belong in localconfig, and needs to go
- # somewhere better
- use Bugzilla::Config($contenttypes)
-
=head1 DESCRIPTION
This package contains ways to access Bugzilla configuration parameters.
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm
index 1d2e96614..a747aebd6 100644
--- a/Bugzilla/DB.pm
+++ b/Bugzilla/DB.pm
@@ -135,9 +135,9 @@ sub connect_shadow {
}
sub connect_main {
- my $dsn = "DBI:mysql:host=$::db_host;database=$::db_name;port=$::db_port";
+ my $dsn = "DBI:mysql:host=$db_host;database=$db_name;port=$db_port";
- $dsn .= ";mysql_socket=$::db_sock" if $::db_sock;
+ $dsn .= ";mysql_socket=$db_sock" if $db_sock;
return _connect($dsn);
}
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index f9342e11f..d981c7a59 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -29,7 +29,7 @@ package Bugzilla::Template;
use strict;
-use Bugzilla::Config;
+use Bugzilla::Config qw(:DEFAULT $templatedir $datadir);
use Bugzilla::Util;
# for time2str - replace by TT Date plugin??
@@ -37,6 +37,7 @@ use Date::Format ();
use base qw(Template);
+# XXX - mod_perl
my $template_include_path;
# Make an ordered list out of a HTTP Accept-Language header see RFC 2616, 14.4
@@ -69,13 +70,16 @@ sub sortAcceptLanguage {
# If no Accept-Language is present it uses the defined default
sub getTemplateIncludePath () {
# Return cached value if available
+
+ # XXXX - mod_perl!
if ($template_include_path) {
return $template_include_path;
}
my $languages = trim(Param('languages'));
if (not ($languages =~ /,/)) {
return $template_include_path =
- ["template/$languages/custom", "template/$languages/default"];
+ ["$templatedir/$languages/custom",
+ "$templatedir/$languages/default"];
}
my @languages = sortAcceptLanguage($languages);
my @accept_language = sortAcceptLanguage($ENV{'HTTP_ACCEPT_LANGUAGE'} || "" );
@@ -92,7 +96,9 @@ sub getTemplateIncludePath () {
}
push(@usedlanguages, Param('defaultlanguage'));
return $template_include_path =
- [map(("template/$_/custom", "template/$_/default"), @usedlanguages)];
+ [map(("$templatedir/$_/custom",
+ "$templatedir/$_/default"),
+ @usedlanguages)];
}
@@ -177,7 +183,7 @@ sub create {
PRE_CHOMP => 1,
TRIM => 1,
- COMPILE_DIR => 'data/',
+ COMPILE_DIR => "$datadir/template",
# Functions for processing text within templates in various ways.
# IMPORTANT! When adding a filter here that does not override a
@@ -321,4 +327,3 @@ C<Bugzilla-E<gt>instance-E<gt>template> to get an already created module.
=head1 SEE ALSO
L<Bugzilla>, L<Template>
-
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index c0d671744..4660b374d 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -47,6 +47,8 @@ sub is_tainted {
}
sub trick_taint {
+ require Carp;
+ Carp::confess("Undef to trick_taint") unless defined $_[0];
$_[0] =~ /^(.*)$/s;
$_[0] = $1;
return (defined($_[0]));
diff --git a/checksetup.pl b/checksetup.pl
index da8715c4d..5f05e7c7a 100755
--- a/checksetup.pl
+++ b/checksetup.pl
@@ -118,10 +118,18 @@ use lib ".";
use vars qw( $db_name %answer );
use Bugzilla::Constants;
+my $silent;
+
+# The use of some Bugzilla modules brings in modules we need to test for
+# Check first, via BEGIN
+BEGIN {
+
+ # However, don't run under -c (because of tests)
+ if (!$^C) {
+
###########################################################################
# Non-interactive override
###########################################################################
-my $silent;
if ($ARGV[0]) {
do $ARGV[0]
or ($@ && die("Error $@ processing $ARGV[0]"))
@@ -322,18 +330,14 @@ if (%missing) {
exit;
}
+}
+}
+
###########################################################################
# Global definitions
###########################################################################
-# We use require + import here instead of "use" to load Bugzilla::Config
-# because Bugzilla::Config has dependencies on some of the modules tested
-# for above, so we need to wait until those dependency checks have been
-# done before loading it, rather than loading it at compile time.
-# see http://bugzilla.mozilla.org/show_bug.cgi?id=170073
-
-require Bugzilla::Config;
-import Bugzilla::Config qw(:DEFAULT :admin);
+use Bugzilla::Config qw(:DEFAULT :admin :locations);
# 12/17/00 justdave@syndicomm.com - removed declarations of the localconfig
# variables from this location. We don't want these declared here. They'll
@@ -372,7 +376,7 @@ import Bugzilla::Config qw(:DEFAULT :admin);
print "Checking user setup ...\n" unless $silent;
$@ = undef;
-do 'localconfig';
+do $localconfig;
if ($@) { # capture errors in localconfig, bug 97290
print STDERR <<EOT;
An error has occurred while reading your
@@ -404,7 +408,7 @@ sub LocalVar ($$)
my ($name, $definition) = @_;
return if LocalVarExists($name); # if localconfig declared it, we're done.
$newstuff .= " " . $name;
- open FILE, '>>localconfig';
+ open FILE, '>>', $localconfig;
print FILE ($answer{$name} or $definition), "\n\n";
close FILE;
}
@@ -682,7 +686,7 @@ LocalVar('platforms', '
if ($newstuff ne "") {
print "\nThis version of Bugzilla contains some variables that you may want\n",
"to change and adapt to your local settings. Please edit the file\n",
- "'localconfig' and rerun checksetup.pl\n\n",
+ "'$localconfig' and rerun checksetup.pl\n\n",
"The following variables are new to localconfig since you last ran\n",
"checksetup.pl: $newstuff\n\n";
exit;
@@ -757,29 +761,31 @@ EOF
#
# The |require "globals.pl"| above ends up creating a template object with
-# a COMPILE_DIR of 'data'. This means that TT creates the directory for us,
+# a COMPILE_DIR of "$datadir". This means that TT creates the directory for us,
# so this code wouldn't run if we just checked for the existence of the
-# directory. Instead, check for the existence of 'data/nomail', which is
+# directory. Instead, check for the existence of '$datadir/nomail', which is
# created in this block
-unless (-d 'data' && -e 'data/nomail') {
- print "Creating data directory ...\n";
+unless (-d $datadir && -e "$datadir/nomail") {
+ print "Creating data directory ($datadir) ...\n";
# permissions for non-webservergroup are fixed later on
- mkdir 'data', 0770;
- mkdir 'data/mimedump-tmp', 01777;
- open FILE, '>>data/nomail'; close FILE;
- open FILE, '>>data/mail'; close FILE;
+ mkdir $datadir, 0770;
+ mkdir "$datadir/mimedump-tmp", 01777;
+ open FILE, '>>', "$datadir/nomail"; close FILE;
+ open FILE, '>>', "$datadir/mail"; close FILE;
}
# 2000-12-14 New graphing system requires a directory to put the graphs in
-# This code copied from what happens for the 'data' dir above.
+# This code copied from what happens for the data dir above.
# If the graphs dir is not present, we assume that they have been using
# a Bugzilla with the old data format, and so upgrade their data files.
+
+# NB - the graphs dir isn't movable yet, unlike the datadir
unless (-d 'graphs') {
print "Creating graphs directory...\n";
# permissions for non-webservergroup are fixed later on
- mkdir 'graphs', 0770;
+ mkdir 'graphs', 0770;
# Upgrade data format
- foreach my $in_file (glob("data/mining/*"))
+ foreach my $in_file (glob("$datadir/mining/*"))
{
# Don't try and upgrade image or db files!
if (($in_file =~ /\.gif$/i) ||
@@ -791,7 +797,7 @@ unless (-d 'graphs') {
rename("$in_file", "$in_file.orig") or next;
open(IN, "$in_file.orig") or next;
- open(OUT, ">$in_file") or next;
+ open(OUT, '>', $in_file) or next;
# Fields in the header
my @declared_fields = ();
@@ -852,13 +858,13 @@ unless (-d 'graphs') {
}
}
-unless (-d 'data/mining') {
- mkdir 'data/mining', 0700;
+unless (-d "$datadir/mining") {
+ mkdir "$datadir/mining", 0700;
}
-unless (-d 'data/webdot') {
+unless (-d "$webdotdir") {
# perms/ownership are fixed up later
- mkdir 'data/webdot', 0700;
+ mkdir "$webdotdir", 0700;
}
if ($my_create_htaccess) {
@@ -870,7 +876,7 @@ if ($my_create_htaccess) {
}
if (!-e ".htaccess") {
print "Creating .htaccess...\n";
- open HTACCESS, ">.htaccess";
+ open HTACCESS, '>', '.htaccess';
print HTACCESS <<'END';
# don't allow people to retrieve non-cgi executable files or our private data
<FilesMatch ^(.*\.pl|.*localconfig.*|runtests.sh)$>
@@ -892,7 +898,7 @@ END
close HTACCESS;
if ($oldaccess =~ s/\|localconfig\|/\|.*localconfig.*\|/) {
print "Repairing .htaccess...\n";
- open HTACCESS, ">.htaccess";
+ open HTACCESS, '>', '.htaccess';
print HTACCESS $oldaccess;
print HTACCESS <<'END';
<FilesMatch ^(localconfig.js|localconfig.rdf)$>
@@ -905,7 +911,7 @@ END
}
if (!-e "Bugzilla/.htaccess") {
print "Creating Bugzilla/.htaccess...\n";
- open HTACCESS, ">Bugzilla/.htaccess";
+ open HTACCESS, '>', 'Bugzilla/.htaccess';
print HTACCESS <<'END';
# nothing in this directory is retrievable unless overriden by an .htaccess
# in a subdirectory
@@ -914,9 +920,12 @@ END
close HTACCESS;
chmod $fileperm, "Bugzilla/.htaccess";
}
- if (!-e "data/.htaccess") {
- print "Creating data/.htaccess...\n";
- open HTACCESS, ">data/.htaccess";
+ # Even though $datadir may not (and should not) be in the webtree,
+ # we can't know for sure, so create the .htaccess anyeay. Its harmless
+ # if its not accessible...
+ if (!-e "$datadir/.htaccess") {
+ print "Creating $datadir/.htaccess...\n";
+ open HTACCESS, '>', "$datadir/.htaccess";
print HTACCESS <<'END';
# nothing in this directory is retrievable unless overriden by an .htaccess
# in a subdirectory; the only exception is duplicates.rdf, which is used by
@@ -927,22 +936,23 @@ deny from all
</Files>
END
close HTACCESS;
- chmod $fileperm, "data/.htaccess";
+ chmod $fileperm, "$datadir/.htaccess";
}
- if (!-e "template/.htaccess") {
- print "Creating template/.htaccess...\n";
- open HTACCESS, ">template/.htaccess";
+ # Ditto for the template dir
+ if (!-e "$templatedir/.htaccess") {
+ print "Creating $templatedir/.htaccess...\n";
+ open HTACCESS, '>', "$templatedir/.htaccess";
print HTACCESS <<'END';
# nothing in this directory is retrievable unless overriden by an .htaccess
# in a subdirectory
deny from all
END
close HTACCESS;
- chmod $fileperm, "template/.htaccess";
+ chmod $fileperm, "$templatedir/.htaccess";
}
- if (!-e "data/webdot/.htaccess") {
- print "Creating data/webdot/.htaccess...\n";
- open HTACCESS, ">data/webdot/.htaccess";
+ if (!-e "$webdotdir/.htaccess") {
+ print "Creating $webdotdir/.htaccess...\n";
+ open HTACCESS, '>', "$webdotdir/.htaccess";
print HTACCESS <<'END';
# Restrict access to .dot files to the public webdot server at research.att.com
# if research.att.com ever changed their IP, or if you use a different
@@ -961,7 +971,7 @@ END
Deny from all
END
close HTACCESS;
- chmod $fileperm, "data/webdot/.htaccess";
+ chmod $fileperm, "$webdotdir/.htaccess";
}
}
@@ -969,7 +979,7 @@ END
if ($my_index_html) {
if (!-e "index.html") {
print "Creating index.html...\n";
- open HTML, ">index.html";
+ open HTML, '>', 'index.html';
print HTML <<'END';
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
@@ -989,22 +999,23 @@ END
print "\n\n";
print "*** It appears that you still have an old index.html hanging\n";
print " around. The contents of this file should be moved into a\n";
- print " template and placed in the 'template/en/custom' directory.\n\n";
+ print " template and placed in the 'en/custom' directory within";
+ print " your template directory.\n\n";
}
close HTML;
}
}
{
- if (-e 'data/template') {
+ if (-e "$datadir/template") {
print "Removing existing compiled templates ...\n" unless $silent;
- File::Path::rmtree('data/template');
+ File::Path::rmtree("$datadir/template");
#Check that the directory was really removed
- if(-e 'data/template') {
+ if(-e "$datadir/template") {
print "\n\n";
- print "The data/template directory could not be removed. Please\n";
+ print "The directory '$datadir/template' could not be removed. Please\n";
print "remove it manually and rerun checksetup.pl.\n\n";
exit;
}
@@ -1016,15 +1027,15 @@ END
my @templatepaths = ();
{
use File::Spec;
- opendir(DIR, "template") || die "Can't open 'template': $!";
+ opendir(DIR, $templatedir) || die "Can't open '$templatedir': $!";
my @files = grep { /^[a-z-]+$/i } readdir(DIR);
closedir DIR;
foreach my $dir (@files) {
next if($dir =~ /^CVS$/i);
- my $path = File::Spec->catdir('template', $dir, 'custom');
+ my $path = File::Spec->catdir($templatedir, $dir, 'custom');
push(@templatepaths, $path) if(-d $path);
- $path = File::Spec->catdir('template', $dir, 'default');
+ $path = File::Spec->catdir($templatedir, $dir, 'default');
push(@templatepaths, $path) if(-d $path);
}
}
@@ -1063,8 +1074,8 @@ END
PRE_CHOMP => 1 ,
TRIM => 1 ,
- # becomes data/template/{en, ...}/{custom,default}
- COMPILE_DIR => 'data/',
+ # => $datadir/template/`pwd`/template/{en, ...}/{custom,default}
+ COMPILE_DIR => "$datadir/template",
# These don't actually need to do anything here, just exist
FILTERS =>
@@ -1090,15 +1101,15 @@ END
}
# Just to be sure ...
-unlink "data/versioncache";
+unlink "$datadir/versioncache";
-# Remove parameters from the data/params file that no longer exist in Bugzilla,
+# Remove parameters from the params file that no longer exist in Bugzilla,
# and set the defaults for new ones
my @oldparams = UpdateParams();
if (@oldparams) {
- open(PARAMFILE, ">>old-params.txt")
+ open(PARAMFILE, '>>', 'old-params.txt')
|| die "$0: Can't open old-params.txt for writing: $!\n";
print "The following parameters are no longer used in Bugzilla, " .
@@ -1222,16 +1233,16 @@ if ($my_webservergroup) {
# caller's uid. Maybe there should be a $bugzillauid, and call with that
# userid.
fixPerms('.htaccess', $<, $webservergid, 027); # glob('*') doesn't catch dotfiles
- fixPerms('data/.htaccess', $<, $webservergid, 027);
- fixPerms('data/duplicates', $<, $webservergid, 027, 1);
- fixPerms('data/mining', $<, $webservergid, 027, 1);
- fixPerms('data/template', $<, $webservergid, 007, 1); # webserver will write to these
- fixPerms('data/webdot', $<, $webservergid, 007, 1);
- fixPerms('data/webdot/.htaccess', $<, $webservergid, 027);
- fixPerms('data/params', $<, $webservergid, 017);
+ fixPerms("$datadir/.htaccess", $<, $webservergid, 027);
+ fixPerms("$datadir/duplicates", $<, $webservergid, 027, 1);
+ fixPerms("$datadir/mining", $<, $webservergid, 027, 1);
+ fixPerms("$datadir/template", $<, $webservergid, 007, 1); # webserver will write to these
+ fixPerms($webdotdir, $<, $webservergid, 007, 1);
+ fixPerms("$webdotdir/.htaccess", $<, $webservergid, 027);
+ fixPerms("$datadir/params", $<, $webservergid, 017);
fixPerms('*', $<, $webservergid, 027);
fixPerms('Bugzilla', $<, $webservergid, 027, 1);
- fixPerms('template', $<, $webservergid, 027, 1);
+ fixPerms($templatedir, $<, $webservergid, 027, 1);
fixPerms('css', $<, $webservergid, 027, 1);
fixPerms('js', $<, $webservergid, 027, 1);
chmod 0644, 'globals.pl';
@@ -1239,32 +1250,32 @@ if ($my_webservergroup) {
# Don't use fixPerms here, because it won't change perms on the directory
# unless its using recursion
- chown $<, $webservergid, 'data';
- chmod 0771, 'data';
+ chown $<, $webservergid, $datadir;
+ chmod 0771, $datadir;
chown $<, $webservergid, 'graphs';
chmod 0770, 'graphs';
} else {
# get current gid from $( list
my $gid = (split " ", $()[0];
fixPerms('.htaccess', $<, $gid, 022); # glob('*') doesn't catch dotfiles
- fixPerms('data/.htaccess', $<, $gid, 022);
- fixPerms('data/duplicates', $<, $gid, 022, 1);
- fixPerms('data/mining', $<, $gid, 022, 1);
- fixPerms('data/template', $<, $gid, 000, 1); # webserver will write to these
- fixPerms('data/webdot', $<, $gid, 000, 1);
- chmod 01777, 'data/webdot';
- fixPerms('data/webdot/.htaccess', $<, $gid, 022);
- fixPerms('data/params', $<, $gid, 011);
+ fixPerms("$datadir/.htaccess", $<, $gid, 022);
+ fixPerms("$datadir/duplicates", $<, $gid, 022, 1);
+ fixPerms("$datadir/mining", $<, $gid, 022, 1);
+ fixPerms("$datadir/template", $<, $gid, 000, 1); # webserver will write to these
+ fixPerms($webdotdir, $<, $gid, 000, 1);
+ chmod 01777, $webdotdir;
+ fixPerms("$webdotdir/.htaccess", $<, $gid, 022);
+ fixPerms("$datadir/params", $<, $gid, 011);
fixPerms('*', $<, $gid, 022);
fixPerms('Bugzilla', $<, $gid, 022, 1);
- fixPerms('template', $<, $gid, 022, 1);
+ fixPerms($templatedir, $<, $gid, 022, 1);
fixPerms('css', $<, $gid, 022, 1);
fixPerms('js', $<, $gid, 022, 1);
# Don't use fixPerms here, because it won't change perms on the directory
# unless its using recursion
- chown $<, $gid, 'data';
- chmod 0777, 'data';
+ chown $<, $gid, $datadir;
+ chmod 0777, $datadir;
chown $<, $gid, 'graphs';
chmod 01777, 'graphs';
}
@@ -1362,7 +1373,7 @@ The '$my_db_name' database is not accessible. This might have several reasons:
Bugzilla Guide in the doc directory and all parts of the MySQL
documentation.
* There is an subtle problem with Perl, DBI, DBD::mysql and MySQL. Make
- sure all settings in 'localconfig' are correct. If all else fails, set
+ sure all settings in '$localconfig' are correct. If all else fails, set
'\$db_check' to zero.\n
EOF
}
@@ -1410,11 +1421,11 @@ if( Param('webdotbase') && Param('webdotbase') !~ /^https?:/ ) {
}
# Check .htaccess allows access to generated images
- if(-e "data/webdot/.htaccess") {
- open HTACCESS, "data/webdot/.htaccess";
+ if(-e "$webdotdir/.htaccess") {
+ open HTACCESS, "$webdotdir/.htaccess";
if(! grep(/png/,<HTACCESS>)) {
print "Dependency graph images are not accessible.\n";
- print "Delete data/webdot/.htaccess and re-run checksetup.pl to rectify.\n";
+ print "Delete $webdotdir/.htaccess and re-run checksetup.pl to rectify.\n";
}
close HTACCESS;
}
@@ -2880,11 +2891,11 @@ if (&TableExists('comments')) {
}
# 2001-04-08 Added a special directory for the duplicates stats.
-unless (-d 'data/duplicates') {
+unless (-d "$datadir/duplicates") {
print "Creating duplicates directory...\n";
- mkdir 'data/duplicates', 0770;
+ mkdir "$datadir/duplicates", 0770;
if ($my_webservergroup eq "") {
- chmod 01777, 'data/duplicates';
+ chmod 01777, "$datadir/duplicates";
}
}
@@ -3126,20 +3137,20 @@ if (!GetFieldDef("bugs", "alias")) {
# 2002-07-15 davef@tetsubo.com - bug 67950
# Move quips to the db.
-if (-r 'data/comments' && -s 'data/comments'
- && open (COMMENTS, "<data/comments")) {
- print "Populating quips table from data/comments...\n\n";
+if (-r "$datadir/comments" && -s "$datadir/comments"
+ && open (COMMENTS, "<$datadir/comments")) {
+ print "Populating quips table from $datadir/comments...\n\n";
while (<COMMENTS>) {
chomp;
$dbh->do("INSERT INTO quips (quip) VALUES ("
. $dbh->quote($_) . ")");
}
- print "The data/comments file (used to store quips) has been copied into\n" .
- "the database, and the data/comments file moved to data/comments.bak - \n" .
+ print "The $datadir/comments file (used to store quips) has been copied into\n" .
+ "the database, and the $datadir/comments file moved to $datadir/comments.bak - \n" .
"you can delete this fileonce you're satisfied the migration worked\n" .
"correctly.\n\n";
close COMMENTS;
- rename("data/comments", "data/comments.bak");
+ rename("$datadir/comments", "$datadir/comments.bak");
}
# 2002-07-31 bbaetz@student.usyd.edu.au bug 158236
@@ -3731,7 +3742,7 @@ if (!$series_exists) {
# Convert the name in the same way that collectstats.pl does
my $product_file = $product;
$product_file =~ s/\//-/gs;
- $product_file = "data/mining/$product_file";
+ $product_file = "$datadir/mining/$product_file";
# There are many reasons that this might fail (e.g. no stats for this
# product), so we don't worry if it does.
@@ -3883,8 +3894,8 @@ if ($sth->rows == 0) {
# Here we look to see what the emailregexp is set to so we can
# check the email addy they enter. Bug 96675. If they have no
# params (likely but not always the case), we use the default.
- if (-e "data/params") {
- require "data/params"; # if they have a params file, use that
+ if (-e "$datadir/params") {
+ require "$datadir/params"; # if they have a params file, use that
}
if (Param('emailregexp')) {
$mailcheckexp = Param('emailregexp');
@@ -4128,7 +4139,7 @@ if (!$adminuid) { die "No administrator!" } # should never get here
# when test product was created, admin was unknown
$dbh->do("UPDATE components SET initialowner = $adminuid WHERE initialowner = 0");
-unlink "data/versioncache";
+unlink "$datadir/versioncache";
print "Reminder: Bugzilla now requires version 8.7 or later of sendmail.\n" unless $silent;
diff --git a/collectstats.pl b/collectstats.pl
index 5c1f6d499..002d5fba2 100755
--- a/collectstats.pl
+++ b/collectstats.pl
@@ -38,6 +38,7 @@ use Bugzilla::Search;
use Bugzilla::User;
use Bugzilla;
+use Bugzilla::Config qw(:DEFAULT $datadir);
# Turn off output buffering (probably needed when displaying output feedback
# in the regenerate mode.)
@@ -66,7 +67,7 @@ push( @myproducts, "-All-", @::legal_product );
my $tstart = time;
foreach (@myproducts) {
- my $dir = "data/mining";
+ my $dir = "$datadir/mining";
&check_data_dir ($dir);
@@ -87,8 +88,8 @@ CollectSeriesData();
# Generate a static RDF file containing the default view of the duplicates data.
open(CGI, "GATEWAY_INTERFACE=cmdline REQUEST_METHOD=GET QUERY_STRING=ctype=rdf ./duplicates.cgi |")
|| die "can't fork duplicates.cgi: $!";
-open(RDF, ">data/duplicates.tmp")
- || die "can't write to data/duplicates.tmp: $!";
+open(RDF, ">$datadir/duplicates.tmp")
+ || die "can't write to $datadir/duplicates.tmp: $!";
my $headers_done = 0;
while (<CGI>) {
print RDF if $headers_done;
@@ -96,9 +97,9 @@ while (<CGI>) {
}
close CGI;
close RDF;
-if (-s "data/duplicates.tmp") {
- rename("data/duplicates.rdf", "data/duplicates-old.rdf");
- rename("data/duplicates.tmp", "data/duplicates.rdf");
+if (-s "$datadir/duplicates.tmp") {
+ rename("$datadir/duplicates.rdf", "$datadir/duplicates-old.rdf");
+ rename("$datadir/duplicates.tmp", "$datadir/duplicates.rdf");
}
sub check_data_dir {
@@ -182,11 +183,11 @@ sub calculate_dupes {
# Save % count here in a date-named file
# so we can read it back in to do changed counters
# First, delete it if it exists, so we don't add to the contents of an old file
- if (my @files = <data/duplicates/dupes$today*>) {
+ if (my @files = <$datadir/duplicates/dupes$today*>) {
unlink @files;
}
- dbmopen(%count, "data/duplicates/dupes$today", 0644) || die "Can't open DBM dupes file: $!";
+ dbmopen(%count, "$datadir/duplicates/dupes$today", 0644) || die "Can't open DBM dupes file: $!";
# Create a hash with key "a bug number", value "bug which that bug is a
# direct dupe of" - straight from the duplicates table.
diff --git a/contrib/bug_email.pl b/contrib/bug_email.pl
index a1e537cfe..e26b9a68c 100755
--- a/contrib/bug_email.pl
+++ b/contrib/bug_email.pl
@@ -37,7 +37,7 @@
#
# You need to work with bug_email.pl the MIME::Parser installed.
#
-# $Id: bug_email.pl,v 1.16 2003/08/22 14:59:13 justdave%syndicomm.com Exp $
+# $Id: bug_email.pl,v 1.17 2003/11/22 03:50:41 bbaetz%acm.org Exp $
###############################################################
# 02/12/2000 (SML)
@@ -69,12 +69,15 @@
use strict;
use MIME::Parser;
-chdir '..'; # this script lives in contrib
-push @INC, "contrib/.";
-push @INC, ".";
+BEGIN {
+ chdir '..'; # this script lives in contrib
+ push @INC, "contrib/.";
+ push @INC, ".";
+}
require "globals.pl";
-require "BugzillaEmail.pm";
+use BugzillaEmail;
+use Bugzilla::Config qw(:DEFAULT $datadir);
use lib ".";
use lib "../";
@@ -137,8 +140,8 @@ sub storeAttachments( $$ )
print "Error while reading attachment $decoded_file!\n";
next;
}
- # print "unlinking data/mimedump-tmp/$decoded_file";
- # unlink "data/mimedump-tmp/$decoded_file";
+ # print "unlinking $datadir/mimedump-tmp/$decoded_file";
+ # unlink "$datadir/mimedump-tmp/$decoded_file";
} else {
# data is in the scalar
$data = $decoded_file;
@@ -248,7 +251,7 @@ sub Reply( $$$$ ) {
die "Cannot find sender-email-address" unless defined( $Sender );
if( $test ) {
- open( MAIL, ">>data/bug_email_test.log" );
+ open( MAIL, '>>', "$datadir/bug_email_test.log" );
}
else {
open( MAIL, "| /usr/sbin/sendmail -t" );
@@ -697,10 +700,10 @@ my $parser = new MIME::Parser;
# Create and set the output directory:
# FIXME: There should be a $BUGZILLA_HOME variable (SML)
-(-d "data/mimedump-tmp") or mkdir "data/mimedump-tmp",0755 or die "mkdir: $!";
-(-w "data/mimedump-tmp") or die "can't write to directory";
+(-d "$datadir/mimedump-tmp") or mkdir "$datadir/mimedump-tmp",0755 or die "mkdir: $!";
+(-w "$datadir/mimedump-tmp") or die "can't write to directory";
-$parser->output_dir("data/mimedump-tmp");
+$parser->output_dir("$datadir/mimedump-tmp");
# Read the MIME message:
my $entity = $parser->read(\*STDIN) or die "couldn't parse MIME stream";
diff --git a/contrib/bugzilla_email_append.pl b/contrib/bugzilla_email_append.pl
index 2ed39c482..da098e66c 100755
--- a/contrib/bugzilla_email_append.pl
+++ b/contrib/bugzilla_email_append.pl
@@ -31,11 +31,15 @@
use strict;
use MIME::Parser;
-chdir ".."; # this script lives in contrib, change to main
-push @INC, "contrib";
-push @INC, "."; # this script lives in contrib
+BEGIN {
+ chdir ".."; # this script lives in contrib, change to main
+ push @INC, "contrib";
+ push @INC, "."; # this script lives in contrib
+}
+
require "globals.pl";
-require "BugzillaEmail.pm";
+use BugzillaEmail;
+use Bugzilla::Config qw(:DEFAULT $datadir);
# Create a new MIME parser:
my $parser = new MIME::Parser;
@@ -44,10 +48,10 @@ my $Comment = "";
# Create and set the output directory:
# FIXME: There should be a $BUGZILLA_HOME variable (SML)
-(-d "data/mimedump-tmp") or mkdir "data/mimedump-tmp",0755 or die "mkdir: $!";
-(-w "data/mimedump-tmp") or die "can't write to directory";
+(-d "$datadir/mimedump-tmp") or mkdir "$datadir/mimedump-tmp",0755 or die "mkdir: $!";
+(-w "$datadir/mimedump-tmp") or die "can't write to directory";
-$parser->output_dir("data/mimedump-tmp");
+$parser->output_dir("$datadir/mimedump-tmp");
# Read the MIME message:
my $entity = $parser->read(\*STDIN) or die "couldn't parse MIME stream";
diff --git a/defparams.pl b/defparams.pl
index 8c1d93917..75e0437db 100644
--- a/defparams.pl
+++ b/defparams.pl
@@ -49,6 +49,8 @@ use strict;
use vars qw(@param_list);
use File::Spec; # for find_languages
+use Bugzilla::Config qw(:DEFAULT $templatedir $webdotdir);
+
# Checking functions for the various values
# Some generic checking functions are included in Bugzilla::Config
@@ -98,10 +100,10 @@ sub check_webdotbase {
return "The file path \"$value\" is not a valid executable. Please specify the complete file path to 'dot' if you intend to generate graphs locally.";
}
# Check .htaccess allows access to generated images
- if(-e "data/webdot/.htaccess") {
- open HTACCESS, "data/webdot/.htaccess";
+ if(-e "$webdotdir/.htaccess") {
+ open HTACCESS, "$webdotdir/.htaccess";
if(! grep(/ \\\.png\$/,<HTACCESS>)) {
- return "Dependency graph images are not accessible.\nAssuming that you have not modified the file, delete data/webdot/.htaccess and re-run checksetup.pl to rectify.\n";
+ return "Dependency graph images are not accessible.\nAssuming that you have not modified the file, delete $webdotdir/.htaccess and re-run checksetup.pl to rectify.\n";
}
close HTACCESS;
}
@@ -155,8 +157,8 @@ sub check_languages {
return "You need to specify a language tag."
}
foreach my $language (@languages) {
- if( ! -d "template/$language/custom"
- && ! -d "template/$language/default") {
+ if( ! -d "$templatedir/$language/custom"
+ && ! -d "$templatedir/$language/default") {
return "The template directory for $language does not exist";
}
}
@@ -165,7 +167,7 @@ sub check_languages {
sub find_languages {
my @languages = ();
- opendir(DIR, "template") || return "Can't open 'template' directory: $!";
+ opendir(DIR, $templatedir) || return "Can't open 'template' directory: $!";
my @langdirs = grep { /^[a-z-]+$/i } readdir(DIR);
closedir DIR;
@@ -702,7 +704,7 @@ You will get this message once a day until you\'ve dealt with these bugs!
</ul>
The default value is a publically-accessible webdot server. If you change
this value, make certain that the webdot server can read files from your
- data/webdot directory. On Apache you do this by editing the .htaccess file,
+ webdot directory. On Apache you do this by editing the .htaccess file,
for other systems the needed measures may vary. You can run checksetup.pl
to recreate the .htaccess file if it has been lost.',
type => 't',
diff --git a/doeditparams.cgi b/doeditparams.cgi
index 04d0ac98b..3a89a0fd0 100755
--- a/doeditparams.cgi
+++ b/doeditparams.cgi
@@ -26,7 +26,7 @@ use strict;
use lib qw(.);
use Bugzilla;
-use Bugzilla::Config qw(:DEFAULT :admin);
+use Bugzilla::Config qw(:DEFAULT :admin $datadir);
require "CGI.pl";
@@ -111,7 +111,7 @@ foreach my $i (GetParamList()) {
WriteParams();
-unlink "data/versioncache";
+unlink "$datadir/versioncache";
print "<p>OK, done.</p>\n";
print $howto;
diff --git a/duplicates.cgi b/duplicates.cgi
index e8d82d2f7..5da90e7b9 100755
--- a/duplicates.cgi
+++ b/duplicates.cgi
@@ -36,6 +36,7 @@ use vars qw($buffer);
use Bugzilla;
use Bugzilla::Search;
+use Bugzilla::Config qw(:DEFAULT $datadir);
use Bugzilla::Constants;
my $cgi = Bugzilla->cgi;
@@ -116,10 +117,10 @@ my $yesterday = days_ago(1);
use Errno;
use Fcntl;
-if (!tie(%dbmcount, 'AnyDBM_File', "data/duplicates/dupes$today",
+if (!tie(%dbmcount, 'AnyDBM_File', "$datadir/duplicates/dupes$today",
O_RDONLY, 0644)) {
if ($!{ENOENT}) {
- if (!tie(%dbmcount, 'AnyDBM_File', "data/duplicates/dupes$yesterday",
+ if (!tie(%dbmcount, 'AnyDBM_File', "$datadir/duplicates/dupes$yesterday",
O_RDONLY, 0644)) {
my $vars = { today => $today };
if ($!{ENOENT}) {
@@ -163,7 +164,7 @@ my $dobefore = 0;
my %delta;
my $whenever = days_ago($changedsince);
-if (!tie(%before, 'AnyDBM_File', "data/duplicates/dupes$whenever",
+if (!tie(%before, 'AnyDBM_File', "$datadir/duplicates/dupes$whenever",
O_RDONLY, 0644)) {
# Ignore file not found errors
if (!$!{ENOENT}) {
diff --git a/editcomponents.cgi b/editcomponents.cgi
index 67ccfcd8a..87ab9d9a6 100755
--- a/editcomponents.cgi
+++ b/editcomponents.cgi
@@ -31,6 +31,7 @@ use lib ".";
require "CGI.pl";
require "globals.pl";
+use Bugzilla::Config qw(:DEFAULT $datadir);
use Bugzilla::Series;
# Shut up misguided -w warnings about "used only once". For some reason,
@@ -471,7 +472,7 @@ if ($action eq 'new') {
}
# Make versioncache flush
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
print "OK, done.<p>\n";
if ($product) {
@@ -666,7 +667,7 @@ if ($action eq 'delete') {
print "Components deleted.<P>\n";
SendSQL("UNLOCK TABLES");
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
PutTrailer($localtrailer);
exit;
}
@@ -836,7 +837,7 @@ if ($action eq 'update') {
SendSQL("UPDATE components SET name=" . SqlQuote($component) .
"WHERE id=$component_id");
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
print "Updated component name.<BR>\n";
}
SendSQL("UNLOCK TABLES");
diff --git a/editkeywords.cgi b/editkeywords.cgi
index cf2c44efc..c51580272 100755
--- a/editkeywords.cgi
+++ b/editkeywords.cgi
@@ -25,6 +25,8 @@ use lib ".";
require "CGI.pl";
+use Bugzilla::Config qw(:DEFAULT $datadir);
+
use vars qw($template $vars);
my $localtrailer = "<A HREF=\"editkeywords.cgi\">edit</A> more keywords";
@@ -240,7 +242,7 @@ if ($action eq 'new') {
SqlQuote($description) . ")");
# Make versioncache flush
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
print "OK, done.<p>\n";
PutTrailer("<a href=\"editkeywords.cgi\">edit</a> more keywords",
@@ -328,7 +330,7 @@ if ($action eq 'update') {
" WHERE id = $id");
# Make versioncache flush
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
print Bugzilla->cgi->header();
@@ -373,7 +375,7 @@ if ($action eq 'delete') {
SendSQL("DELETE FROM keyworddefs WHERE id = $id");
# Make versioncache flush
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
print Bugzilla->cgi->header();
diff --git a/editmilestones.cgi b/editmilestones.cgi
index 19582b485..7a77de155 100755
--- a/editmilestones.cgi
+++ b/editmilestones.cgi
@@ -19,8 +19,7 @@ use lib ".";
require "CGI.pl";
require "globals.pl";
-
-
+use Bugzilla::Config qw(:DEFAULT $datadir);
# TestProduct: just returns if the specified product does exists
# CheckProduct: same check, optionally emit an error text
@@ -315,7 +314,7 @@ if ($action eq 'new') {
SqlQuote($milestone) . ", $product_id, $sortkey)");
# Make versioncache flush
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
print "OK, done.<p>\n";
PutTrailer("<A HREF=\"editmilestones.cgi?product=$product&amp;action=add\">add</a> another milestone or $localtrailer");
@@ -456,7 +455,7 @@ if ($action eq 'delete') {
print "Milestone deleted.<P>\n";
SendSQL("UNLOCK TABLES");
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
PutTrailer($localtrailer);
exit;
}
@@ -523,7 +522,7 @@ if ($action eq 'update') {
SendSQL("UPDATE milestones SET sortkey=$sortkey
WHERE product_id=" . $product_id . "
AND value=" . SqlQuote($milestoneold));
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
print "Updated sortkey.<BR>\n";
}
if ($milestone ne $milestoneold) {
@@ -552,7 +551,7 @@ if ($action eq 'update') {
"SET defaultmilestone = " . SqlQuote($milestone) .
" WHERE id = $product_id" .
" AND defaultmilestone = " . SqlQuote($milestoneold));
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
print "Updated milestone.<BR>\n";
}
SendSQL("UNLOCK TABLES");
diff --git a/editproducts.cgi b/editproducts.cgi
index 07dbcc9e3..b02588949 100755
--- a/editproducts.cgi
+++ b/editproducts.cgi
@@ -35,6 +35,8 @@ require "CGI.pl";
require "globals.pl";
use Bugzilla::Series;
+use Bugzilla::Config qw(:DEFAULT $datadir);
+
# Shut up misguided -w warnings about "used only once". "use vars" just
# doesn't work for me.
use vars qw(@legal_bug_status @legal_resolution);
@@ -432,7 +434,7 @@ if ($action eq 'new') {
}
# Make versioncache flush
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
print "OK, done.<p>\n";
PutTrailer($localtrailer,
@@ -675,7 +677,7 @@ if ($action eq 'delete') {
SendSQL("UNLOCK TABLES");
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
PutTrailer($localtrailer);
exit;
}
@@ -1200,7 +1202,7 @@ if ($action eq 'update') {
print "Updated product name.<BR>\n";
}
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
SendSQL("UNLOCK TABLES");
if ($checkvotes) {
diff --git a/editversions.cgi b/editversions.cgi
index d47ec5d76..9c4a5e5ea 100755
--- a/editversions.cgi
+++ b/editversions.cgi
@@ -32,8 +32,7 @@ use lib ".";
require "CGI.pl";
require "globals.pl";
-
-
+use Bugzilla::Config qw(:DEFAULT $datadir);
# TestProduct: just returns if the specified product does exists
# CheckProduct: same check, optionally emit an error text
@@ -317,7 +316,7 @@ if ($action eq 'new') {
SqlQuote($version) . ", $product_id)");
# Make versioncache flush
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
print "OK, done.<p>\n";
PutTrailer("<A HREF=\"editversions.cgi?product=$product&amp;action=add\">add</a> another version or $localtrailer");
@@ -446,7 +445,7 @@ if ($action eq 'delete') {
print "Version deleted.<P>\n";
SendSQL("UNLOCK TABLES");
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
PutTrailer($localtrailer);
exit;
}
@@ -527,7 +526,7 @@ if ($action eq 'update') {
SET value=" . SqlQuote($version) . "
WHERE product_id = $product_id
AND value=" . SqlQuote($versionold));
- unlink "data/versioncache";
+ unlink "$datadir/versioncache";
print "Updated version.<BR>\n";
}
SendSQL("UNLOCK TABLES");
diff --git a/globals.pl b/globals.pl
index f420ea319..174990634 100644
--- a/globals.pl
+++ b/globals.pl
@@ -32,7 +32,7 @@ use Bugzilla::DB qw(:DEFAULT :deprecated);
use Bugzilla::Constants;
use Bugzilla::Util;
# Bring ChmodDataFile in until this is all moved to the module
-use Bugzilla::Config qw(:DEFAULT ChmodDataFile);
+use Bugzilla::Config qw(:DEFAULT ChmodDataFile $localconfig $datadir);
# Shut up misguided -w warnings about "used only once". For some reason,
# "use vars" chokes on me when I try it here.
@@ -68,7 +68,7 @@ sub globals_pl_sillyness {
# XXX - Move this to Bugzilla::Config once code which uses these has moved out
# of globals.pl
-do 'localconfig';
+do $localconfig;
use DBI;
@@ -242,7 +242,7 @@ sub GenerateVersionTable {
require File::Temp;
my ($fh, $tmpname) = File::Temp::tempfile("versioncache.XXXXX",
- DIR => "data");
+ DIR => "$datadir");
print $fh "#\n";
print $fh "# DO NOT EDIT!\n";
@@ -322,8 +322,8 @@ sub GenerateVersionTable {
print $fh "1;\n";
close $fh;
- rename $tmpname, "data/versioncache" || die "Can't rename $tmpname to versioncache";
- ChmodDataFile('data/versioncache', 0666);
+ rename $tmpname, "$datadir/versioncache" || die "Can't rename $tmpname to versioncache";
+ ChmodDataFile("$datadir/versioncache", 0666);
}
@@ -349,8 +349,8 @@ sub ModTime {
$::VersionTableLoaded = 0;
sub GetVersionTable {
return if $::VersionTableLoaded;
- my $mtime = ModTime("data/versioncache");
- if (!defined $mtime || $mtime eq "" || !-r "data/versioncache") {
+ my $mtime = ModTime("$datadir/versioncache");
+ if (!defined $mtime || $mtime eq "" || !-r "$datadir/versioncache") {
$mtime = 0;
}
if (time() - $mtime > 3600) {
@@ -358,13 +358,13 @@ sub GetVersionTable {
Token::CleanTokenTable() if Bugzilla->dbwritesallowed;
GenerateVersionTable();
}
- require 'data/versioncache';
+ require "$datadir/versioncache";
if (!defined %::versions) {
GenerateVersionTable();
- do 'data/versioncache';
+ do "$datadir/versioncache";
if (!defined %::versions) {
- die "Can't generate file data/versioncache";
+ die "Can't generate file $datadir/versioncache";
}
}
$::VersionTableLoaded = 1;
diff --git a/importxml.pl b/importxml.pl
index 3d0ea6206..5b0599e98 100755
--- a/importxml.pl
+++ b/importxml.pl
@@ -60,6 +60,7 @@ chdir $::path;
use lib ($::path);
use Bugzilla;
+use Bugzilla::Config qw(:DEFAULT $datadir);
use XML::Parser;
use Data::Dumper;
@@ -126,7 +127,7 @@ sub MailMessage {
sub Log {
my ($str) = (@_);
Lock();
- open(FID, ">>data/maillog") || die "Can't write to data/maillog";
+ open(FID, ">>$datadir/maillog") || die "Can't write to $datadir/maillog";
print FID time2str("%D %H:%M", time()) . ": $str\n";
close FID;
Unlock();
@@ -135,13 +136,13 @@ sub Log {
sub Lock {
if ($::lockcount <= 0) {
$::lockcount = 0;
- open(LOCKFID, ">>data/maillock") || die "Can't open data/maillock: $!";
+ open(LOCKFID, ">>$datadir/maillock") || die "Can't open $datadir/maillock: $!";
my $val = flock(LOCKFID,2);
if (!$val) { # '2' is magic 'exclusive lock' const.
print Bugzilla->cgi->header();
print "Lock failed: $val\n";
}
- chmod 0666, "data/maillock";
+ chmod 0666, "$datadir/maillock";
}
$::lockcount++;
}
diff --git a/move.pl b/move.pl
index b00572705..d08830b2b 100755
--- a/move.pl
+++ b/move.pl
@@ -32,6 +32,7 @@ use vars qw($template $userid %COOKIE);
use Bug;
use Bugzilla;
+use Bugzilla::Config qw(:DEFAULT $datadir);
use Bugzilla::BugMail;
$::lockcount = 0;
@@ -50,7 +51,7 @@ my $cgi = Bugzilla->cgi;
sub Log {
my ($str) = (@_);
Lock();
- open(FID, ">>data/maillog") || die "Can't write to data/maillog";
+ open(FID, ">>$datadir/maillog") || die "Can't write to $datadir/maillog";
print FID time2str("%D %H:%M", time()) . ": $str\n";
close FID;
Unlock();
@@ -59,13 +60,13 @@ sub Log {
sub Lock {
if ($::lockcount <= 0) {
$::lockcount = 0;
- open(LOCKFID, ">>data/maillock") || die "Can't open data/maillock: $!";
+ open(LOCKFID, ">>$datadir/maillock") || die "Can't open $datadir/maillock: $!";
my $val = flock(LOCKFID,2);
if (!$val) { # '2' is magic 'exclusive lock' const.
print $cgi->header();
print "Lock failed: $val\n";
}
- chmod 0666, "data/maillock";
+ chmod 0666, "$datadir/maillock";
}
$::lockcount++;
}
diff --git a/page.cgi b/page.cgi
index 1f1ef768f..91027ff4f 100755
--- a/page.cgi
+++ b/page.cgi
@@ -23,7 +23,7 @@
###############################################################################
# This CGI is a general template display engine. To display templates using it,
-# put them in the "pages" subdirectory of template/en/default, call them
+# put them in the "pages" subdirectory of en/default, call them
# "foo.<ctype>.tmpl" and use the URL page.cgi?id=foo.<ctype> , where <ctype> is
# a content-type, e.g. html.
###############################################################################
diff --git a/reports.cgi b/reports.cgi
index 71ecf6c31..67274a6d5 100755
--- a/reports.cgi
+++ b/reports.cgi
@@ -37,6 +37,8 @@ use strict;
use lib qw(.);
+use Bugzilla::Config qw(:DEFAULT $datadir);
+
require "CGI.pl";
use vars qw(%FORM); # globals from CGI.pl
@@ -48,7 +50,7 @@ $@ && ThrowCodeError("gd_not_installed");
eval "use Chart::Lines";
$@ && ThrowCodeError("chart_lines_not_installed");
-my $dir = "data/mining";
+my $dir = "$datadir/mining";
my $graph_dir = "graphs";
use Bugzilla;
diff --git a/showdependencygraph.cgi b/showdependencygraph.cgi
index d13f77c5d..5fe5143ec 100755
--- a/showdependencygraph.cgi
+++ b/showdependencygraph.cgi
@@ -27,6 +27,7 @@ use lib qw(.);
use File::Temp;
use Bugzilla;
+use Bugzilla::Config qw(:DEFAULT $webdotdir);
require "CGI.pl";
@@ -85,7 +86,7 @@ if (!defined($::FORM{'id'}) && !defined($::FORM{'doall'})) {
my ($fh, $filename) = File::Temp::tempfile("XXXXXXXXXX",
SUFFIX => '.dot',
- DIR => "data/webdot");
+ DIR => $webdotdir);
my $urlbase = Param('urlbase');
print $fh "digraph G {";
@@ -189,7 +190,7 @@ if ($webdotbase =~ /^https?:/) {
my $dotfh;
my ($pngfh, $pngfilename) = File::Temp::tempfile("XXXXXXXXXX",
SUFFIX => '.png',
- DIR => 'data/webdot');
+ DIR => $webdotdir);
open (DOT, '-|') or exec ($webdotbase, "-Tpng", $filename);
print $pngfh $_ while <DOT>;
close DOT;
@@ -198,7 +199,7 @@ if ($webdotbase =~ /^https?:/) {
my ($mapfh, $mapfilename) = File::Temp::tempfile("XXXXXXXXXX",
SUFFIX => '.map',
- DIR => 'data/webdot');
+ DIR => $webdotdir);
open (DOT, '-|') or exec ($webdotbase, "-Tismap", $filename);
print $mapfh $_ while <DOT>;
close DOT;
@@ -209,15 +210,16 @@ if ($webdotbase =~ /^https?:/) {
# Cleanup any old .dot files created from previous runs.
my $since = time() - 24 * 60 * 60;
# Can't use glob, since even calling that fails taint checks for perl < 5.6
-opendir(DIR, "data/webdot/");
-my @files = grep { /\.dot$|\.png$|\.map$/ && -f "data/webdot/$_" } readdir(DIR);
+opendir(DIR, $webdotdir);
+my @files = grep { /\.dot$|\.png$|\.map$/ && -f "$webdotdir/$_" } readdir(DIR);
closedir DIR;
foreach my $f (@files)
{
- $f = "data/webdot/$f";
+ $f = "$webdotdir/$f";
# Here we are deleting all old files. All entries are from the
- # data/webdot/ directory. Since we're deleting the file (not following
+ # $webdot directory. Since we're deleting the file (not following
# symlinks), this can't escape to delete anything it shouldn't
+ # (unless someone moves the location of $webdotdir, of course)
trick_taint($f);
if (ModTime($f) < $since) {
unlink $f;