Skip to content

Commit

Permalink
Item13066: Another attempt at useful errors
Browse files Browse the repository at this point in the history
without beating up the admin.

 - Don't error an empty Password if ConfigureFilter is configured
 - Try better to only warn when a save is likely to lock out access to
   configure.
  • Loading branch information
gac410 committed Dec 2, 2014
1 parent 5242173 commit af43c40
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
21 changes: 17 additions & 4 deletions core/lib/Foswiki/Configure/Checkers/ConfigureFilter.pm
Expand Up @@ -49,10 +49,23 @@ sub check_current_value {
}
}

$reporter->WARN(
"You have not set a Pasword, your $Foswiki::cfg{SuperAdminGroup} contains no users, or your filter eliminated all users in the $Foswiki::cfg{SuperAdminGroup}.
You *Must* have a usable ID matching this filter to access configure. Do not save the configuration unless you are sure you have not locked yourself out of configure!"
) unless ( $Foswiki::cfg{Password} || scalar @filtered );
if (
(
$Foswiki::cfg{ConfigureFilter}
&& Foswiki::Func::getCanonicalUserID() !~
m/$Foswiki::cfg{ConfigureFilter}/
)
&& !$Foswiki::cfg{Password}
&& scalar @filtered < 2
)
{
$reporter->WARN(
"You have not set an admin Pasword. Your $Foswiki::cfg{SuperAdminGroup} contains no users, or your filter eliminated all users in the $Foswiki::cfg{SuperAdminGroup}
and your filter does not match your current ID "
. Foswiki::Func::getCanonicalUserID()
. ": You *Must* have a usable ID matching this filter to access configure. Do not save the configuration unless you are sure you have not locked yourself out of configure!"
);
}

}

Expand Down
21 changes: 14 additions & 7 deletions core/lib/Foswiki/Configure/Checkers/Password.pm
Expand Up @@ -26,15 +26,22 @@ sub check_current_value {

$reporter->WARN(
"$Foswiki::cfg{SuperAdminGroup} contains no users except for the super admin $Foswiki::cfg{AdminUserWikiName} ($Foswiki::cfg{AdminUserLogin}) and the sudo admin password is not set ( =\$Foswiki::cfg{Password}= )"
) if ( scalar @admins lt 2 && !$Foswiki::cfg{Password} );

$reporter->ERROR(
"The existing super admin password does not appear to be a valid password. You will be unable to access the super admin $Foswiki::cfg{AdminUserWikiName} ($Foswiki::cfg{AdminUserLogin})
using the current configuration. The password should be saved as an \"\$apr1:...\" encoded password."
)
unless ( $Foswiki::cfg{Password} =~ m/^\$apr1\$/
&& length( $Foswiki::cfg{Password} ) eq 37 );
if ( scalar @admins lt 2
&& !$Foswiki::cfg{Password}
&& !$Foswiki::cfg{ConfigureFilter} );

if (
$Foswiki::cfg{Password}
&& ( $Foswiki::cfg{Password} !~ m/^\$apr1\$/
|| length( $Foswiki::cfg{Password} ) ne 37 )
)
{
$reporter->ERROR(
"This admin password does not appear to be a valid password. You will be unable to access the super admin $Foswiki::cfg{AdminUserWikiName} ($Foswiki::cfg{AdminUserLogin})
using the current configuration. If you want to be able to use the super admin user, the password should be saved as an \"\$apr1:...\" encoded password. Show the help for more details."
);
}
}

1;
Expand Down

0 comments on commit af43c40

Please sign in to comment.