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

Function acl_check_proxy_grant_access

phx_percona/percona/sql/sql_acl.cc:8960–9027  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8958
8959
8960bool
8961acl_check_proxy_grant_access(THD *thd, const char *host, const char *user,
8962 bool with_grant)
8963{
8964 DBUG_ENTER("acl_check_proxy_grant_access");
8965 DBUG_PRINT("info", ("user=%s host=%s with_grant=%d", user, host,
8966 (int) with_grant));
8967 if (!initialized)
8968 {
8969 my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables");
8970 DBUG_RETURN(1);
8971 }
8972
8973 /* replication slave thread can do anything */
8974 if (thd->slave_thread)
8975 {
8976 DBUG_PRINT("info", ("replication slave"));
8977 DBUG_RETURN(FALSE);
8978 }
8979
8980 /*
8981 one can grant proxy for self to others.
8982 Security context in THD contains two pairs of (user,host):
8983 1. (user,host) pair referring to inbound connection.
8984 2. (priv_user,priv_host) pair obtained from mysql.user table after doing
8985 authnetication of incoming connection.
8986 Privileges should be checked wrt (priv_user, priv_host) tuple, because
8987 (user,host) pair obtained from inbound connection may have different
8988 values than what is actually stored in mysql.user table and while granting
8989 or revoking proxy privilege, user is expected to provide entries mentioned
8990 in mysql.user table.
8991 */
8992 if (!strcmp(thd->security_ctx->priv_user, user) &&
8993 !my_strcasecmp(system_charset_info, host,
8994 thd->security_ctx->priv_host))
8995 {
8996 DBUG_PRINT("info", ("strcmp (%s, %s) my_casestrcmp (%s, %s) equal",
8997 thd->security_ctx->priv_user, user,
8998 host, thd->security_ctx->priv_host));
8999 DBUG_RETURN(FALSE);
9000 }
9001
9002 mysql_mutex_lock(&acl_cache->lock);
9003
9004 /* check for matching WITH PROXY rights */
9005 for (uint i=0; i < acl_proxy_users.elements; i++)
9006 {
9007 ACL_PROXY_USER *proxy= dynamic_element(&acl_proxy_users, i,
9008 ACL_PROXY_USER *);
9009 DEBUG_SYNC(thd, "before_proxy_matches");
9010 if (proxy->matches(thd->security_ctx->get_host()->ptr(),
9011 thd->security_ctx->user,
9012 thd->security_ctx->get_ip()->ptr(),
9013 user) &&
9014 proxy->get_with_grant())
9015 {
9016 DBUG_PRINT("info", ("found"));
9017 mysql_mutex_unlock(&acl_cache->lock);

Callers

nothing calls this directly

Calls 3

matchesMethod · 0.80
get_hostMethod · 0.80
get_with_grantMethod · 0.80

Tested by

no test coverage detected