]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 644334 - Add hook to Bugzilla::Install::Filesystem to allow extensions to create...
authorDavid Lawrence <dlawrence@mozilla.com>
Fri, 1 Apr 2011 04:01:47 +0000 (00:01 -0400)
committerDavid Lawrence <dlawrence@mozilla.com>
Fri, 1 Apr 2011 04:01:47 +0000 (00:01 -0400)
r/a=mkanat

Bugzilla/Hook.pm
Bugzilla/Install/Filesystem.pm
extensions/Example/Extension.pm

index 14b27b48d58aef77b1267428d33ec0fa2a556f67..714054fd072c8a4b259005a78d9a2b50ade41472 100644 (file)
@@ -713,6 +713,99 @@ time should be printed.
 
 =back
 
+=head2 install_filesystem
+
+Allows for additional files and directories to be added to the
+list of files and directories already managed by checksetup.pl.
+You will be able to also set the permissions for the files and
+directories using this hook.  You are also able to set or change 
+permissions for current files and directories using this hook.
+You are also able to create appropriate htaccess files for the 
+any directories to secure its contents. For examples see 
+L<FILESYSTEM> in L<Bugzilla::Install::Filesystem>.
+
+Params:
+
+=over
+
+=item C<files>
+
+Hash reference of files that are already present when your extension was
+installed but need to have specific permissions set. Each file key
+points to another hash reference containing the following settings.
+
+Params:
+
+=over
+
+=item C<perms> - Permissions to be set on the file.
+
+=back
+
+=item C<create_dirs>
+
+Hash reference containing the name of each directory that will be created,
+pointing at its default permissions.
+
+=item C<non_recurse_dirs>
+
+Hash reference containing directories that we want to set the perms on, but not
+recurse through. These are directories not created in checksetup.pl. Each directory
+key's value is the permissions to be set on the directory.
+
+=item C<recurse_dirs>
+
+Hash reference of directories that will have permissions set for each item inside 
+each of the directories, including the directory itself. Each directory key
+points to another hash reference containing the following settings.
+
+Params:
+
+=over
+
+=item C<files> - Permissions to be set on any files beneath the directory.
+
+=item C<dirs> - Permissions to be set on the directory itself and any directories
+beneath it.
+
+=back
+
+=item C<create_files>
+
+Hash reference of additional files to be created. Each file key points to another
+hash reference containing the following settings.
+
+Params:
+
+=over
+
+=item C<perms> - The permissions to be set on the file itself.
+
+=item C<contents> - The contents to be added to the file or leave blank for an
+empty file.
+
+=back
+
+=item C<htaccess>
+
+Hash reference containing htaccess files to be created. You can set the permissions
+for the htaccess as well as the contents of the file. Each file key points to another 
+hash reference containing the following settings.
+
+Params:
+
+=over
+
+=item C<perms> - Permissions to be set on the htaccess file.
+
+=item C<contents> - Contents of the htaccess file. It can be set manually or
+use L<HT_DEFAULT_DENY> defined in L<Bugzilla::Install::Filesystem> to deny all
+by default.
+
+=back
+
+=back
+
 =head2 install_update_db
 
 This happens at the very end of all the tables being updated
index ce20fcda503ac7d710903884d4736b4e85b5c34c..2881ab0478d66c2f25a4a1071cd4760506be0d8f 100644 (file)
@@ -32,6 +32,7 @@ use Bugzilla::Error;
 use Bugzilla::Install::Localconfig;
 use Bugzilla::Install::Util qw(install_string);
 use Bugzilla::Util;
+use Bugzilla::Hook;
 
 use File::Find;
 use File::Path;
@@ -360,6 +361,15 @@ EOT
         },
     );
 
+    Bugzilla::Hook::process('install_filesystem', {
+        files            => \%files,
+        create_dirs      => \%create_dirs,
+        non_recurse_dirs => \%non_recurse_dirs,
+        recurse_dirs     => \%recurse_dirs,
+        create_files     => \%create_files,
+        htaccess         => \%htaccess,
+    });
+
     my %all_files = (%create_files, %htaccess, %index_html, %files);
     my %all_dirs  = (%create_dirs, %non_recurse_dirs);
 
index 9162ccd234c5a4d0672a5bfac6fb3d65dfb89477..09c839e62652a047a8b365a7985b8bd8c1e30353 100644 (file)
@@ -31,6 +31,7 @@ use Bugzilla::User;
 use Bugzilla::User::Setting;
 use Bugzilla::Util qw(diff_arrays html_quote);
 use Bugzilla::Status qw(is_open_state);
+use Bugzilla::Install::Filesystem;
 
 # This is extensions/Example/lib/Util.pm. I can load this here in my
 # Extension.pm only because I have a Config.pm.
@@ -400,6 +401,33 @@ sub install_before_final_checks {
     # hook/global/setting-descs-settings.none.tmpl .
 }
 
+sub install_filesystem {
+    my ($self, $args) = @_;
+    my $create_dirs  = $args->{'create_dirs'};
+    my $recurse_dirs = $args->{'recurse_dirs'};
+    my $htaccess     = $args->{'htaccess'};
+
+    # Create a new directory in datadir specifically for this extension.
+    # The directory will need to allow files to be created by the extension
+    # code as well as allow the webserver to server content from it.
+    # my $data_path = bz_locations->{'datadir'} . "/" . __PACKAGE__->NAME;
+    # $create_dirs->{$data_path} = Bugzilla::Install::Filesystem::DIR_CGI_WRITE;
+   
+    # Update the permissions of any files and directories that currently reside
+    # in the extension's directory. 
+    # $recurse_dirs->{$data_path} = {
+    #     files => Bugzilla::Install::Filesystem::CGI_READ,
+    #     dirs  => Bugzilla::Install::Filesystem::DIR_CGI_WRITE
+    # };
+    
+    # Create a htaccess file that allows specific content to be served from the 
+    # extension's directory.
+    # $htaccess->{"$data_path/.htaccess"} = {
+    #     perms    => Bugzilla::Install::Filesystem::WS_SERVE,
+    #     contents => Bugzilla::Install::Filesystem::HT_DEFAULT_DENY
+    # };
+}
+
 sub mailer_before_send {
     my ($self, $args) = @_;