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

Function fill_schema_user_privileges

phx_percona/percona/sql/sql_acl.cc:9130–9205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9128
9129
9130int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, Item *cond)
9131{
9132#ifndef NO_EMBEDDED_ACCESS_CHECKS
9133 int error= 0;
9134 uint counter;
9135 ACL_USER *acl_user;
9136 ulong want_access;
9137 char buff[100];
9138 TABLE *table= tables->table;
9139 bool no_global_access= check_access(thd, SELECT_ACL, "mysql",
9140 NULL, NULL, 1, 1);
9141 char *curr_host= thd->security_ctx->priv_host_name();
9142 DBUG_ENTER("fill_schema_user_privileges");
9143
9144 if (!initialized)
9145 DBUG_RETURN(0);
9146 mysql_mutex_lock(&acl_cache->lock);
9147
9148 for (counter=0 ; counter < acl_users.elements ; counter++)
9149 {
9150 const char *user,*host, *is_grantable="YES";
9151 acl_user=dynamic_element(&acl_users,counter,ACL_USER*);
9152 if (!(user=acl_user->user))
9153 user= "";
9154 if (!(host=acl_user->host.get_host()))
9155 host= "";
9156
9157 if (no_global_access &&
9158 (strcmp(thd->security_ctx->priv_user, user) ||
9159 my_strcasecmp(system_charset_info, curr_host, host)))
9160 continue;
9161
9162 if (acl_is_utility_user(user, host, NULL))
9163 continue;
9164
9165 want_access= acl_user->access;
9166 if (!(want_access & GRANT_ACL))
9167 is_grantable= "NO";
9168
9169 strxmov(buff,"'",user,"'@'",host,"'",NullS);
9170 if (!(want_access & ~GRANT_ACL))
9171 {
9172 if (update_schema_privilege(thd, table, buff, 0, 0, 0, 0,
9173 STRING_WITH_LEN("USAGE"), is_grantable))
9174 {
9175 error= 1;
9176 goto err;
9177 }
9178 }
9179 else
9180 {
9181 uint priv_id;
9182 ulong j,test_access= want_access & ~GRANT_ACL;
9183 for (priv_id=0, j = SELECT_ACL;j <= GLOBAL_ACLS; priv_id++,j <<= 1)
9184 {
9185 if (test_access & j)
9186 {
9187 if (update_schema_privilege(thd, table, buff, 0, 0, 0, 0,

Callers

nothing calls this directly

Calls 3

acl_is_utility_userFunction · 0.85
update_schema_privilegeFunction · 0.85
get_hostMethod · 0.80

Tested by

no test coverage detected