Commit ed5c3b39 authored by Max Kanat-Alexander's avatar Max Kanat-Alexander

Bug 457373: Refactor the permissions system in Bugzilla::Install::Filesystem

to use constants instead of local variables. Also, change the permissions so that they are stricter in general, and work better under suexec. This also fixes the problem that dependency graphs didn't work under suexec, and adds a "web" directory by default to Extensions created with extension/create.pl. r=mkanat, a=mkanat (module owner)
parent 92adf6a5
...@@ -649,6 +649,17 @@ case your templates should probably be in a directory like ...@@ -649,6 +649,17 @@ case your templates should probably be in a directory like
F<extensions/Foo/template/en/default/page/foo/> so as not to conflict with F<extensions/Foo/template/en/default/page/foo/> so as not to conflict with
other pages that other extensions might add. other pages that other extensions might add.
=head2 CSS, JavaScript, and Images
If you include CSS, JavaScript, and images in your extension that are
served directly to the user (that is, they're not read by a script and
then printed--they're just linked directly in your HTML), they should go
into the F<web/> subdirectory of your extension.
So, for example, if you had a CSS file called F<style.css> and your
extension was called F<Foo>, your file would go into
F<extensions/Foo/web/style.css>.
=head2 Disabling Your Extension =head2 Disabling Your Extension
If you want your extension to be totally ignored by Bugzilla (it will If you want your extension to be totally ignored by Bugzilla (it will
......
...@@ -41,7 +41,7 @@ mkpath($extension_dir) ...@@ -41,7 +41,7 @@ mkpath($extension_dir)
|| die "$extension_dir already exists or cannot be created.\n"; || die "$extension_dir already exists or cannot be created.\n";
my $lcname = lc($name); my $lcname = lc($name);
foreach my $path (qw(lib template/en/default/hook), foreach my $path (qw(lib web template/en/default/hook),
"template/en/default/$lcname") "template/en/default/$lcname")
{ {
mkpath("$extension_dir/$path") || die "$extension_dir/$path: $!"; mkpath("$extension_dir/$path") || die "$extension_dir/$path: $!";
...@@ -55,6 +55,7 @@ my %create_files = ( ...@@ -55,6 +55,7 @@ my %create_files = (
'config.pm.tmpl' => 'Config.pm', 'config.pm.tmpl' => 'Config.pm',
'extension.pm.tmpl' => 'Extension.pm', 'extension.pm.tmpl' => 'Extension.pm',
'util.pm.tmpl' => 'lib/Util.pm', 'util.pm.tmpl' => 'lib/Util.pm',
'web-readme.txt.tmpl' => 'web/README',
'hook-readme.txt.tmpl' => 'template/en/default/hook/README', 'hook-readme.txt.tmpl' => 'template/en/default/hook/README',
'name-readme.txt.tmpl' => "template/en/default/$lcname/README", 'name-readme.txt.tmpl' => "template/en/default/$lcname/README",
); );
......
...@@ -29,6 +29,7 @@ use File::Temp; ...@@ -29,6 +29,7 @@ use File::Temp;
use Bugzilla; use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Install::Filesystem;
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::Error; use Bugzilla::Error;
use Bugzilla::Bug; use Bugzilla::Bug;
...@@ -114,7 +115,13 @@ if (!defined $cgi->param('id') && $display ne 'doall') { ...@@ -114,7 +115,13 @@ if (!defined $cgi->param('id') && $display ne 'doall') {
my ($fh, $filename) = File::Temp::tempfile("XXXXXXXXXX", my ($fh, $filename) = File::Temp::tempfile("XXXXXXXXXX",
SUFFIX => '.dot', SUFFIX => '.dot',
DIR => $webdotdir); DIR => $webdotdir,
UNLINK => 1);
chmod Bugzilla::Install::Filesystem::CGI_WRITE, $filename
or warn install_string('chmod_failed', { path => $filename,
error => $! });
my $urlbase = Bugzilla->params->{'urlbase'}; my $urlbase = Bugzilla->params->{'urlbase'};
print $fh "digraph G {"; print $fh "digraph G {";
...@@ -244,8 +251,6 @@ foreach my $k (keys(%seen)) { ...@@ -244,8 +251,6 @@ foreach my $k (keys(%seen)) {
print $fh "}\n"; print $fh "}\n";
close $fh; close $fh;
chmod 0777, $filename;
my $webdotbase = Bugzilla->params->{'webdotbase'}; my $webdotbase = Bugzilla->params->{'webdotbase'};
if ($webdotbase =~ /^https?:/) { if ($webdotbase =~ /^https?:/) {
...@@ -263,13 +268,18 @@ if ($webdotbase =~ /^https?:/) { ...@@ -263,13 +268,18 @@ if ($webdotbase =~ /^https?:/) {
my ($pngfh, $pngfilename) = File::Temp::tempfile("XXXXXXXXXX", my ($pngfh, $pngfilename) = File::Temp::tempfile("XXXXXXXXXX",
SUFFIX => '.png', SUFFIX => '.png',
DIR => $webdotdir); DIR => $webdotdir);
chmod Bugzilla::Install::Filesystem::WS_SERVE, $pngfilename
or warn install_string('chmod_failed', { path => $pngfilename,
error => $! });
binmode $pngfh; binmode $pngfh;
open(DOT, "\"$webdotbase\" -Tpng $filename|"); open(DOT, "\"$webdotbase\" -Tpng $filename|");
binmode DOT; binmode DOT;
print $pngfh $_ while <DOT>; print $pngfh $_ while <DOT>;
close DOT; close DOT;
close $pngfh; close $pngfh;
# On Windows $pngfilename will contain \ instead of / # On Windows $pngfilename will contain \ instead of /
$pngfilename =~ s|\\|/|g if ON_WINDOWS; $pngfilename =~ s|\\|/|g if ON_WINDOWS;
...@@ -287,12 +297,18 @@ if ($webdotbase =~ /^https?:/) { ...@@ -287,12 +297,18 @@ if ($webdotbase =~ /^https?:/) {
my ($mapfh, $mapfilename) = File::Temp::tempfile("XXXXXXXXXX", my ($mapfh, $mapfilename) = File::Temp::tempfile("XXXXXXXXXX",
SUFFIX => '.map', SUFFIX => '.map',
DIR => $webdotdir); DIR => $webdotdir);
chmod Bugzilla::Install::Filesystem::WS_SERVE, $mapfilename
or warn install_string('chmod_failed', { path => $mapfilename,
error => $! });
binmode $mapfh; binmode $mapfh;
open(DOT, "\"$webdotbase\" -Tismap $filename|"); open(DOT, "\"$webdotbase\" -Tismap $filename|");
binmode DOT; binmode DOT;
print $mapfh $_ while <DOT>; print $mapfh $_ while <DOT>;
close DOT; close DOT;
close $mapfh; close $mapfh;
$vars->{'image_map'} = CreateImagemap($mapfilename); $vars->{'image_map'} = CreateImagemap($mapfilename);
} }
......
[%# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Everything Solved, Inc.
# Portions created by the Initial Developer are Copyright (C) 2010 the
# Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Max Kanat-Alexander <mkanat@bugzilla.org>
#%]
[% PROCESS global/variables.none.tmpl %]
Web-accessible files, like JavaScript, CSS, and images go in this
directory. You can reference them directly in your HTML. For example,
if you have a file called "style.css" and your extension is called
"Foo", you would put it in "extensions/Foo/web/style.css", and then
you could link to it in HTML like:
<link href="extensions/Foo/web/style.css" rel="stylesheet" type="text/css">
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