1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 05_webpath.dpatch by Alexis Sukrieh <sukria@sukria.net>
4
## All lines beginning with `## DP:' are a description of the patch.
5
## DP: Update Config.pm to point to the right locations and support vhosts
8
diff -urNad trunk~/Bugzilla/Config.pm trunk/Bugzilla/Config.pm
9
--- trunk~/Bugzilla/Config.pm 2006-11-04 15:56:30.000000000 +0100
10
+++ trunk/Bugzilla/Config.pm 2006-11-15 07:56:22.000000000 +0100
12
# graphs (since the path will be wrong in the HTML). This will be fixed at
17
-our $templatedir = "$libpath/template";
18
+# support for multi-site installation through X_BUGZILLA_SITE variable to
19
+# be passed by Apache.
21
+if (defined $ENV{X_BUGZILLA_SITE}) {
22
+ $xsite = "$ENV{X_BUGZILLA_SITE}";
23
+ # untaint (make sure it has no '/' and is overall something sane)
24
+ if ($xsite =~ m/^(\w[\w\-.]*)$/) {
27
+ die "invalid X_BUGZILLA_SITE: $xsite";
31
+# constant default paths
32
+our $libpath = '/usr/share/bugzilla';
33
+our $pmpath = '/usr/share/perl5';
34
+our $templatedir = "/var/lib/bugzilla/template";
35
+our $params_file = "/etc/bugzilla/params";
41
if ($ENV{'PROJECT'} && $ENV{'PROJECT'} =~ /^(\w+)$/) {
43
- $localconfig = "$libpath/localconfig.$project";
44
- $datadir = "$libpath/data/$project";
46
- $localconfig = "$libpath/localconfig";
47
- $datadir = "$libpath/data";
48
+ $localconfig = "/etc/bugzilla/localconfig.$project";
49
+ $datadir = "/var/lib/bugzilla/data/$project";
52
+# If we have a $xsite (the Debian way), let's manage the conf paths correctly
54
+ $localconfig = "/etc/bugzilla/sites/${xsite}/localconfig";
55
+ $params_file = "/etc/bugzilla/sites/${xsite}/params";
56
+ $datadir = "/var/lib/bugzilla/data-${xsite}";
57
+ $templatedir = (-d "/var/lib/bugzilla/template-${xsite}") ?
58
+ "/var/lib/bugzilla/template-${xsite}" :
59
+ "/var/lib/bugzilla/template";
64
+ $localconfig = "/etc/bugzilla/localconfig";
65
+ $datadir = "/var/lib/bugzilla/data";
68
our $attachdir = "$datadir/attachments";
69
our $webdotdir = "$datadir/webdot";
71
our @parampanels = ();
75
Exporter::export_ok_tags('admin', 'db', 'locations', 'params');
78
-$Bugzilla::Config::VERSION = "2.22.1";
79
+$Bugzilla::Config::VERSION = "2.22.1-debian2";
83
use vars qw(@param_list);
86
+# For providing a simple way to install several virtual hosts of the same
87
+# package, we use also here an Apache environment variable for specifing
88
+# the webpath. This will give a nice way to customize several VirtualHosts.
90
+$WEBPATH = $ENV{'X_BUGZILLA_WEBPATH'} if defined $ENV{'X_BUGZILLA_WEBPATH'};
91
+$WEBPATH = "/bugzilla/" if (not defined $WEBPATH);
93
# Data::Dumper is required as needed, below. The problem is that then when
94
# the code locally sets $Data::Dumper::Foo, this triggers 'used only once'
98
# XXX - mod_perl - need to register Apache init handler for params
101
+ # make sure localconfig exists
102
+ unless (-f $localconfig ) {
103
+ die "$localconfig is not here";
106
# read in localconfig variables
109
+ die "Could not execute `$localconfig'! ; make sure permissions are ok.";
111
- if (-e "$datadir/params") {
112
+ if (-e "$params_file") {
113
# Handle reading old param files by munging the symbol table
114
# Don't have to do this if we use safe mode, since its evaled
115
# in a sandbox where $foo is in the same module as $::foo
116
#local *::param = \%param;
118
- # Note that checksetup.pl sets file permissions on '$datadir/params'
119
+ # Note that checksetup.pl sets file permissions on '$params_file'
121
# Using Safe mode is _not_ a guarantee of safety if someone does
122
# manage to write to the file. However, it won't hurt...
123
# See bug 165144 for not needing to eval this at all
126
- $s->rdo("$datadir/params");
127
- die "Error reading $datadir/params: $!" if $!;
128
- die "Error evaluating $datadir/params: $@" if $@;
129
+ $s->rdo("$params_file");
130
+ die "Error reading $params_file: $!" if $!;
131
+ die "Error evaluating $params_file: $@" if $@;
133
# Now read the param back out from the sandbox
134
%param = %{$s->varglob('param')};
138
# Load in the param definitions
139
-foreach my $item ((glob "$libpath/Bugzilla/Config/*.pm")) {
140
+foreach my $item ((glob "$pmpath/Bugzilla/Config/*.pm")) {
141
$item =~ m#/([^/]+)\.pm$#;
143
next if ($module eq 'Common');
144
@@ -309,10 +352,21 @@
148
- rename $tmpname, "$datadir/params"
149
- || die "Can't rename $tmpname to $datadir/params: $!";
151
+ # We write it by hand
152
+ # this works really better than the original rename() call
153
+ # and will prevent overwriting of symlinks.
154
+ open TMPFILE, "<$tmpname" or die "$!";
155
+ open PARAMSFILE, ">$params_file" or die $!;
156
+ while (<TMPFILE>) {
157
+ print PARAMSFILE $_;
164
- ChmodDataFile("$datadir/params", 0666);
165
+ ChmodDataFile("$params_file", 0666);
168
# Some files in the data directory must be world readable if and only if
169
diff -urNad trunk~/Bugzilla/Template.pm trunk/Bugzilla/Template.pm
170
--- trunk~/Bugzilla/Template.pm 2006-11-04 15:56:30.000000000 +0100
171
+++ trunk/Bugzilla/Template.pm 2006-11-15 07:55:51.000000000 +0100
173
require Bugzilla::BugMail;
174
Bugzilla::BugMail::Send($id, $mailrecipients);
178
+ 'webpath' => $Bugzilla::Config::WEBPATH,
181
# This could be made a ref, or even a CONSTANT with TT2.08