diff options
author | unknown <guilhem@mysql.com> | 2003-06-11 17:07:33 +0200 |
---|---|---|
committer | unknown <guilhem@mysql.com> | 2003-06-11 17:07:33 +0200 |
commit | b7e0c11a272b52c8a9c2b84d13bd9622c7dcf4b2 (patch) | |
tree | 4b8adcbf6de30c4e11830d69086c10983aeefc45 | |
parent | 0826127b2b826871fb3dcf1a1497d364d62da3b9 (diff) | |
download | mariadb-git-b7e0c11a272b52c8a9c2b84d13bd9622c7dcf4b2.tar.gz |
We now require SUPER privilege for SET PSEUDO_THREAD_ID.
mysql-test/r/rpl_temporary.result:
result update
mysql-test/t/rpl_temporary.test:
test that PSEUDO_THREAD_ID now requires SUPER.
sql/set_var.cc:
Class for pseudo_thread_id (it used to be sys_var_thd_ulong, but we
decided to require the SUPER privilege so we needed a check() function,
which sys_var_thd_ulong does not feature (check() is virtual in sys_var
and in sys_var_thd_ulong too).
sql/set_var.h:
Class for pseudo_thread_id
-rw-r--r-- | mysql-test/r/rpl_temporary.result | 2 | ||||
-rw-r--r-- | mysql-test/t/rpl_temporary.test | 8 | ||||
-rw-r--r-- | sql/set_var.cc | 17 | ||||
-rw-r--r-- | sql/set_var.h | 9 |
4 files changed, 35 insertions, 1 deletions
diff --git a/mysql-test/r/rpl_temporary.result b/mysql-test/r/rpl_temporary.result index 3d811aeb09c..cf2b8814047 100644 --- a/mysql-test/r/rpl_temporary.result +++ b/mysql-test/r/rpl_temporary.result @@ -5,6 +5,8 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; reset master; +SET @@session.pseudo_thread_id=100; +ERROR HY000: Access denied. You need the SUPER privilege for this operation drop table if exists t1,t2; create table t1(f int); create table t2(f int); diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test index f939856ea1f..442788ad019 100644 --- a/mysql-test/t/rpl_temporary.test +++ b/mysql-test/t/rpl_temporary.test @@ -19,6 +19,14 @@ connection master; connect (con1,localhost,root,,); connect (con2,localhost,root,,); +connect (con3,localhost,test,,); + +# We are going to use SET PSEUDO_THREAD_ID in this test; +# check that it requires the SUPER privilege. + +connection con3; +--error 1227 +SET @@session.pseudo_thread_id=100; let $VERSION=`select version()`; diff --git a/sql/set_var.cc b/sql/set_var.cc index ad3966f76f9..a5377d8ebc6 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -168,7 +168,11 @@ sys_var_thd_ulong sys_max_error_count("max_error_count", &SV::max_error_count); sys_var_thd_ulong sys_max_heap_table_size("max_heap_table_size", &SV::max_heap_table_size); -sys_var_thd_ulong sys_pseudo_thread_id("pseudo_thread_id", +/* + sys_pseudo_thread_id has its own class (instead of sys_var_thd_ulong) because + we want a check() function. +*/ +sys_var_pseudo_thread_id sys_pseudo_thread_id("pseudo_thread_id", &SV::pseudo_thread_id); sys_var_thd_ha_rows sys_max_join_size("max_join_size", &SV::max_join_size, @@ -1454,6 +1458,17 @@ byte *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type) return (byte*) &thd->current_insert_id; } +bool sys_var_pseudo_thread_id::check(THD *thd, set_var *var) +{ + if (thd->master_access & SUPER_ACL) + return 0; + else + { + my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER"); + return 1; + } +} + #ifdef HAVE_REPLICATION bool sys_var_slave_skip_counter::check(THD *thd, set_var *var) diff --git a/sql/set_var.h b/sql/set_var.h index 998d61ff2d1..5a0fbd21809 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -212,6 +212,15 @@ public: byte *value_ptr(THD *thd, enum_var_type type); }; +class sys_var_pseudo_thread_id :public sys_var_thd_ulong +{ +public: + sys_var_pseudo_thread_id(const char *name_arg, ulong SV::*offset_arg) + :sys_var_thd_ulong(name_arg, offset_arg) + {} + bool check(THD *thd, set_var *var); +}; + class sys_var_thd_ha_rows :public sys_var_thd { |