Skip to content

Commit

Permalink
Item12952: Improve behavior of bootstrap mode.
Browse files Browse the repository at this point in the history
Make admin decisions based upon isBOOTSTRAP as early in execution as
possible, so that later changes to isBOOTSTRAP are not recognized.

By setting admin user early, it "sticks" when the initial foswiki
session is created.  This leaves the user logged in as admin after the
initial configuration is saved, so that they have a chance to make
changes to AdminGroup without getting locked out.
  • Loading branch information
gac410 committed Sep 13, 2014
1 parent 1eecf96 commit a07393b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 9 additions & 1 deletion core/lib/Foswiki.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1768,6 +1768,11 @@ sub new {
ASSERT( !$query || UNIVERSAL::isa( $query, 'Foswiki::Request' ) )
if DEBUG;

# Override user to be admin if no configuration exists.
# Do this really early, so that later changes in isBOOTSTRAPPING can't change
# Foswiki's behavior.
$defaultUser = 'admin' if ( $Foswiki::cfg{isBOOTSTRAPPING} );

unless ( defined $Foswiki::cfg{TempfileDir} && $Foswiki::cfg{TempfileDir} )
{

Expand Down Expand Up @@ -2107,8 +2112,11 @@ sub new {

#Monitor::MARK("Preferences all set up");

# Set both isadmin and authenticated contexts. If the current user
# is admin, then they either authenticated, or we are in bootstrap.
if ( $this->{users}->isAdmin( $this->{user} ) ) {
$this->{context}{isadmin} = 1;
$this->{context}{authenticated} = 1;
$this->{context}{isadmin} = 1;
}

# Finish plugin initialization - register handlers
Expand Down
3 changes: 0 additions & 3 deletions core/lib/Foswiki/Users.pm
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,6 @@ True if the user is an admin
sub isAdmin {
my ( $this, $cUID ) = @_;

# If bootstrapping the configuration, always admin
return 1 if $Foswiki::cfg{isBOOTSTRAPPING};

return 0 unless defined $cUID;

return $this->{isAdmin}->{$cUID}
Expand Down

0 comments on commit a07393b

Please sign in to comment.