MCPcopy Create free account
hub / github.com/Tencent/phxsql / init_check_host

Function init_check_host

phx_percona/percona/sql/sql_acl.cc:2238–2280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2236*/
2237
2238static void init_check_host(void)
2239{
2240 DBUG_ENTER("init_check_host");
2241 (void) my_init_dynamic_array(&acl_wild_hosts,sizeof(class ACL_HOST_AND_IP),
2242 acl_users.elements,1);
2243 (void) my_hash_init(&acl_check_hosts,system_charset_info,
2244 acl_users.elements, 0, 0,
2245 (my_hash_get_key) check_get_key, 0, 0);
2246 if (!allow_all_hosts)
2247 {
2248 for (uint i=0 ; i < acl_users.elements ; i++)
2249 {
2250 ACL_USER *acl_user=dynamic_element(&acl_users,i,ACL_USER*);
2251 if (acl_user->host.has_wildcard())
2252 { // Has wildcard
2253 uint j;
2254 for (j=0 ; j < acl_wild_hosts.elements ; j++)
2255 { // Check if host already exists
2256 ACL_HOST_AND_IP *acl=dynamic_element(&acl_wild_hosts,j,
2257 ACL_HOST_AND_IP *);
2258 if (!my_strcasecmp(system_charset_info,
2259 acl_user->host.get_host(), acl->get_host()))
2260 break; // already stored
2261 }
2262 if (j == acl_wild_hosts.elements) // If new
2263 (void) push_dynamic(&acl_wild_hosts,(uchar*) &acl_user->host);
2264 }
2265 else if (!my_hash_search(&acl_check_hosts,(uchar*)
2266 acl_user->host.get_host(),
2267 strlen(acl_user->host.get_host())))
2268 {
2269 if (my_hash_insert(&acl_check_hosts,(uchar*) acl_user))
2270 { // End of memory
2271 allow_all_hosts=1; // Should never happen
2272 DBUG_VOID_RETURN;
2273 }
2274 }
2275 }
2276 }
2277 freeze_size(&acl_wild_hosts);
2278 freeze_size(&acl_check_hosts.array);
2279 DBUG_VOID_RETURN;
2280}
2281
2282
2283/*

Callers 3

sql_acl.ccFile · 0.85
acl_reloadFunction · 0.85
rebuild_check_hostFunction · 0.85

Calls 2

has_wildcardMethod · 0.80
get_hostMethod · 0.80

Tested by

no test coverage detected