summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2009-12-15 00:12:04 +0100
committermkanat%bugzilla.org <>2009-12-15 00:12:04 +0100
commit6f9ef526d76a1586aa3f194a13c62f018a47b1e3 (patch)
tree4ecf0fdcea62752b48322de7b9d4958ddc74e8b8
parent426f563ff945f256dae9bd1a0b3774026a93e9c0 (diff)
downloadbugzilla-6f9ef526d76a1586aa3f194a13c62f018a47b1e3.tar.gz
bugzilla-6f9ef526d76a1586aa3f194a13c62f018a47b1e3.tar.xz
Bug 524603: Allow a non-root jobqueue.pl to write to data/mailer.testfile (for the "Test" mail_delivery_method)
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
-rw-r--r--Bugzilla/Install/Filesystem.pm26
1 files changed, 25 insertions, 1 deletions
diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm
index 12c0bc222..63cff1e21 100644
--- a/Bugzilla/Install/Filesystem.pm
+++ b/Bugzilla/Install/Filesystem.pm
@@ -36,6 +36,7 @@ use Bugzilla::Util;
use File::Find;
use File::Path;
use File::Basename;
+use File::Copy qw(move);
use IO::File;
use POSIX ();
@@ -129,7 +130,6 @@ sub FILESYSTEM {
'docs/*/README.docs' => { perms => $owner_readable },
"$datadir/bugzilla-update.xml" => { perms => $ws_writeable },
"$datadir/params" => { perms => $ws_writeable },
- "$datadir/mailer.testfile" => { perms => $ws_writeable },
"$extensionsdir/create.pl" => { perms => $owner_executable },
);
@@ -212,6 +212,12 @@ sub FILESYSTEM {
my %create_files = (
"$datadir/extensions/additional" => { perms => $ws_readable,
contents => '' },
+ # We create this file so that it always has the right owner
+ # and permissions. Otherwise, the webserver creates it as
+ # owned by itself, which can cause problems if jobqueue.pl
+ # or something else is not running as the webserver or root.
+ "$datadir/mailer.testfile" => { perms => $ws_writeable,
+ contents => '' },
);
# Each standard stylesheet has an associated custom stylesheet that
@@ -347,6 +353,13 @@ sub update_filesystem {
}
}
+ # Move the testfile if we can't write to it, so that we can re-create
+ # it with the correct permissions below.
+ if (!-w "$datadir/mailer.testfile") {
+ _rename_file("$datadir/mailer.testfile",
+ "$datadir/mailer.testfile.old");
+ }
+
_create_files(%files);
if ($params->{index_html}) {
_create_files(%{$fs->{index_html}});
@@ -442,6 +455,17 @@ sub create_htaccess {
}
}
+sub _rename_file {
+ my ($from, $to) = @_;
+ print "Renaming $from to $to...\n";
+ if (-e $to) {
+ warn "$to already exists, not moving\n";
+ }
+ else {
+ move($from, $to) or warn $!;
+ }
+}
+
# A helper for the above functions.
sub _create_files {
my (%files) = @_;