Commit 2899c8bf authored by terry%mozilla.org's avatar terry%mozilla.org

Patch by Holger Schurig <holger@holger.om.org> -- If there is no exactly ONE

user in the profiles table, then this user will be promoted into all groups.
parent 7404b977
...@@ -287,8 +287,12 @@ web browser!). You'll be prompted for logon info, and you should enter your ...@@ -287,8 +287,12 @@ web browser!). You'll be prompted for logon info, and you should enter your
email address and then select 'mail me my password'. When you get the password email address and then select 'mail me my password'. When you get the password
mail, log in with it. Don't finish entering that new bug. mail, log in with it. Don't finish entering that new bug.
Now, bring up MySQL, and add yourself to every group. This will Now, add yourself to every group. The magic checksetup.pl script can do
effectively make you 'superuser'. The SQL to type is: this for you, if you run it again now. That script will notice if there's
exactly one user in the database, and if so, add that person to every group.
If you want to add someone to every group by hand, you can do it by
typing the appropriate MySQL commands. Run mysql, and type:
update profiles set groupset=0x7fffffffffffffff where login_name = 'XXX'; update profiles set groupset=0x7fffffffffffffff where login_name = 'XXX';
......
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
# - automatically changes the table definitions of older BugZilla # - automatically changes the table definitions of older BugZilla
# installations # installations
# - populates the groups # - populates the groups
# - put the first user into all groups so that the system can
# be administrated
# - changes already existing SQL tables if you change your local # - changes already existing SQL tables if you change your local
# settings, e.g. when you add a new platform # settings, e.g. when you add a new platform
# #
...@@ -78,7 +80,6 @@ ...@@ -78,7 +80,6 @@
########################################################################### ###########################################################################
# Global definitions # Global definitions
########################################################################### ###########################################################################
...@@ -95,7 +96,7 @@ use strict; ...@@ -95,7 +96,7 @@ use strict;
use vars qw( use vars qw(
$webservergroup $webservergroup
$db_host $db_port $db_name $db_user $db_host $db_port $db_name $db_user
@severities @priorities @opsys @platforms @severities @priorities @opsys @platforms
); );
...@@ -117,27 +118,27 @@ unless (eval "require 5.004") { ...@@ -117,27 +118,27 @@ unless (eval "require 5.004") {
unless (eval "require DBI") { unless (eval "require DBI") {
die "Please install the DBI module. You can do this by running (as root)\n\n", die "Please install the DBI module. You can do this by running (as root)\n\n",
" perl -MCPAN -eshell\n", " perl -MCPAN -eshell\n",
" install DBI\n"; " install DBI\n";
} }
unless (eval "require Data::Dumper") { unless (eval "require Data::Dumper") {
die "Please install the Data::Dumper module. You can do this by running (as root)\n\n", die "Please install the Data::Dumper module. You can do this by running (as root)\n\n",
" perl -MCPAN -eshell\n", " perl -MCPAN -eshell\n",
" install Data::Dumper\n"; " install Data::Dumper\n";
} }
unless (eval "require Mysql") { unless (eval "require Mysql") {
die "Please install the Mysql database driver. You can do this by running (as root)\n\n", die "Please install the Mysql database driver. You can do this by running (as root)\n\n",
" perl -MCPAN -eshell\n", " perl -MCPAN -eshell\n",
" install Msql-Mysql\n\n", " install Msql-Mysql\n\n",
"Be sure to enable the Mysql emulation!"; "Be sure to enable the Mysql emulation!";
} }
unless (eval "require Date::Parse") { unless (eval "require Date::Parse") {
die "Please install the Date::Parse module. You can do this by running (as root)\n\n", die "Please install the Date::Parse module. You can do this by running (as root)\n\n",
" perl -MCPAN -eshell\n", " perl -MCPAN -eshell\n",
" install Date::Parse\n"; " install Date::Parse\n";
} }
# The following two modules are optional: # The following two modules are optional:
...@@ -229,10 +230,10 @@ LocalVar('$db_host', ' ...@@ -229,10 +230,10 @@ LocalVar('$db_host', '
# #
# How to access the SQL database: # How to access the SQL database:
# #
$db_host = "localhost"; # where is the database? $db_host = "localhost"; # where is the database?
$db_port = 3306; # which port to use $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
'); ');
...@@ -242,13 +243,13 @@ LocalVar('@severities', ' ...@@ -242,13 +243,13 @@ LocalVar('@severities', '
# Which bug and feature-request severities do you want? # Which bug and feature-request severities do you want?
# #
@severities = ( @severities = (
"blocker", "blocker",
"critical", "critical",
"major", "major",
"normal", "normal",
"minor", "minor",
"trivial", "trivial",
"enhancement" "enhancement"
); );
'); ');
...@@ -259,11 +260,11 @@ LocalVar('@priorities', ' ...@@ -259,11 +260,11 @@ 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?
# #
@priorities = ( @priorities = (
"P1", "P1",
"P2", "P2",
"P3", "P3",
"P4", "P4",
"P5" "P5"
); );
'); ');
...@@ -274,31 +275,31 @@ LocalVar('@opsys', ' ...@@ -274,31 +275,31 @@ LocalVar('@opsys', '
# What operatings systems may your products run on? # What operatings systems may your products run on?
# #
@opsys = ( @opsys = (
"All", "All",
"Windows 3.1", "Windows 3.1",
"Windows 95", "Windows 95",
"Windows 98", "Windows 98",
"Windows NT", "Windows NT",
"Mac System 7", "Mac System 7",
"Mac System 7.5", "Mac System 7.5",
"Mac System 7.6.1", "Mac System 7.6.1",
"Mac System 8.0", "Mac System 8.0",
"Mac System 8.5", "Mac System 8.5",
"Mac System 8.6", "Mac System 8.6",
"AIX", "AIX",
"BSDI", "BSDI",
"HP-UX", "HP-UX",
"IRIX", "IRIX",
"Linux", "Linux",
"FreeBSD", "FreeBSD",
"OSF/1", "OSF/1",
"Solaris", "Solaris",
"SunOS", "SunOS",
"Neutrino", "Neutrino",
"OS/2", "OS/2",
"BeOS", "BeOS",
"OpenVMS", "OpenVMS",
"other" "other"
); );
'); ');
...@@ -309,14 +310,14 @@ LocalVar('@platforms', ' ...@@ -309,14 +310,14 @@ LocalVar('@platforms', '
# What hardware platforms may your products run on? # What hardware platforms may your products run on?
# #
@platforms = ( @platforms = (
"All", "All",
"DEC", "DEC",
"HP", "HP",
"Macintosh", "Macintosh",
"PC", "PC",
"SGI", "SGI",
"Sun", "Sun",
"Other" "Other"
); );
'); ');
...@@ -325,10 +326,10 @@ LocalVar('@platforms', ' ...@@ -325,10 +326,10 @@ LocalVar('@platforms', '
if ($newstuff ne "") { if ($newstuff ne "") {
print "This version of Bugzilla contains some variables that you may \n", print "This version of Bugzilla contains some variables that you may \n",
"to change and adapt to your local settings. Please edit the file\n", "to change and adapt to your local settings. Please edit the file\n",
"'localconfig' and return checksetup.pl\n\n", "'localconfig' and return checksetup.pl\n\n",
"The following variables are new to localconfig since you last ran\n", "The following variables are new to localconfig since you last ran\n",
"checksetup.pl: $newstuff\n"; "checksetup.pl: $newstuff\n";
exit; exit;
} }
...@@ -347,15 +348,16 @@ if ($newstuff ne "") { ...@@ -347,15 +348,16 @@ 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;
open FILE, '>>data/nomail'; close FILE; open FILE, '>>data/nomail'; close FILE;
open FILE, '>>data/mail'; close FILE; open FILE, '>>data/mail'; close FILE;
chmod 0666, glob('data/*'); chmod 0666, glob('data/*');
} }
# Just to be sure ... # Just to be sure ...
unlink "data/versioncache"; unlink "data/versioncache";
...@@ -380,19 +382,20 @@ unlink "data/versioncache"; ...@@ -380,19 +382,20 @@ unlink "data/versioncache";
# +++ Can anybody tell me what a Windows Perl would do with this code? # +++ Can anybody tell me what a Windows Perl would do with this code?
# #
if ($webservergroup) {
# Funny! getgrname returns the GID if fed with NAME ...
my $webservergid = getgrnam($webservergroup);
chown 0, $webservergid, glob('*');
chmod 0640, glob('*');
# Funny! getgrname returns the GID if fed with NAME ... chmod 0750, glob('*.cgi'),
'processmail',
'whineatnews.pl',
'collectstats.pl',
'checksetup.pl';
if ($webservergroup ne "") { chmod 0770, 'data';
my $webservergid = getgrnam($webservergroup); chmod 0666, glob('data/*');
chown 0, $webservergid, glob('*');
chmod 0640, glob('*');
chmod 0750, glob('*.cgi'),
'processmail',
'whineatnews.pl',
'collectstats.pl',
'checksetup.pl';
} }
...@@ -407,10 +410,11 @@ if ($webservergroup ne "") { ...@@ -407,10 +410,11 @@ if ($webservergroup ne "") {
# Check if we have access to --MYSQL-- # Check if we have access to --MYSQL--
# #
# This settings are not yet changeable, because other code depends on it: # This settings are not yet changeable, because other code depends on
# the fact that we use MySQL and not, say, PostgreSQL.
my $db_base = 'mysql'; my $db_base = 'mysql';
my $db_pass = ''; # Password to attach to the MySQL database my $db_pass = ''; # Password to attach to the MySQL database
use DBI; use DBI;
...@@ -423,19 +427,17 @@ my @databases = $drh->func($db_host, $db_port, '_ListDBs'); ...@@ -423,19 +427,17 @@ my @databases = $drh->func($db_host, $db_port, '_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, 'admin') $drh->func('createdb', $db_name, 'admin')
or die "The '$db_name' database does not exist. I tried to create the database,\n", or die "The '$db_name' database does not exist. I tried to create the database,\n",
"but that didn't work, probably because of access rigths. Read the README\n", "but that didn't work, probably because of access rigths. Read the README\n",
"file and the documentation of $db_base to make sure that everything is\n", "file and the documentation of $db_base to make sure that everything is\n",
"set up correctly.\n"; "set up correctly.\n";
} }
# 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 }
...@@ -549,7 +551,7 @@ $table{cc} = ...@@ -549,7 +551,7 @@ $table{cc} =
$table{components} = $table{components} =
'value tinytext, 'value tinytext,
program varchar(64), program varchar(64),
initialowner tinytext not null, # Should arguably be a mediumint! initialowner tinytext not null, # Should arguably be a mediumint!
initialqacontact tinytext not null, # Should arguably be a mediumint! initialqacontact tinytext not null, # Should arguably be a mediumint!
description mediumtext not null'; description mediumtext not null';
...@@ -601,6 +603,7 @@ $table{products} = ...@@ -601,6 +603,7 @@ $table{products} =
disallownew tinyint not null, disallownew tinyint not null,
votesperuser smallint not null'; votesperuser smallint not null';
$table{profiles} = $table{profiles} =
'userid mediumint not null auto_increment primary key, 'userid mediumint not null auto_increment primary key,
login_name varchar(255) not null, login_name varchar(255) not null,
...@@ -640,6 +643,8 @@ $table{votes} = ...@@ -640,6 +643,8 @@ $table{votes} =
my @tables = $dbh->func('_ListTables'); my @tables = $dbh->func('_ListTables');
#print 'Tables: ', join " ", @tables, "\n"; #print 'Tables: ', join " ", @tables, "\n";
# 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) . '"';
...@@ -649,13 +654,17 @@ my $platforms = '"' . join('", "', @platforms) . '"'; ...@@ -649,13 +654,17 @@ my $platforms = '"' . join('", "', @platforms) . '"';
while (my ($tabname, $fielddef) = each %table) { while (my ($tabname, $fielddef) = each %table) {
next if grep /^$tabname$/, @tables; next if grep /^$tabname$/, @tables;
print "Creating table $tabname ...\n"; print "Creating table $tabname ...\n";
# add lines here if you add more --LOCAL-- config vars that end up in
# the enums:
$fielddef =~ s/\$severities/$severities/; $fielddef =~ s/\$severities/$severities/;
$fielddef =~ s/\$priorities/$priorities/; $fielddef =~ s/\$priorities/$priorities/;
$fielddef =~ s/\$opsys/$opsys/; $fielddef =~ s/\$opsys/$opsys/;
$fielddef =~ s/\$platforms/$platforms/; $fielddef =~ s/\$platforms/$platforms/;
$dbh->do("CREATE TABLE $tabname (\n$fielddef\n)") $dbh->do("CREATE TABLE $tabname (\n$fielddef\n)")
or die "Could not create table '$tabname'. Please check your '$db_base' access.\n"; or die "Could not create table '$tabname'. Please check your '$db_base' access.\n";
} }
...@@ -688,16 +697,16 @@ sub AddGroup ($$) ...@@ -688,16 +697,16 @@ sub AddGroup ($$)
# normalize bits # normalize bits
my $bit; my $bit;
if (defined $row[0]) { if (defined $row[0]) {
$bit = $row[0] << 1; $bit = $row[0] << 1;
} else { } else {
$bit = 1; $bit = 1;
} }
print "Adding group $name ...\n"; print "Adding group $name ...\n";
$sth = $dbh->prepare('INSERT INTO groups $sth = $dbh->prepare('INSERT INTO groups
(bit, name, description, userregexp) (bit, name, description, userregexp)
VALUES (?, ?, ?, ?)'); VALUES (?, ?, ?, ?)');
$sth->execute($bit, $name, $desc, ""); $sth->execute($bit, $name, $desc, "");
} }
...@@ -710,7 +719,9 @@ AddGroup 'tweakparams', 'Can tweak operating parameters'; ...@@ -710,7 +719,9 @@ AddGroup 'tweakparams', 'Can tweak operating parameters';
AddGroup 'editgroupmembers', 'Can put people in and out of groups that they are members of.'; AddGroup 'editgroupmembers', 'Can put people in and out of groups that they are members of.';
AddGroup 'creategroups', 'Can create and destroy groups.'; AddGroup 'creategroups', 'Can create and destroy groups.';
AddGroup 'editcomponents', 'Can create, destroy, and edit components.'; AddGroup 'editcomponents', 'Can create, destroy, and edit components.';
#AddGroup 'editproducts', 'Can create, destroy, and edit products.';
########################################################################### ###########################################################################
...@@ -719,21 +730,22 @@ AddGroup 'editcomponents', 'Can create, destroy, and edit components.'; ...@@ -719,21 +730,22 @@ AddGroup 'editcomponents', 'Can create, destroy, and edit components.';
my $sth = $dbh->prepare("SELECT product FROM products"); my $sth = $dbh->prepare("SELECT product FROM products");
$sth->execute; $sth->execute;
if ($sth->rows == 0) { unless ($sth->rows) {
print "Creating initial dummy product 'TestProduct' ...\n"; print "Creating initial dummy product 'TestProduct' ...\n";
$sth = $dbh->prepare('INSERT INTO products(product, description) VALUES ("TestProduct", "This is a test product. This ought to be blown away and replaced with real stuff in a finished installation of bugzilla.")'); $dbh->do('INSERT INTO products(product, description) VALUES ("TestProduct",
$sth->execute(); "This is a test product. This ought to be blown away and replaced with " .
$sth = $dbh->prepare('INSERT INTO versions (value, program) VALUES ("other", "TestProduct")'); "real stuff in a finished installation of bugzilla.")');
$sth->execute(); $dbh->do('INSERT INTO versions (value, program) VALUES ("other", "TestProduct")');
$sth = $dbh->prepare('INSERT INTO components (value, program, description) VALUES ("TestComponent", "TestProduct", "This is a test component in the test product database. This ought to be blown away and replaced with real stuff in a finished installation of bugzilla.")'); $dbh->do('INSERT INTO components (value, program, description) VALUES ("TestComponent",
$sth->execute(); "TestProduct", "This is a test component in the test product database. " .
"This ought to be blown away and replaced with real stuff in a finished " .
"installation of bugzilla.")');
} }
########################################################################### ###########################################################################
# Detect changed local settings # Detect changed local settings
########################################################################### ###########################################################################
...@@ -753,7 +765,7 @@ sub GetFieldDef ($$) ...@@ -753,7 +765,7 @@ sub GetFieldDef ($$)
while (my $ref = $sth->fetchrow_arrayref) { while (my $ref = $sth->fetchrow_arrayref) {
next if $$ref[0] ne $field; next if $$ref[0] ne $field;
return $ref; return $ref;
} }
} }
sub CheckEnumField ($$@) sub CheckEnumField ($$@)
...@@ -762,7 +774,7 @@ sub CheckEnumField ($$@) ...@@ -762,7 +774,7 @@ sub CheckEnumField ($$@)
my $ref = GetFieldDef($table, $field); my $ref = GetFieldDef($table, $field);
#print "0: $$ref[0] 1: $$ref[1] 2: $$ref[2] 3: $$ref[3] 4: $$ref[4]\n"; #print "0: $$ref[0] 1: $$ref[1] 2: $$ref[2] 3: $$ref[3] 4: $$ref[4]\n";
$_ = "enum('" . join("','", @against) . "')"; $_ = "enum('" . join("','", @against) . "')";
if ($$ref[1] ne $_) { if ($$ref[1] ne $_) {
print "Updating field $field in table $table ...\n"; print "Updating field $field in table $table ...\n";
...@@ -790,6 +802,31 @@ CheckEnumField('bugs', 'rep_platform', @platforms); ...@@ -790,6 +802,31 @@ CheckEnumField('bugs', 'rep_platform', @platforms);
########################################################################### ###########################################################################
# Promote first user into every group
###########################################################################
#
# Assume you just logged in. Now how can you administrate the system? Just
# execute checksetup.pl again. If there is only 1 user in bugzilla, then
# this user is promoted into every group.
#
$sth = $dbh->prepare("SELECT login_name FROM profiles");
$sth->execute;
# when we have exactly one user ...
if ($sth->rows == 1) {
my @row = $sth->fetchrow_array;
print "Putting user $row[0] into every group ...\n";
# are this enought f's for now? :-)
$dbh->do("update profiles set groupset=0xffffffffffff");
}
###########################################################################
# Update the tables to the current definition # Update the tables to the current definition
########################################################################### ###########################################################################
...@@ -819,7 +856,7 @@ sub RenameField ($$$) ...@@ -819,7 +856,7 @@ sub RenameField ($$$)
my ($table, $field, $newname) = @_; my ($table, $field, $newname) = @_;
my $ref = GetFieldDef($table, $field); my $ref = GetFieldDef($table, $field);
return unless $ref; # already fixed? return unless $ref; # already fixed?
#print "0: $$ref[0] 1: $$ref[1] 2: $$ref[2] 3: $$ref[3] 4: $$ref[4]\n"; #print "0: $$ref[0] 1: $$ref[1] 2: $$ref[2] 3: $$ref[3] 4: $$ref[4]\n";
if ($$ref[1] ne $newname) { if ($$ref[1] ne $newname) {
...@@ -861,7 +898,8 @@ sub DropField ($$) ...@@ -861,7 +898,8 @@ sub DropField ($$)
# 5/12/99 Added a pref to control how much email you get. This needs a new # 5/12/99 Added a pref to control how much email you get. This needs a new
# column in the profiles table, so feed the following to mysql: # column in the profiles table, so feed the following to mysql:
AddField('profiles', 'emailnotification', 'enum("ExcludeSelfChanges", "CConly", "All") not null default "ExcludeSelfChanges"'); AddField('profiles', 'emailnotification', 'enum("ExcludeSelfChanges", "CConly",
"All") not null default "ExcludeSelfChanges"');
......
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