Commit 8087daae authored by Alexander Barkov's avatar Alexander Barkov

Require FILE privilege to DROP a table with FILE_NAME.

modified:
  mysql-test/suite/connect/r/bin.result
  mysql-test/suite/connect/t/grant.inc
  storage/connect/ha_connect.cc
  storage/connect/ha_connect.h
parent 79f84fdc
...@@ -48,6 +48,8 @@ ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) ...@@ -48,6 +48,8 @@ ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
ALTER TABLE t1 READONLY=1; ALTER TABLE t1 READONLY=1;
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO) ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
DROP TABLE t1; DROP TABLE t1;
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
DROP TABLE t1;
DROP USER user@localhost; DROP USER user@localhost;
# #
# Testing errors # Testing errors
......
...@@ -41,7 +41,8 @@ DELETE FROM t1; ...@@ -41,7 +41,8 @@ DELETE FROM t1;
TRUNCATE TABLE t1; TRUNCATE TABLE t1;
--error ER_ACCESS_DENIED_ERROR --error ER_ACCESS_DENIED_ERROR
ALTER TABLE t1 READONLY=1; ALTER TABLE t1 READONLY=1;
# TODO: DROP --error ER_ACCESS_DENIED_ERROR
DROP TABLE t1;
--disconnect user --disconnect user
--connection default --connection default
DROP TABLE t1; DROP TABLE t1;
......
...@@ -2884,9 +2884,8 @@ int ha_connect::delete_all_rows() ...@@ -2884,9 +2884,8 @@ int ha_connect::delete_all_rows()
} // end of delete_all_rows } // end of delete_all_rows
bool ha_connect::check_privileges(THD *thd, TABLE *table_arg) bool ha_connect::check_privileges(THD *thd, PTOS options)
{ {
PTOS options= GetTableOptionStruct(table_arg);
if (!options || !options->type) if (!options || !options->type)
goto err; goto err;
...@@ -2967,7 +2966,8 @@ int ha_connect::external_lock(THD *thd, int lock_type) ...@@ -2967,7 +2966,8 @@ int ha_connect::external_lock(THD *thd, int lock_type)
if (!g) if (!g)
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
if (lock_type != F_UNLCK && check_privileges(thd, table)) PTOS options= GetTableOptionStruct(table);
if (lock_type != F_UNLCK && check_privileges(thd, options))
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
// Action will depend on lock_type // Action will depend on lock_type
...@@ -3265,6 +3265,12 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to) ...@@ -3265,6 +3265,12 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to)
// Now we can work // Now we can work
pos= share->option_struct; pos= share->option_struct;
if (check_privileges(thd, pos))
{
free_table_share(share);
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
}
if (IsFileType(GetTypeID(pos->type)) && !pos->filename) { if (IsFileType(GetTypeID(pos->type)) && !pos->filename) {
// This is a table whose files must be erased or renamed */ // This is a table whose files must be erased or renamed */
char ftype[8], *new_exts[2]; char ftype[8], *new_exts[2];
...@@ -3887,7 +3893,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -3887,7 +3893,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
DBUG_ASSERT(options); DBUG_ASSERT(options);
type= GetTypeID(options->type); type= GetTypeID(options->type);
if (check_privileges(current_thd, table_arg)) if (check_privileges(current_thd, options))
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
if (options->data_charset) { if (options->data_charset) {
......
...@@ -361,7 +361,7 @@ const char *GetValStr(OPVAL vop, bool neg); ...@@ -361,7 +361,7 @@ const char *GetValStr(OPVAL vop, bool neg);
int optimize(THD* thd, HA_CHECK_OPT* check_opt); int optimize(THD* thd, HA_CHECK_OPT* check_opt);
protected: protected:
bool check_privileges(THD *thd, TABLE *table_arg); bool check_privileges(THD *thd, PTOS options);
char *GetListOption(const char *opname, const char *oplist, const char *def= NULL); char *GetListOption(const char *opname, const char *oplist, const char *def= NULL);
#if defined(MARIADB) #if defined(MARIADB)
char *encode(PGLOBAL g, char *cnm); char *encode(PGLOBAL g, char *cnm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment