MySQL 9.1.0
Source Code Documentation
sql_auth_cache.h File Reference
#include <assert.h>
#include <string.h>
#include <sys/types.h>
#include <atomic>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_selectors.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/properties.hpp>
#include <boost/pending/property.hpp>
#include <list>
#include <memory>
#include <string>
#include <unordered_map>
#include "lex_string.h"
#include "lf.h"
#include "map_helpers.h"
#include "mf_wcomp.h"
#include "my_alloc.h"
#include "my_compiler.h"
#include "my_inttypes.h"
#include "my_sharedlib.h"
#include "my_sys.h"
#include "mysql/components/services/bits/mysql_mutex_bits.h"
#include "mysql/mysql_lex_string.h"
#include "mysql/strings/m_ctype.h"
#include "mysql_com.h"
#include "mysql_time.h"
#include "sql/auth/auth_common.h"
#include "sql/auth/auth_internal.h"
#include "sql/auth/partial_revokes.h"
#include "sql/malloc_allocator.h"
#include "sql/psi_memory_key.h"
#include "sql/sql_connect.h"
#include "violite.h"

Go to the source code of this file.

Classes

class  ACL_HOST_AND_IP
 
class  ACL_ACCESS
 
class  ACL_compare
 Class that compares ACL_ACCESS objects. More...
 
class  ACL_USER_compare
 Class that compares ACL_USER objects. More...
 
class  ACL_HOST
 
class  Acl_credential
 
class  ACL_USER
 
class  ACL_USER::Password_locked_state
 
class  ACL_DB
 
class  ACL_PROXY_USER
 
class  acl_entry
 
class  GRANT_COLUMN
 
class  GRANT_NAME
 
class  GRANT_TABLE
 
class  Acl_cache_allocator< T >
 
struct  Acl_cache_allocator< T >::rebind< U >
 
class  Acl_map
 Container for global, schema, table/view and routine ACL maps. More...
 
class  Acl_cache
 
class  Acl_cache_lock_guard
 Lock guard for ACL Cache. More...
 
class  Acl_restrictions
 Cache to store the Restrictions of every auth_id. More...
 

Namespaces

namespace  boost
 Tag dispatch for custom Role_properties.
 

Macros

#define NUM_CREDENTIALS   2
 
#define PRIMARY_CRED   (NUM_CREDENTIALS - NUM_CREDENTIALS)
 
#define SECOND_CRED   (PRIMARY_CRED + 1)
 

Typedefs

typedef Acl_cache_allocator< ACL_USER * > Acl_user_ptr_allocator
 
typedef std::list< ACL_USER *, Acl_user_ptr_allocatorAcl_user_ptr_list
 
typedef boost::property< boost::vertex_acl_user_t, ACL_USER, boost::property< boost::vertex_name_t, std::string > > Role_properties
 Custom vertex properties used in Granted_roles_graph TODO ACL_USER contains too much information. More...
 
typedef boost::property< boost::edge_capacity_t, int > Role_edge_properties
 
typedef boost::adjacency_list< boost::setS, boost::vecS, boost::bidirectionalS, Role_properties, Role_edge_propertiesGranted_roles_graph
 A graph of all users/roles privilege inheritance. More...
 
typedef boost::graph_traits< Granted_roles_graph >::vertex_descriptor Role_vertex_descriptor
 The data type of a vertex in the Granted_roles_graph. More...
 
typedef boost::graph_traits< Granted_roles_graph >::edge_descriptor Role_edge_descriptor
 The data type of an edge in the Granted_roles_graph. More...
 
typedef std::unordered_map< std::string, Role_vertex_descriptorRole_index_map
 The datatype of the map between authids and graph vertex descriptors. More...
 
using degree_s_t = boost::graph_traits< Granted_roles_graph >::degree_size_type
 The type used for the number of edges incident to a vertex in the graph. More...
 
using out_edge_itr_t = boost::graph_traits< Granted_roles_graph >::out_edge_iterator
 The type for the iterator returned by out_edges(). More...
 
using in_edge_itr_t = boost::graph_traits< Granted_roles_graph >::in_edge_iterator
 The type for the iterator returned by in_edges(). More...
 
typedef LF_HASH Acl_cache_internal
 

Enumerations

enum  boost::vertex_acl_user_t { boost::vertex_acl_user }
 
enum class  Acl_cache_lock_mode { READ_MODE = 1 , WRITE_MODE }
 Enum for specifying lock type over Acl cache. More...
 

Functions

Acl_user_ptr_listcached_acl_users_for_name (const char *name)
 Fetch the list of ACL_USERs which share name or have no name. More...
 
void rebuild_cached_acl_users_for_name (void)
 Build the lists of ACL_USERs which share name or have no name. More...
 
template<class T >
T * name_hash_search (const malloc_unordered_multimap< std::string, unique_ptr_destroy_only< T > > &name_hash, const char *host, const char *ip, const char *db, const char *user, const char *tname, bool exact, bool name_tolower)
 
GRANT_NAMEroutine_hash_search (const char *host, const char *ip, const char *db, const char *user, const char *tname, bool proc, bool exact)
 
GRANT_TABLEtable_hash_search (const char *host, const char *ip, const char *db, const char *user, const char *tname, bool exact)
 
GRANT_COLUMNcolumn_hash_search (GRANT_TABLE *t, const char *cname, size_t length)
 
 boost::BOOST_INSTALL_PROPERTY (vertex, acl_user)
 
Acl_cacheget_global_acl_cache ()
 

Variables

MEM_ROOT global_acl_memory
 
MEM_ROOT memex
 
const size_t ACL_PREALLOC_SIZE = 10U
 
Prealloced_array< ACL_USER, ACL_PREALLOC_SIZE > * acl_users
 
Prealloced_array< ACL_PROXY_USER, ACL_PREALLOC_SIZE > * acl_proxy_users
 
Prealloced_array< ACL_DB, ACL_PREALLOC_SIZE > * acl_dbs
 
Prealloced_array< ACL_HOST_AND_IP, ACL_PREALLOC_SIZE > * acl_wild_hosts
 
std::unique_ptr< malloc_unordered_multimap< std::string, unique_ptr_destroy_only< GRANT_TABLE > > > column_priv_hash
 
std::unique_ptr< malloc_unordered_multimap< std::string, unique_ptr_destroy_only< GRANT_NAME > > > proc_priv_hash
 
std::unique_ptr< malloc_unordered_multimap< std::string, unique_ptr_destroy_only< GRANT_NAME > > > func_priv_hash
 
collation_unordered_map< std::string, ACL_USER * > * acl_check_hosts
 
bool allow_all_hosts
 
uint grant_version
 
std::unique_ptr< Acl_restrictionsacl_restrictions
 
MYSQL_PLUGIN_IMPORT CHARSET_INFOfiles_charset_info
 

Macro Definition Documentation

◆ NUM_CREDENTIALS

#define NUM_CREDENTIALS   2

◆ PRIMARY_CRED

#define PRIMARY_CRED   (NUM_CREDENTIALS - NUM_CREDENTIALS)

◆ SECOND_CRED

#define SECOND_CRED   (PRIMARY_CRED + 1)

Typedef Documentation

◆ Acl_cache_internal

◆ Acl_user_ptr_allocator

◆ Acl_user_ptr_list

◆ degree_s_t

using degree_s_t = boost::graph_traits<Granted_roles_graph>::degree_size_type

The type used for the number of edges incident to a vertex in the graph.

◆ Granted_roles_graph

typedef boost::adjacency_list<boost::setS, boost::vecS, boost::bidirectionalS, Role_properties, Role_edge_properties> Granted_roles_graph

A graph of all users/roles privilege inheritance.

◆ in_edge_itr_t

using in_edge_itr_t = boost::graph_traits<Granted_roles_graph>::in_edge_iterator

The type for the iterator returned by in_edges().

◆ out_edge_itr_t

using out_edge_itr_t = boost::graph_traits<Granted_roles_graph>::out_edge_iterator

The type for the iterator returned by out_edges().

◆ Role_edge_descriptor

typedef boost::graph_traits<Granted_roles_graph>::edge_descriptor Role_edge_descriptor

The data type of an edge in the Granted_roles_graph.

◆ Role_edge_properties

typedef boost::property<boost::edge_capacity_t, int> Role_edge_properties

◆ Role_index_map

typedef std::unordered_map<std::string, Role_vertex_descriptor> Role_index_map

The datatype of the map between authids and graph vertex descriptors.

◆ Role_properties

typedef boost::property<boost::vertex_acl_user_t, ACL_USER, boost::property<boost::vertex_name_t, std::string> > Role_properties

Custom vertex properties used in Granted_roles_graph TODO ACL_USER contains too much information.

We only need global access, username and hostname. If this was a POD we don't have to hold the same mutex as ACL_USER.

◆ Role_vertex_descriptor

typedef boost::graph_traits<Granted_roles_graph>::vertex_descriptor Role_vertex_descriptor

The data type of a vertex in the Granted_roles_graph.

Enumeration Type Documentation

◆ Acl_cache_lock_mode

enum class Acl_cache_lock_mode
strong

Enum for specifying lock type over Acl cache.

Enumerator
READ_MODE 
WRITE_MODE 

Function Documentation

◆ cached_acl_users_for_name()

Acl_user_ptr_list * cached_acl_users_for_name ( const char *  name)

Fetch the list of ACL_USERs which share name or have no name.

Parameters
[in]nameUser entry to be searched
Returns
List of users that share same name

◆ column_hash_search()

GRANT_COLUMN * column_hash_search ( GRANT_TABLE t,
const char *  cname,
size_t  length 
)
inline

◆ get_global_acl_cache()

Acl_cache * get_global_acl_cache ( )

◆ name_hash_search()

template<class T >
T * name_hash_search ( const malloc_unordered_multimap< std::string, unique_ptr_destroy_only< T > > &  name_hash,
const char *  host,
const char *  ip,
const char *  db,
const char *  user,
const char *  tname,
bool  exact,
bool  name_tolower 
)

◆ rebuild_cached_acl_users_for_name()

void rebuild_cached_acl_users_for_name ( void  )

Build the lists of ACL_USERs which share name or have no name.

All accounts with same name will be chained so that they can be retrieved by a single lookup. These entries are sorted using ACL_compare to make sure that most specific account is picked up first. Anonymous user is added to each chain.

◆ routine_hash_search()

GRANT_NAME * routine_hash_search ( const char *  host,
const char *  ip,
const char *  db,
const char *  user,
const char *  tname,
bool  proc,
bool  exact 
)
inline

◆ table_hash_search()

GRANT_TABLE * table_hash_search ( const char *  host,
const char *  ip,
const char *  db,
const char *  user,
const char *  tname,
bool  exact 
)
inline

Variable Documentation

◆ acl_check_hosts

collation_unordered_map<std::string, ACL_USER *>* acl_check_hosts
extern

◆ acl_dbs

◆ ACL_PREALLOC_SIZE

const size_t ACL_PREALLOC_SIZE = 10U

◆ acl_proxy_users

◆ acl_restrictions

std::unique_ptr<Acl_restrictions> acl_restrictions
extern

◆ acl_users

◆ acl_wild_hosts

◆ allow_all_hosts

bool allow_all_hosts
extern

◆ column_priv_hash

std::unique_ptr<malloc_unordered_multimap< std::string, unique_ptr_destroy_only<GRANT_TABLE> > > column_priv_hash
extern

◆ files_charset_info

MYSQL_PLUGIN_IMPORT CHARSET_INFO* files_charset_info
extern

◆ func_priv_hash

std::unique_ptr< malloc_unordered_multimap<std::string, unique_ptr_destroy_only<GRANT_NAME> > > func_priv_hash

◆ global_acl_memory

MEM_ROOT global_acl_memory
extern

◆ grant_version

uint grant_version
extern

◆ memex

MEM_ROOT memex
extern

◆ proc_priv_hash

std::unique_ptr< malloc_unordered_multimap<std::string, unique_ptr_destroy_only<GRANT_NAME> > > proc_priv_hash
extern