From d014dbcc293118e2dd43ba2d36465b745537d5f8 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Tue, 30 Jun 2015 23:23:27 +0530 Subject: [PATCH 1/2] Trial Approach to solve Privileges bug for RFE#657 Signed-off-by: Deven Bansod --- db_operations.php | 1 + db_routines.php | 1 + doc/faq.rst | 7 + libraries/check_user_privileges.lib.php | 209 ++++++++++++++++++ libraries/dbi/DBIDummy.class.php | 20 ++ libraries/operations.lib.php | 104 +++++++-- libraries/rte/rte_routines.lib.php | 17 +- libraries/structure.lib.php | 1 + libraries/tbl_columns_definition_form.inc.php | 3 +- tbl_operations.php | 1 + tbl_structure.php | 1 + .../column_adjust_privileges.phtml | 24 +- .../column_attributes.phtml | 5 +- 13 files changed, 367 insertions(+), 27 deletions(-) diff --git a/db_operations.php b/db_operations.php index 7099be344e..12b2e1d5d3 100644 --- a/db_operations.php +++ b/db_operations.php @@ -21,6 +21,7 @@ require_once 'libraries/mysql_charsets.inc.php'; /** * functions implementation for this script */ +require_once 'libraries/check_user_privileges.lib.php'; require_once 'libraries/operations.lib.php'; // add a javascript file for jQuery functions to handle Ajax actions diff --git a/db_routines.php b/db_routines.php index c273b7b291..be7791c649 100644 --- a/db_routines.php +++ b/db_routines.php @@ -16,6 +16,7 @@ require_once 'libraries/mysql_charsets.inc.php'; /** * Include all other files */ +require_once 'libraries/check_user_privileges.lib.php'; require_once 'libraries/rte/rte_routines.lib.php'; /** diff --git a/doc/faq.rst b/doc/faq.rst index 48649158d9..5909f6807f 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -2065,6 +2065,13 @@ Notes: *column-related privileges* for the columns inside the table are also adjusted to the table's new name. +* While adjusting privileges, the user performing the operation **must** have the following + privileges: + + * SELECT, INSERT, UPDATE, DELETE privileges on following tables: + `mysql`.`db`, `mysql`.`columns_priv`, `mysql`.`tables_priv`, `mysql`.`procs_priv` + * FLUSH privilege (GLOBAL) + Thus, if you want to replicate the database/table/column/procedure as it is while renaming/copying/moving these objects, make sure you have checked this option. diff --git a/libraries/check_user_privileges.lib.php b/libraries/check_user_privileges.lib.php index aa118617e2..d03bb34c31 100644 --- a/libraries/check_user_privileges.lib.php +++ b/libraries/check_user_privileges.lib.php @@ -14,6 +14,208 @@ if (! defined('PHPMYADMIN')) { */ $GLOBALS['is_superuser'] = $GLOBALS['dbi']->isSuperuser(); +/** + * Check if user has required privileges for + * performing 'FLUSH PRIVILEGES' operation + * + * @return void + */ +function PMA_checkRequiredPrivilegesForFlushing() +{ + + $res = $GLOBALS['dbi']->tryQuery( + 'FLUSH PRIVILEGES' + ); + + // Save the value + $GLOBALS['flush_priv'] = $res; +} + +/** + * Check if user has required privileges for + * performing 'Adjust Privileges' operations + * + * @return void + */ +function PMA_checkRequiredPrivilgesForAdjust() +{ + $privs_available = true; + // FOR DB PRIVS + $select_privs_available = $GLOBALS['dbi']->tryQuery( + 'SELECT * FROM `mysql`.`db` LIMIT 1' + ); + + $privs_available = $select_privs_available && $privs_available; + + if ($privs_available) { + $delete_privs_available = $GLOBALS['dbi']->tryQuery( + 'DELETE FROM `mysql`.`db` WHERE `host` = "" AND ' + . '`Db` = "" AND `User` = "" LIMIT 1;' + ); + $privs_available = $delete_privs_available && $privs_available; + } + + if ($privs_available) { + $insert_privs_available = $GLOBALS['dbi']->tryQuery( + 'INSERT INTO `mysql`.`db`(`host`, `Db`, `User`) VALUES("pma_test_host", ' + . '"mysql", "pma_test_user");' + ); + // If successful test insert, delete the test row + if ($insert_privs_available) { + $GLOBALS['dbi']->tryQuery( + 'DELETE FROM `mysql`.`db` WHERE host = "pma_test_host" AND ' + . 'Db = "mysql" AND User = "pma_test_user" LIMIT 1;' + ); + } + $privs_available = $insert_privs_available && $privs_available; + } + + if ($privs_available) { + $update_privs_available = $GLOBALS['dbi']->tryQuery( + 'UPDATE `mysql`.`db` SET `host` = "" WHERE `host` = "" AND ' + . '`Db` = "" AND `User` = "" LIMIT 1;' + ); + $privs_available = $update_privs_available && $privs_available; + } + // save the value + $GLOBALS['db_priv'] = $privs_available; + // reset the value + $privs_available = true; + + // FOR COLUMNS_PRIV + $select_privs_available = $GLOBALS['dbi']->tryQuery( + 'SELECT * FROM `mysql`.`columns_priv` LIMIT 1' + ); + + $privs_available = $select_privs_available && $privs_available; + + if ($privs_available) { + $delete_privs_available = $GLOBALS['dbi']->tryQuery( + 'DELETE FROM `mysql`.`columns_priv` WHERE `host` = "" AND ' + . '`Db` = "" AND `User` = "" LIMIT 1;' + ); + $privs_available = $delete_privs_available && $privs_available; + } + + if ($privs_available) { + $insert_privs_available = $GLOBALS['dbi']->tryQuery( + 'INSERT INTO `mysql`.`columns_priv`(`host`, `Db`, `User`, `Table_name`,' + . ' `Column_name`) VALUES("pma_test_host", ' + . '"mysql", "pma_test_user", "", "")' + ); + // If successful test insert, delete the test row + if ($insert_privs_available) { + $GLOBALS['dbi']->tryQuery( + 'DELETE FROM `mysql`.`columns_priv` WHERE host = "pma_test_host" AND ' + . 'Db = "mysql" AND User = "pma_test_user" AND Table_name = ""' + . ' AND Column_name = "" LIMIT 1;' + ); + } + $privs_available = $insert_privs_available && $privs_available; + } + + if ($privs_available) { + $update_privs_available = $GLOBALS['dbi']->tryQuery( + 'UPDATE `mysql`.`columns_priv` SET `host` = "" WHERE `host` = "" AND ' + . '`Db` = "" AND `User` = "" AND Column_name = "" AND Table_name = "" LIMIT 1;' + ); + $privs_available = $update_privs_available && $privs_available; + + } + // Save the value + $GLOBALS['col_priv'] = $privs_available; + // Reset the value + $privs_available = true; + + // FOR TABLES_PRIV + $select_privs_available = $GLOBALS['dbi']->tryQuery( + 'SELECT * FROM `mysql`.`tables_priv` LIMIT 1' + ); + + $privs_available = $select_privs_available && $privs_available; + + if ($privs_available) { + $delete_privs_available = $GLOBALS['dbi']->tryQuery( + 'DELETE FROM `mysql`.`tables_priv` WHERE `host` = "" AND ' + . '`Db` = "" AND `User` = "" AND Table_name = "" LIMIT 1;' + ); + $privs_available = $delete_privs_available && $privs_available; + } + + if ($privs_available) { + $insert_privs_available = $GLOBALS['dbi']->tryQuery( + 'INSERT INTO `mysql`.`tables_priv`(`host`, `Db`, `User`, `Table_name`' + . ') VALUES("pma_test_host", ' + . '"mysql", "pma_test_user", "")' + ); + // If successful test insert, delete the test row + if ($insert_privs_available) { + $GLOBALS['dbi']->tryQuery( + 'DELETE FROM `mysql`.`tables_priv` WHERE host = "pma_test_host" AND ' + . 'Db = "mysql" AND User = "pma_test_user" AND Table_name = "" LIMIT 1;' + ); + } + $privs_available = $insert_privs_available && $privs_available; + } + + if ($privs_available) { + $update_privs_available = $GLOBALS['dbi']->tryQuery( + 'UPDATE `mysql`.`tables_priv` SET `host` = "" WHERE `host` = "" AND ' + . '`Db` = "" AND `User` = "" AND Table_name = "" LIMIT 1;' + ); + $privs_available = $update_privs_available && $privs_available; + + } + // Save the value + $GLOBALS['table_priv'] = $privs_available; + // Reset the value + $privs_available = true; + + // FOR PROCS_PRIV + $select_privs_available = $GLOBALS['dbi']->tryQuery( + 'SELECT * FROM `mysql`.`procs_priv` LIMIT 1' + ); + + $privs_available = $select_privs_available && $privs_available; + + if ($privs_available) { + $delete_privs_available = $GLOBALS['dbi']->tryQuery( + 'DELETE FROM `mysql`.`procs_priv` WHERE `host` = "" AND ' + . '`Db` = "" AND `User` = "" AND `Routine_name` = ""' + . ' AND `Routine_type` = "" LIMIT 1;' + ); + $privs_available = $delete_privs_available && $privs_available; + } + + if ($privs_available) { + $insert_privs_available = $GLOBALS['dbi']->tryQuery( + 'INSERT INTO `mysql`.`procs_priv`(`host`, `Db`, `User`, `Routine_name`,' + . ' `Routine_type`) VALUES("pma_test_host", ' + . '"mysql", "pma_test_user", "", "PROCEDURE")' + ); + // If successful test insert, delete the test row + if ($insert_privs_available) { + $GLOBALS['dbi']->tryQuery( + 'DELETE FROM `mysql`.`procs_priv` WHERE `host` = "pma_test_host" AND ' + . '`Db` = "mysql" AND `User` = "pma_test_user" AND `Routine_name` = ""' + . ' AND `Routine_type` = "PROCEDURE" LIMIT 1;' + ); + } + $privs_available = $insert_privs_available && $privs_available; + } + + if ($privs_available) { + $update_privs_available = $GLOBALS['dbi']->tryQuery( + 'UPDATE `mysql`.`procs_priv` SET `host` = "" WHERE `host` = "" AND ' + . '`Db` = "" AND `User` = "" AND `Routine_name` = "" LIMIT 1;' + ); + $privs_available = $update_privs_available && $privs_available; + } + // Save the value + $GLOBALS['proc_priv'] = $privs_available; + +} + /** * sets privilege information extracted from SHOW GRANTS result * @@ -185,6 +387,13 @@ if (!PMA_DRIZZLE) { } else { PMA_analyseShowGrant(); } + + // Check if privileges to 'mysql'.col_privs, 'mysql'.db, + // 'mysql'.table_privs, 'mysql'.proc_privs and privileges for + // flushing the privileges are available + PMA_checkRequiredPrivilegesForFlushing(); + PMA_checkRequiredPrivilgesForAdjust(); + } else { // todo: for simple_user_policy only database with user's login can be created // (unless logged in as root) diff --git a/libraries/dbi/DBIDummy.class.php b/libraries/dbi/DBIDummy.class.php index 10323afe6d..7ac4c44155 100644 --- a/libraries/dbi/DBIDummy.class.php +++ b/libraries/dbi/DBIDummy.class.php @@ -559,6 +559,26 @@ $GLOBALS['dummy_queries'] = array( array( 'query' => "SHOW EVENTS FROM `default`", 'result' => array() + ), + array( + 'query' => "FLUSH PRIVILEGES", + 'result' => array() + ), + array( + 'query' => "SELECT * FROM `mysql`.`db` LIMIT 1", + 'result' => array() + ), + array( + 'query' => "SELECT * FROM `mysql`.`columns_priv` LIMIT 1", + 'result' => array() + ), + array( + 'query' => "SELECT * FROM `mysql`.`tables_priv` LIMIT 1", + 'result' => array() + ), + array( + 'query' => "SELECT * FROM `mysql`.`procs_priv` LIMIT 1", + 'result' => array() ) ); /** diff --git a/libraries/operations.lib.php b/libraries/operations.lib.php index 9b938e3c48..306e770755 100644 --- a/libraries/operations.lib.php +++ b/libraries/operations.lib.php @@ -77,11 +77,26 @@ function PMA_getHtmlForRenameDatabase($db) $html_output .= ''; - $html_output .= ''; + + if (isset($GLOBALS['db_priv']) && $GLOBALS['db_priv'] + && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] + ) { + $html_output .= ''; + } else { + $html_output .= ''; + } + $html_output .= '
'; + . __('Adjust Privileges') . PMA_Util::showDocu('faq', 'faq6-39') + . '
'; + $html_output .= '' . '' . '
' @@ -205,11 +220,25 @@ function PMA_getHtmlForCopyDatabase($db) $html_output .= '
'; $html_output .= '
'; - $html_output .= ''; + + if (isset($GLOBALS['db_priv']) && $GLOBALS['db_priv'] + && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] + ) { + $html_output .= ''; + } else { + $html_output .= ''; + } $html_output .= '
'; + $html_output .= '' . '
' - . '' - . '
'; + + if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv'] + && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] + ) { + $html_output .= ''; + } else { + $html_output .= ''; + } + + $html_output .= '
' . '
'; @@ -868,10 +911,23 @@ function PMA_getHtmlForRenameTable() . 'value="' . htmlspecialchars($GLOBALS['table']) . '" required="required" />' . '' - . '' - . '' - . '
'; - if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv'] - && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] - ) { - $html_output .= ''; - } else { - $html_output .= ''; + if (! PMA_DRIZZLE) { + if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv'] + && isset($GLOBALS['col_priv']) && $GLOBALS['col_priv'] + && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] + ) { + $html_output .= ''; + } else { + $html_output .= ''; + } + $html_output .= '
'; } - $html_output .= '
' - . ''; - - $html_output .= '
' + $html_output .= '
' . '' . '
' . '' @@ -913,25 +939,28 @@ function PMA_getHtmlForRenameTable() . '' . ''; - if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv'] - && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] - ) { - $html_output .= ''; - } else { - $html_output .= ''; + if (! PMA_DRIZZLE) { + if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv'] + && isset($GLOBALS['col_priv']) && $GLOBALS['col_priv'] + && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] + ) { + $html_output .= ''; + } else { + $html_output .= ''; + } + $html_output .= ''; } - $html_output .= '' - . '' - . ''; + + $html_output .= ''; return $html_output; } @@ -1264,25 +1293,27 @@ function PMA_getHtmlForCopytable() $html_output .= '
'; - if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv'] - && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] - ) { - $html_output .= ''; - } else { - $html_output .= ''; + if (! PMA_DRIZZLE) { + if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv'] + && isset($GLOBALS['col_priv']) && $GLOBALS['col_priv'] + && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] + ) { + $html_output .= ''; + } else { + $html_output .= ''; + } + $html_output .= '
'; } - $html_output .= '
'; - if (isset($_COOKIE['pma_switch_to_new']) && $_COOKIE['pma_switch_to_new'] == 'true' ) { @@ -1914,24 +1945,30 @@ function PMA_getQueryAndResultForPartition() */ function PMA_AdjustPrivileges_renameOrMoveTable($oldDb, $oldTable, $newDb, $newTable) { - $GLOBALS['dbi']->selectDb('mysql'); + if (! PMA_DRIZZLE) { + if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv'] + && isset($GLOBALS['col_priv']) && $GLOBALS['col_priv'] + && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] + ) { + $GLOBALS['dbi']->selectDb('mysql'); - // For table specific privileges - $query_table_specific = 'UPDATE ' . PMA_Util::backquote('tables_priv') - . 'SET Db = "' . $newDb . '", Table_name = "' . $newTable - . '" where Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";'; - $GLOBALS['dbi']->query($query_table_specific); + // For table specific privileges + $query_table_specific = 'UPDATE ' . PMA_Util::backquote('tables_priv') + . 'SET Db = "' . $newDb . '", Table_name = "' . $newTable + . '" where Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";'; + $GLOBALS['dbi']->query($query_table_specific); - // For column specific privileges - $query_col_specific = 'UPDATE ' . PMA_Util::backquote('columns_priv') - . 'SET Db = "' . $newDb . '", Table_name = "' . $newTable - . '" where Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";'; - $GLOBALS['dbi']->query($query_col_specific); - - // Finally FLUSH the new privileges - $flush_query = "FLUSH PRIVILEGES;"; - $GLOBALS['dbi']->query($flush_query); + // For column specific privileges + $query_col_specific = 'UPDATE ' . PMA_Util::backquote('columns_priv') + . 'SET Db = "' . $newDb . '", Table_name = "' . $newTable + . '" where Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";'; + $GLOBALS['dbi']->query($query_col_specific); + // Finally FLUSH the new privileges + $flush_query = "FLUSH PRIVILEGES;"; + $GLOBALS['dbi']->query($flush_query); + } + } } /** @@ -1946,46 +1983,52 @@ function PMA_AdjustPrivileges_renameOrMoveTable($oldDb, $oldTable, $newDb, $newT */ function PMA_AdjustPrivileges_copyTable($oldDb, $oldTable, $newDb, $newTable) { - $GLOBALS['dbi']->selectDb('mysql'); + if (! PMA_DRIZZLE) { + if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv'] + && isset($GLOBALS['col_priv']) && $GLOBALS['col_priv'] + && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] + ) { + $GLOBALS['dbi']->selectDb('mysql'); - // For Table Specific privileges - $query_table_specific_old = 'SELECT * FROM ' - . PMA_Util::backquote('tables_priv') . ' where ' - . 'Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";'; + // For Table Specific privileges + $query_table_specific_old = 'SELECT * FROM ' + . PMA_Util::backquote('tables_priv') . ' where ' + . 'Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";'; - $old_privs_table = $GLOBALS['dbi']->fetchResult($query_table_specific_old, 0); + $old_privs_table = $GLOBALS['dbi']->fetchResult($query_table_specific_old, 0); - foreach ($old_privs_table as $old_priv) { - $newDb_table_privs_query = 'INSERT INTO ' - . PMA_Util::backquote('tables_priv') . ' VALUES("' - . $old_priv[0] . '", "' . $newDb . '", "' . $old_priv[2] . '", "' - . $newTable . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "' - . $old_priv[6] . '", "' . $old_priv[7] . '");'; + foreach ($old_privs_table as $old_priv) { + $newDb_table_privs_query = 'INSERT INTO ' + . PMA_Util::backquote('tables_priv') . ' VALUES("' + . $old_priv[0] . '", "' . $newDb . '", "' . $old_priv[2] . '", "' + . $newTable . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "' + . $old_priv[6] . '", "' . $old_priv[7] . '");'; - $GLOBALS['dbi']->query($newDb_table_privs_query); + $GLOBALS['dbi']->query($newDb_table_privs_query); + } + + // For Column Specific privileges + $query_col_specific_old = 'SELECT * FROM ' + . PMA_Util::backquote('columns_priv') . ' WHERE ' + . 'Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";'; + + $old_privs_col = $GLOBALS['dbi']->fetchResult($query_col_specific_old, 0); + + foreach ($old_privs_col as $old_priv) { + $newDb_col_privs_query = 'INSERT INTO ' + . PMA_Util::backquote('columns_priv') . ' VALUES("' + . $old_priv[0] . '", "' . $newDb . '", "' . $old_priv[2] . '", "' + . $newTable . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "' + . $old_priv[6] . '");'; + + $GLOBALS['dbi']->query($newDb_col_privs_query); + } + + // Finally FLUSH the new privileges + $flush_query = "FLUSH PRIVILEGES;"; + $GLOBALS['dbi']->query($flush_query); + } } - - // For Column Specific privileges - $query_col_specific_old = 'SELECT * FROM ' - . PMA_Util::backquote('columns_priv') . ' WHERE ' - . 'Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";'; - - $old_privs_col = $GLOBALS['dbi']->fetchResult($query_col_specific_old, 0); - - foreach ($old_privs_col as $old_priv) { - $newDb_col_privs_query = 'INSERT INTO ' - . PMA_Util::backquote('columns_priv') . ' VALUES("' - . $old_priv[0] . '", "' . $newDb . '", "' . $old_priv[2] . '", "' - . $newTable . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "' - . $old_priv[6] . '");'; - - $GLOBALS['dbi']->query($newDb_col_privs_query); - } - - // Finally FLUSH the new privileges - $flush_query = "FLUSH PRIVILEGES;"; - $GLOBALS['dbi']->query($flush_query); - } /** diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php index 75714cf519..8f2db513ac 100644 --- a/libraries/rte/rte_routines.lib.php +++ b/libraries/rte/rte_routines.lib.php @@ -301,21 +301,28 @@ function PMA_RTN_handleEditor() $db, $_REQUEST['item_original_type'], $_REQUEST['item_original_name'] ); - // Backup the Old Privileges before dropping - // if $_REQUEST['item_adjust_privileges'] set - $privilegesBackup = array(); - if (isset($_REQUEST['item_adjust_privileges']) - && ! empty($_REQUEST['item_adjust_privileges']) - ) { - $privilegesBackupQuery = 'SELECT * FROM ' . PMA_Util::backquote('mysql') - . '.' . PMA_Util::backquote('procs_priv') - . ' where Routine_name = "' . $_REQUEST['item_original_name'] - . '" AND Routine_type = "' . $_REQUEST['item_original_type'] - . '";'; - $privilegesBackup = $GLOBALS['dbi']->fetchResult( - $privilegesBackupQuery, 0 - ); + if (! defined('PMA_DRIZZLE') || ! PMA_DRIZZLE) { + if (isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv'] + && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] + ) { + // Backup the Old Privileges before dropping + // if $_REQUEST['item_adjust_privileges'] set + $privilegesBackup = array(); + if (isset($_REQUEST['item_adjust_privileges']) + && ! empty($_REQUEST['item_adjust_privileges']) + ) { + $privilegesBackupQuery = 'SELECT * FROM ' . PMA_Util::backquote('mysql') + . '.' . PMA_Util::backquote('procs_priv') + . ' where Routine_name = "' . $_REQUEST['item_original_name'] + . '" AND Routine_type = "' . $_REQUEST['item_original_type'] + . '";'; + + $privilegesBackup = $GLOBALS['dbi']->fetchResult( + $privilegesBackupQuery, 0 + ); + } + } } $drop_routine = "DROP {$_REQUEST['item_original_type']} " @@ -355,23 +362,30 @@ function PMA_RTN_handleEditor() // Default value $resultAdjust = false; - // Insert all the previous privileges - // but with the new name and the new type - foreach ($privilegesBackup as $priv) { - $adjustProcPrivilege = 'INSERT INTO ' - . PMA_Util::backquote('mysql') . '.' - . PMA_Util::backquote('procs_priv') - . ' VALUES("' . $priv[0] . '", "' - . $priv[1] . '", "' . $priv[2] . '", "' - . $_REQUEST['item_name'] . '", "' - . $_REQUEST['item_type'] . '", "' - . $priv[5] . '", "' - . $priv[6] . '", "' - . $priv[7] . '");'; - $resultAdjust = $GLOBALS['dbi']->query( - $adjustProcPrivilege - ); + if (! defined('PMA_DRIZZLE') || ! PMA_DRIZZLE) { + if (isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv'] + && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] + ) { + // Insert all the previous privileges + // but with the new name and the new type + foreach ($privilegesBackup as $priv) { + $adjustProcPrivilege = 'INSERT INTO ' + . PMA_Util::backquote('mysql') . '.' + . PMA_Util::backquote('procs_priv') + . ' VALUES("' . $priv[0] . '", "' + . $priv[1] . '", "' . $priv[2] . '", "' + . $_REQUEST['item_name'] . '", "' + . $_REQUEST['item_type'] . '", "' + . $priv[5] . '", "' + . $priv[6] . '", "' + . $priv[7] . '");'; + $resultAdjust = $GLOBALS['dbi']->query( + $adjustProcPrivilege + ); + } + } } + if ($resultAdjust) { // Flush the Privileges $flushPrivQuery = 'FLUSH PRIVILEGES;'; @@ -1101,19 +1115,21 @@ function PMA_RTN_getEditorForm($mode, $operation, $routine) $retval .= " " . __('Adjust Privileges'); $retval .= PMA_Util::showDocu('faq', 'faq6-39'); $retval .= ""; - if (isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv'] - && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] - ) { - $retval .= " "; - } else { - $retval .= " "; + if (! defined('PMA_DRIZZLE') || ! PMA_DRIZZLE) { + if (isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv'] + && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] + ) { + $retval .= " "; + } else { + $retval .= " "; + } } $retval .= ""; } diff --git a/libraries/structure.lib.php b/libraries/structure.lib.php index 88bc5c62ba..1fa6a61eb5 100644 --- a/libraries/structure.lib.php +++ b/libraries/structure.lib.php @@ -2785,26 +2785,33 @@ function PMA_adjustColumnPrivileges($db, $table, $adjust_privileges) { $changed = false; - $GLOBALS['dbi']->selectDb('mysql'); + if (! defined('PMA_DRIZZLE') || ! PMA_DRIZZLE) { + if (isset($GLOBALS['col_priv']) && $GLOBALS['col_priv'] + && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv'] + ) { - // For Column specific privileges - foreach ($adjust_privileges as $oldCol => $newCol) { - $query_adjust_col_privileges = 'UPDATE ' - . PMA_Util::backquote('columns_priv') . ' ' - . 'SET Column_name = "' . $newCol . '" ' - . 'WHERE Db = "' . $db . '" AND Table_name = "' . $table - . '" AND Column_name = "' . $oldCol . '";'; + $GLOBALS['dbi']->selectDb('mysql'); - $GLOBALS['dbi']->query($query_adjust_col_privileges); + // For Column specific privileges + foreach ($adjust_privileges as $oldCol => $newCol) { + $query_adjust_col_privileges = 'UPDATE ' + . PMA_Util::backquote('columns_priv') . ' ' + . 'SET Column_name = "' . $newCol . '" ' + . 'WHERE Db = "' . $db . '" AND Table_name = "' . $table + . '" AND Column_name = "' . $oldCol . '";'; - // i.e. if atleast one column privileges adjusted - $changed = true; - } + $GLOBALS['dbi']->query($query_adjust_col_privileges); - if ($changed) { - // Finally FLUSH the new privileges - $flushPrivQuery = "FLUSH PRIVILEGES;"; - $GLOBALS['dbi']->query($flushPrivQuery); + // i.e. if atleast one column privileges adjusted + $changed = true; + } + + if ($changed) { + // Finally FLUSH the new privileges + $flushPrivQuery = "FLUSH PRIVILEGES;"; + $GLOBALS['dbi']->query($flushPrivQuery); + } + } } return $changed; diff --git a/templates/columns_definitions/column_attributes.phtml b/templates/columns_definitions/column_attributes.phtml index a3df524384..eb4049c463 100644 --- a/templates/columns_definitions/column_attributes.phtml +++ b/templates/columns_definitions/column_attributes.phtml @@ -84,7 +84,7 @@ $ci_offset = -1; 'columnMeta' => isset($columnMeta) ? $columnMeta : null )); ?> - +