MCPcopy Create free account
hub / github.com/MariaDB/server / init_check_host

Function init_check_host

sql/sql_acl.cc:3952–3997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3950*/
3951
3952static void init_check_host(void)
3953{
3954 DBUG_ENTER("init_check_host");
3955 (void) my_init_dynamic_array(key_memory_acl_mem, &acl_wild_hosts,
3956 sizeof(struct acl_host_and_ip),
3957 acl_users.elements, 1, MYF(0));
3958 (void) my_hash_init(key_memory_acl_mem, &acl_check_hosts,
3959 Lex_ident_host::charset_info(),
3960 acl_users.elements, 0, 0, check_get_key, 0, 0);
3961 if (!allow_all_hosts)
3962 {
3963 for (size_t i=0 ; i < acl_users.elements ; i++)
3964 {
3965 ACL_USER *acl_user=dynamic_element(&acl_users,i,ACL_USER*);
3966 const Lex_ident_host acl_user_hostname(acl_user->hostname());
3967 if (strchr(acl_user->host.hostname,wild_many) ||
3968 strchr(acl_user->host.hostname,wild_one) ||
3969 acl_user->host.ip_mask)
3970 { // Has wildcard
3971 size_t j;
3972 for (j=0 ; j < acl_wild_hosts.elements ; j++)
3973 { // Check if host already exists
3974 acl_host_and_ip *acl=dynamic_element(&acl_wild_hosts,j,
3975 acl_host_and_ip *);
3976 if (acl_user_hostname.streq(Lex_cstring_strlen(acl->hostname)))
3977 break; // already stored
3978 }
3979 if (j == acl_wild_hosts.elements) // If new
3980 (void) push_dynamic(&acl_wild_hosts,(uchar*) &acl_user->host);
3981 }
3982 else if (!my_hash_search(&acl_check_hosts,(uchar*)
3983 acl_user->host.hostname,
3984 strlen(acl_user->host.hostname)))
3985 {
3986 if (my_hash_insert(&acl_check_hosts,(uchar*) acl_user))
3987 { // End of memory
3988 allow_all_hosts=1; // Should never happen
3989 DBUG_VOID_RETURN;
3990 }
3991 }
3992 }
3993 }
3994 freeze_size(&acl_wild_hosts);
3995 freeze_size(&acl_check_hosts.array);
3996 DBUG_VOID_RETURN;
3997}
3998
3999
4000/*

Callers 3

acl_loadFunction · 0.85
acl_reloadFunction · 0.85
rebuild_check_hostFunction · 0.85

Calls 6

Lex_cstring_strlenClass · 0.85
my_hash_searchFunction · 0.85
my_hash_insertFunction · 0.85
freeze_sizeFunction · 0.85
hostnameMethod · 0.80
streqMethod · 0.45

Tested by

no test coverage detected