From 958e1a758168b4908bcdd237518ab85b93d7e1bb Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Thu, 31 Dec 2009 12:37:48 +0000 Subject: Bug 519858 - Move uncommonly used parameters out of the "Required" section and into a "General" and "Advanced" section Patch by Max Kanat-Alexander r=LpSolit, a=LpSolit --- Bugzilla/Install/Filesystem.pm | 45 +++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'Bugzilla/Install/Filesystem.pm') diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm index 2a000acae..c95b2eecb 100644 --- a/Bugzilla/Install/Filesystem.pm +++ b/Bugzilla/Install/Filesystem.pm @@ -45,6 +45,7 @@ our @EXPORT = qw( update_filesystem create_htaccess fix_all_file_permissions + fix_file_permissions ); # This looks like a constant because it effectively is, but @@ -562,12 +563,20 @@ sub _update_old_charts { } } +sub fix_file_permissions { + my ($file) = @_; + return if ON_WINDOWS; + my $perms = FILESYSTEM()->{all_files}->{$file}->{perms}; + # Note that _get_owner_and_group is always silent here. + my ($owner_id, $group_id) = _get_owner_and_group(); + _fix_perms($file, $owner_id, $group_id, $perms); +} sub fix_all_file_permissions { my ($output) = @_; - my $ws_group = Bugzilla->localconfig->{'webservergroup'}; - my $group_id = _check_web_server_group($ws_group, $output); + # _get_owner_and_group also checks that the webservergroup is valid. + my ($owner_id, $group_id) = _get_owner_and_group($output); return if ON_WINDOWS; @@ -578,9 +587,6 @@ sub fix_all_file_permissions { print get_text('install_file_perms_fix') . "\n" if $output; - my $owner_id = POSIX::getuid(); - $group_id = POSIX::getgid() unless defined $group_id; - foreach my $dir (sort keys %dirs) { next unless -d $dir; _fix_perms($dir, $owner_id, $group_id, $dirs{$dir}); @@ -617,6 +623,16 @@ sub fix_all_file_permissions { _fix_cvs_dirs($owner_id, '.'); } +sub _get_owner_and_group { + my ($output) = @_; + my $group_id = _check_web_server_group($output); + return () if ON_WINDOWS; + + my $owner_id = POSIX::getuid(); + $group_id = POSIX::getgid() unless defined $group_id; + return ($owner_id, $group_id); +} + # A helper for fix_all_file_permissions sub _fix_cvs_dirs { my ($owner_id, $dir) = @_; @@ -633,17 +649,22 @@ sub _fix_cvs_dirs { sub _fix_perms { my ($name, $owner, $group, $perms) = @_; #printf ("Changing $name to %o\n", $perms); - chown $owner, $group, $name - or warn install_string('chown_failed', { path => $name, - error => $! }) . "\n"; + + # The webserver should never try to chown files. + if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE) { + chown $owner, $group, $name + or warn install_string('chown_failed', { path => $name, + error => $! }) . "\n"; + } chmod $perms, $name or warn install_string('chmod_failed', { path => $name, error => $! }) . "\n"; } sub _check_web_server_group { - my ($group, $output) = @_; + my ($output) = @_; + my $group = Bugzilla->localconfig->{'webservergroup'}; my $filename = bz_locations()->{'localconfig'}; my $group_id; @@ -727,4 +748,10 @@ Params: C<$output> - C if you want this function to print Returns: nothing +=item C + +Given the name of a file, its permissions will be fixed according to +how they are supposed to be set in Bugzilla's current configuration. +If it fails to set the permissions, a warning will be printed to STDERR. + =back -- cgit v1.2.3-24-g4f1b