1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge 10.11 into 11.4

This commit is contained in:
Marko Mäkelä
2024-12-02 11:35:34 +02:00
420 changed files with 6452 additions and 4162 deletions

View File

@@ -569,18 +569,20 @@ public:
};
static uchar* acl_entry_get_key(acl_entry *entry, size_t *length,
my_bool not_used __attribute__((unused)))
static const uchar *acl_entry_get_key(const void *entry_, size_t *length,
my_bool)
{
auto entry= static_cast<const acl_entry *>(entry_);
*length=(uint) entry->length;
return (uchar*) entry->key;
return reinterpret_cast<const uchar *>(entry->key);
}
static uchar* acl_role_get_key(ACL_ROLE *entry, size_t *length,
my_bool not_used __attribute__((unused)))
static const uchar *acl_role_get_key(const void *entry_, size_t *length,
my_bool)
{
auto entry= static_cast<const ACL_ROLE *>(entry_);
*length=(uint) entry->user.length;
return (uchar*) entry->user.str;
return reinterpret_cast<const uchar *>(entry->user.str);
}
struct ROLE_GRANT_PAIR : public Sql_alloc
@@ -595,11 +597,12 @@ struct ROLE_GRANT_PAIR : public Sql_alloc
const char *rolename, bool with_admin_option);
};
static uchar* acl_role_map_get_key(ROLE_GRANT_PAIR *entry, size_t *length,
my_bool not_used __attribute__((unused)))
static const uchar *acl_role_map_get_key(const void *entry_, size_t *length,
my_bool)
{
auto entry= static_cast<const ROLE_GRANT_PAIR *>(entry_);
*length=(uint) entry->hashkey.length;
return (uchar*) entry->hashkey.str;
return reinterpret_cast<const uchar *>(entry->hashkey.str);
}
bool ROLE_GRANT_PAIR::init(MEM_ROOT *mem, const char *username,
@@ -688,7 +691,6 @@ bool ROLE_GRANT_PAIR::init(MEM_ROOT *mem, const char *username,
static DYNAMIC_ARRAY acl_hosts, acl_users, acl_proxy_users;
static Dynamic_array<ACL_DB> acl_dbs(PSI_INSTRUMENT_MEM, 0, 50);
typedef Dynamic_array<ACL_DB>::CMP_FUNC acl_dbs_cmp;
static HASH acl_roles;
/*
An hash containing mappings user <--> role
@@ -706,10 +708,10 @@ static DYNAMIC_ARRAY acl_wild_hosts;
static Hash_filo<acl_entry> *acl_cache;
static uint grant_version=0; /* Version of priv tables. incremented by acl_load */
static privilege_t get_access(TABLE *form, uint fieldnr, uint *next_field=0);
static int acl_compare(const ACL_ACCESS *a, const ACL_ACCESS *b);
static int acl_user_compare(const ACL_USER *a, const ACL_USER *b);
static int acl_compare(const void *a, const void *b);
static int acl_user_compare(const void *a, const void *b);
static void rebuild_acl_users();
static int acl_db_compare(const ACL_DB *a, const ACL_DB *b);
static int acl_db_compare(const void *a, const void *b);
static void rebuild_acl_dbs();
static void init_check_host(void);
static void rebuild_check_host(void);
@@ -726,9 +728,9 @@ static bool add_role_user_mapping(const char *uname, const char *hname, const ch
static bool get_YN_as_bool(Field *field);
#define ROLE_CYCLE_FOUND 2
static int traverse_role_graph_up(ACL_ROLE *, void *,
int (*) (ACL_ROLE *, void *),
int (*) (ACL_ROLE *, ACL_ROLE *, void *));
static int
traverse_role_graph_up(ACL_ROLE *, void *, int (*)(ACL_USER_BASE *, void *),
int (*)(ACL_USER_BASE *, ACL_ROLE *, void *));
static int traverse_role_graph_down(ACL_USER_BASE *, void *,
int (*) (ACL_USER_BASE *, void *),
@@ -2260,13 +2262,15 @@ error:
}
static void free_acl_user(ACL_USER *user)
static void free_acl_user(void *user_)
{
ACL_USER *user= static_cast<ACL_USER *>(user_);
delete_dynamic(&(user->role_grants));
}
static void free_acl_role(ACL_ROLE *role)
static void free_acl_role(void *role_)
{
ACL_ROLE *role= static_cast<ACL_ROLE *>(role_);
delete_dynamic(&(role->role_grants));
delete_dynamic(&(role->parent_grantee));
}
@@ -2542,10 +2546,9 @@ bool acl_init(bool dont_read_acl_tables)
bool return_val;
DBUG_ENTER("acl_init");
acl_cache= new Hash_filo<acl_entry>(key_memory_acl_cache, ACL_CACHE_SIZE, 0, 0,
(my_hash_get_key) acl_entry_get_key,
(my_hash_free_key) my_free,
&my_charset_utf8mb3_bin);
acl_cache= new Hash_filo<acl_entry>(key_memory_acl_cache, ACL_CACHE_SIZE, 0,
0, acl_entry_get_key, my_free,
&my_charset_utf8mb3_bin);
/*
cache built-in native authentication plugins,
@@ -2915,7 +2918,7 @@ void acl_free(bool end)
acl_public= NULL;
free_root(&acl_memroot,MYF(0));
delete_dynamic(&acl_hosts);
delete_dynamic_with_callback(&acl_users, (FREE_FUNC) free_acl_user);
delete_dynamic_with_callback(&acl_users, free_acl_user);
acl_dbs.free_memory();
delete_dynamic(&acl_wild_hosts);
delete_dynamic(&acl_proxy_users);
@@ -2998,12 +3001,11 @@ bool acl_reload(THD *thd)
my_init_dynamic_array(key_memory_acl_mem, &acl_users, sizeof(ACL_USER), 50, 100, MYF(0));
acl_dbs.init(key_memory_acl_mem, 50, 100);
my_init_dynamic_array(key_memory_acl_mem, &acl_proxy_users, sizeof(ACL_PROXY_USER), 50, 100, MYF(0));
my_hash_init2(key_memory_acl_mem, &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(key_memory_acl_mem, &acl_roles, 50, &my_charset_utf8mb3_bin, 0,
0, 0, acl_role_get_key, 0, free_acl_role, 0);
my_hash_init2(key_memory_acl_mem, &acl_roles_mappings, 50,
&my_charset_utf8mb3_bin, 0, 0, 0, (my_hash_get_key)
acl_role_map_get_key, 0, 0, 0);
&my_charset_utf8mb3_bin, 0, 0, 0, acl_role_map_get_key, 0, 0,
0);
old_mem= acl_memroot;
delete_dynamic(&acl_wild_hosts);
my_hash_free(&acl_check_hosts);
@@ -3029,7 +3031,7 @@ bool acl_reload(THD *thd)
my_hash_free(&old_acl_roles);
free_root(&old_mem,MYF(0));
delete_dynamic(&old_acl_hosts);
delete_dynamic_with_callback(&old_acl_users, (FREE_FUNC) free_acl_user);
delete_dynamic_with_callback(&old_acl_users, free_acl_user);
delete_dynamic(&old_acl_proxy_users);
my_hash_free(&old_acl_roles_mappings);
}
@@ -3079,8 +3081,10 @@ static privilege_t get_access(TABLE *form, uint fieldnr, uint *next_field)
}
static int acl_compare(const ACL_ACCESS *a, const ACL_ACCESS *b)
static int acl_compare(const void *a_, const void *b_)
{
const ACL_ACCESS *a= static_cast<const ACL_ACCESS *>(a_);
const ACL_ACCESS *b= static_cast<const ACL_ACCESS *>(b_);
if (a->sort > b->sort)
return -1;
if (a->sort < b->sort)
@@ -3088,8 +3092,11 @@ static int acl_compare(const ACL_ACCESS *a, const ACL_ACCESS *b)
return 0;
}
static int acl_user_compare(const ACL_USER *a, const ACL_USER *b)
static int acl_user_compare(const void *a_, const void *b_)
{
const ACL_USER *a= static_cast<const ACL_USER *>(a_);
const ACL_USER *b= static_cast<const ACL_USER *>(b_);
int res= strcmp(a->user.str, b->user.str);
if (res)
return res;
@@ -3108,8 +3115,10 @@ static int acl_user_compare(const ACL_USER *a, const ACL_USER *b)
return -strcmp(a->host.hostname, b->host.hostname);
}
static int acl_db_compare(const ACL_DB *a, const ACL_DB *b)
static int acl_db_compare(const void *a_, const void *b_)
{
const ACL_DB *a= static_cast<const ACL_DB *>(a_);
const ACL_DB *b= static_cast<const ACL_DB *>(b_);
int res= strcmp(a->user, b->user);
if (res)
return res;
@@ -3505,11 +3514,11 @@ int acl_setrole(THD *thd, const char *rolename, privilege_t access)
return 0;
}
static uchar* check_get_key(ACL_USER *buff, size_t *length,
my_bool not_used __attribute__((unused)))
static const uchar *check_get_key(const void *buff_, size_t *length, my_bool)
{
auto buff= static_cast<const ACL_USER *>(buff_);
*length=buff->hostname_length;
return (uchar*) buff->host.hostname;
return reinterpret_cast<const uchar *>(buff->host.hostname);
}
@@ -3854,9 +3863,9 @@ static void init_check_host(void)
(void) my_init_dynamic_array(key_memory_acl_mem, &acl_wild_hosts,
sizeof(struct acl_host_and_ip),
acl_users.elements, 1, MYF(0));
(void) my_hash_init(key_memory_acl_mem, &acl_check_hosts,system_charset_info,
acl_users.elements, 0, 0,
(my_hash_get_key) check_get_key, 0, 0);
(void) my_hash_init(key_memory_acl_mem, &acl_check_hosts,
system_charset_info, acl_users.elements, 0, 0,
check_get_key, 0, 0);
if (!allow_all_hosts)
{
for (size_t i=0 ; i < acl_users.elements ; i++)
@@ -5455,11 +5464,12 @@ public:
};
static uchar* get_key_column(GRANT_COLUMN *buff, size_t *length,
my_bool not_used __attribute__((unused)))
static const uchar *get_key_column(const void *buff_, size_t *length, my_bool)
{
auto buff=
static_cast<const GRANT_COLUMN *>(buff_);
*length=buff->key_length;
return (uchar*) buff->column;
return reinterpret_cast<const uchar *>(buff->column);
}
class GRANT_NAME :public Sql_alloc
@@ -5503,7 +5513,7 @@ public:
void init_hash()
{
my_hash_init2(key_memory_acl_memex, &hash_columns, 4, system_charset_info,
0, 0, 0, (my_hash_get_key) get_key_column, 0, 0, 0);
0, 0, 0, get_key_column, 0, 0, 0);
}
};
@@ -5688,16 +5698,17 @@ GRANT_TABLE::~GRANT_TABLE()
}
static uchar* get_grant_table(GRANT_NAME *buff, size_t *length,
my_bool not_used __attribute__((unused)))
static const uchar *get_grant_table(const void *buff_, size_t *length, my_bool)
{
auto buff= static_cast<const GRANT_NAME *>(buff_);
*length=buff->key_length;
return (uchar*) buff->hash_key;
return reinterpret_cast<const uchar *>(buff->hash_key);
}
static void free_grant_table(GRANT_TABLE *grant_table)
static void free_grant_table(void *grant_table_)
{
GRANT_TABLE *grant_table= static_cast<GRANT_TABLE *>(grant_table_);
grant_table->~GRANT_TABLE();
}
@@ -6334,19 +6345,20 @@ static enum PRIVS_TO_MERGE::what sp_privs_to_merge(enum_sp_type type)
}
static int init_role_for_merging(ACL_ROLE *role, void *context)
static int init_role_for_merging(ACL_USER_BASE *role_, void *context)
{
ACL_ROLE *role= static_cast<ACL_ROLE *>(role_);
role->counter= 0;
return 0;
}
static int count_subgraph_nodes(ACL_ROLE *role, ACL_ROLE *grantee, void *context)
static int count_subgraph_nodes(ACL_USER_BASE *, ACL_ROLE *grantee, void *context)
{
grantee->counter++;
return 0;
}
static int merge_role_privileges(ACL_ROLE *, ACL_ROLE *, void *);
static int merge_role_privileges(ACL_USER_BASE *, ACL_ROLE *, void *);
static bool merge_one_role_privileges(ACL_ROLE *grantee, PRIVS_TO_MERGE what);
/**
@@ -6586,13 +6598,11 @@ end:
*/
static int traverse_role_graph_up(ACL_ROLE *role, void *context,
int (*on_node) (ACL_ROLE *role, void *context),
int (*on_edge) (ACL_ROLE *current, ACL_ROLE *neighbour, void *context))
int (*on_node) (ACL_USER_BASE *role, void *context),
int (*on_edge) (ACL_USER_BASE *current, ACL_ROLE *neighbour, void *context))
{
return traverse_role_graph_impl(role, context,
my_offsetof(ACL_ROLE, parent_grantee),
(int (*)(ACL_USER_BASE *, void *))on_node,
(int (*)(ACL_USER_BASE *, ACL_ROLE *, void *))on_edge);
return traverse_role_graph_impl(
role, context, my_offsetof(ACL_ROLE, parent_grantee), on_node, on_edge);
}
/**
@@ -6623,10 +6633,11 @@ static int traverse_role_graph_down(ACL_USER_BASE *user, void *context,
entries using the role hash. We put all these "interesting"
entries in a (suposedly small) dynamic array and them use it for merging.
*/
static uchar* role_key(const ACL_ROLE *role, size_t *klen, my_bool)
static const uchar *role_key(const void *role_, size_t *klen, my_bool)
{
auto role= static_cast<const ACL_ROLE *>(role_);
*klen= role->user.length;
return (uchar*) role->user.str;
return reinterpret_cast<const uchar *>(role->user.str);
}
typedef Hash_set<ACL_ROLE> role_hash_t;
@@ -6645,8 +6656,10 @@ static bool merge_role_global_privileges(ACL_ROLE *grantee)
return old != grantee->access;
}
static int db_name_sort(const int *db1, const int *db2)
static int db_name_sort(const void *db1_, const void *db2_)
{
auto db1= static_cast<const int *>(db1_);
auto db2= static_cast<const int *>(db2_);
return strcmp(acl_dbs.at(*db1).db, acl_dbs.at(*db2).db);
}
@@ -6799,8 +6812,10 @@ static bool merge_role_db_privileges(ACL_ROLE *grantee, const char *dbname,
return update_flags;
}
static int table_name_sort(GRANT_TABLE * const *tbl1, GRANT_TABLE * const *tbl2)
static int table_name_sort(const void *tbl1_, const void *tbl2_)
{
auto tbl1= static_cast<const GRANT_TABLE *const *>(tbl1_);
auto tbl2= static_cast<const GRANT_TABLE *const *>(tbl2_);
int res = strcmp((*tbl1)->db, (*tbl2)->db);
if (res) return res;
return strcmp((*tbl1)->tname, (*tbl2)->tname);
@@ -7001,8 +7016,10 @@ static bool merge_role_table_and_column_privileges(ACL_ROLE *grantee,
return update_flags;
}
static int routine_name_sort(GRANT_NAME * const *r1, GRANT_NAME * const *r2)
static int routine_name_sort(const void *r1_, const void *r2_)
{
auto r1= static_cast<const GRANT_NAME *const *>(r1_);
auto r2= static_cast<const GRANT_NAME *const *>(r2_);
int res= strcmp((*r1)->db, (*r2)->db);
if (res) return res;
return strcmp((*r1)->tname, (*r2)->tname);
@@ -7125,7 +7142,7 @@ static bool merge_role_routine_grant_privileges(ACL_ROLE *grantee,
/**
update privileges of the 'grantee' from all roles, granted to it
*/
static int merge_role_privileges(ACL_ROLE *role __attribute__((unused)),
static int merge_role_privileges(ACL_USER_BASE *,
ACL_ROLE *grantee, void *context)
{
PRIVS_TO_MERGE *data= (PRIVS_TO_MERGE *)context;
@@ -8111,20 +8128,16 @@ static bool grant_load(THD *thd,
Sql_mode_instant_remove sms(thd, MODE_PAD_CHAR_TO_FULL_LENGTH);
(void) my_hash_init(key_memory_acl_memex, &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);
&my_charset_utf8mb3_bin, 0, 0, 0, get_grant_table,
free_grant_table, 0);
(void) my_hash_init(key_memory_acl_memex, &proc_priv_hash,
&my_charset_utf8mb3_bin, 0,0,0, (my_hash_get_key)
get_grant_table, 0,0);
&my_charset_utf8mb3_bin, 0, 0, 0, get_grant_table, 0, 0);
(void) my_hash_init(key_memory_acl_memex, &func_priv_hash,
&my_charset_utf8mb3_bin, 0,0,0, (my_hash_get_key)
get_grant_table, 0,0);
&my_charset_utf8mb3_bin, 0, 0, 0, get_grant_table, 0, 0);
(void) my_hash_init(key_memory_acl_memex, &package_spec_priv_hash,
&my_charset_utf8mb3_bin, 0,0,0, (my_hash_get_key)
get_grant_table, 0,0);
&my_charset_utf8mb3_bin, 0, 0, 0, get_grant_table, 0, 0);
(void) my_hash_init(key_memory_acl_memex, &package_body_priv_hash,
&my_charset_utf8mb3_bin, 0,0,0, (my_hash_get_key)
get_grant_table, 0,0);
&my_charset_utf8mb3_bin, 0, 0, 0, get_grant_table, 0, 0);
init_sql_alloc(key_memory_acl_mem, &grant_memroot, ACL_ALLOC_BLOCK_SIZE, 0, MYF(0));
t_table= tables_priv.table();
@@ -12294,9 +12307,9 @@ void Sql_cmd_grant::warn_hostname_requires_resolving(THD *thd,
while ((user= it++))
{
if (opt_skip_name_resolve && hostname_requires_resolving(user->host.str))
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARN_HOSTNAME_WONT_WORK,
ER_THD(thd, ER_WARN_HOSTNAME_WONT_WORK));
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARN_HOSTNAME_WONT_WORK,
ER_THD(thd, ER_WARN_HOSTNAME_WONT_WORK));
}
}
@@ -13465,7 +13478,7 @@ static bool secure_auth(THD *thd)
else
{
my_error(ER_NOT_SUPPORTED_AUTH_MODE, MYF(0));
general_log_print(thd, COM_CONNECT,
general_log_print(thd, COM_CONNECT, "%s",
ER_THD(thd, ER_NOT_SUPPORTED_AUTH_MODE));
}
return 1;
@@ -13538,7 +13551,7 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio,
if (switch_from_short_to_long_scramble)
{
my_error(ER_NOT_SUPPORTED_AUTH_MODE, MYF(0));
general_log_print(mpvio->auth_info.thd, COM_CONNECT,
general_log_print(mpvio->auth_info.thd, COM_CONNECT, "%s",
ER_THD(mpvio->auth_info.thd, ER_NOT_SUPPORTED_AUTH_MODE));
DBUG_RETURN (1);
}
@@ -13628,7 +13641,7 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio)
!ignore_max_password_errors(mpvio->acl_user))
{
my_error(ER_USER_IS_BLOCKED, MYF(0));
general_log_print(mpvio->auth_info.thd, COM_CONNECT,
general_log_print(mpvio->auth_info.thd, COM_CONNECT, "%s",
ER_THD(mpvio->auth_info.thd, ER_USER_IS_BLOCKED));
DBUG_RETURN(1);
}
@@ -13643,7 +13656,7 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio)
DBUG_ASSERT(my_strcasecmp(system_charset_info,
mpvio->acl_user->auth->plugin.str, old_password_plugin_name.str));
my_error(ER_NOT_SUPPORTED_AUTH_MODE, MYF(0));
general_log_print(mpvio->auth_info.thd, COM_CONNECT,
general_log_print(mpvio->auth_info.thd, COM_CONNECT, "%s",
ER_THD(mpvio->auth_info.thd, ER_NOT_SUPPORTED_AUTH_MODE));
DBUG_RETURN (1);
}