[Rt-commit] r11211 - in rt/branches/3.8-TESTING: etc
ruz at bestpractical.com
ruz at bestpractical.com
Wed Mar 26 18:18:50 EDT 2008
Author: ruz
Date: Wed Mar 26 18:18:49 2008
New Revision: 11211
Modified:
rt/branches/3.8-TESTING/etc/initialdata
rt/branches/3.8-TESTING/lib/RT/Handle.pm
Log:
* move all system must have objects from initialdata to RT::Handle
and make that code safe and re-entrant
Modified: rt/branches/3.8-TESTING/etc/initialdata
==============================================================================
--- rt/branches/3.8-TESTING/etc/initialdata (original)
+++ rt/branches/3.8-TESTING/etc/initialdata Wed Mar 26 18:18:49 2008
@@ -1,19 +1,15 @@
# Initial data for a fresh RT3 Installation.
@Users = (
- { Name => 'Nobody',
- RealName => 'Nobody in particular',
- Comments => 'Do not delete or modify this user. It is integral '
- . 'to RT\'s internal data structures',
- Privileged => '0', },
-
{ Name => 'root',
Gecos => 'root',
RealName => 'Enoch Root',
Password => 'password',
EmailAddress => "root\@localhost",
Comments => 'SuperUser',
- Privileged => '1', } );
+ Privileged => '1',
+ },
+);
@Groups = (
{ Name => '',
@@ -668,9 +664,6 @@
);
@ACL = (
- { UserId => 'Nobody', # - principalId
- Right => 'OwnTicket', },
-
{ UserId => 'root', # - principalid
Right => 'SuperUser', },
Modified: rt/branches/3.8-TESTING/lib/RT/Handle.pm
==============================================================================
--- rt/branches/3.8-TESTING/lib/RT/Handle.pm (original)
+++ rt/branches/3.8-TESTING/lib/RT/Handle.pm Wed Mar 26 18:18:49 2008
@@ -519,27 +519,29 @@
require RT::CurrentUser;
my $CurrentUser = new RT::CurrentUser;
- my @warnings;
+ my @warns;
- my $test_user = RT::User->new($CurrentUser);
- $test_user->Load('RT_System');
- if ( $test_user->id ) {
- push @warns, "Found system user in the DB.";
- }
- else {
- my $user = RT::User->new( $CurrentUser );
- my ( $val, $msg ) = $user->_BootstrapCreate(
- Name => 'RT_System',
- RealName => 'The RT System itself',
- Comments => 'Do not delete or modify this user. '
- . 'It is integral to RT\'s internal database structures',
- Creator => '1',
- LastUpdatedBy => '1',
- );
- return ($val, $msg) unless $val;
- }
+ {
+ my $test_user = RT::User->new($CurrentUser);
+ $test_user->Load('RT_System');
+ if ( $test_user->id ) {
+ push @warns, "Found system user in the DB.";
+ }
+ else {
+ my $user = RT::User->new( $CurrentUser );
+ my ( $val, $msg ) = $user->_BootstrapCreate(
+ Name => 'RT_System',
+ RealName => 'The RT System itself',
+ Comments => 'Do not delete or modify this user. '
+ . 'It is integral to RT\'s internal database structures',
+ Creator => '1',
+ LastUpdatedBy => '1',
+ );
+ return ($val, $msg) unless $val;
+ }
- DBIx::SearchBuilder::Record::Cachable->FlushCache;
+ DBIx::SearchBuilder::Record::Cachable->FlushCache;
+ }
$CurrentUser = new RT::CurrentUser;
$CurrentUser->LoadByName('RT_System');
@@ -547,28 +549,72 @@
return (0, "Couldn't load system user");
}
- my $test_ace = RT::ACE->new( $CurrentUser );
- $test_ace->LoadByCols(
- PrincipalId => ACLEquivGroupId( $CurrentUser->Id ),
- PrincipalType => 'Group',
- RightName => 'SuperUser',
- ObjectType => 'RT::System',
- ObjectId => 1,
- );
- if ( $test_ace->id ) {
- push @warns, "System user has global SuperUser right.";
-
- } else {
- my $superuser_ace = RT::ACE->new( $CurrentUser );
- $superuser_ace->_BootstrapCreate(
+ {
+ my $test_ace = RT::ACE->new( $CurrentUser );
+ $test_ace->LoadByCols(
PrincipalId => ACLEquivGroupId( $CurrentUser->Id ),
PrincipalType => 'Group',
RightName => 'SuperUser',
ObjectType => 'RT::System',
ObjectId => 1,
);
+ if ( $test_ace->id ) {
+ push @warns, "System user has global SuperUser right.";
+
+ } else {
+ my $superuser_ace = RT::ACE->new( $CurrentUser );
+ $superuser_ace->_BootstrapCreate(
+ PrincipalId => ACLEquivGroupId( $CurrentUser->Id ),
+ PrincipalType => 'Group',
+ RightName => 'SuperUser',
+ ObjectType => 'RT::System',
+ ObjectId => 1,
+ );
+ }
+ DBIx::SearchBuilder::Record::Cachable->FlushCache;
+ }
+
+ # nobody
+ {
+ my $user = RT::User->new( $CurrentUser );
+ $user->Load('Nobody');
+ if ( $user->id ) {
+ push @warns, "Found 'Nobody' user in the DB.";
+ }
+ else {
+ $user = RT::User->new( $CurrentUser );
+ my ( $val, $msg ) = $user->_BootstrapCreate(
+ Name => 'Nobody',
+ RealName => 'Nobody in particular',
+ Comments => 'Do not delete or modify this user. It is integral '
+ .'to RT\'s internal data structures',
+ Privileged => '0',
+ );
+ return ($val, $msg) unless $val;
+ }
+
+ my $test_ace = RT::ACE->new( $CurrentUser );
+ $test_ace->LoadByCols(
+ PrincipalId => ACLEquivGroupId( $user->Id ),
+ PrincipalType => 'Group',
+ RightName => 'OwnTicket',
+ ObjectType => 'RT::System',
+ ObjectId => 1,
+ );
+ if ( $test_ace->id ) {
+ push @warns, "User 'Nobody' has global OwnTicket right.";
+ } else {
+ my $ace = RT::ACE->new( $CurrentUser );
+ my ( $val, $msg ) = $ace->_BootstrapCreate(
+ PrincipalId => ACLEquivGroupId( $user->Id ),
+ PrincipalType => 'Group',
+ RightName => 'OwnTicket',
+ ObjectType => 'RT::System',
+ ObjectId => 1,
+ );
+ return ($val, $msg) unless $val;
+ }
}
- DBIx::SearchBuilder::Record::Cachable->FlushCache;
push @warns, "You appear to have a functional RT database."
if @warns;
More information about the Rt-commit
mailing list