Commit 6f9ef526 authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

Bug 524603: Allow a non-root jobqueue.pl to write to data/mailer.testfile (for…

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
parent 426f563f
...@@ -36,6 +36,7 @@ use Bugzilla::Util; ...@@ -36,6 +36,7 @@ use Bugzilla::Util;
use File::Find; use File::Find;
use File::Path; use File::Path;
use File::Basename; use File::Basename;
use File::Copy qw(move);
use IO::File; use IO::File;
use POSIX (); use POSIX ();
...@@ -129,7 +130,6 @@ sub FILESYSTEM { ...@@ -129,7 +130,6 @@ sub FILESYSTEM {
'docs/*/README.docs' => { perms => $owner_readable }, 'docs/*/README.docs' => { perms => $owner_readable },
"$datadir/bugzilla-update.xml" => { perms => $ws_writeable }, "$datadir/bugzilla-update.xml" => { perms => $ws_writeable },
"$datadir/params" => { perms => $ws_writeable }, "$datadir/params" => { perms => $ws_writeable },
"$datadir/mailer.testfile" => { perms => $ws_writeable },
"$extensionsdir/create.pl" => { perms => $owner_executable }, "$extensionsdir/create.pl" => { perms => $owner_executable },
); );
...@@ -212,6 +212,12 @@ sub FILESYSTEM { ...@@ -212,6 +212,12 @@ sub FILESYSTEM {
my %create_files = ( my %create_files = (
"$datadir/extensions/additional" => { perms => $ws_readable, "$datadir/extensions/additional" => { perms => $ws_readable,
contents => '' }, 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 # Each standard stylesheet has an associated custom stylesheet that
...@@ -347,6 +353,13 @@ sub update_filesystem { ...@@ -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); _create_files(%files);
if ($params->{index_html}) { if ($params->{index_html}) {
_create_files(%{$fs->{index_html}}); _create_files(%{$fs->{index_html}});
...@@ -442,6 +455,17 @@ sub create_htaccess { ...@@ -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. # A helper for the above functions.
sub _create_files { sub _create_files {
my (%files) = @_; my (%files) = @_;
......
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