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

Function acl_check_host

phx_percona/percona/sql/sql_acl.cc:2301–2331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2299/* Return true if there is no users that can match the given host */
2300
2301bool acl_check_host(const char *host, const char *ip)
2302{
2303 if (allow_all_hosts)
2304 return 0;
2305 mysql_mutex_lock(&acl_cache->lock);
2306
2307 if ((host && my_hash_search(&acl_check_hosts,(uchar*) host,strlen(host))) ||
2308 (ip && my_hash_search(&acl_check_hosts,(uchar*) ip, strlen(ip))))
2309 {
2310 mysql_mutex_unlock(&acl_cache->lock);
2311 return 0; // Found host
2312 }
2313 for (uint i=0 ; i < acl_wild_hosts.elements ; i++)
2314 {
2315 ACL_HOST_AND_IP *acl=dynamic_element(&acl_wild_hosts,i,ACL_HOST_AND_IP*);
2316 if (acl->compare_hostname(host, ip))
2317 {
2318 mysql_mutex_unlock(&acl_cache->lock);
2319 return 0; // Host ok
2320 }
2321 }
2322 mysql_mutex_unlock(&acl_cache->lock);
2323 if (ip != NULL)
2324 {
2325 /* Increment HOST_CACHE.COUNT_HOST_ACL_ERRORS. */
2326 Host_errors errors;
2327 errors.m_host_acl= 1;
2328 inc_host_errors(ip, &errors);
2329 }
2330 return 1; // Host is not allowed
2331}
2332
2333
2334/**

Callers

nothing calls this directly

Calls 1

compare_hostnameMethod · 0.80

Tested by

no test coverage detected