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
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.
Now, bring up MySQL, and add yourself to every group. This will
effectively make you 'superuser'. The SQL to type is:
Now, add yourself to every group. The magic checksetup.pl script can do
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';
......
......@@ -46,6 +46,8 @@
# - automatically changes the table definitions of older BugZilla
# installations
# - 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
# settings, e.g. when you add a new platform
#
......@@ -78,7 +80,6 @@
###########################################################################
# Global definitions
###########################################################################
......@@ -356,6 +357,7 @@ unless (-d 'data') {
chmod 0666, glob('data/*');
}
# Just to be sure ...
unlink "data/versioncache";
......@@ -380,10 +382,8 @@ unlink "data/versioncache";
# +++ Can anybody tell me what a Windows Perl would do with this code?
#
# Funny! getgrname returns the GID if fed with NAME ...
if ($webservergroup ne "") {
if ($webservergroup) {
# Funny! getgrname returns the GID if fed with NAME ...
my $webservergid = getgrnam($webservergroup);
chown 0, $webservergid, glob('*');
chmod 0640, glob('*');
......@@ -393,6 +393,9 @@ if ($webservergroup ne "") {
'whineatnews.pl',
'collectstats.pl',
'checksetup.pl';
chmod 0770, 'data';
chmod 0666, glob('data/*');
}
......@@ -407,7 +410,8 @@ if ($webservergroup ne "") {
# 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_pass = ''; # Password to attach to the MySQL database
......@@ -429,8 +433,6 @@ unless (grep /^$db_name$/, @databases) {
"set up correctly.\n";
}
# now get a handle to the database:
my $connectstring = "dbi:$db_base:$db_name:host=$db_host:port=$db_port";
my $dbh = DBI->connect($connectstring, $db_user, $db_pass)
......@@ -601,6 +603,7 @@ $table{products} =
disallownew tinyint not null,
votesperuser smallint not null';
$table{profiles} =
'userid mediumint not null auto_increment primary key,
login_name varchar(255) not null,
......@@ -640,6 +643,8 @@ $table{votes} =
my @tables = $dbh->func('_ListTables');
#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 $priorities = '"' . join('", "', @priorities) . '"';
my $opsys = '"' . join('", "', @opsys) . '"';
......@@ -649,6 +654,10 @@ my $platforms = '"' . join('", "', @platforms) . '"';
while (my ($tabname, $fielddef) = each %table) {
next if grep /^$tabname$/, @tables;
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/\$priorities/$priorities/;
$fielddef =~ s/\$opsys/$opsys/;
......@@ -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 'creategroups', 'Can create and destroy groups.';
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.';
my $sth = $dbh->prepare("SELECT product FROM products");
$sth->execute;
if ($sth->rows == 0) {
unless ($sth->rows) {
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.")');
$sth->execute();
$sth = $dbh->prepare('INSERT INTO versions (value, program) VALUES ("other", "TestProduct")');
$sth->execute();
$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.")');
$sth->execute();
$dbh->do('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 versions (value, program) VALUES ("other", "TestProduct")');
$dbh->do('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.")');
}
###########################################################################
# Detect changed local settings
###########################################################################
......@@ -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
###########################################################################
......@@ -861,7 +898,8 @@ sub DropField ($$)
# 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:
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