diff options
Diffstat (limited to 'sql/sql_acl.cc')
-rw-r--r-- | sql/sql_acl.cc | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index b986c854391..67263386706 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB Corporation. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -63,8 +63,10 @@ bool mysql_user_table_is_in_short_password_format= false; bool using_global_priv_table= true; // set that from field length in acl_load? +#ifndef NO_EMBEDDED_ACCESS_CHECKS const uint max_hostname_length= 60; const uint max_dbname_length= 64; +#endif #include "sql_acl_getsort.ic" @@ -2244,7 +2246,7 @@ bool acl_init(bool dont_read_acl_tables) acl_cache= new Hash_filo<acl_entry>(ACL_CACHE_SIZE, 0, 0, (my_hash_get_key) acl_entry_get_key, (my_hash_free_key) free, - &my_charset_utf8_bin); + &my_charset_utf8mb3_bin); /* cache built-in native authentication plugins, @@ -2681,10 +2683,10 @@ bool acl_reload(THD *thd) my_init_dynamic_array(&acl_users, sizeof(ACL_USER), 50, 100, MYF(0)); acl_dbs.init(50, 100); my_init_dynamic_array(&acl_proxy_users, sizeof(ACL_PROXY_USER), 50, 100, MYF(0)); - my_hash_init2(&acl_roles,50, &my_charset_utf8_bin, + my_hash_init2(&acl_roles,50, &my_charset_utf8mb3_bin, 0, 0, 0, (my_hash_get_key) acl_role_get_key, 0, (void (*)(void *))free_acl_role, 0); - my_hash_init2(&acl_roles_mappings, 50, &my_charset_utf8_bin, 0, 0, 0, + my_hash_init2(&acl_roles_mappings, 50, &my_charset_utf8mb3_bin, 0, 0, 0, (my_hash_get_key) acl_role_map_get_key, 0, 0, 0); old_mem= acl_memroot; delete_dynamic(&acl_wild_hosts); @@ -4168,7 +4170,7 @@ bool hostname_requires_resolving(const char *hostname) if (hostname == my_localhost || (hostname_len == localhost_len && - !my_strnncoll(system_charset_info, + !system_charset_info->strnncoll( (const uchar *) hostname, hostname_len, (const uchar *) my_localhost, strlen(my_localhost)))) { @@ -7568,21 +7570,20 @@ static bool grant_load(THD *thd, TABLE *t_table, *c_table, *p_table; bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; MEM_ROOT *save_mem_root= thd->mem_root; - sql_mode_t old_sql_mode= thd->variables.sql_mode; DBUG_ENTER("grant_load"); - thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH; + Sql_mode_instant_remove sms(thd, MODE_PAD_CHAR_TO_FULL_LENGTH); - (void) my_hash_init(&column_priv_hash, &my_charset_utf8_bin, + (void) my_hash_init(&column_priv_hash, &my_charset_utf8mb3_bin, 0,0,0, (my_hash_get_key) get_grant_table, (my_hash_free_key) free_grant_table,0); - (void) my_hash_init(&proc_priv_hash, &my_charset_utf8_bin, + (void) my_hash_init(&proc_priv_hash, &my_charset_utf8mb3_bin, 0,0,0, (my_hash_get_key) get_grant_table, 0,0); - (void) my_hash_init(&func_priv_hash, &my_charset_utf8_bin, + (void) my_hash_init(&func_priv_hash, &my_charset_utf8mb3_bin, 0,0,0, (my_hash_get_key) get_grant_table, 0,0); - (void) my_hash_init(&package_spec_priv_hash, &my_charset_utf8_bin, + (void) my_hash_init(&package_spec_priv_hash, &my_charset_utf8mb3_bin, 0,0,0, (my_hash_get_key) get_grant_table, 0,0); - (void) my_hash_init(&package_body_priv_hash, &my_charset_utf8_bin, + (void) my_hash_init(&package_body_priv_hash, &my_charset_utf8mb3_bin, 0,0,0, (my_hash_get_key) get_grant_table, 0,0); init_sql_alloc(&grant_memroot, "GRANT", ACL_ALLOC_BLOCK_SIZE, 0, MYF(0)); @@ -7696,7 +7697,6 @@ end_unlock: t_table->file->ha_index_end(); thd->mem_root= save_mem_root; end_index_init: - thd->variables.sql_mode= old_sql_mode; DBUG_RETURN(return_val); } @@ -10683,7 +10683,6 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list, bool handle_as_role) LEX_USER *user_name, *tmp_user_name; List_iterator <LEX_USER> user_list(list); bool binlog= false; - sql_mode_t old_sql_mode= thd->variables.sql_mode; DBUG_ENTER("mysql_drop_user"); DBUG_PRINT("entry", ("Handle as %s", handle_as_role ? "role" : "user")); @@ -10695,7 +10694,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list, bool handle_as_role) if ((result= tables.open_and_lock(thd, tables_to_open, TL_WRITE))) DBUG_RETURN(result != 1); - thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH; + Sql_mode_instant_remove sms(thd, MODE_PAD_CHAR_TO_FULL_LENGTH); mysql_rwlock_wrlock(&LOCK_grant); mysql_mutex_lock(&acl_cache->lock); @@ -10770,7 +10769,6 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list, bool handle_as_role) result |= write_bin_log(thd, FALSE, thd->query(), thd->query_length()); mysql_rwlock_unlock(&LOCK_grant); - thd->variables.sql_mode= old_sql_mode; DBUG_RETURN(result); } @@ -11309,7 +11307,7 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name, for (counter= 0, revoked= 0 ; counter < hash->records ; ) { GRANT_NAME *grant_proc= (GRANT_NAME*) my_hash_element(hash, counter); - if (!my_strcasecmp(&my_charset_utf8_bin, grant_proc->db, sp_db) && + if (!my_strcasecmp(&my_charset_utf8mb3_bin, grant_proc->db, sp_db) && !my_strcasecmp(system_charset_info, grant_proc->tname, sp_name)) { LEX_USER lex_user; @@ -12768,7 +12766,7 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio) */ ulong nr1=1, nr2=4; CHARSET_INFO *cs= &my_charset_latin1; - cs->coll->hash_sort(cs, (uchar*) sctx->user, strlen(sctx->user), &nr1, &nr2); + cs->hash_sort((uchar*) sctx->user, strlen(sctx->user), &nr1, &nr2); mysql_mutex_lock(&acl_cache->lock); if (!acl_users.elements) @@ -13921,11 +13919,7 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len) if (command == COM_CONNECT && !(thd->main_security_ctx.master_access & SUPER_ACL)) { - mysql_mutex_lock(&LOCK_connection_count); - bool count_ok= (*thd->scheduler->connection_count <= - *thd->scheduler->max_connections); - mysql_mutex_unlock(&LOCK_connection_count); - if (!count_ok) + if (*thd->scheduler->connection_count > *thd->scheduler->max_connections) { // too many connections my_error(ER_CON_COUNT_ERROR, MYF(0)); DBUG_RETURN(1); |