Commit 462e4d85 authored by dave%intrec.com's avatar dave%intrec.com

Fix for bug 52921: checksetup.pl fails to create database with password.

Now it won't choke on this anymore. Patch also includes a Perl 5.6 compatibility update (see bug 52921 and bug 44622 for details).
parent 4c3068ee
...@@ -95,18 +95,26 @@ ...@@ -95,18 +95,26 @@
use diagnostics; use diagnostics;
use strict; use strict;
# #
# This are the --LOCAL-- variables defined in 'localconfig' # This are the --LOCAL-- variables defined in 'localconfig'
# #
use vars qw( # Shut up misguided -w warnings about "used only once". "use vars" just
$webservergroup # doesn't work for global vars.
$db_host $db_port $db_name $db_user $db_pass $db_check sub sillyness {
@severities @priorities @opsys @platforms my $zz;
); $zz = $::webservergroup;
$zz = $::db_host;
$zz = $::db_port;
$zz = $::db_user;
$zz = $::db_name;
$zz = $::db_pass;
$zz = $::db_check;
$zz = @::severities;
$zz = @::priorities;
$zz = @::opsys;
$zz = @::platforms;
}
# Trim whitespace from front and back. # Trim whitespace from front and back.
...@@ -230,7 +238,7 @@ sub LocalVar ($$) ...@@ -230,7 +238,7 @@ sub LocalVar ($$)
# #
LocalVar('$webservergroup', ' LocalVar('$::webservergroup', '
# #
# This is the group your web server runs on. # This is the group your web server runs on.
# If you have a windows box, ignore this setting. # If you have a windows box, ignore this setting.
...@@ -243,7 +251,7 @@ $webservergroup = "nobody"; ...@@ -243,7 +251,7 @@ $webservergroup = "nobody";
LocalVar('$db_host', ' LocalVar('$::db_host', '
# #
# How to access the SQL database: # How to access the SQL database:
# #
...@@ -252,7 +260,7 @@ $db_port = 3306; # which port to use ...@@ -252,7 +260,7 @@ $db_port = 3306; # which port to use
$db_name = "bugs"; # name of the MySQL database $db_name = "bugs"; # name of the MySQL database
$db_user = "bugs"; # user to attach to the MySQL database $db_user = "bugs"; # user to attach to the MySQL database
'); ');
LocalVar('$db_pass', ' LocalVar('$::db_pass', '
# #
# Some people actually use passwords with their MySQL database ... # Some people actually use passwords with their MySQL database ...
# #
...@@ -261,7 +269,7 @@ $db_pass = ""; ...@@ -261,7 +269,7 @@ $db_pass = "";
LocalVar('$db_check', ' LocalVar('$::db_check', '
# #
# Should checksetup.pl try to check if your MySQL setup is correct? # Should checksetup.pl try to check if your MySQL setup is correct?
# (with some combinations of MySQL/Msql-mysql/Perl/moonphase this doesn\'t work) # (with some combinations of MySQL/Msql-mysql/Perl/moonphase this doesn\'t work)
...@@ -270,7 +278,7 @@ $db_check = 1; ...@@ -270,7 +278,7 @@ $db_check = 1;
'); ');
LocalVar('@severities', ' LocalVar('@::severities', '
# #
# Which bug and feature-request severities do you want? # Which bug and feature-request severities do you want?
# #
...@@ -287,7 +295,7 @@ LocalVar('@severities', ' ...@@ -287,7 +295,7 @@ LocalVar('@severities', '
LocalVar('@priorities', ' LocalVar('@::priorities', '
# #
# Which priorities do you want to assign to bugs and feature-request? # Which priorities do you want to assign to bugs and feature-request?
# #
...@@ -302,7 +310,7 @@ LocalVar('@priorities', ' ...@@ -302,7 +310,7 @@ LocalVar('@priorities', '
LocalVar('@opsys', ' LocalVar('@::opsys', '
# #
# What operatings systems may your products run on? # What operatings systems may your products run on?
# #
...@@ -342,7 +350,7 @@ LocalVar('@opsys', ' ...@@ -342,7 +350,7 @@ LocalVar('@opsys', '
LocalVar('@platforms', ' LocalVar('@::platforms', '
# #
# What hardware platforms may your products run on? # What hardware platforms may your products run on?
# #
...@@ -385,7 +393,7 @@ if ($newstuff ne "") { ...@@ -385,7 +393,7 @@ if ($newstuff ne "") {
unless (-d 'data') { unless (-d 'data') {
print "Creating data directory ...\n"; print "Creating data directory ...\n";
mkdir 'data', 0770; mkdir 'data', 0770;
if ($webservergroup eq "") { if ($::webservergroup eq "") {
chmod 0777, 'data'; chmod 0777, 'data';
} }
open FILE, '>>data/comments'; close FILE; open FILE, '>>data/comments'; close FILE;
...@@ -454,10 +462,10 @@ sub isExecutableFile { ...@@ -454,10 +462,10 @@ sub isExecutableFile {
return undef; return undef;
} }
if ($webservergroup) { if ($::webservergroup) {
mkdir 'shadow', 0770 unless -d 'shadow'; mkdir 'shadow', 0770 unless -d 'shadow';
# Funny! getgrname returns the GID if fed with NAME ... # Funny! getgrname returns the GID if fed with NAME ...
my $webservergid = getgrnam($webservergroup); my $webservergid = getgrnam($::webservergroup);
# chmod needs to be called with a valid uid, not 0. $< returns the # chmod needs to be called with a valid uid, not 0. $< returns the
# caller's uid. Maybe there should be a $bugzillauid, and call with that # caller's uid. Maybe there should be a $bugzillauid, and call with that
# userid. # userid.
...@@ -502,17 +510,21 @@ use DBI; ...@@ -502,17 +510,21 @@ use DBI;
my $drh = DBI->install_driver($db_base) my $drh = DBI->install_driver($db_base)
or die "Can't connect to the $db_base. Is the database installed and up and running?\n"; or die "Can't connect to the $db_base. Is the database installed and up and running?\n";
if ($db_check) { if ($::db_check) {
# Do we have the database itself? # Do we have the database itself?
my $dsn = "DBI:$db_base:$db_name;$db_host;$db_port"; # original DSN line was:
my $dbh = DBI->connect($dsn, $db_user, $db_pass); # my $dsn = "DBI:$db_base:$::db_name;$::db_host;$::db_port";
# removed the $db_name because we don't know it exists yet, and this will
# fail if we request it here and it doesn't. - dave@intrec.com 2000/09/16
my $dsn = "DBI:$db_base:;$::db_host;$::db_port";
my $dbh = DBI->connect($dsn, $::db_user, $::db_pass);
my @databases = $dbh->func('_ListDBs'); my @databases = $dbh->func('_ListDBs');
unless (grep /^$db_name$/, @databases) { unless (grep /^$::db_name$/, @databases) {
print "Creating database $db_name ...\n"; print "Creating database $::db_name ...\n";
$drh->func('createdb', $db_name, "$db_host:$db_port", $db_user, $db_pass, 'admin') $drh->func('createdb', $::db_name, "$::db_host:$::db_port", $::db_user, $::db_pass, 'admin')
or die <<"EOF" or die <<"EOF"
The '$db_name' database is not accessible. This might have several reasons: The '$::db_name' database is not accessible. This might have several reasons:
* MySQL is not running. * MySQL is not running.
* MySQL is running, but the rights are not set correct. Go and read the * MySQL is running, but the rights are not set correct. Go and read the
...@@ -526,10 +538,10 @@ EOF ...@@ -526,10 +538,10 @@ EOF
} }
# now get a handle to the database: # now get a handle to the database:
my $connectstring = "dbi:$db_base:$db_name:host=$db_host:port=$db_port"; my $connectstring = "dbi:$db_base:$::db_name:host=$::db_host:port=$::db_port";
my $dbh = DBI->connect($connectstring, $db_user, $db_pass) my $dbh = DBI->connect($connectstring, $::db_user, $::db_pass)
or die "Can't connect to the table '$connectstring'.\n", or die "Can't connect to the table '$connectstring'.\n",
"Have you read Bugzilla's README? Have you read the doc of '$db_name'?\n"; "Have you read Bugzilla's README? Have you read the doc of '$::db_name'?\n";
END { $dbh->disconnect if $dbh } END { $dbh->disconnect if $dbh }
...@@ -840,10 +852,10 @@ my @tables = $dbh->func('_ListTables'); ...@@ -840,10 +852,10 @@ my @tables = $dbh->func('_ListTables');
# add lines here if you add more --LOCAL-- config vars that end up in the enums: # add lines here if you add more --LOCAL-- config vars that end up in the enums:
my $severities = '"' . join('", "', @severities) . '"'; my $severities = '"' . join('", "', @::severities) . '"';
my $priorities = '"' . join('", "', @priorities) . '"'; my $priorities = '"' . join('", "', @::priorities) . '"';
my $opsys = '"' . join('", "', @opsys) . '"'; my $opsys = '"' . join('", "', @::opsys) . '"';
my $platforms = '"' . join('", "', @platforms) . '"'; my $platforms = '"' . join('", "', @::platforms) . '"';
# go throught our %table hash and create missing tables # go throught our %table hash and create missing tables
while (my ($tabname, $fielddef) = each %table) { while (my ($tabname, $fielddef) = each %table) {
...@@ -1137,10 +1149,10 @@ sub CheckEnumField ($$@) ...@@ -1137,10 +1149,10 @@ sub CheckEnumField ($$@)
# are ignored. # are ignored.
# #
CheckEnumField('bugs', 'bug_severity', @severities); CheckEnumField('bugs', 'bug_severity', @::severities);
CheckEnumField('bugs', 'priority', @priorities); CheckEnumField('bugs', 'priority', @::priorities);
CheckEnumField('bugs', 'op_sys', @opsys); CheckEnumField('bugs', 'op_sys', @::opsys);
CheckEnumField('bugs', 'rep_platform', @platforms); CheckEnumField('bugs', 'rep_platform', @::platforms);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment