MySQL  8.0.16
Source Code Documentation
Security_context Class Reference

A set of THD members describing the current authenticated user. More...

#include <sql_security_ctx.h>

Public Member Functions

 Security_context (THD *thd=nullptr)
 
 Security_context (MEM_ROOT *m_mem_root, THD *thd=nullptr)
 
 ~Security_context ()
 
 Security_context (const Security_context &src_sctx)
 
Security_contextoperator= (const Security_context &src_sctx)
 
void skip_grants (const char *user="skip-grants user", const char *host="skip-grants host")
 Grants all privilegs to user. More...
 
bool is_skip_grants_user ()
 
LEX_CSTRING user () const
 Getter method for member m_user. More...
 
void set_user_ptr (const char *user_arg, const size_t user_arg_length)
 Setter method for member m_user. More...
 
void assign_user (const char *user_arg, const size_t user_arg_length)
 Setter method for member m_user. More...
 
std::pair< bool, boolhas_global_grant (const char *priv, size_t priv_len)
 Checks if the Current_user has the asked dynamic privilege. More...
 
std::pair< bool, boolhas_global_grant (const Auth_id &auth_id, const std::string &privilege, bool cumulative=false)
 Checks if the Auth_id have the asked dynamic privilege. More...
 
bool can_operate_with (const Auth_id &auth_id, const std::string &privilege, bool cumulative=false, bool ignore_if_nonextant=true)
 Checks if the specified auth_id with privilege can work with the current_user. More...
 
int activate_role (LEX_CSTRING user, LEX_CSTRING host, bool validate_access=false)
 This method pushes a role to the list of active roles. More...
 
void clear_active_roles (void)
 This helper method clears the active roles list and frees the allocated memory used for any previously activated roles. More...
 
List_of_auth_id_refsget_active_roles ()
 
size_t get_num_active_roles () const
 
void get_active_roles (THD *, List< LEX_USER > &)
 Get sorted list of roles in LEX_USER format. More...
 
void checkout_access_maps (void)
 Subscribes to a cache entry of aggregated ACLs. More...
 
ulong db_acl (LEX_CSTRING db, bool use_pattern_scan=true) const
 
ulong procedure_acl (LEX_CSTRING db, LEX_CSTRING procedure_name)
 
ulong function_acl (LEX_CSTRING db, LEX_CSTRING procedure_name)
 
ulong table_acl (LEX_CSTRING db, LEX_CSTRING table)
 
Grant_table_aggregate table_and_column_acls (LEX_CSTRING db, LEX_CSTRING table)
 
bool has_with_admin_acl (const LEX_CSTRING &role_name, const LEX_CSTRING &role_host)
 
bool any_sp_acl (const LEX_CSTRING &db)
 
bool any_table_acl (const LEX_CSTRING &db)
 
LEX_CSTRING host () const
 Getter method for member m_host. More...
 
void set_host_ptr (const char *host_arg, const size_t host_arg_length)
 Setter method for member m_host. More...
 
void assign_host (const char *host_arg, const size_t host_arg_length)
 Setter method for member m_host. More...
 
LEX_CSTRING ip () const
 Getter method for member m_ip. More...
 
void set_ip_ptr (const char *ip_arg, const int ip_arg_length)
 Setter method for member m_ip. More...
 
void assign_ip (const char *ip_arg, const int ip_arg_length)
 Setter method for member m_ip. More...
 
LEX_CSTRING host_or_ip () const
 Getter method for member m_host_or_ip. More...
 
void set_host_or_ip_ptr ()
 Setter method for member m_host_or_ip. More...
 
void set_host_or_ip_ptr (const char *host_or_ip_arg, const int host_or_ip_arg_length)
 Setter method for member m_host_or_ip. More...
 
LEX_CSTRING external_user () const
 Getter method for member m_external_user. More...
 
void set_external_user_ptr (const char *ext_user_arg, const int ext_user_arg_length)
 Setter method for member m_external_user. More...
 
void assign_external_user (const char *ext_user_arg, const int ext_user_arg_length)
 Setter method for member m_external_user. More...
 
LEX_CSTRING priv_user () const
 Getter method for member m_priv_user. More...
 
void assign_priv_user (const char *priv_user_arg, const size_t priv_user_arg_length)
 Setter method for member m_priv_user. More...
 
LEX_CSTRING proxy_user () const
 Getter method for member m_proxy_user. More...
 
void assign_proxy_user (const char *proxy_user_arg, const size_t proxy_user_arg_length)
 Setter method for member m_proxy_user. More...
 
LEX_CSTRING priv_host () const
 Getter method for member m_priv_host. More...
 
void assign_priv_host (const char *priv_host_arg, const size_t priv_host_arg_length)
 Setter method for member m_priv_host. More...
 
const char * priv_host_name () const
 
ulong master_access () const
 Getter method for member m_master_access. More...
 
ulong master_access (const std::string &db_name) const
 
const Restrictions restrictions () const
 
void set_master_access (ulong master_access)
 
void set_master_access (ulong master_access, const Restrictions &restrictions)
 
bool has_account_assigned () const
 Check if a an account has been assigned to the security context. More...
 
bool check_access (ulong want_access, const std::string &db_name="", bool match_any=false)
 Check permission against m_master_access. More...
 
ulong current_db_access () const
 
Returns the schema level effective privileges (with applied roles) for the currently active schema. More...
 
void cache_current_db_access (ulong db_access)
 Cache the schema level effective privileges (apply roles first!) for the currently active schema. More...
 
bool password_expired () const
 Getter method for member m_password_expired. More...
 
void set_password_expired (bool password_expired)
 
bool change_security_context (THD *thd, const LEX_CSTRING &definer_user, const LEX_CSTRING &definer_host, LEX_STRING *db, Security_context **backup, bool force=false)
 Initialize this security context from the passed in credentials and activate it in the current thread. More...
 
void restore_security_context (THD *thd, Security_context *backup)
 
bool user_matches (Security_context *)
 
void logout ()
 
bool account_is_locked ()
 Locked account can still be used as routine definers and when they are there shouldn't be any checks for expired passwords. More...
 
void lock_account (bool is_locked)
 
void set_drop_policy (const std::function< void(Security_context *)> &func)
 
void add_as_local_temp_privs (const std::vector< std::string > &privs)
 
bool check_in_local_temp_privs (const std::string &priv)
 
bool has_drop_policy (void)
 
bool has_executed_drop_policy (void)
 
void execute_drop_policy (void)
 
bool is_access_restricted_on_db (ulong want_access, const std::string &db_name) const
 
void clear_db_restrictions ()
 

Private Member Functions

void init ()
 
void destroy ()
 
void copy_security_ctx (const Security_context &src_sctx)
 Deep copy status of sctx object to this. More...
 
ulong filter_access (const ulong access, const std::string &db_name) const
 If there is a restriction attached to an access on the given database then remove that access otherwise return the access without any change. More...
 
void init_restrictions (const Restrictions &restrictions)
 
std::pair< bool, boolfetch_global_grant (const ACL_USER &acl_user, const std::string &privilege, bool cumulative=false)
 Checks if the acl_user does have the asked dynamic privilege. More...
 

Private Attributes

String m_user
 m_user - user of the client, set to NULL until the user has been read from the connection More...
 
String m_host
 m_host - host of the client More...
 
String m_ip
 m_ip - client IP More...
 
String m_host_or_ip
 m_host_or_ip - points to host if host is available, otherwise points to ip More...
 
String m_external_user
 
char m_priv_user [USERNAME_LENGTH]
 m_priv_user - The user privilege we are using. More...
 
size_t m_priv_user_length
 
char m_proxy_user [USERNAME_LENGTH+MAX_HOSTNAME+5]
 
size_t m_proxy_user_length
 
char m_priv_host [MAX_HOSTNAME]
 The host privilege we are using. More...
 
size_t m_priv_host_length
 
ulong m_master_access
 Global privileges from mysql.user. More...
 
ulong m_db_access
 Privileges for current db. More...
 
bool m_password_expired
 password expiration flag. More...
 
List_of_auth_id_refs m_active_roles
 
Acl_mapm_acl_map
 
int m_map_checkout_count
 
bool m_is_locked
 True if this account can't be logged into. More...
 
bool m_is_skip_grants_user
 True if the skip_grants_user is set. More...
 
bool m_executed_drop_policy
 
bool m_has_drop_policy
 
std::unique_ptr< std::function< void(Security_context *)> > m_drop_policy
 
Restrictions m_restrictions
 
THDm_thd
 m_thd - Thread handle, set to nullptr if this does not belong to any THD yet More...
 

Detailed Description

A set of THD members describing the current authenticated user.

Constructor & Destructor Documentation

◆ Security_context() [1/3]

Security_context::Security_context ( THD thd = nullptr)

◆ Security_context() [2/3]

Security_context::Security_context ( MEM_ROOT m_mem_root,
THD thd = nullptr 
)

◆ ~Security_context()

Security_context::~Security_context ( )

◆ Security_context() [3/3]

Security_context::Security_context ( const Security_context src_sctx)

Member Function Documentation

◆ account_is_locked()

bool Security_context::account_is_locked ( )
inline

Locked account can still be used as routine definers and when they are there shouldn't be any checks for expired passwords.

◆ activate_role()

int Security_context::activate_role ( LEX_CSTRING  role,
LEX_CSTRING  role_host,
bool  validate_access = false 
)

This method pushes a role to the list of active roles.

It requires Acl_cache_lock_guard.

This method allocates memory which must be freed when the role is deactivated.

Parameters
roleThe role name
role_hostThe role hostname-part.
validate_accessTrue if access validation should be performed. Default value is false.

◆ add_as_local_temp_privs()

void Security_context::add_as_local_temp_privs ( const std::vector< std::string > &  privs)

◆ any_sp_acl()

bool Security_context::any_sp_acl ( const LEX_CSTRING db)

◆ any_table_acl()

bool Security_context::any_table_acl ( const LEX_CSTRING db)

◆ assign_external_user()

void Security_context::assign_external_user ( const char *  ext_user_arg,
const int  ext_user_arg_length 
)

Setter method for member m_external_user.

Copies ext_user_arg value to the m_external_user if it is not null else m_external_user is set to NULL.

Parameters
[in]ext_user_argNew user value for m_external_user.
[in]ext_user_arg_lengthLength of "ext_user_arg" param.

◆ assign_host()

void Security_context::assign_host ( const char *  host_arg,
const size_t  host_arg_length 
)

Setter method for member m_host.

Copies host_arg value to the m_host if it is not null else m_user is set to empty string.

Parameters
[in]host_argNew user value for m_host.
[in]host_arg_lengthLength of "host_arg" param.

◆ assign_ip()

void Security_context::assign_ip ( const char *  ip_arg,
const int  ip_arg_length 
)

Setter method for member m_ip.

Copies ip_arg value to the m_ip if it is not null else m_ip is set to NULL.

Parameters
[in]ip_argNew user value for m_ip.
[in]ip_arg_lengthLength of "ip_arg" param.

◆ assign_priv_host()

void Security_context::assign_priv_host ( const char *  priv_host_arg,
const size_t  priv_host_arg_length 
)

Setter method for member m_priv_host.

Parameters
[in]priv_host_argNew user value for m_priv_host.
[in]priv_host_arg_lengthLength of "priv_host_arg" param.

◆ assign_priv_user()

void Security_context::assign_priv_user ( const char *  priv_user_arg,
const size_t  priv_user_arg_length 
)

Setter method for member m_priv_user.

Parameters
[in]priv_user_argNew user value for m_priv_user.
[in]priv_user_arg_lengthLength of "priv_user_arg" param.

◆ assign_proxy_user()

void Security_context::assign_proxy_user ( const char *  proxy_user_arg,
const size_t  proxy_user_arg_length 
)

Setter method for member m_proxy_user.

Parameters
[in]proxy_user_argNew user value for m_proxy_user.
[in]proxy_user_arg_lengthLength of "proxy_user_arg" param.

◆ assign_user()

void Security_context::assign_user ( const char *  user_arg,
const size_t  user_arg_length 
)

Setter method for member m_user.

Copies user_arg value to the m_user if it is not null else m_user is set to NULL.

Parameters
[in]user_argNew user value for m_user.
[in]user_arg_lengthLength of "user_arg" param.

◆ cache_current_db_access()

void Security_context::cache_current_db_access ( ulong  db_access)
inline

Cache the schema level effective privileges (apply roles first!) for the currently active schema.

◆ can_operate_with()

bool Security_context::can_operate_with ( const Auth_id auth_id,
const std::string &  privilege,
bool  cumulative = false,
bool  ignore_if_nonextant = true 
)

Checks if the specified auth_id with privilege can work with the current_user.

If the auth_id has the specified privilege then current_user must also have the same privilege. Throws error is the auth_id has the privilege but current_user does not have it.

Parameters
[in]auth_idAuth_id that could represent either a user or a role
[in]privilegePrivilege to check for mismatch
[in]cumulativeFlag to decide how to check the privileges of auth_id false - privilege granted directly or set through a role true - privileges granted directly or coming through roles granted to it irrespective the roles are active or not.
[in]ignore_if_nonextantFlag to decide how to treat the non-existing auth_id. true - consider as privilege exists false - consider as privilege do not exist
Returns
Return values
trueauth_id has the privilege but the current_auth does not
falseOtherwise

◆ change_security_context()

bool Security_context::change_security_context ( THD thd,
const LEX_CSTRING definer_user,
const LEX_CSTRING definer_host,
LEX_STRING db,
Security_context **  backup,
bool  force = false 
)

Initialize this security context from the passed in credentials and activate it in the current thread.

Parameters
thd
definer_user
definer_host
db
[out]backupSave a pointer to the current security context in the thread. In case of success it points to the saved old context, otherwise it points to NULL.
forceForce context switch
Note
The Security_context_factory should be used as a replacement to this function at every opportunity.

During execution of a statement, multiple security contexts may be needed:

  • the security context of the authenticated user, used as the default security context for all top-level statements
  • in case of a view or a stored program, possibly the security context of the definer of the routine, if the object is defined with SQL SECURITY DEFINER option.

The currently "active" security context is parameterized in THD member security_ctx. By default, after a connection is established, this member points at the "main" security context

  • the credentials of the authenticated user.

Later, if we would like to execute some sub-statement or a part of a statement under credentials of a different user, e.g. definer of a procedure, we authenticate this user in a local instance of Security_context by means of this method (and ultimately by means of acl_getroot), and make the local instance active in the thread by re-setting thd->m_security_ctx pointer.

Note, that the life cycle and memory management of the "main" and temporary security contexts are different. For the main security context, the memory for user/host/ip is allocated on system heap, and the THD class frees this memory in its destructor. The only case when contents of the main security context may change during its life time is when someone issued CHANGE USER command. Memory management of a "temporary" security context is responsibility of the module that creates it.

Return values
truethere is no user with the given credentials. The erro is reported in the thread.
falsesuccess

◆ check_access()

bool Security_context::check_access ( ulong  want_access,
const std::string &  db_name = "",
bool  match_any = false 
)

Check permission against m_master_access.

Check global access

Parameters
want_accessThe required privileges
db_nameThe database name to check if it has restrictions attached
match_anyif the security context must match all or any of the req. privileges.
Returns
True if the security context fulfills the access requirements.

◆ check_in_local_temp_privs()

bool Security_context::check_in_local_temp_privs ( const std::string &  priv)

◆ checkout_access_maps()

void Security_context::checkout_access_maps ( void  )

Subscribes to a cache entry of aggregated ACLs.

A Security_context can only have one subscription at a time. If another one is requested, the former will be returned.

◆ clear_active_roles()

void Security_context::clear_active_roles ( void  )

This helper method clears the active roles list and frees the allocated memory used for any previously activated roles.

◆ clear_db_restrictions()

void Security_context::clear_db_restrictions ( )
inline

◆ copy_security_ctx()

void Security_context::copy_security_ctx ( const Security_context src_sctx)
private

Deep copy status of sctx object to this.

Parameters
[in]src_sctxObject from which status should be copied.

◆ current_db_access()

ulong Security_context::current_db_access ( ) const
inline


Returns the schema level effective privileges (with applied roles) for the currently active schema.

◆ db_acl()

ulong Security_context::db_acl ( LEX_CSTRING  db,
bool  use_pattern_scan = true 
) const

◆ destroy()

void Security_context::destroy ( )
private

◆ execute_drop_policy()

void Security_context::execute_drop_policy ( void  )

◆ external_user()

LEX_CSTRING Security_context::external_user ( ) const
inline

Getter method for member m_external_user.

Return values
LEX_CSTRINGobject having constant pointer to m_external_host.Ptr and its length

◆ fetch_global_grant()

std::pair< bool, bool > Security_context::fetch_global_grant ( const ACL_USER acl_user,
const std::string &  privilege,
bool  cumulative = false 
)
private

Checks if the acl_user does have the asked dynamic privilege.

This method assumes acl_cache_lock is already taken and ACL_USER is valid

Parameters
[in]acl_userACL_USER to check for privilege
[in]privilegeprivilege to check for
[in]cumulativeFlag to decide how to fetch the privileges of ACL_USER false - privilege granted directly or set through a role true - privileges granted directly or coming through roles granted to it irrespective the roles are active or not.
Returns
pair/<has_privilege, has_with_grant_option/>
Return values
/<true,true/>has required privilege with grant option
/<true,false/>has required privilege without grant option
/<false,false/>does not have the required privilege

◆ filter_access()

ulong Security_context::filter_access ( const ulong  access,
const std::string &  db_name 
) const
private

If there is a restriction attached to an access on the given database then remove that access otherwise return the access without any change.

Parameters
[in]accessaccess mask to be scanned to remove
[in]db_namedatabase to be searched in the restrictions
Return values
filteredaccess mask

◆ function_acl()

ulong Security_context::function_acl ( LEX_CSTRING  db,
LEX_CSTRING  procedure_name 
)

◆ get_active_roles() [1/2]

List_of_auth_id_refs * Security_context::get_active_roles ( void  )

◆ get_active_roles() [2/2]

void Security_context::get_active_roles ( THD thd,
List< LEX_USER > &  list 
)

Get sorted list of roles in LEX_USER format.

Parameters
[in]thdFor mem_root
[out]listList of active roles

◆ get_num_active_roles()

size_t Security_context::get_num_active_roles ( void  ) const

◆ has_account_assigned()

bool Security_context::has_account_assigned ( ) const
inline

Check if a an account has been assigned to the security context.

The account assigment to the security context is always executed in the following order: 1) assign user's name to the context 2) assign user's hostname to the context Whilst user name can be null, hostname cannot. This is why we can say that the full account has been assigned to the context when hostname is not equal to empty string.

Returns
Account assignment status
Return values
trueaccount has been assigned to the security context
falseaccount has not yet been assigned to the security context

◆ has_drop_policy()

bool Security_context::has_drop_policy ( void  )

◆ has_executed_drop_policy()

bool Security_context::has_executed_drop_policy ( void  )

◆ has_global_grant() [1/2]

std::pair< bool, bool > Security_context::has_global_grant ( const char *  priv,
size_t  priv_len 
)

Checks if the Current_user has the asked dynamic privilege.

if the server is initializing the datadir, or current_user is –skip-grants-user then it returns that user has privilege with grant option.

Parameters
[in]privprivilege to check
[in]priv_lenlength of privilege
Returns
pair/<has_privilege, has_with_grant_option/>
Return values
/<true,true/>has required privilege with grant option
/<true,false/>has required privilege without grant option
/<false,false/>does not have the required privilege

◆ has_global_grant() [2/2]

std::pair< bool, bool > Security_context::has_global_grant ( const Auth_id auth_id,
const std::string &  privilege,
bool  cumulative = false 
)

Checks if the Auth_id have the asked dynamic privilege.

Parameters
[in]auth_idAuth_id that could represent either a user or a role
[in]privilegeprivilege to check for
[in]cumulativeFlag to decide how to fetch the privileges of ACL_USER false - privilege granted directly or set through a role true - privileges granted directly or coming through roles granted to it irrespective the roles are active or not.
Returns
pair/<has_privilege, has_with_grant_option/>
Return values
/<true,true/>has required privilege with grant option
/<true,false/>has required privilege without grant option
/<false,false/>does not have the required privilege, OR auth_id does not exist.

◆ has_with_admin_acl()

bool Security_context::has_with_admin_acl ( const LEX_CSTRING role_name,
const LEX_CSTRING role_host 
)

◆ host()

LEX_CSTRING Security_context::host ( ) const

Getter method for member m_host.

Return values
LEX_CSTRINGobject having constant pointer to m_host.Ptr and its length.

◆ host_or_ip()

LEX_CSTRING Security_context::host_or_ip ( ) const
inline

Getter method for member m_host_or_ip.

Return values
LEX_CSTRINGobject having constant pointer to m_host_or_ip.Ptr and its length

◆ init()

void Security_context::init ( )
private

◆ init_restrictions()

void Security_context::init_restrictions ( const Restrictions restrictions)
private

◆ ip()

LEX_CSTRING Security_context::ip ( ) const

Getter method for member m_ip.

Return values
LEX_CSTRINGobject having constant pointer to m_ip.Ptr and its length

◆ is_access_restricted_on_db()

bool Security_context::is_access_restricted_on_db ( ulong  want_access,
const std::string &  db_name 
) const

◆ is_skip_grants_user()

bool Security_context::is_skip_grants_user ( )
inline

◆ lock_account()

void Security_context::lock_account ( bool  is_locked)
inline

◆ logout()

void Security_context::logout ( )

◆ master_access() [1/2]

ulong Security_context::master_access ( ) const
inline

Getter method for member m_master_access.

◆ master_access() [2/2]

ulong Security_context::master_access ( const std::string &  db_name) const

◆ operator=()

Security_context & Security_context::operator= ( const Security_context src_sctx)

◆ password_expired()

bool Security_context::password_expired ( ) const
inline

Getter method for member m_password_expired.

◆ priv_host()

LEX_CSTRING Security_context::priv_host ( ) const

Getter method for member m_priv_host.

Return values
LEX_CSTRINGobject having constant pointer to m_priv_host.Ptr and its length

◆ priv_host_name()

const char * Security_context::priv_host_name ( ) const
inline

◆ priv_user()

LEX_CSTRING Security_context::priv_user ( ) const

Getter method for member m_priv_user.

Return values
LEX_CSTRINGobject having constant pointer to m_priv_user.Ptr and its length

◆ procedure_acl()

ulong Security_context::procedure_acl ( LEX_CSTRING  db,
LEX_CSTRING  procedure_name 
)

◆ proxy_user()

LEX_CSTRING Security_context::proxy_user ( ) const

Getter method for member m_proxy_user.

Return values
LEX_CSTRINGobject having constant pointer to m_proxy_user.Ptr and its length

◆ restore_security_context()

void Security_context::restore_security_context ( THD thd,
Security_context backup 
)

◆ restrictions()

const Restrictions Security_context::restrictions ( ) const
inline

◆ set_drop_policy()

void Security_context::set_drop_policy ( const std::function< void(Security_context *)> &  func)

◆ set_external_user_ptr()

void Security_context::set_external_user_ptr ( const char *  ext_user_arg,
const int  ext_user_arg_length 
)

Setter method for member m_external_user.

Function just sets the ext_user_arg pointer to the m_external_user, ext_user_arg is not copied.

Parameters
[in]ext_user_argNew user value for m_external_user.
[in]ext_user_arg_lengthLength of "ext_user_arg" param.

◆ set_host_or_ip_ptr() [1/2]

void Security_context::set_host_or_ip_ptr ( )
inline

Setter method for member m_host_or_ip.

◆ set_host_or_ip_ptr() [2/2]

void Security_context::set_host_or_ip_ptr ( const char *  host_or_ip_arg,
const int  host_or_ip_arg_length 
)
inline

Setter method for member m_host_or_ip.

Parameters
[in]host_or_ip_argNew user value for m_host_or_ip.
[in]host_or_ip_arg_lengthLength of "host_or_ip_arg" param.

◆ set_host_ptr()

void Security_context::set_host_ptr ( const char *  host_arg,
const size_t  host_arg_length 
)

Setter method for member m_host.

Function just sets the host_arg pointer value to the m_host, host_arg value is not copied. host_arg value must not be NULL.

Parameters
[in]host_argNew user value for m_host.
[in]host_arg_lengthLength of "host_arg" param.

◆ set_ip_ptr()

void Security_context::set_ip_ptr ( const char *  ip_arg,
const int  ip_arg_length 
)

Setter method for member m_ip.

Function just sets the ip_arg pointer value to the m_ip, ip_arg value is not copied.

Parameters
[in]ip_argNew user value for m_ip.
[in]ip_arg_lengthLength of "ip_arg" param.

◆ set_master_access() [1/2]

void Security_context::set_master_access ( ulong  master_access)
inline

◆ set_master_access() [2/2]

void Security_context::set_master_access ( ulong  master_access,
const Restrictions restrictions 
)
inline

◆ set_password_expired()

void Security_context::set_password_expired ( bool  password_expired)
inline

◆ set_user_ptr()

void Security_context::set_user_ptr ( const char *  user_arg,
const size_t  user_arg_length 
)

Setter method for member m_user.

Function just sets the user_arg pointer value to the m_user, user_arg value is not copied.

Parameters
[in]user_argNew user value for m_user.
[in]user_arg_lengthLength of "user_arg" param.

◆ skip_grants()

void Security_context::skip_grants ( const char *  user = "skip-grants user",
const char *  host = "skip-grants host" 
)

Grants all privilegs to user.

Sets the user and host name of privilege user.

Parameters
[in]userUser name for current_user to set. Default value is "skip-grants user"
[in]hostHost name for the current user to set. Default value is "skip-grants host"

◆ table_acl()

ulong Security_context::table_acl ( LEX_CSTRING  db,
LEX_CSTRING  table 
)

◆ table_and_column_acls()

Grant_table_aggregate Security_context::table_and_column_acls ( LEX_CSTRING  db,
LEX_CSTRING  table 
)

◆ user()

LEX_CSTRING Security_context::user ( ) const

Getter method for member m_user.

Return values
LEX_CSTRINGobject having constant pointer to m_user.Ptr and its length.

◆ user_matches()

bool Security_context::user_matches ( Security_context them)

Member Data Documentation

◆ m_acl_map

Acl_map* Security_context::m_acl_map
private

◆ m_active_roles

List_of_auth_id_refs Security_context::m_active_roles
private

◆ m_db_access

ulong Security_context::m_db_access
private

Privileges for current db.

◆ m_drop_policy

std::unique_ptr<std::function<void(Security_context *)> > Security_context::m_drop_policy
private

◆ m_executed_drop_policy

bool Security_context::m_executed_drop_policy
private

◆ m_external_user

String Security_context::m_external_user
private

◆ m_has_drop_policy

bool Security_context::m_has_drop_policy
private

◆ m_host

String Security_context::m_host
private

m_host - host of the client

◆ m_host_or_ip

String Security_context::m_host_or_ip
private

m_host_or_ip - points to host if host is available, otherwise points to ip

◆ m_ip

String Security_context::m_ip
private

m_ip - client IP

◆ m_is_locked

bool Security_context::m_is_locked
private

True if this account can't be logged into.

◆ m_is_skip_grants_user

bool Security_context::m_is_skip_grants_user
private

True if the skip_grants_user is set.

◆ m_map_checkout_count

int Security_context::m_map_checkout_count
private

◆ m_master_access

ulong Security_context::m_master_access
private

Global privileges from mysql.user.

◆ m_password_expired

bool Security_context::m_password_expired
private

password expiration flag.

This flag is set according to connecting user's context and not the effective user.

◆ m_priv_host

char Security_context::m_priv_host[MAX_HOSTNAME]
private

The host privilege we are using.

◆ m_priv_host_length

size_t Security_context::m_priv_host_length
private

◆ m_priv_user

char Security_context::m_priv_user[USERNAME_LENGTH]
private

m_priv_user - The user privilege we are using.

May be "" for anonymous user.

◆ m_priv_user_length

size_t Security_context::m_priv_user_length
private

◆ m_proxy_user

char Security_context::m_proxy_user[USERNAME_LENGTH+MAX_HOSTNAME+5]
private

◆ m_proxy_user_length

size_t Security_context::m_proxy_user_length
private

◆ m_restrictions

Restrictions Security_context::m_restrictions
private

◆ m_thd

THD* Security_context::m_thd
private

m_thd - Thread handle, set to nullptr if this does not belong to any THD yet

◆ m_user

String Security_context::m_user
private

m_user - user of the client, set to NULL until the user has been read from the connection


The documentation for this class was generated from the following files: