Skip to content

Commit aa233d2

Browse files
committed
Bug #21251297 and Bug #21436364: Make some P_S tables world readable
The MySQL ACL system does not currently support granting stuff to public. So the only currently possible fix is to make performance schema override the ACL code and return that the tables are accessible to public. Fixed by reverting parts of the fix for bug #14569746 pertaining to PERFORMANCE_SCHEMA.SESSION_ACCOUNT_CONNECT_ATTR, namely re-introducing the PFS_readonly_world_acl derived class and returning it into the tables share. Also used PFS_readonly_world_acl (and another derivate of PFS_truncatable_world_acl) to ensure performance_schema.session_status, performance_schema.global_status, performance_schema.session_variables and performance_schema.global_variables are using the world readable derivates too. Test cases updated.
1 parent 0f09321 commit aa233d2

9 files changed

+74
-7
lines changed

mysql-test/suite/perfschema/r/connect_attrs.result

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ SELECT COUNT(DISTINCT PROCESSLIST_ID)
3535
FROM performance_schema.session_connect_attrs;
3636
COUNT(DISTINCT PROCESSLIST_ID)
3737
2
38+
# must return 1
3839
SELECT COUNT(DISTINCT PROCESSLIST_ID)
3940
FROM performance_schema.session_account_connect_attrs;
40-
ERROR 42000: SELECT command denied to user 'wl5924'@'localhost' for table 'session_account_connect_attrs'
41+
COUNT(DISTINCT PROCESSLIST_ID)
42+
1
4143
SELECT COUNT(DISTINCT PROCESSLIST_ID)
4244
FROM performance_schema.session_connect_attrs;
4345
ERROR 42000: SELECT command denied to user 'wl5924'@'localhost' for table 'session_connect_attrs'

mysql-test/suite/perfschema/t/connect_attrs.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ SELECT COUNT(DISTINCT PROCESSLIST_ID)
5757
FROM performance_schema.session_connect_attrs;
5858

5959
connection non_privileged_user;
60-
--error ER_TABLEACCESS_DENIED_ERROR
60+
--echo # must return 1
6161
SELECT COUNT(DISTINCT PROCESSLIST_ID)
6262
FROM performance_schema.session_account_connect_attrs;
6363

storage/perfschema/pfs_engine_table.cc

+26
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,19 @@ PFS_readonly_acl::check(ulong want_access, ulong *save_priv) const
843843
return ACL_INTERNAL_ACCESS_CHECK_GRANT;
844844
}
845845

846+
847+
PFS_readonly_world_acl pfs_readonly_world_acl;
848+
849+
ACL_internal_access_result
850+
PFS_readonly_world_acl::check(ulong want_access, ulong *save_priv) const
851+
{
852+
ACL_internal_access_result res= PFS_readonly_acl::check(want_access, save_priv);
853+
if (res == ACL_INTERNAL_ACCESS_CHECK_GRANT)
854+
res= ACL_INTERNAL_ACCESS_GRANTED;
855+
return res;
856+
}
857+
858+
846859
PFS_truncatable_acl pfs_truncatable_acl;
847860

848861
ACL_internal_access_result
@@ -858,6 +871,19 @@ PFS_truncatable_acl::check(ulong want_access, ulong *save_priv) const
858871
return ACL_INTERNAL_ACCESS_CHECK_GRANT;
859872
}
860873

874+
875+
PFS_truncatable_world_acl pfs_truncatable_world_acl;
876+
877+
ACL_internal_access_result
878+
PFS_truncatable_world_acl::check(ulong want_access, ulong *save_priv) const
879+
{
880+
ACL_internal_access_result res= PFS_truncatable_acl::check(want_access, save_priv);
881+
if (res == ACL_INTERNAL_ACCESS_CHECK_GRANT)
882+
res= ACL_INTERNAL_ACCESS_GRANTED;
883+
return res;
884+
}
885+
886+
861887
PFS_updatable_acl pfs_updatable_acl;
862888

863889
ACL_internal_access_result

storage/perfschema/pfs_engine_table.h

+39
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,45 @@ class PFS_unknown_acl : public ACL_internal_table_access
403403
/** Singleton instance of PFS_unknown_acl. */
404404
extern PFS_unknown_acl pfs_unknown_acl;
405405

406+
407+
/**
408+
Privileges for world readable tables.
409+
*/
410+
class PFS_readonly_world_acl : public PFS_readonly_acl
411+
{
412+
public:
413+
PFS_readonly_world_acl()
414+
{}
415+
416+
~PFS_readonly_world_acl()
417+
{}
418+
virtual ACL_internal_access_result check(ulong want_access, ulong *save_priv) const;
419+
};
420+
421+
422+
/** Singleton instance of PFS_readonly_world_acl */
423+
extern PFS_readonly_world_acl pfs_readonly_world_acl;
424+
425+
426+
/**
427+
Privileges for world readable truncatable tables.
428+
*/
429+
class PFS_truncatable_world_acl : public PFS_truncatable_acl
430+
{
431+
public:
432+
PFS_truncatable_world_acl()
433+
{}
434+
435+
~PFS_truncatable_world_acl()
436+
{}
437+
virtual ACL_internal_access_result check(ulong want_access, ulong *save_priv) const;
438+
};
439+
440+
441+
/** Singleton instance of PFS_readonly_world_acl */
442+
extern PFS_truncatable_world_acl pfs_truncatable_world_acl;
443+
444+
406445
/** Position of a cursor, for simple iterations. */
407446
struct PFS_simple_index
408447
{

storage/perfschema/table_global_status.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ PFS_engine_table_share
5050
table_global_status::m_share=
5151
{
5252
{ C_STRING_WITH_LEN("global_status") },
53-
&pfs_truncatable_acl,
53+
&pfs_truncatable_world_acl,
5454
table_global_status::create,
5555
NULL, /* write_row */
5656
table_global_status::delete_all_rows,

storage/perfschema/table_global_variables.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ PFS_engine_table_share
5050
table_global_variables::m_share=
5151
{
5252
{ C_STRING_WITH_LEN("global_variables") },
53-
&pfs_readonly_acl,
53+
&pfs_readonly_world_acl,
5454
table_global_variables::create,
5555
NULL, /* write_row */
5656
NULL, /* delete_all_rows */

storage/perfschema/table_session_account_connect_attrs.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ PFS_engine_table_share
2121
table_session_account_connect_attrs::m_share=
2222
{
2323
{ C_STRING_WITH_LEN("session_account_connect_attrs") },
24-
&pfs_readonly_acl,
24+
&pfs_readonly_world_acl,
2525
table_session_account_connect_attrs::create,
2626
NULL, /* write_row */
2727
NULL, /* delete_all_rows */

storage/perfschema/table_session_status.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ PFS_engine_table_share
5050
table_session_status::m_share=
5151
{
5252
{ C_STRING_WITH_LEN("session_status") },
53-
&pfs_readonly_acl,
53+
&pfs_readonly_world_acl,
5454
table_session_status::create,
5555
NULL, /* write_row */
5656
NULL, /* delete_all_rows */

storage/perfschema/table_session_variables.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ PFS_engine_table_share
5050
table_session_variables::m_share=
5151
{
5252
{ C_STRING_WITH_LEN("session_variables") },
53-
&pfs_readonly_acl,
53+
&pfs_readonly_world_acl,
5454
table_session_variables::create,
5555
NULL, /* write_row */
5656
NULL, /* delete_all_rows */

0 commit comments

Comments
 (0)