Bugzilla::Config::* code style, move validation functions away from Common

hinted-selects
Vitaliy Filippov 2014-10-20 14:06:28 +04:00
parent d2e8010766
commit fe19b5071a
20 changed files with 970 additions and 935 deletions

View File

@ -1,5 +1,3 @@
# -*- 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
@ -37,27 +35,29 @@ use Bugzilla::Config::Common;
our $sortkey = 200;
sub get_param_list {
my $class = shift;
my @param_list = (
{
name => 'allowbugdeletion',
type => 'b',
default => 0
},
sub get_param_list
{
my $class = shift;
my @param_list = (
{
name => 'allowbugdeletion',
type => 'b',
default => 0
},
{
name => 'allowemailchange',
type => 'b',
default => 1
},
{
name => 'allowemailchange',
type => 'b',
default => 1
},
{
name => 'allowuserdeletion',
type => 'b',
default => 0
});
return @param_list;
{
name => 'allowuserdeletion',
type => 'b',
default => 0
},
);
return @param_list;
}
1;

View File

@ -1,5 +1,3 @@
# -*- 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
@ -30,28 +28,29 @@
# Max Kanat-Alexander <mkanat@bugzilla.org>
package Bugzilla::Config::Advanced;
use strict;
our $sortkey = 1700;
use constant get_param_list => (
{
name => 'cookiedomain',
type => 't',
default => ''
},
{
name => 'cookiedomain',
type => 't',
default => ''
},
{
name => 'inbound_proxies',
type => 't',
default => ''
},
{
name => 'inbound_proxies',
type => 't',
default => ''
},
{
name => 'proxy_url',
type => 't',
default => ''
},
{
name => 'proxy_url',
type => 't',
default => ''
},
);
1;

View File

@ -1,5 +1,3 @@
# -*- 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
@ -33,84 +31,109 @@ package Bugzilla::Config::Attachment;
use strict;
use Bugzilla;
use Bugzilla::Config::Common;
our $sortkey = 400;
sub get_param_list {
my $class = shift;
my @param_list = (
{
name => 'allow_attachment_display',
type => 'b',
default => 0
},
sub check_maxattachmentsize
{
my $check = check_numeric(@_);
return $check if $check;
my $size = shift;
my $dbh = Bugzilla->dbh;
if ($dbh->isa('Bugzilla::DB::Mysql'))
{
my (undef, $max_packet) = $dbh->selectrow_array("SHOW VARIABLES LIKE 'max\\_allowed\\_packet'");
my $byte_size = $size * 1024;
if ($max_packet < $byte_size)
{
return "You asked for a maxattachmentsize of $byte_size bytes," .
" but the max_allowed_packet setting in MySQL currently" .
" only allows packets up to $max_packet bytes";
}
}
return "";
}
{
name => 'attachment_base',
type => 't',
default => '',
checker => \&check_urlbase
},
sub get_param_list
{
my $class = shift;
my @param_list = (
{
name => 'allow_attachment_display',
type => 'b',
default => 0
},
{
name => 'allow_attachment_deletion',
type => 'b',
default => 0
},
{
name => 'attachment_base',
type => 't',
default => '',
checker => \&check_urlbase
},
{
name => 'use_supa_applet',
type => 'b',
default => 0,
},
{
name => 'allow_attachment_deletion',
type => 'b',
default => 0
},
{
name => 'supa_jar_url',
type => 't',
default => '',
},
{
name => 'use_supa_applet',
type => 'b',
default => 0,
},
# The maximum size (in bytes) for patches and non-patch attachments.
# The default limit is 1000KB, which is 24KB less than mysql's default
# maximum packet size (which determines how much data can be sent in a
# single mysql packet and thus how much data can be inserted into the
# database) to provide breathing space for the data in other fields of
# the attachment record as well as any mysql packet overhead (I don't
# know of any, but I suspect there may be some.)
{
name => 'maxattachmentsize',
type => 't',
default => '1000',
checker => \&check_maxattachmentsize
},
{
name => 'supa_jar_url',
type => 't',
default => '',
},
{
name => 'force_attach_bigfile',
type => 'b',
default => 1,
},
# The maximum size (in bytes) for attachments STORED IN THE DATABASE (!!!)
# By default Bugzilla4Intranet DOES NOT store ANY attachments in the DB,
# because force_attach_bigfile=1 by default.
#
# The default limit is 1000KB, which is 24KB less than mysql's default
# maximum packet size (which determines how much data can be sent in a
# single mysql packet and thus how much data can be inserted into the
# database) to provide breathing space for the data in other fields of
# the attachment record as well as any mysql packet overhead (I don't
# know of any, but I suspect there may be some.)
{
name => 'maxattachmentsize',
type => 't',
default => '1000',
checker => \&check_maxattachmentsize
},
{
name => 'maxlocalattachment',
type => 't',
default => '5000',
checker => \&check_numeric
},
{
name => 'force_attach_bigfile',
type => 'b',
default => 1,
},
{
name => 'inline_attachment_mime',
type => 't',
default => '^text/|^image/',
},
{
name => 'maxlocalattachment',
type => 't',
default => '5000',
checker => \&check_numeric
},
{
name => 'mime_types_file',
type => 't',
default => '',
},
);
return @param_list;
{
name => 'inline_attachment_mime',
type => 't',
default => '^text/|^image/',
},
{
name => 'mime_types_file',
type => 't',
default => '',
},
);
return @param_list;
}
1;

View File

@ -35,108 +35,146 @@ use Bugzilla::Config::Common;
our $sortkey = 300;
sub get_param_list {
my $class = shift;
my @param_list = (
{
name => 'auth_env_id',
type => 't',
default => '',
},
sub check_user_verify_class
{
# doeditparams traverses the list of params, and for each one it checks,
# then updates. This means that if one param checker wants to look at
# other params, it must be below that other one. So you can't have two
# params mutually dependent on each other.
# This means that if someone clears the LDAP config params after setting
# the login method as LDAP, we won't notice, but all logins will fail.
# So don't do that.
{
name => 'auth_env_email',
type => 't',
default => '',
},
my $params = Bugzilla->params;
my ($list, $entry) = @_;
$list || return 'You need to specify at least one authentication mechanism';
for my $class (split /,\s*/, $list)
{
my $res = check_multi($class, $entry);
return $res if $res;
if ($class eq 'RADIUS')
{
if (!Bugzilla->feature('auth_radius'))
{
return "RADIUS support is not available. Run checksetup.pl for more details";
}
return "RADIUS servername (RADIUS_server) is missing" if !$params->{RADIUS_server};
return "RADIUS_secret is empty" if !$params->{RADIUS_secret};
}
elsif ($class eq 'LDAP')
{
if (!Bugzilla->feature('auth_ldap'))
{
return "LDAP support is not available. Run checksetup.pl for more details";
}
return "LDAP servername (LDAPserver) is missing" if !$params->{LDAPserver};
return "LDAPBaseDN is empty" if !$params->{LDAPBaseDN};
}
}
return "";
}
{
name => 'auth_env_realname',
type => 't',
default => '',
},
sub get_param_list
{
my $class = shift;
my @param_list = (
{
name => 'auth_env_id',
type => 't',
default => '',
},
# XXX in the future:
#
# user_verify_class and user_info_class should have choices gathered from
# whatever sits in their respective directories
#
# rather than comma-separated lists, these two should eventually become
# arrays, but that requires alterations to editparams first
{
name => 'auth_env_email',
type => 't',
default => '',
},
{
name => 'user_info_class',
type => 's',
choices => [ 'CGI', 'Env', 'Env,CGI', 'FOF_Sudo,CGI', 'FOF_Sudo,Env,CGI' ],
default => 'CGI',
checker => \&check_multi
},
{
name => 'auth_env_realname',
type => 't',
default => '',
},
{
name => 'user_verify_class',
type => 'o',
choices => [ 'DB', 'RADIUS', 'LDAP' ],
default => 'DB',
checker => \&check_user_verify_class
},
# XXX in the future:
#
# user_verify_class and user_info_class should have choices gathered from
# whatever sits in their respective directories
#
# rather than comma-separated lists, these two should eventually become
# arrays, but that requires alterations to editparams first
{
name => 'rememberlogin',
type => 's',
choices => ['on', 'defaulton', 'defaultoff', 'off'],
default => 'on',
checker => \&check_multi
},
{
name => 'user_info_class',
type => 's',
choices => [ 'CGI', 'Env', 'Env,CGI', 'FOF_Sudo,CGI', 'FOF_Sudo,Env,CGI' ],
default => 'CGI',
checker => \&check_multi
},
{
name => 'requirelogin',
type => 'b',
default => '0'
},
{
name => 'user_verify_class',
type => 'o',
choices => [ 'DB', 'RADIUS', 'LDAP' ],
default => 'DB',
checker => \&check_user_verify_class
},
{
name => 'emailregexp',
type => 't',
default => q:^[\\w\\.\\+\\-=]+@[\\w\\.\\-]+\\.[\\w\\-]+$:,
checker => \&check_regexp
},
{
name => 'rememberlogin',
type => 's',
choices => ['on', 'defaulton', 'defaultoff', 'off'],
default => 'on',
checker => \&check_multi
},
{
name => 'emailregexpdesc',
type => 'l',
default => 'A legal address must contain exactly one \'@\', and at least ' .
'one \'.\' after the @.'
},
{
name => 'requirelogin',
type => 'b',
default => '0'
},
{
name => 'emailsuffix',
type => 't',
default => ''
},
{
name => 'emailregexp',
type => 't',
default => q:^[\\w\\.\\+\\-=]+@[\\w\\.\\-]+\\.[\\w\\-]+$:,
checker => \&check_regexp
},
{
name => 'createemailregexp',
type => 't',
default => q:.*:,
checker => \&check_regexp
},
{
name => 'emailregexpdesc',
type => 'l',
default => 'A legal address must contain exactly one \'@\', and at least one \'.\' after the @.'
},
{
name => 'max_login_attempts',
type => 't',
default => 5,
checker => sub { $_[0] =~ /^\d+$/so ? "" : "must be a positive integer value or 0 (means no limit)" },
},
{
name => 'emailsuffix',
type => 't',
default => ''
},
{
name => 'login_lockout_interval',
type => 't',
default => 30,
checker => sub { $_[0] =~ /^[1-9]\d*$/so ? "" : "must be a positive integer value" },
},
{
name => 'createemailregexp',
type => 't',
default => q:.*:,
checker => \&check_regexp
},
);
return @param_list;
{
name => 'max_login_attempts',
type => 't',
default => 5,
checker => sub { $_[0] =~ /^\d+$/so ? "" : "must be a positive integer value or 0 (means no limit)" },
},
{
name => 'login_lockout_interval',
type => 't',
default => 30,
checker => sub { $_[0] =~ /^[1-9]\d*$/so ? "" : "must be a positive integer value" },
},
);
return @param_list;
}
1;

View File

@ -1,5 +1,3 @@
# -*- 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
@ -37,57 +35,59 @@ use Bugzilla::Config::Common;
our $sortkey = 700;
sub get_param_list {
my $class = shift;
my @param_list = (
{
name => 'move-enabled',
type => 'b',
default => 0
},
sub get_param_list
{
my $class = shift;
my @param_list = (
{
name => 'move-enabled',
type => 'b',
default => 0
},
{
name => 'move-button-text',
type => 't',
default => 'Move To Bugscape'
},
{
name => 'move-button-text',
type => 't',
default => 'Move To Bugscape'
},
{
name => 'move-to-url',
type => 't',
default => ''
},
{
name => 'move-to-url',
type => 't',
default => ''
},
{
name => 'move-to-address',
type => 't',
default => 'bugzilla-import'
},
{
name => 'move-to-address',
type => 't',
default => 'bugzilla-import'
},
{
name => 'moved-from-address',
type => 't',
default => 'bugzilla-admin'
},
{
name => 'moved-from-address',
type => 't',
default => 'bugzilla-admin'
},
{
name => 'movers',
type => 't',
default => ''
},
{
name => 'movers',
type => 't',
default => ''
},
{
name => 'moved-default-product',
type => 't',
default => ''
},
{
name => 'moved-default-product',
type => 't',
default => ''
},
{
name => 'moved-default-component',
type => 't',
default => ''
} );
return @param_list;
{
name => 'moved-default-component',
type => 't',
default => ''
},
);
return @param_list;
}
1;

View File

@ -1,5 +1,3 @@
# -*- 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
@ -35,282 +33,96 @@ package Bugzilla::Config::Common;
use strict;
use Email::Address;
use Socket;
use Bugzilla::Util;
use Bugzilla::Constants;
use Bugzilla::Field;
use Bugzilla::Group;
use Bugzilla::Status;
use base qw(Exporter);
@Bugzilla::Config::Common::EXPORT =
qw(check_multi check_numeric check_regexp check_url check_group
check_sslbase check_shadowdb check_urlbase check_webdotbase
check_user_verify_class
check_mail_delivery_method check_notification check_utf8
check_smtp_auth check_theschwartz_available
check_maxattachmentsize check_email
@Bugzilla::Config::Common::EXPORT = qw(
check_multi check_numeric check_regexp check_url
check_urlbase check_email
);
# Checking functions for the various values
sub check_multi {
sub check_multi
{
my ($value, $param) = (@_);
if ($param->{'type'} eq "s") {
unless (scalar(grep {$_ eq $value} (@{$param->{'choices'}}))) {
return "Invalid choice '$value' for single-select list param '$param->{'name'}'";
if ($param->{type} eq "s")
{
unless (grep { $_ eq $value } @{$param->{choices}})
{
return "Invalid choice '$value' for single-select list param '$param->{name}'";
}
return "";
}
elsif ($param->{'type'} eq 'm' || $param->{'type'} eq 'o') {
foreach my $chkParam (split(',', $value)) {
unless (scalar(grep {$_ eq $chkParam} (@{$param->{'choices'}}))) {
return "Invalid choice '$chkParam' for multi-select list param '$param->{'name'}'";
elsif ($param->{type} eq 'm' || $param->{type} eq 'o')
{
foreach my $chkParam (split ',', $value)
{
unless (grep { $_ eq $chkParam } @{$param->{choices}})
{
return "Invalid choice '$chkParam' for multi-select list param '$param->{name}'";
}
}
return "";
}
else {
return "Invalid param type '$param->{'type'}' for check_multi(); " .
"contact your Bugzilla administrator";
else
{
die "BUG: Invalid param type '$param->{type}' for check_multi()";
}
}
sub check_numeric {
sub check_numeric
{
my ($value) = (@_);
if ($value !~ /^[0-9]+$/) {
if ($value !~ /^[0-9]+$/)
{
return "must be a numeric value";
}
return "";
}
sub check_regexp {
sub check_regexp
{
my ($value) = (@_);
eval { qr/$value/ };
return $@;
}
sub check_email {
sub check_email
{
my ($value) = @_;
if ($value !~ $Email::Address::mailbox) {
if ($value !~ $Email::Address::mailbox)
{
return "must be a valid email address.";
}
return "";
}
sub check_sslbase {
my $url = shift;
if ($url ne '') {
if ($url !~ m#^https://([^/]+).*/$#) {
return "must be a legal URL, that starts with https and ends with a slash.";
}
my $host = $1;
# Fall back to port 443 if for some reason getservbyname() fails.
my $port = getservbyname('https', 'tcp') || 443;
if ($host =~ /^(.+):(\d+)$/) {
$host = $1;
$port = $2;
}
local *SOCK;
my $proto = getprotobyname('tcp');
socket(SOCK, PF_INET, SOCK_STREAM, $proto);
my $iaddr = inet_aton($host) || return "The host $host cannot be resolved";
my $sin = sockaddr_in($port, $iaddr);
if (!connect(SOCK, $sin)) {
return "Failed to connect to $host:$port; unable to enable SSL";
}
close(SOCK);
}
return "";
}
sub check_utf8 {
my $utf8 = shift;
# You cannot turn off the UTF-8 parameter if you've already converted
# your tables to utf-8.
my $dbh = Bugzilla->dbh;
if ($dbh->isa('Bugzilla::DB::Mysql') && $dbh->bz_db_is_utf8 && !$utf8) {
return "You cannot disable UTF-8 support, because your MySQL database"
. " is encoded in UTF-8";
}
return "";
}
sub check_group {
my $group_name = shift;
return "" unless $group_name;
my $group = new Bugzilla::Group({'name' => $group_name});
unless (defined $group) {
return "Must be an existing group name";
}
return "";
}
sub check_shadowdb {
my ($value) = (@_);
$value = trim($value);
if ($value eq "") {
return "";
}
if (!Bugzilla->params->{'shadowdbhost'}) {
return "You need to specify a host when using a shadow database";
}
# Can't test existence of this because ConnectToDatabase uses the param,
# but we can't set this before testing....
# This can really only be fixed after we can use the DBI more openly
return "";
}
sub check_urlbase {
sub check_urlbase
{
my ($url) = (@_);
if ($url && $url !~ m:^http.*/$:) {
return "must be a legal URL, that starts with http and ends with a slash.";
if ($url && $url !~ m:^http.*/$:)
{
return 'must be a legal URL, that starts with http and ends with a slash.';
}
return "";
}
sub check_url {
sub check_url
{
my ($url) = (@_);
return '' if $url eq ''; # Allow empty URLs
if ($url !~ m:/$:) {
if ($url !~ m:/$:)
{
return 'must be a legal URL, absolute or relative, ending with a slash.';
}
return '';
}
sub check_webdotbase {
my ($value) = (@_);
$value = trim($value);
if ($value eq "") {
return "";
}
if ($value !~ /^https?:/) {
if (!-x $value) {
return "The file path \"$value\" is not a valid executable. Please specify the complete file path to 'dot' if you intend to generate graphs locally.";
}
# Check .htaccess allows access to generated images
my $webdotdir = bz_locations()->{'webdotdir'};
if (-e "$webdotdir/.htaccess") {
open HTACCESS, "$webdotdir/.htaccess";
local $/ = undef;
if (!grep /png/,<HTACCESS>) {
return "Dependency graph images are not accessible.\nAssuming that you have not modified the file, delete $webdotdir/.htaccess and re-run checksetup.pl to rectify.\n";
}
close HTACCESS;
}
}
return "";
}
sub check_user_verify_class {
# doeditparams traverses the list of params, and for each one it checks,
# then updates. This means that if one param checker wants to look at
# other params, it must be below that other one. So you can't have two
# params mutually dependent on each other.
# This means that if someone clears the LDAP config params after setting
# the login method as LDAP, we won't notice, but all logins will fail.
# So don't do that.
my $params = Bugzilla->params;
my ($list, $entry) = @_;
$list || return 'You need to specify at least one authentication mechanism';
for my $class (split /,\s*/, $list) {
my $res = check_multi($class, $entry);
return $res if $res;
if ($class eq 'RADIUS') {
if (!Bugzilla->feature('auth_radius')) {
return "RADIUS support is not available. Run checksetup.pl"
. " for more details";
}
return "RADIUS servername (RADIUS_server) is missing"
if !$params->{"RADIUS_server"};
return "RADIUS_secret is empty" if !$params->{"RADIUS_secret"};
}
elsif ($class eq 'LDAP') {
if (!Bugzilla->feature('auth_ldap')) {
return "LDAP support is not available. Run checksetup.pl"
. " for more details";
}
return "LDAP servername (LDAPserver) is missing"
if !$params->{"LDAPserver"};
return "LDAPBaseDN is empty" if !$params->{"LDAPBaseDN"};
}
}
return "";
}
sub check_mail_delivery_method {
my $check = check_multi(@_);
return $check if $check;
my $mailer = shift;
if ($mailer eq 'sendmail' and ON_WINDOWS) {
# look for sendmail.exe
return "Failed to locate " . SENDMAIL_EXE
unless -e SENDMAIL_EXE;
}
return "";
}
sub check_maxattachmentsize {
my $check = check_numeric(@_);
return $check if $check;
my $size = shift;
my $dbh = Bugzilla->dbh;
if ($dbh->isa('Bugzilla::DB::Mysql')) {
my (undef, $max_packet) = $dbh->selectrow_array(
q{SHOW VARIABLES LIKE 'max\_allowed\_packet'});
my $byte_size = $size * 1024;
if ($max_packet < $byte_size) {
return "You asked for a maxattachmentsize of $byte_size bytes,"
. " but the max_allowed_packet setting in MySQL currently"
. " only allows packets up to $max_packet bytes";
}
}
return "";
}
sub check_notification {
my $option = shift;
my @current_version =
(BUGZILLA_VERSION =~ m/^(\d+)\.(\d+)(?:(rc|\.)(\d+))?\+?$/);
if ($current_version[1] % 2 && $option eq 'stable_branch_release') {
return "You are currently running a development snapshot, and so your " .
"installation is not based on a branch. If you want to be notified " .
"about the next stable release, you should select " .
"'latest_stable_release' instead";
}
if ($option ne 'disabled' && !Bugzilla->feature('updates')) {
return "Some Perl modules are missing to get notifications about " .
"new releases. See the output of checksetup.pl for more information";
}
return "";
}
sub check_smtp_auth {
my $username = shift;
if ($username and !Bugzilla->feature('smtp_auth')) {
return "SMTP Authentication is not available. Run checksetup.pl for"
. " more details";
}
return "";
}
sub check_theschwartz_available {
my $use_queue = shift;
if ($use_queue && !Bugzilla->feature('jobqueue')) {
return "Using the job queue requires that you have certain Perl"
. " modules installed. See the output of checksetup.pl"
. " for more information";
}
return "";
}
# OK, here are the parameter definitions themselves.
#
# Each definition is a hash with keys:
@ -369,12 +181,13 @@ sub check_theschwartz_available {
# }
#
# Here, 'b' is the default option, and 'a' and 'c' are other possible
# options, but only one at a time!
# options, but only one at a time!
#
# &check_multi should always be used as the param verification function
# for list (single and multiple) parameter types.
sub get_param_list {
sub get_param_list
{
return;
}

View File

@ -1,5 +1,3 @@
# -*- 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
@ -33,54 +31,86 @@ package Bugzilla::Config::Core;
use strict;
use Socket;
use Bugzilla::Config::Common;
our $sortkey = 100;
sub check_sslbase
{
my $url = shift;
if ($url ne '')
{
if ($url !~ m#^https://([^/]+).*/$#)
{
return "must be a legal URL, that starts with https and ends with a slash.";
}
my $host = $1;
# Fall back to port 443 if for some reason getservbyname() fails.
my $port = getservbyname('https', 'tcp') || 443;
if ($host =~ /^(.+):(\d+)$/)
{
$host = $1;
$port = $2;
}
local *SOCK;
my $proto = getprotobyname('tcp');
socket(SOCK, PF_INET, SOCK_STREAM, $proto);
my $iaddr = inet_aton($host) || return "The host $host cannot be resolved";
my $sin = sockaddr_in($port, $iaddr);
if (!connect(SOCK, $sin))
{
return "Failed to connect to $host:$port; unable to enable SSL";
}
close(SOCK);
}
return "";
}
use constant get_param_list => (
{
name => 'error_log',
type => 't',
default => 'errorlog',
},
{
name => 'error_log',
type => 't',
default => 'errorlog',
},
{
name => 'report_code_errors_to_maintainer',
type => 'b',
default => 1,
},
{
name => 'report_code_errors_to_maintainer',
type => 'b',
default => 1,
},
{
name => 'report_user_errors_to_maintainer',
type => 'b',
default => 0,
},
{
name => 'report_user_errors_to_maintainer',
type => 'b',
default => 0,
},
{
name => 'urlbase',
type => 't',
default => '',
checker => \&check_urlbase
},
{
name => 'urlbase',
type => 't',
default => '',
checker => \&check_urlbase,
},
{
name => 'ssl_redirect',
type => 'b',
default => 0
},
{
name => 'ssl_redirect',
type => 'b',
default => 0,
},
{
name => 'sslbase',
type => 't',
default => '',
checker => \&check_sslbase
},
{
name => 'sslbase',
type => 't',
default => '',
checker => \&check_sslbase,
},
{
name => 'cookiepath',
type => 't',
default => '/'
},
{
name => 'cookiepath',
type => 't',
default => '/',
},
);
1;

View File

@ -1,5 +1,3 @@
# -*- 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
@ -37,50 +35,80 @@ use Bugzilla::Config::Common;
our $sortkey = 800;
sub get_param_list {
my $class = shift;
my @param_list = (
{
name => 'webdotbase',
type => 't',
default => 'http://www.research.att.com/~north/cgi-bin/webdot.cgi/%urlbase%',
checker => \&check_webdotbase
},
sub check_webdotbase
{
my ($value) = (@_);
$value = trim($value);
if ($value eq "")
{
return "";
}
if ($value !~ /^https?:/)
{
if (!-x $value)
{
return "The file path \"$value\" is not a valid executable. Please specify the complete file path to 'dot' if you intend to generate graphs locally.";
}
# Check .htaccess allows access to generated images
my $webdotdir = bz_locations()->{webdotdir};
if (-e "$webdotdir/.htaccess")
{
open HTACCESS, "$webdotdir/.htaccess";
local $/ = undef;
if (!grep /png/, <HTACCESS>)
{
return "Dependency graph images are not accessible.\nAssuming that you have not modified the file, delete $webdotdir/.htaccess and re-run checksetup.pl to rectify.\n";
}
close HTACCESS;
}
}
return "";
}
{
name => 'webtwopibase',
type => 't',
default => '',
checker => \&check_webdotbase
},
sub get_param_list
{
my $class = shift;
my @param_list = (
{
name => 'webdotbase',
type => 't',
default => 'http://www.research.att.com/~north/cgi-bin/webdot.cgi/%urlbase%',
checker => \&check_webdotbase
},
{
name => 'graph_rankdir',
type => 's',
choices => ['LR', 'RL', 'TB', 'BT'],
default => 'LR'
},
{
name => 'webtwopibase',
type => 't',
default => '',
checker => \&check_webdotbase
},
{
name => 'localdottimeout',
type => 't',
default => '5'
},
{
name => 'graph_rankdir',
type => 's',
choices => ['LR', 'RL', 'TB', 'BT'],
default => 'LR'
},
{
name => 'graph_font',
type => 't',
default => '',
},
{
name => 'localdottimeout',
type => 't',
default => '5'
},
{
name => 'graph_font_size',
type => 't',
default => '8',
},
{
name => 'graph_font',
type => 't',
default => '',
},
);
return @param_list;
{
name => 'graph_font_size',
type => 't',
default => '8',
},
);
return @param_list;
}
1;

View File

@ -1,5 +1,3 @@
# -*- 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
@ -30,83 +28,116 @@
# Max Kanat-Alexander <mkanat@bugzilla.org>
package Bugzilla::Config::General;
use strict;
use Bugzilla::Config::Common;
use POSIX;
use Bugzilla::Config::Common;
use Bugzilla::Constants;
our $sortkey = 150;
sub check_notification
{
my $option = shift;
my @current_version = (BUGZILLA_VERSION =~ m/^(\d+)\.(\d+)(?:(rc|\.)(\d+))?\+?$/);
if ($current_version[1] % 2 && $option eq 'stable_branch_release')
{
return "You are currently running a development snapshot, and so your " .
"installation is not based on a branch. If you want to be notified " .
"about the next stable release, you should select " .
"'latest_stable_release' instead";
}
if ($option ne 'disabled' && !Bugzilla->feature('updates'))
{
return "Some Perl modules are missing to get notifications about " .
"new releases. See the output of checksetup.pl for more information";
}
return "";
}
sub check_utf8
{
my $utf8 = shift;
# You cannot turn off the UTF-8 parameter if you've already converted your tables to utf-8.
my $dbh = Bugzilla->dbh;
if ($dbh->isa('Bugzilla::DB::Mysql') && $dbh->bz_db_is_utf8 && !$utf8)
{
return "You cannot disable UTF-8 support, because your MySQL database is encoded in UTF-8";
}
return "";
}
use constant get_param_list => (
{
name => 'maintainer',
type => 't',
no_reset => '1',
default => '',
checker => \&check_email
},
{
name => 'maintainer',
type => 't',
no_reset => '1',
default => '',
checker => \&check_email
},
{
name => 'docs_urlbase',
type => 't',
default => 'docs/%lang%/html/',
checker => \&check_url
},
{
name => 'docs_urlbase',
type => 't',
default => 'docs/%lang%/html/',
checker => \&check_url
},
{
name => 'utf8',
type => 'b',
default => '0',
checker => \&check_utf8
},
{
name => 'utf8',
type => 'b',
default => '0',
checker => \&check_utf8
},
{
name => 'announcehtml',
type => 'l',
default => ''
},
{
name => 'announcehtml',
type => 'l',
default => ''
},
{
name => 'entryheaderhtml',
type => 'l',
default =>
{
name => 'entryheaderhtml',
type => 'l',
default =>
'<p>Before reporting a bug, please read the <a href="page.cgi?id=bug-writing.html">
bug writing guidelines</a>, please look at the list of
<a href="duplicates.cgi">most frequently reported bugs</a>, and please
<a href="query.cgi">search</a> for the bug.</p><hr />'
},
},
{
name => 'bannerhtml',
type => 'l',
default => ''
},
{
name => 'bannerhtml',
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
},
{
name => 'upgrade_notification',
type => 's',
choices => ['development_snapshot', 'latest_stable_release', 'stable_branch_release', 'disabled'],
default => 'latest_stable_release',
checker => \&check_notification
},
{
name => 'new_functionality_msg',
type => 'l',
default => ''
},
{
name => 'new_functionality_msg',
type => 'l',
default => ''
},
{
name => 'new_functionality_tsp',
type => 't',
default => POSIX::strftime "%Y-%m-%d %H:%M:%S", localtime
},
{
name => 'new_functionality_tsp',
type => 't',
default => POSIX::strftime("%Y-%m-%d %H:%M:%S", localtime)
},
{
name => 'shutdownhtml',
type => 'l',
default => ''
},
{
name => 'shutdownhtml',
type => 'l',
default => ''
},
);
1;

View File

@ -1,5 +1,3 @@
# -*- 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
@ -38,65 +36,81 @@ use Bugzilla::Group;
our $sortkey = 900;
sub get_param_list {
my $class = shift;
my @param_list = (
{
name => 'makeproductgroups',
type => 'b',
default => 1
},
{
name => 'chartgroup',
type => 's',
choices => \&_get_all_group_names,
default => 'editbugs',
checker => \&check_group
},
{
name => 'insidergroup',
type => 's',
choices => \&_get_all_group_names,
default => '',
checker => \&check_group
},
{
name => 'timetrackinggroup',
type => 's',
choices => \&_get_all_group_names,
default => 'editbugs',
checker => \&check_group
},
{
name => 'querysharegroup',
type => 's',
choices => \&_get_all_group_names,
default => 'editbugs',
checker => \&check_group
},
{
name => 'usevisibilitygroups',
type => 'b',
default => 0
},
{
name => 'strict_isolation',
type => 'b',
default => 0
} );
return @param_list;
sub check_group
{
my $group_name = shift;
return "" unless $group_name;
my $group = new Bugzilla::Group({ name => $group_name });
unless (defined $group)
{
return "Must be an existing group name";
}
return "";
}
sub _get_all_group_names {
my @group_names = map {$_->name} Bugzilla::Group->get_all;
unshift(@group_names, '');
sub _get_all_group_names
{
my @group_names = map { $_->name } Bugzilla::Group->get_all;
unshift @group_names, '';
return \@group_names;
}
sub get_param_list
{
my $class = shift;
my @param_list = (
{
name => 'makeproductgroups',
type => 'b',
default => 1
},
{
name => 'chartgroup',
type => 's',
choices => \&_get_all_group_names,
default => 'editbugs',
checker => \&check_group
},
{
name => 'insidergroup',
type => 's',
choices => \&_get_all_group_names,
default => '',
checker => \&check_group
},
{
name => 'timetrackinggroup',
type => 's',
choices => \&_get_all_group_names,
default => 'editbugs',
checker => \&check_group
},
{
name => 'querysharegroup',
type => 's',
choices => \&_get_all_group_names,
default => 'editbugs',
checker => \&check_group
},
{
name => 'usevisibilitygroups',
type => 'b',
default => 0
},
{
name => 'strict_isolation',
type => 'b',
default => 0
},
);
return @param_list;
}
1;

View File

@ -1,5 +1,7 @@
#!/usr/bin/perl
# Integration with other systems (MediaWiki, ViewVC, etc) config
# License: Dual-license MPL 1.1+ or GPL 3.0+
# Author(s): Vitaliy Filippov <vitalif@mail.ru>
package Bugzilla::Config::Integration;

View File

@ -1,5 +1,3 @@
# -*- 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
@ -37,51 +35,53 @@ use Bugzilla::Config::Common;
our $sortkey = 1000;
sub get_param_list {
my $class = shift;
my @param_list = (
{
name => 'LDAPserver',
type => 't',
default => ''
},
sub get_param_list
{
my $class = shift;
my @param_list = (
{
name => 'LDAPserver',
type => 't',
default => ''
},
{
name => 'LDAPstarttls',
type => 'b',
default => 0
},
{
name => 'LDAPstarttls',
type => 'b',
default => 0
},
{
name => 'LDAPbinddn',
type => 't',
default => ''
},
{
name => 'LDAPbinddn',
type => 't',
default => ''
},
{
name => 'LDAPBaseDN',
type => 't',
default => ''
},
{
name => 'LDAPBaseDN',
type => 't',
default => ''
},
{
name => 'LDAPuidattribute',
type => 't',
default => 'uid'
},
{
name => 'LDAPuidattribute',
type => 't',
default => 'uid'
},
{
name => 'LDAPmailattribute',
type => 't',
default => 'mail'
},
{
name => 'LDAPmailattribute',
type => 't',
default => 'mail'
},
{
name => 'LDAPfilter',
type => 't',
default => '',
} );
return @param_list;
{
name => 'LDAPfilter',
type => 't',
default => '',
},
);
return @param_list;
}
1;

View File

@ -1,5 +1,3 @@
# -*- 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
@ -33,73 +31,117 @@ package Bugzilla::Config::MTA;
use strict;
use Bugzilla;
use Bugzilla::Constants;
use Bugzilla::Config::Common;
our $sortkey = 1200;
sub get_param_list {
my $class = shift;
my @param_list = (
{
name => 'mail_delivery_method',
type => 's',
choices => ['Sendmail', 'SMTP', 'Test', 'None'],
default => 'Sendmail',
checker => \&check_mail_delivery_method
},
sub check_mail_delivery_method
{
my $check = check_multi(@_);
return $check if $check;
my $mailer = shift;
if ($mailer eq 'sendmail' && ON_WINDOWS)
{
# look for sendmail.exe
return "Failed to locate " . SENDMAIL_EXE unless -e SENDMAIL_EXE;
}
return "";
}
{
name => 'mailfrom',
type => 't',
default => 'bugzilla-daemon'
},
sub check_smtp_auth
{
my $username = shift;
if ($username && !Bugzilla->feature('smtp_auth'))
{
return "SMTP Authentication is not available. Run checksetup.pl for more details";
}
return "";
}
{
name => 'use_mailer_queue',
type => 'b',
default => 0,
checker => \&check_theschwartz_available,
},
sub check_theschwartz_available
{
my $use_queue = shift;
if ($use_queue && !Bugzilla->feature('jobqueue'))
{
return "Using the job queue requires that you have certain Perl" .
" modules installed. See the output of checksetup.pl" .
" for more information";
}
return "";
}
{
name => 'sendmailnow',
type => 'b',
default => 1
},
sub get_param_list
{
my $class = shift;
my @param_list = (
{
name => 'mail_delivery_method',
type => 's',
choices => ['Sendmail', 'SMTP', 'Test', 'None'],
default => 'Sendmail',
checker => \&check_mail_delivery_method
},
{
name => 'smtpserver',
type => 't',
default => 'localhost'
},
{
name => 'smtp_username',
type => 't',
default => '',
checker => \&check_smtp_auth
},
{
name => 'smtp_password',
type => 'p',
default => ''
},
{
name => 'smtp_debug',
type => 'b',
default => 0
},
{
name => 'whinedays',
type => 't',
default => 7,
checker => \&check_numeric
},
{
name => 'globalwatchers',
type => 't',
default => '',
}, );
return @param_list;
{
name => 'mailfrom',
type => 't',
default => 'bugzilla-daemon'
},
{
name => 'use_mailer_queue',
type => 'b',
default => 0,
checker => \&check_theschwartz_available,
},
{
name => 'sendmailnow',
type => 'b',
default => 1
},
{
name => 'smtpserver',
type => 't',
default => 'localhost'
},
{
name => 'smtp_username',
type => 't',
default => '',
checker => \&check_smtp_auth
},
{
name => 'smtp_password',
type => 'p',
default => '',
},
{
name => 'smtp_debug',
type => 'b',
default => 0
},
{
name => 'whinedays',
type => 't',
default => 7,
checker => \&check_numeric
},
{
name => 'globalwatchers',
type => 't',
default => ''
},
);
return @param_list;
}
1;

View File

@ -1,5 +1,3 @@
# -*- 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
@ -37,39 +35,41 @@ use Bugzilla::Config::Common;
our $sortkey = 1300;
sub get_param_list {
my $class = shift;
my @param_list = (
{
name => 'cvsroot',
type => 't',
default => '',
},
sub get_param_list
{
my $class = shift;
my @param_list = (
{
name => 'cvsroot',
type => 't',
default => '',
},
{
name => 'cvsroot_get',
type => 't',
default => '',
},
{
name => 'cvsroot_get',
type => 't',
default => '',
},
{
name => 'bonsai_url',
type => 't',
default => ''
},
{
name => 'bonsai_url',
type => 't',
default => ''
},
{
name => 'lxr_url',
type => 't',
default => ''
},
{
name => 'lxr_url',
type => 't',
default => ''
},
{
name => 'lxr_root',
type => 't',
default => '',
} );
return @param_list;
{
name => 'lxr_root',
type => 't',
default => '',
}
);
return @param_list;
}
1;

View File

@ -1,5 +1,3 @@
# -*- 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
@ -37,49 +35,50 @@ use Bugzilla::Config::Common;
our $sortkey = 1400;
sub get_param_list {
my $class = shift;
my @param_list = (
{
name => 'quip_list_entry_control',
type => 's',
choices => ['open', 'moderated', 'closed'],
default => 'open',
checker => \&check_multi
},
sub get_param_list
{
my $class = shift;
my @param_list = (
{
name => 'quip_list_entry_control',
type => 's',
choices => ['open', 'moderated', 'closed'],
default => 'open',
checker => \&check_multi
},
{
name => 'mostfreqthreshold',
type => 't',
default => '2',
checker => \&check_numeric
},
{
name => 'mostfreqthreshold',
type => 't',
default => '2',
checker => \&check_numeric
},
{
name => 'mybugstemplate',
type => 't',
default => 'buglist.cgi?bug_status=UNCONFIRMED&amp;bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOPENED&amp;emailassigned_to1=1&amp;emailreporter1=1&amp;emailtype1=exact&amp;email1=%userid%&amp;field0-0-0=bug_status&amp;type0-0-0=notequals&amp;value0-0-0=UNCONFIRMED&amp;field0-0-1=reporter&amp;type0-0-1=equals&amp;value0-0-1=%userid%'
},
{
name => 'mybugstemplate',
type => 't',
default => 'buglist.cgi?bug_status=UNCONFIRMED&amp;bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOPENED&amp;emailassigned_to1=1&amp;emailreporter1=1&amp;emailtype1=exact&amp;email1=%userid%&amp;field0-0-0=bug_status&amp;type0-0-0=notequals&amp;value0-0-0=UNCONFIRMED&amp;field0-0-1=reporter&amp;type0-0-1=equals&amp;value0-0-1=%userid%'
},
{
name => 'defaultquery',
type => 't',
default => 'bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailassigned_to2=1&emailreporter2=1&emailcc2=1&emailqa_contact2=1&order=Importance&long_desc_type=substring'
},
{
name => 'defaultquery',
type => 't',
default => 'bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailassigned_to2=1&emailreporter2=1&emailcc2=1&emailqa_contact2=1&order=Importance&long_desc_type=substring'
},
{
name => 'specific_search_allow_empty_words',
type => 'b',
default => 1
},
{
name => 'specific_search_allow_empty_words',
type => 'b',
default => 1
},
{
name => 'stem_language',
type => 't',
default => 'en',
},
);
return @param_list;
{
name => 'stem_language',
type => 't',
default => 'en',
},
);
return @param_list;
}
1;

View File

@ -1,5 +1,3 @@
# -*- 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
@ -27,34 +25,35 @@ use Bugzilla::Config::Common;
our $sortkey = 1100;
sub get_param_list {
my $class = shift;
my @param_list = (
{
name => 'RADIUS_server',
type => 't',
default => ''
},
sub get_param_list
{
my $class = shift;
my @param_list = (
{
name => 'RADIUS_server',
type => 't',
default => ''
},
{
name => 'RADIUS_secret',
type => 't',
default => ''
},
{
name => 'RADIUS_secret',
type => 't',
default => ''
},
{
name => 'RADIUS_NAS_IP',
type => 't',
default => ''
},
{
name => 'RADIUS_NAS_IP',
type => 't',
default => ''
},
{
name => 'RADIUS_email_suffix',
type => 't',
default => ''
},
);
return @param_list;
{
name => 'RADIUS_email_suffix',
type => 't',
default => ''
},
);
return @param_list;
}
1;

View File

@ -1,5 +1,3 @@
# -*- 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
@ -37,37 +35,57 @@ use Bugzilla::Config::Common;
our $sortkey = 1500;
sub get_param_list {
my $class = shift;
my @param_list = (
{
name => 'shadowdbhost',
type => 't',
default => '',
},
sub check_shadowdb
{
my ($value) = (@_);
$value = trim($value);
if ($value eq "")
{
return "";
}
if (!Bugzilla->params->{shadowdbhost})
{
return "You need to specify a host when using a shadow database";
}
# Can't test existence of this because ConnectToDatabase uses the param,
# but we can't set this before testing....
# This can really only be fixed after we can use the DBI more openly
return "";
}
{
name => 'shadowdbport',
type => 't',
default => '3306',
checker => \&check_numeric,
},
sub get_param_list
{
my $class = shift;
my @param_list = (
{
name => 'shadowdbhost',
type => 't',
default => '',
},
{
name => 'shadowdbsock',
type => 't',
default => '',
},
{
name => 'shadowdbport',
type => 't',
default => '3306',
checker => \&check_numeric,
},
# This entry must be _after_ the shadowdb{host,port,sock} settings so that
# they can be used in the validation here
{
name => 'shadowdb',
type => 't',
default => '',
checker => \&check_shadowdb
} );
return @param_list;
{
name => 'shadowdbsock',
type => 't',
default => '',
},
# This entry must be _after_ the shadowdb{host,port,sock} settings so that
# they can be used in the validation here
{
name => 'shadowdb',
type => 't',
default => '',
checker => \&check_shadowdb
},
);
return @param_list;
}
1;

View File

@ -1,5 +1,3 @@
# -*- 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
@ -37,42 +35,43 @@ use Bugzilla::Config::Common;
our $sortkey = 1600;
sub get_param_list {
my $class = shift;
my @param_list = (
{
name => 'usemenuforusers',
type => 'b',
default => '0'
},
sub get_param_list
{
my $class = shift;
my @param_list = (
{
name => 'usemenuforusers',
type => 'b',
default => '0'
},
{
name => 'maxusermatches',
type => 't',
default => '1000',
checker => \&check_numeric
},
{
name => 'maxusermatches',
type => 't',
default => '1000',
checker => \&check_numeric
},
{
name => 'confirmuniqueusermatch',
type => 'b',
default => 1,
},
{
name => 'confirmuniqueusermatch',
type => 'b',
default => 1,
},
{
name => 'emailin_autoregister',
type => 'b',
default => 1,
},
{
name => 'emailin_autoregister',
type => 'b',
default => 1,
},
{
name => 'levenshteinusermatch',
type => 't',
default => '0',
checker => sub { $_[0] =~ /^\d+(\.\d+)?$/so ? "" : "must be a float or integer value" },
},
);
return @param_list;
{
name => 'levenshteinusermatch',
type => 't',
default => '0',
checker => sub { $_[0] =~ /^\d+(\.\d+)?$/so ? "" : "must be a float or integer value" },
},
);
return @param_list;
}
1;

View File

@ -132,7 +132,7 @@ if ($action eq 'save' && $current_module)
}
else
{
$changed = ($value eq Bugzilla->params->{$name})? 0 : 1;
$changed = ($value eq Bugzilla->params->{$name}) ? 0 : 1;
}
if ($changed)

View File

@ -108,10 +108,10 @@
[%# CONTENT PANEL %]
<form method="post" action="editparams.cgi">
[% PROCESS admin/params/common.html.tmpl panel = current_panel %]
<input type="hidden" name="section" value="[% current_panel.name FILTER html %]">
<input type="hidden" name="action" value="save">
<input type="hidden" name="token" value="[% token FILTER html %]">
<input type="submit" name="action" value="Save Changes">
<input type="hidden" name="section" value="[% current_panel.name FILTER html %]" />
<input type="hidden" name="action" value="save" />
<input type="hidden" name="token" value="[% token FILTER html %]" />
<input type="submit" value="Save Changes" />
</form>
[% END %]
</td>