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]));
......
...@@ -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