MySQL  8.0.19
Source Code Documentation
dynamic_privilege_table.h
Go to the documentation of this file.
1 /* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
2 
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6 
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 #ifndef DYNAMIC_PRIVILEGE_TABLE_H
23 #define DYNAMIC_PRIVILEGE_TABLE_H
24 
25 #include <functional>
26 #include <string>
27 #include <unordered_set>
28 
29 #include "lex_string.h"
30 #include "sql/auth/auth_common.h"
31 
32 class THD;
33 struct TABLE;
34 struct TABLE_LIST;
35 
36 typedef std::unordered_set<std::string> Dynamic_privilege_register;
37 
40  const Auth_id_ref &auth_id,
41  const LEX_CSTRING &privilege,
42  bool with_grant_option,
43  bool delete_option);
45  public:
46  enum Operation { GRANT, REVOKE };
49  : m_thd(thd), m_table(table), m_no_update(false) {}
50  bool operator()(const std::string &priv, const Auth_id_ref &auth_id,
51  bool grant_option,
53  if (m_no_update) return false;
54  LEX_CSTRING cstr_priv = {priv.c_str(), priv.length()};
56  cstr_priv, grant_option,
57  op == Operation::REVOKE);
58  }
59 
60  private:
64 };
65 
67 void register_dynamic_privilege_impl(const std::string &priv);
69  std::function<bool(const char *)> action);
70 #endif
Auth_id_ref
std::pair< LEX_CSTRING, LEX_CSTRING > Auth_id_ref
user, host tuple which reference either acl_cache or g_default_roles
Definition: auth_common.h:74
auth_common.h
MYSQL_LEX_CSTRING
Definition: mysql_lex_string.h:39
THD
Definition: sql_class.h:764
Update_dynamic_privilege_table::m_no_update
bool m_no_update
Definition: dynamic_privilege_table.h:63
MYSQL_LEX_CSTRING::length
size_t length
Definition: mysql_lex_string.h:41
Update_dynamic_privilege_table::GRANT
@ GRANT
Definition: dynamic_privilege_table.h:46
TABLE
Definition: table.h:1305
true
#define true
Definition: config_static.h:44
populate_dynamic_privilege_caches
bool populate_dynamic_privilege_caches(THD *thd, TABLE_LIST *tablelst)
Given an open table handler this function refresh the list of dynamic privilege grants by reading the...
Definition: dynamic_privilege_table.cc:88
iterate_all_dynamic_privileges
bool iterate_all_dynamic_privileges(THD *thd, std::function< bool(const char *)> action)
Definition: dynamic_privilege_table.cc:238
lex_string.h
Update_dynamic_privilege_table::REVOKE
@ REVOKE
Definition: dynamic_privilege_table.h:46
register_dynamic_privilege_impl
void register_dynamic_privilege_impl(const std::string &priv)
Update_dynamic_privilege_table::m_thd
THD * m_thd
Definition: dynamic_privilege_table.h:61
Update_dynamic_privilege_table::operator()
bool operator()(const std::string &priv, const Auth_id_ref &auth_id, bool grant_option, Update_dynamic_privilege_table::Operation op)
Definition: dynamic_privilege_table.h:50
TABLE_LIST
Definition: table.h:2467
Update_dynamic_privilege_table::Operation
Operation
Definition: dynamic_privilege_table.h:46
Update_dynamic_privilege_table::Update_dynamic_privilege_table
Update_dynamic_privilege_table(THD *thd, TABLE *table)
Definition: dynamic_privilege_table.h:48
Update_dynamic_privilege_table::m_table
TABLE * m_table
Definition: dynamic_privilege_table.h:62
get_dynamic_privilege_register
Dynamic_privilege_register * get_dynamic_privilege_register(void)
This function returns a pointer to a global variable allocated on the heap.
Definition: dynamic_privilege_table.cc:71
Update_dynamic_privilege_table::Update_dynamic_privilege_table
Update_dynamic_privilege_table()
Definition: dynamic_privilege_table.h:47
TABLE_LIST::table
TABLE * table
Definition: table.h:3209
Dynamic_privilege_register
std::unordered_set< std::string > Dynamic_privilege_register
Definition: dynamic_privilege_table.h:34
modify_dynamic_privileges_in_table
bool modify_dynamic_privileges_in_table(THD *thd, TABLE *table, const Auth_id_ref &auth_id, const LEX_CSTRING &privilege, bool with_grant_option, bool delete_option)
Delete or insert a row in the mysql.dynamic_privilege table.
Definition: dynamic_privilege_table.cc:192
Update_dynamic_privilege_table
Definition: dynamic_privilege_table.h:44
false
#define false
Definition: config_static.h:43