From 01dddf095a106ffb5e056dc6eaad60de511afa8f Mon Sep 17 00:00:00 2001 From: "jani@ua141d10.elisa.omakaista.fi" <> Date: Tue, 22 Mar 2005 15:57:24 +0200 Subject: [PATCH] - Added new error message. - Changed error message in sql_acl.cc - Added some more tests for GRANT. --- Docs/mysqld_error.txt | 2 ++ mysql-test/r/grant2.result | 2 +- mysql-test/r/grant3.result | 17 +++++++++++++++++ mysql-test/t/grant2.test | 2 +- mysql-test/t/grant3-master.opt | 1 + mysql-test/t/grant3.test | 32 ++++++++++++++++++++++++++++++++ sql/share/errmsg.txt | 2 ++ sql/sql_acl.cc | 2 +- 8 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 mysql-test/r/grant3.result create mode 100644 mysql-test/t/grant3-master.opt create mode 100644 mysql-test/t/grant3.test diff --git a/Docs/mysqld_error.txt b/Docs/mysqld_error.txt index 6370d8aac46..7f5560a5914 100644 --- a/Docs/mysqld_error.txt +++ b/Docs/mysqld_error.txt @@ -595,3 +595,5 @@ character-set=latin1 "Invalid ON UPDATE clause for '%-.64s' field", #define ER_UNSUPPORTED_PS 1295 "This command is not supported in the prepared statement protocol yet", +#define ER_CANT_CREATE_USER_WITH_GRANT 1296 +"You are not allowed to create a user with GRANT" diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index e6db7bd682f..ecd43cc2860 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -165,7 +165,7 @@ GRANT UPDATE (c2) ON "test"."t2" TO 'mysqltest_1'@'%' GRANT UPDATE ON "test"."t1" TO 'mysqltest_1'@'%' drop user 'mysqltest_1', 'mysqltest_3'; grant all on test.t1 to 'mysqltest_1'; -ERROR 42000: 'root'@'localhost' is not allowed to create new users +ERROR HY000: You are not allowed to create a user with GRANT drop user 'mysqltest_1'; ERROR HY000: Operation DROP USER failed for 'mysqltest_1'@'%' drop table t1, t2; diff --git a/mysql-test/r/grant3.result b/mysql-test/r/grant3.result new file mode 100644 index 00000000000..ae37db3af42 --- /dev/null +++ b/mysql-test/r/grant3.result @@ -0,0 +1,17 @@ +SET NAMES binary; +drop table if exists t1; +delete from mysql.user where user like 'mysqltest\_%'; +delete from mysql.db where user like 'mysqltest\_%'; +delete from mysql.tables_priv where user like 'mysqltest\_%'; +delete from mysql.columns_priv where user like 'mysqltest\_%'; +flush privileges; +create user mysqltest_1@localhost; +grant grant option on mysql.* to mysqltest_1@localhost; +grant select on `my\_1`.* to mysqltest_1@localhost with grant option; +grant select on `my\_1`.* to mysqltest_2@localhost; +ERROR HY000: You are not allowed to create a user with GRANT +delete from mysql.user where user like 'mysqltest\_%'; +delete from mysql.db where user like 'mysqltest\_%'; +delete from mysql.tables_priv where user like 'mysqltest\_%'; +delete from mysql.columns_priv where user like 'mysqltest\_%'; +flush privileges; diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index f86cf2a1db7..7aefbb5d9ff 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -179,7 +179,7 @@ show grants for 'mysqltest_1'; drop user 'mysqltest_1', 'mysqltest_3'; # # Grant must not create user ---error 1211 +--error 1410 grant all on test.t1 to 'mysqltest_1'; --error 1396 drop user 'mysqltest_1'; diff --git a/mysql-test/t/grant3-master.opt b/mysql-test/t/grant3-master.opt new file mode 100644 index 00000000000..4b11f5902c1 --- /dev/null +++ b/mysql-test/t/grant3-master.opt @@ -0,0 +1 @@ +--safe-user-create diff --git a/mysql-test/t/grant3.test b/mysql-test/t/grant3.test new file mode 100644 index 00000000000..dca4ff9496e --- /dev/null +++ b/mysql-test/t/grant3.test @@ -0,0 +1,32 @@ +# Test of GRANT commands + +SET NAMES binary; +connect (master,localhost,root,,); +connection master; + +# Cleanup +--disable_warnings +drop table if exists t1; +--enable_warnings + +delete from mysql.user where user like 'mysqltest\_%'; +delete from mysql.db where user like 'mysqltest\_%'; +delete from mysql.tables_priv where user like 'mysqltest\_%'; +delete from mysql.columns_priv where user like 'mysqltest\_%'; +flush privileges; + +create user mysqltest_1@localhost; +grant grant option on mysql.* to mysqltest_1@localhost; +grant select on `my\_1`.* to mysqltest_1@localhost with grant option; +connect (user_a,localhost,mysqltest_1,,); +connection user_a; +--error 1410 +grant select on `my\_1`.* to mysqltest_2@localhost; +disconnect user_a; +connection default; + +delete from mysql.user where user like 'mysqltest\_%'; +delete from mysql.db where user like 'mysqltest\_%'; +delete from mysql.tables_priv where user like 'mysqltest\_%'; +delete from mysql.columns_priv where user like 'mysqltest\_%'; +flush privileges; diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index d4caeebb70c..886c37b7061 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5332,3 +5332,5 @@ ER_STARTUP eng "%s: ready for connections.\nVersion: '%s' socket: '%s' port: %d %s" ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR eng "Can't load value from file with fixed size rows to variable" +ER_CANT_CREATE_USER_WITH_GRANT + eng "You are not allowed to create a user with GRANT" diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index c51e5e00aa1..de5df4559db 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1627,7 +1627,7 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, else if (((thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER) && !password_len) || !create_user) { - my_error(ER_NO_PERMISSION_TO_CREATE_USER, MYF(0), + my_error(ER_CANT_CREATE_USER_WITH_GRANT, MYF(0), thd->user, thd->host_or_ip); goto end; }