Merge branch 'master' into master-security
This commit is contained in:
commit
9c8f537a23
@ -1470,17 +1470,21 @@ class DbQbe
|
||||
// Of course we only want to check each table once
|
||||
$checked_tables = $candidate_columns;
|
||||
$tsize = array();
|
||||
$csize = array();
|
||||
$maxsize = -1;
|
||||
$result = '';
|
||||
foreach ($candidate_columns as $table) {
|
||||
if ($checked_tables[$table] != 1) {
|
||||
$_table = new Table($table, $this->_db);
|
||||
$tsize[$table] = $_table->countRecords();
|
||||
$checked_tables[$table] = 1;
|
||||
}
|
||||
$csize[$table] = $tsize[$table];
|
||||
if ($tsize[$table] > $maxsize) {
|
||||
$maxsize = $tsize[$table];
|
||||
$result = $table;
|
||||
}
|
||||
}
|
||||
// Return largest table
|
||||
return array_search(max($csize), $csize);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -586,26 +586,26 @@ function PMA_AdjustPrivileges_moveDB($oldDb, $newname)
|
||||
|
||||
// For Db specific privileges
|
||||
$query_db_specific = 'UPDATE ' . Util::backquote('db')
|
||||
. 'SET Db = "' . $newname
|
||||
. '" where Db = "' . $oldDb . '";';
|
||||
. 'SET Db = \'' . Util::sqlAddSlashes($newname)
|
||||
. '\' where Db = \'' . Util::sqlAddSlashes($oldDb) . '\';';
|
||||
$GLOBALS['dbi']->query($query_db_specific);
|
||||
|
||||
// For table specific privileges
|
||||
$query_table_specific = 'UPDATE ' . Util::backquote('tables_priv')
|
||||
. 'SET Db = "' . $newname
|
||||
. '" where Db = "' . $oldDb . '";';
|
||||
. 'SET Db = \'' . Util::sqlAddSlashes($newname)
|
||||
. '\' where Db = \'' . Util::sqlAddSlashes($oldDb) . '\';';
|
||||
$GLOBALS['dbi']->query($query_table_specific);
|
||||
|
||||
// For column specific privileges
|
||||
$query_col_specific = 'UPDATE ' . Util::backquote('columns_priv')
|
||||
. 'SET Db = "' . $newname
|
||||
. '" where Db = "' . $oldDb . '";';
|
||||
. 'SET Db = \'' . Util::sqlAddSlashes($newname)
|
||||
. '\' where Db = \'' . Util::sqlAddSlashes($oldDb) . '\';';
|
||||
$GLOBALS['dbi']->query($query_col_specific);
|
||||
|
||||
// For procedures specific privileges
|
||||
$query_proc_specific = 'UPDATE ' . Util::backquote('procs_priv')
|
||||
. 'SET Db = "' . $newname
|
||||
. '" where Db = "' . $oldDb . '";';
|
||||
. 'SET Db = \'' . Util::sqlAddSlashes($newname)
|
||||
. '\' where Db = \'' . Util::sqlAddSlashes($oldDb) . '\';';
|
||||
$GLOBALS['dbi']->query($query_proc_specific);
|
||||
|
||||
// Finally FLUSH the new privileges
|
||||
@ -1941,16 +1941,16 @@ function PMA_AdjustPrivileges_renameOrMoveTable($oldDb, $oldTable, $newDb, $newT
|
||||
|
||||
// For table specific privileges
|
||||
$query_table_specific = 'UPDATE ' . Util::backquote('tables_priv')
|
||||
. 'SET Db = "' . $newDb . '", Table_name = "' . $newTable
|
||||
. '" where Db = "' . $oldDb . '" AND Table_name = "' . $oldTable
|
||||
. '";';
|
||||
. 'SET Db = \'' . Util::sqlAddSlashes($newDb) . '\', Table_name = \'' . Util::sqlAddSlashes($newTable)
|
||||
. '\' where Db = \'' . Util::sqlAddSlashes($oldDb) . '\' AND Table_name = \'' . Util::sqlAddSlashes($oldTable)
|
||||
. '\';';
|
||||
$GLOBALS['dbi']->query($query_table_specific);
|
||||
|
||||
// For column specific privileges
|
||||
$query_col_specific = 'UPDATE ' . Util::backquote('columns_priv')
|
||||
. 'SET Db = "' . $newDb . '", Table_name = "' . $newTable
|
||||
. '" where Db = "' . $oldDb . '" AND Table_name = "' . $oldTable
|
||||
. '";';
|
||||
. 'SET Db = \'' . Util::sqlAddSlashes($newDb) . '\', Table_name = \'' . Util::sqlAddSlashes($newTable)
|
||||
. '\' where Db = \'' . Util::sqlAddSlashes($oldDb) . '\' AND Table_name = \'' . Util::sqlAddSlashes($oldTable)
|
||||
. '\';';
|
||||
$GLOBALS['dbi']->query($query_col_specific);
|
||||
|
||||
// Finally FLUSH the new privileges
|
||||
|
||||
@ -499,14 +499,14 @@ function PMA_getSqlQueryForDisplayPrivTable($db, $table, $username, $hostname)
|
||||
return "SELECT * FROM `mysql`.`db`"
|
||||
. " WHERE `User` = '" . Util::sqlAddSlashes($username) . "'"
|
||||
. " AND `Host` = '" . Util::sqlAddSlashes($hostname) . "'"
|
||||
. " AND '" . Util::unescapeMysqlWildcards($db) . "'"
|
||||
. " AND '" . Util::sqlAddSlashes(Util::unescapeMysqlWildcards($db)) . "'"
|
||||
. " LIKE `Db`;";
|
||||
}
|
||||
return "SELECT `Table_priv`"
|
||||
. " FROM `mysql`.`tables_priv`"
|
||||
. " WHERE `User` = '" . Util::sqlAddSlashes($username) . "'"
|
||||
. " AND `Host` = '" . Util::sqlAddSlashes($hostname) . "'"
|
||||
. " AND `Db` = '" . Util::unescapeMysqlWildcards($db) . "'"
|
||||
. " AND `Db` = '" . Util::sqlAddSlashes(Util::unescapeMysqlWildcards($db)) . "'"
|
||||
. " AND `Table_name` = '" . Util::sqlAddSlashes($table) . "';";
|
||||
}
|
||||
|
||||
|
||||
@ -539,6 +539,20 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase
|
||||
$sql,
|
||||
$ret
|
||||
);
|
||||
|
||||
// SQL escaping
|
||||
$db = "db' AND";
|
||||
$table = "pma_table";
|
||||
$ret = PMA_getSqlQueryForDisplayPrivTable(
|
||||
$db, $table, $username, $hostname
|
||||
);
|
||||
$this->assertEquals(
|
||||
"SELECT `Table_priv` FROM `mysql`.`tables_priv` "
|
||||
. "WHERE `User` = 'pma_username' AND "
|
||||
. "`Host` = 'pma_hostname' AND `Db` = 'db\' AND' AND "
|
||||
. "`Table_name` = 'pma_table';",
|
||||
$ret
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user