Merge pull request #337 from phpmyadmin/fix-2fa-disable

security - Fix - 2FA/U2F can be disabled without any code change
This commit is contained in:
Maurício Meneghini Fauth 2022-01-13 17:07:06 -03:00 committed by GitHub
commit 13bb2e10bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1563,17 +1563,22 @@ class DatabaseInterface
*/
public function initRelationParamsCache()
{
if (strlen($GLOBALS['db'])) {
$cfgRelation = $this->relation->getRelationsParam();
if (empty($cfgRelation['db'])) {
$this->relation->fixPmaTables($GLOBALS['db'], false);
}
}
$cfgRelation = $this->relation->getRelationsParam();
if (empty($cfgRelation['db']) && isset($GLOBALS['dblist'])) {
if ($GLOBALS['dblist']->databases->exists('phpmyadmin')) {
$this->relation->fixPmaTables('phpmyadmin', false);
}
$storageDbName = $GLOBALS['cfg']['Server']['pmadb'] ?? '';
// Use "phpmyadmin" as a default database name to check to keep the behavior consistent
$storageDbName = $storageDbName !== null
&& is_string($storageDbName)
&& $storageDbName !== '' ? $storageDbName : 'phpmyadmin';
// This will make users not having explicitly listed databases
// have config values filled by the default phpMyAdmin storage table name values
$this->relation->fixPmaTables($storageDbName, false);
// This global will be changed if fixPmaTables did find one valid table
$storageDbName = $GLOBALS['cfg']['Server']['pmadb'] ?? '';
// Empty means that until now no pmadb was found eligible
if (empty($storageDbName)) {
$this->relation->fixPmaTables($GLOBALS['db'], false);
}
}