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/Config.pm | 19 +---- Bugzilla/Config/Advanced.pm | 51 +++++++++++++ Bugzilla/Config/Core.pm | 68 ++--------------- Bugzilla/Config/General.pm | 82 +++++++++++++++++++++ Bugzilla/Install.pm | 7 ++ Bugzilla/Install/Filesystem.pm | 45 ++++++++--- .../en/default/admin/params/advanced.html.tmpl | 42 +++++++++++ template/en/default/admin/params/core.html.tmpl | 68 +---------------- template/en/default/admin/params/general.html.tmpl | 86 ++++++++++++++++++++++ template/en/default/index.html.tmpl | 2 +- template/en/default/welcome-admin.html.tmpl | 9 +-- 11 files changed, 316 insertions(+), 163 deletions(-) create mode 100644 Bugzilla/Config/Advanced.pm create mode 100644 Bugzilla/Config/General.pm create mode 100644 template/en/default/admin/params/advanced.html.tmpl create mode 100644 template/en/default/admin/params/general.html.tmpl diff --git a/Bugzilla/Config.pm b/Bugzilla/Config.pm index ceb1861ed..0361592bf 100644 --- a/Bugzilla/Config.pm +++ b/Bugzilla/Config.pm @@ -35,6 +35,7 @@ use strict; use base qw(Exporter); use Bugzilla::Constants; use Bugzilla::Hook; +use Bugzilla::Install::Filesystem qw(fix_file_permissions); use Data::Dumper; use File::Temp; @@ -297,29 +298,13 @@ sub write_params { rename $tmpname, $param_file or die "Can't rename $tmpname to $param_file: $!"; - ChmodDataFile($param_file, 0666); + fix_file_permissions($param_file); # And now we have to reset the params cache so that Bugzilla will re-read # them. delete Bugzilla->request_cache->{params}; } -# Some files in the data directory must be world readable if and only if -# we don't have a webserver group. Call this function to do this. -# This will become a private function once all the datafile handling stuff -# moves into this package - -# This sub is not perldoc'd for that reason - noone should know about it -sub ChmodDataFile { - my ($file, $mask) = @_; - my $perm = 0770; - if ((stat(bz_locations()->{'datadir'}))[2] & 0002) { - $perm = 0777; - } - $perm = $perm & $mask; - chmod $perm,$file; -} - sub read_param_file { my %params; my $datadir = bz_locations()->{'datadir'}; diff --git a/Bugzilla/Config/Advanced.pm b/Bugzilla/Config/Advanced.pm new file mode 100644 index 000000000..51943f03f --- /dev/null +++ b/Bugzilla/Config/Advanced.pm @@ -0,0 +1,51 @@ +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# 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 Netscape Communications +# Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): Terry Weissman +# Dawn Endico +# Dan Mosedale +# Joe Robins +# Jacob Steenhagen +# J. Paul Reed +# Bradley Baetz +# Joseph Heenan +# Erik Stambaugh +# Frédéric Buclin +# Max Kanat-Alexander + +package Bugzilla::Config::Advanced; +use strict; + +our $sortkey = 1700; + +use constant get_param_list => ( + { + name => 'cookiedomain', + type => 't', + default => '' + }, + + { + name => 'proxy_url', + type => 't', + default => '' + }, +); + +1; diff --git a/Bugzilla/Config/Core.pm b/Bugzilla/Config/Core.pm index 550875e35..1548dcd9c 100644 --- a/Bugzilla/Config/Core.pm +++ b/Bugzilla/Config/Core.pm @@ -37,16 +37,7 @@ use Bugzilla::Config::Common; our $sortkey = 100; -sub get_param_list { - my $class = shift; - my @param_list = ( - { - name => 'maintainer', - type => 't', - default => 'please.set.the.maintainer.parameter@administration.parameters', - checker => \&check_email, - }, - +use constant get_param_list => ( { name => 'urlbase', type => 't', @@ -54,31 +45,17 @@ sub get_param_list { checker => \&check_urlbase }, - { - name => 'docs_urlbase', - type => 't', - default => 'docs/%lang%/html/', - checker => \&check_url - }, - - { - name => 'sslbase', - type => 't', - default => '', - checker => \&check_sslbase - }, - { name => 'ssl_redirect', type => 'b', default => 0 }, - { - name => 'cookiedomain', + name => 'sslbase', type => 't', - default => '' + default => '', + checker => \&check_sslbase }, { @@ -86,41 +63,6 @@ sub get_param_list { type => 't', default => '/' }, - - { - name => 'utf8', - type => 'b', - default => '0', - checker => \&check_utf8 - }, - - { - name => 'shutdownhtml', - type => 'l', - default => '' - }, - - { - name => 'announcehtml', - type => 'l', - default => '' - }, - - { - name => 'proxy_url', - type => 't', - default => '' - }, - - { - name => 'upgrade_notification', - type => 's', - choices => ['development_snapshot', 'latest_stable_release', - 'stable_branch_release', 'disabled'], - default => 'latest_stable_release', - checker => \&check_notification - } ); - return @param_list; -} +); 1; diff --git a/Bugzilla/Config/General.pm b/Bugzilla/Config/General.pm new file mode 100644 index 000000000..3a6b827ed --- /dev/null +++ b/Bugzilla/Config/General.pm @@ -0,0 +1,82 @@ +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# 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 Netscape Communications +# Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): Terry Weissman +# Dawn Endico +# Dan Mosedale +# Joe Robins +# Jacob Steenhagen +# J. Paul Reed +# Bradley Baetz +# Joseph Heenan +# Erik Stambaugh +# Frédéric Buclin +# Max Kanat-Alexander + +package Bugzilla::Config::General; +use strict; +use Bugzilla::Config::Common; + +our $sortkey = 150; + +use constant get_param_list => ( + { + name => 'maintainer', + type => 't', + default => '', + checker => \&check_email + }, + + { + name => 'docs_urlbase', + type => 't', + default => 'docs/%lang%/html/', + checker => \&check_url + }, + + { + name => 'utf8', + type => 'b', + default => '0', + checker => \&check_utf8 + }, + + { + name => 'shutdownhtml', + type => 'l', + default => '' + }, + + { + name => 'announcehtml', + type => 'l', + default => '' + }, + + { + name => 'upgrade_notification', + type => 's', + choices => ['development_snapshot', 'latest_stable_release', + 'stable_branch_release', 'disabled'], + default => 'latest_stable_release', + checker => \&check_notification + }, +); + +1; diff --git a/Bugzilla/Install.pm b/Bugzilla/Install.pm index a32063ca7..10804ab70 100644 --- a/Bugzilla/Install.pm +++ b/Bugzilla/Install.pm @@ -27,6 +27,7 @@ package Bugzilla::Install; use strict; use Bugzilla::Component; +use Bugzilla::Config qw(:admin); use Bugzilla::Constants; use Bugzilla::Error; use Bugzilla::Group; @@ -310,6 +311,12 @@ sub make_admin { $group_insert->execute($user->id, $editusers->id, 0, GRANT_DIRECT); }; + # If there is no maintainer set, make this user the maintainer. + if (!Bugzilla->params->{'maintainer'}) { + SetParam('maintainer', $user->email); + write_params(); + } + print "\n", get_text('install_admin_created', { user => $user }), "\n"; } 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 diff --git a/template/en/default/admin/params/advanced.html.tmpl b/template/en/default/admin/params/advanced.html.tmpl new file mode 100644 index 000000000..d3fe449f8 --- /dev/null +++ b/template/en/default/admin/params/advanced.html.tmpl @@ -0,0 +1,42 @@ +[%# 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 Netscape Communications + # Corporation. Portions created by Netscape are + # Copyright (C) 1998 Netscape Communications Corporation. All + # Rights Reserved. + # + # Contributor(s): Dave Miller + # Frédéric Buclin + #%] + +[% + title = "Advanced" + desc = "Settings for advanced configurations." +%] + +[% param_descs = { + cookiedomain => + "If your website is at 'www.foo.com', setting this to" + _ " '.foo.com' will also allow 'bar.foo.com' to access" + _ " $terms.Bugzilla cookies. This is useful if you have more than" + _ " one hostname pointing at the same web server, and you" + _ " want them to share the $terms.Bugzilla cookie.", + + proxy_url => + "$terms.Bugzilla may have to access the web to get notifications about" + _ " new releases (see the upgrade_notification parameter)." + _ " If your $terms.Bugzilla server is behind a proxy, it may be" + _ " necessary to enter its URL if the web server cannot access the" + _ " HTTP_PROXY environment variable. If you have to authenticate," + _ " use the http://user:pass@proxy_url/ syntax.", +} %] diff --git a/template/en/default/admin/params/core.html.tmpl b/template/en/default/admin/params/core.html.tmpl index b65dde233..b1578f422 100644 --- a/template/en/default/admin/params/core.html.tmpl +++ b/template/en/default/admin/params/core.html.tmpl @@ -25,20 +25,9 @@ %] [% param_descs = { - maintainer => "The email address of the person who maintains this installation " _ - "of ${terms.Bugzilla}.", - urlbase => "The URL that is the common initial leading part of all $terms.Bugzilla " _ "URLs.", - docs_urlbase => "The URL that is the common initial leading part of all " _ - "$terms.Bugzilla documentation URLs. " _ - "It may be an absolute URL, or a URL relative to urlbase " _ - "above. " _ - "Leave this empty to suppress links to the documentation." _ - "'%lang%' will be replaced by user's preferred language " _ - "(if available).", - sslbase => "The URL that is the common initial leading part of all HTTPS " _ "(SSL) $terms.Bugzilla URLs.", @@ -49,13 +38,6 @@ _ " $terms.Bugzilla will send out links using sslbase in emails" _ " instead of urlbase.", - cookiedomain => "The domain for $terms.Bugzilla cookies. Normally blank. " _ - "If your website is at 'www.foo.com', setting this to " _ - "'.foo.com' will also allow 'bar.foo.com' to access " _ - "$terms.Bugzilla cookies. This is useful if you have more than " _ - "one hostname pointing at the same web server, and you " _ - "want them to share the $terms.Bugzilla cookie.", - cookiepath => "Path, relative to your web document root, to which to restrict " _ "$terms.Bugzilla cookies. Normally this is the URI portion of your URL " _ "base. Begin with a / (single slash mark). For instance, if " _ @@ -63,52 +45,4 @@ "this parameter to /bugzilla/. Setting it to / will allow " _ "all sites served by this web server or virtual host to read " _ "$terms.Bugzilla cookies.", - - utf8 => "Use UTF-8 (Unicode) encoding for all text in ${terms.Bugzilla}. New " _ - "installations should set this to true to avoid character encoding " _ - "problems. Existing databases should set this to true " _ - " only after the data has been converted from existing legacy " _ - " character encodings to UTF-8, using the " _ - " contrib/recode.pl script.

Note " _ - " that if you turn this parameter from "off" to " _ - " "on", you must re-run checksetup.pl immediately " _ - " afterward.", - - shutdownhtml => "If this field is non-empty, then $terms.Bugzilla will be completely " _ - "disabled and this text will be displayed instead of all the " _ - "$terms.Bugzilla pages.", - - announcehtml => "If this field is non-empty, then $terms.Bugzilla will " _ - "display whatever is in this field at the top of every " _ - "HTML page. The HTML you put in this field is not " _ - "wrapped or enclosed in anything; you might want to " _ - "wrap it inside a <div>. Give the div " _ - "id=message to get green text inside a " _ - "red box, or class=bz_private for dark " _ - "red on a red background. Anything defined in " _ - "skins/standard/global.css or " _ - "skins/custom/global.css will work. To get " _ - "centered text, use style=\"text-align: " _ - "center;\".", - - proxy_url => "$terms.Bugzilla may have to access the web to get notifications about new " _ - "releases, see the upgrade_notification parameter. In case you are " _ - "behind a proxy, it may be necessary to enter its URL if the web server " _ - "group cannot access the HTTP_PROXY environment variable. If you have to " _ - "authenticate, use the http://user:pass@proxy_url/ syntax.", - - upgrade_notification => "

$terms.Bugzilla can inform you when a new release is available. " _ - "The notification will appear on the $terms.Bugzilla homepage, " _ - "for administrators only.

" _ - "
  • 'development_snapshot' notifies you about the latest " _ - "release on the trunk, i.e. development snapshots.
  • " _ - "
  • 'latest_stable_release' notifies you about the most recent release " _ - "available on the most recent stable branch. This branch may be " _ - "different from the branch your installation is based on.
  • " _ - "
  • 'stable_branch_release' notifies you only about new releases " _ - "corresponding to the branch your installation is based on. " _ - "If you are running a release candidate, you will get " _ - "a notification for newer release candidates too.
  • " _ - "
  • 'disabled' will never notify you about new releases and no " _ - "connection will be established to a remote server.
" } -%] +} %] diff --git a/template/en/default/admin/params/general.html.tmpl b/template/en/default/admin/params/general.html.tmpl new file mode 100644 index 000000000..b8c0c77ed --- /dev/null +++ b/template/en/default/admin/params/general.html.tmpl @@ -0,0 +1,86 @@ +[%# 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 Netscape Communications + # Corporation. Portions created by Netscape are + # Copyright (C) 1998 Netscape Communications Corporation. All + # Rights Reserved. + # + # Contributor(s): Dave Miller + # Frédéric Buclin + #%] + +[% + title = "General" + desc = "Miscellaneous general settings that are not required." +%] + +[% param_descs = { + maintainer => + "The email address of the person who maintains this installation " + _ " of ${terms.Bugzilla}.", + + docs_urlbase => + "The URL that is the common initial leading part of all" + _ " $terms.Bugzilla documentation URLs. It may be an absolute URL," + _ " or a URL relative to the urlbase parameter. Leave this" + _ " empty to suppress links to the documentation." + _ "'%lang%' will be replaced by user's preferred language (if" + _ " documentation is available in that language).", + + utf8 => + "Use UTF-8 (Unicode) encoding for all text in ${terms.Bugzilla}. New" + _ " installations should set this to true to avoid character encoding" + _ " problems. Existing databases should set this to true" + _ " only after the data has been converted from existing legacy" + _ " character encodings to UTF-8, using the contrib/recode.pl" + _ " script." + _ "

Note that if you turn this parameter from "off" to" + _ " "on", you must re-run checksetup.pl immediately" + _ " afterward.

", + + shutdownhtml => + "If this field is non-empty, then $terms.Bugzilla will be completely" + _ " disabled and this text will be displayed instead of all the" + _ " $terms.Bugzilla pages.", + + announcehtml => + "If this field is non-empty, then $terms.Bugzilla will" + _ " display whatever is in this field at the top of every" + _ " HTML page. The HTML you put in this field is not wrapped or" + _ " enclosed in anything. You might want to wrap it inside a" + _ "<div>. Give the div id=\"message\" to get" + _ " green text inside a red box, or class=\"bz_private\" for" + _ " dark red on a red background. Anything defined in " + _ " skins/standard/global.css or skins/custom/global.css" + _ " will work. To get centered text, use style=\"text-align: " + _ " center;\".", + + upgrade_notification => + "$terms.Bugzilla can inform you when a new release is available." + _ " The notification will appear on the $terms.Bugzilla homepage," + _ " for administrators only." + _ "
  • 'development_snapshot' notifies you about the development " + _ " snapshot that has been released.
  • " + _ "
  • 'latest_stable_release' notifies you about the most recent" + _ " release available on the most recent stable branch. This branch" + _ " may be different from the branch your installation is based on.
  • " + _ "
  • 'stable_branch_release' notifies you only about new releases" + _ " corresponding to the branch your installation is based on." + _ " If you are running a release candidate, you will get a notification" + _ " for newer release candidates too.
  • " + _ "
  • 'disabled' will never notify you about new releases and no" + _ " connection will be established to a remote server.
" + _ "

Note that if your $terms.Bugzilla server requires a proxy to" + _ " access the Internet, you may also need to set the proxy_url" + _ " parameter in the Advanced section.

", +} %] diff --git a/template/en/default/index.html.tmpl b/template/en/default/index.html.tmpl index dd00d3550..6dfcdc751 100644 --- a/template/en/default/index.html.tmpl +++ b/template/en/default/index.html.tmpl @@ -96,7 +96,7 @@ YAHOO.util.Event.onDOMReady(onLoadActions);

This message is only shown to logged in users with admin privs. You can configure this notification from the - Parameters page.

+ Parameters page.

[% ELSIF release.error == "cannot_download" %]

The local XML file '[% release.xml_file FILTER html %]' cannot be created. Please make sure the web server can write in this directory and that you can access diff --git a/template/en/default/welcome-admin.html.tmpl b/template/en/default/welcome-admin.html.tmpl index 6e5e36ba4..3c03fb234 100644 --- a/template/en/default/welcome-admin.html.tmpl +++ b/template/en/default/welcome-admin.html.tmpl @@ -41,9 +41,6 @@ parameters for this installation; among others:

    -
  • maintainer, the person - responsible for this installation if something is running wrong.
  • -
  • urlbase, which is the URL pointing to this installation and which will be used in emails (which is also the reason you see this page: as long as this parameter is not set, you will see this @@ -52,9 +49,9 @@
  • cookiepath is important for your browser to manage your cookies correctly.
  • -
  • utf8 will let you encode all - texts into UTF-8, if desired (it is strongly recommended to keep this parameter - turned on).
  • +
  • maintainer, + the person responsible for this installation if something is + running wrongly.

Also important are the following parameters:

-- cgit v1.2.3-24-g4f1b