Commit da857afa authored by bbaetz%acm.org's avatar bbaetz%acm.org

Bug 208604 - Make data/template dir locations configurable

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