]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1446156 - mkdir template_cache: Permission denied
authorDylan William Hardison <dylan@hardison.net>
Fri, 16 Mar 2018 16:53:01 +0000 (12:53 -0400)
committerGitHub <noreply@github.com>
Fri, 16 Mar 2018 16:53:01 +0000 (12:53 -0400)
Bugzilla/Template.pm
checksetup.pl

index 7a97f6da2fab08386bdfff992dedefa9335a8505..ae4f9bbad700f398d559091f7c14a9e2c71dc788 100644 (file)
@@ -1074,6 +1074,8 @@ our %_templates_to_precompile;
 sub precompile_templates {
     my ($output) = @_;
 
+    return unless is_webserver_group();
+
     # Remove the compiled templates.
     my $cache_dir = bz_locations()->{'template_cache'};
     my $datadir = bz_locations()->{'datadir'};
index 6cea8549d25955d69b97ccc4069e0215b9910a4d..d3f08e02482bbe5d9ef4fdd30ab61b792d805487 100755 (executable)
@@ -30,6 +30,7 @@ use Pod::Usage;
 # Bug 1270550 - Tie::Hash::NamedCapture must be loaded before Safe.
 use Tie::Hash::NamedCapture;
 use Safe;
+use English qw(-no_match_vars $EUID $EGID);
 
 use Bugzilla::Constants;
 use Bugzilla::Install::Requirements;
@@ -155,6 +156,16 @@ unless ($ENV{LOCALCONFIG_ENV}) {
 }
 my $lc_hash = Bugzilla->localconfig;
 
+if ( $EUID == 0 && $lc_hash->{webservergroup} && !ON_WINDOWS ) {
+    # So checksetup was run as root, and we have a webserver group set.
+    # Let's assume the user wants us to make files that are writable
+    # by the webserver group.
+
+    $EGID = getgrnam $lc_hash->{webservergroup}; ## no critic (Variables::RequireLocalizedPunctuationVars)
+    umask 002
+        or die "failed to set umask 002: $!";
+}
+
 unless ($switch{'no-database'}) {
     die "urlbase is not set\n" unless $lc_hash->{urlbase};
     die "urlbase must end with slash\n" unless $lc_hash->{urlbase} =~ m{/$}ms;