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

Function acl_getroot

phx_percona/percona/sql/sql_acl.cc:1818–1904  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1816*/
1817
1818bool acl_getroot(Security_context *sctx, char *user, char *host,
1819 char *ip, char *db)
1820{
1821 int res= 1;
1822 uint i;
1823 ACL_USER *acl_user= 0;
1824 DBUG_ENTER("acl_getroot");
1825
1826 DBUG_PRINT("enter", ("Host: '%s', Ip: '%s', User: '%s', db: '%s'",
1827 (host ? host : "(NULL)"), (ip ? ip : "(NULL)"),
1828 user, (db ? db : "(NULL)")));
1829 sctx->user= user;
1830 sctx->set_host(host);
1831 sctx->set_ip(ip);
1832 sctx->host_or_ip= host ? host : (ip ? ip : "");
1833
1834 if (!initialized)
1835 {
1836 /*
1837 here if mysqld's been started with --skip-grant-tables option.
1838 */
1839 sctx->skip_grants();
1840 DBUG_RETURN(FALSE);
1841 }
1842
1843 mysql_mutex_lock(&acl_cache->lock);
1844
1845 sctx->master_access= 0;
1846 sctx->db_access= 0;
1847 *sctx->priv_user= *sctx->priv_host= 0;
1848
1849 /*
1850 Find acl entry in user database.
1851 This is specially tailored to suit the check we do for CALL of
1852 a stored procedure; user is set to what is actually a
1853 priv_user, which can be ''.
1854 */
1855 for (i=0 ; i < acl_users.elements ; i++)
1856 {
1857 ACL_USER *acl_user_tmp= dynamic_element(&acl_users,i,ACL_USER*);
1858 if ((!acl_user_tmp->user && !user[0]) ||
1859 (acl_user_tmp->user && strcmp(user, acl_user_tmp->user) == 0))
1860 {
1861 if (acl_user_tmp->host.compare_hostname(host, ip))
1862 {
1863 acl_user= acl_user_tmp;
1864 res= 0;
1865 break;
1866 }
1867 }
1868 }
1869
1870 if (acl_user)
1871 {
1872 for (i=0 ; i < acl_dbs.elements ; i++)
1873 {
1874 ACL_DB *acl_db= dynamic_element(&acl_dbs, i, ACL_DB*);
1875 if (!acl_db->user ||

Callers

nothing calls this directly

Calls 2

compare_hostnameMethod · 0.80
get_hostMethod · 0.80

Tested by

no test coverage detected